개정판 c8718ae5
add text switch funct
Change-Id: Ief1d22d517665810bc96e1527e7fc72ca1de1574
DTI_PID/DTI_PID/QtImageViewerScene.py | ||
---|---|---|
95 | 95 |
|
96 | 96 |
event.accept() |
97 | 97 |
return |
98 |
elif event.key() == Qt.Key_S and not items: |
|
99 |
texts = [item for item in self.selectedItems() if issubclass(type(item), QEngineeringTextItem)] |
|
100 |
if texts: |
|
101 |
for item in texts: |
|
102 |
item.keyPressEvent(event) |
|
103 |
break |
|
98 | 104 |
elif event.key() in [Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right, Qt.Key_Return]: |
99 | 105 |
_items = self.selectedItems() |
100 | 106 |
texts = [item for item in _items if issubclass(type(item), QEngineeringTextItem)] |
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
258 | 258 |
mergeAction.triggered.connect(self.contextMerge) |
259 | 259 |
menu.addAction(mergeAction) |
260 | 260 |
|
261 |
if len(items) == 2: |
|
262 |
switchAction = QAction('Switch(S)', None) |
|
263 |
switchAction.triggered.connect(self.contextSwitch) |
|
264 |
menu.addAction(switchAction) |
|
265 |
|
|
261 | 266 |
if len(items) > 1: |
262 | 267 |
alignAction = QAction('Resize Selected Texts with This ', None) |
263 | 268 |
alignAction.triggered.connect(self.contextResizeText) |
... | ... | |
297 | 302 |
for lineNo in lineNos: |
298 | 303 |
lineNo.setSelected(True) |
299 | 304 |
|
305 |
def contextSwitch(self): |
|
306 |
textItems = [item for item in self.scene().selectedItems() if issubclass(type(item), QEngineeringTextItem)] |
|
307 |
if len(textItems) != 2: |
|
308 |
return |
|
309 |
|
|
310 |
text1 = textItems[0] |
|
311 |
text2 = textItems[1] |
|
312 |
|
|
313 |
loc1 = [text1.loc[0], text1.loc[1]] |
|
314 |
loc2 = [text2.loc[0], text2.loc[1]] |
|
315 |
|
|
316 |
text1.moveText(1, 0, loc2[0] - loc1[0]) |
|
317 |
text1.moveText(0, 1, loc2[1] - loc1[1]) |
|
318 |
text2.moveText(1, 0, loc1[0] - loc2[0]) |
|
319 |
text2.moveText(0, 1, loc1[1] - loc2[1]) |
|
320 |
|
|
300 | 321 |
def contextResizeText(self): |
301 | 322 |
from QEngineeringTrimLineNoTextItem import QEngineeringLineNoTextItem |
302 | 323 |
|
... | ... | |
434 | 455 |
App.mainWnd().keyPressEvent(event) |
435 | 456 |
elif event.key() == Qt.Key_A: |
436 | 457 |
self.contextSelectAll() |
458 |
elif event.key() == Qt.Key_S: |
|
459 |
self.contextSwitch() |
|
437 | 460 |
|
438 | 461 |
# QGraphicsTextItem.keyPressEvent(self, event) |
439 | 462 |
|
내보내기 Unified diff