프로젝트

일반

사용자정보

개정판 5fdef8c6

ID5fdef8c62d59b7dd7af7d9b1d380245e42a6a8d3
상위 d8c55909
하위 9163f2dc

함의성이(가) 약 일년 전에 추가함

add text size unify funct

Change-Id: I4333a6ee475d14218efb98dbb2e72c721631d4dd

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
169 169

  
170 170
    def contextMenuEvent(self, event):
171 171
        items = self.scene().selectedItems()
172
        menu = QMenu()
172 173
        if len(items) == 1 and self in items:
173
            menu = QMenu()
174

  
175 174
            '''
176 175
            explodeAction = QAction('Explode', None)
177 176
            explodeAction.triggered.connect(self.contextExplode)
......
231 230
            deleteAction = QAction('Delete(E)', None)
232 231
            deleteAction.triggered.connect(self.contextDelete)
233 232
            menu.addAction(deleteAction)
233
        else:
234
            alignAction = QAction('Resize Selected Texts with This ', None)
235
            alignAction.triggered.connect(self.contextResizeText)
236
            menu.addAction(alignAction)
237

  
238
        menu.exec_(event.screenPos())
239

  
240
    def contextResizeText(self):
241
        textItems = [item for item in self.scene().selectedItems() if item is not self and type(item) is QEngineeringLineNoTextItem]
242
        allowed_error = 0.01
243

  
244
        for text in textItems:
245
            if abs(self.angle - text.angle) < allowed_error:
246
                dx = round(self.size[0] - text.size[0])
247
                dy = round(self.size[1] - text.size[1])
248
            else:
249
                dx = round(self.size[1] - text.size[0])
250
                dy = round(self.size[0] - text.size[1])
251

  
252
            text.size[1] = text.size[1] + dy
253
            if abs(text.angle - 1.57) < allowed_error or abs(text.angle - 3.14) < allowed_error:
254
                text.loc[1] = text.loc[1] - dy
255

  
256
            text.size[0] = text.size[0] + dx
257
            if abs(text.angle - 4.71) < allowed_error or abs(text.angle - 4.71) < allowed_error or abs(text.angle - 3.14) < allowed_error:
258
                text.loc[0] = text.loc[0] - dx
234 259

  
235
            menu.exec_(event.screenPos())
260
            text.update_font()
261
            text.update()
236 262

  
237 263
    def contextSelectAll(self):
238 264
        from App import App
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py
264 264
                mergeAction.triggered.connect(self.contextMerge)
265 265
                menu.addAction(mergeAction)
266 266

  
267
            if len(items) > 1:
268
                alignAction = QAction('Resize Selected Texts with This ', None)
269
                alignAction.triggered.connect(self.contextResizeText)
270
                menu.addAction(alignAction)
271

  
267 272
            if len(items) == 1:
268 273
                editAction = QAction('Edit(Return)', None)
269 274
                editAction.triggered.connect(self.contextEdit)
......
284 289

  
285 290
            menu.exec_(event.screenPos())
286 291

  
292
    def contextResizeText(self):
293
        textItems = [item for item in self.scene().selectedItems() if item is not self and type(item) is QEngineeringTextItem]
294
        allowed_error = 0.01
295

  
296
        for text in textItems:
297
            if abs(self.angle - text.angle) < allowed_error:
298
                dx = round(self.size[0] - text.size[0])
299
                dy = round(self.size[1] - text.size[1])
300
            else:
301
                dx = round(self.size[1] - text.size[0])
302
                dy = round(self.size[0] - text.size[1])
303

  
304
            text.size[1] = text.size[1] + dy
305
            if abs(text.angle - 1.57) < allowed_error or abs(text.angle - 3.14) < allowed_error:
306
                text.loc[1] = text.loc[1] - dy
307

  
308
            text.size[0] = text.size[0] + dx
309
            if abs(text.angle - 4.71) < allowed_error or abs(text.angle - 4.71) < allowed_error or abs(text.angle - 3.14) < allowed_error:
310
                text.loc[0] = text.loc[0] - dx
311

  
312
            text.update_font()
313
            text.update()
314

  
287 315
    def contextTrim(self):
288 316
        textItems = [item for item in self.scene().selectedItems() if type(item) is QEngineeringTextItem]
289 317

  
......
364 392
                    self.loc[0] = self.loc[0] - 5
365 393
                    #self.moveText(1, 0, 5)
366 394

  
367
            self.update()
368 395
            self.update_font()
396
            self.update()
369 397
        elif event.key() == Qt.Key_Minus:
370 398
            allowed_error = 0.01
371 399
            modifiers = QApplication.keyboardModifiers()

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)