개정판 d84c6aa6
issue #641: 도면 열기 수정(use scene() instead of scene in graphicsView)
Change-Id: I0e7b571a6511e901a5a417798278606f3237655e
DTI_PID/DTI_PID/CodeTableDialog.py | ||
---|---|---|
156 | 156 |
|
157 | 157 |
if self.code_area: |
158 | 158 |
if self.code_area.scene(): |
159 |
self.graphicsView.scene.removeItem(self.code_area) |
|
159 |
self.graphicsView.scene().removeItem(self.code_area)
|
|
160 | 160 |
self.code_area = None |
161 | 161 |
if self.desc_area: |
162 | 162 |
if self.desc_area.scene(): |
163 |
self.graphicsView.scene.removeItem(self.desc_area) |
|
163 |
self.graphicsView.scene().removeItem(self.desc_area)
|
|
164 | 164 |
self.desc_area = None |
165 | 165 |
self.ui.pushButtonRead.setText('Read from Legend') |
166 | 166 |
else: |
167 | 167 |
if self.code_area: |
168 | 168 |
if self.code_area.scene(): |
169 |
self.graphicsView.scene.removeItem(self.code_area) |
|
169 |
self.graphicsView.scene().removeItem(self.code_area)
|
|
170 | 170 |
self.code_area = None |
171 | 171 |
if self.desc_area: |
172 | 172 |
if self.desc_area.scene(): |
173 |
self.graphicsView.scene.removeItem(self.desc_area) |
|
173 |
self.graphicsView.scene().removeItem(self.desc_area)
|
|
174 | 174 |
self.desc_area = None |
175 | 175 |
self.ui.pushButtonRead.setText('Read from Legend') |
176 | 176 |
|
... | ... | |
181 | 181 |
if self.ui.pushButtonRead.text() == 'Draw Code Area': |
182 | 182 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
183 | 183 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
184 |
self.graphicsView.scene.addItem(item) |
|
184 |
self.graphicsView.scene().addItem(item)
|
|
185 | 185 |
self.code_area = item |
186 | 186 |
self.ui.pushButtonRead.setText('Draw Description Area') |
187 | 187 |
elif self.ui.pushButtonRead.text() == 'Draw Description Area' and self.code_area and self.code_area.scene(): |
188 | 188 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
189 | 189 |
item.setPen(QPen(Qt.blue, THICKNESS, Qt.SolidLine)) |
190 |
self.graphicsView.scene.addItem(item) |
|
190 |
self.graphicsView.scene().addItem(item)
|
|
191 | 191 |
self.desc_area = item |
192 | 192 |
self.ui.pushButtonRead.setText('Read') |
193 | 193 |
self.graphicsView.command = None |
DTI_PID/DTI_PID/CustomCodeTablesDialog.py | ||
---|---|---|
77 | 77 |
graphicsView = App.mainWnd().graphicsView |
78 | 78 |
if dialog.code_area: |
79 | 79 |
if dialog.code_area.scene(): |
80 |
graphicsView.scene.removeItem(dialog.code_area) |
|
80 |
graphicsView.scene().removeItem(dialog.code_area)
|
|
81 | 81 |
if dialog.desc_area: |
82 | 82 |
if dialog.desc_area.scene(): |
83 |
graphicsView.scene.removeItem(dialog.desc_area) |
|
83 |
graphicsView.scene().removeItem(dialog.desc_area)
|
|
84 | 84 |
graphicsView.useDefaultCommand() |
85 | 85 |
|
86 | 86 |
except Exception as ex: |
DTI_PID/DTI_PID/HMBDialog.py | ||
---|---|---|
228 | 228 |
if self.ui.lineEditHMBArea.tag is None: |
229 | 229 |
item = QGraphicsBoundingBoxItem(x, y, width, height) |
230 | 230 |
item.setPen(QPen(Qt.red, THICKNESS, Qt.SolidLine)) |
231 |
self.parent().graphicsView.scene.addItem(item) |
|
231 |
self.parent().graphicsView.scene().addItem(item)
|
|
232 | 232 |
|
233 | 233 |
self.ui.lineEditHMBArea.tag = item |
234 | 234 |
else: |
... | ... | |
461 | 461 |
sys.exc_info()[-1].tb_lineno)) |
462 | 462 |
finally: |
463 | 463 |
if self.ui.lineEditHMBArea.tag is not None: |
464 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditHMBArea.tag) |
|
464 |
self.parent().graphicsView.scene().removeItem(self.ui.lineEditHMBArea.tag)
|
|
465 | 465 |
|
466 | 466 |
QDialog.accept(self) |
467 | 467 |
|
... | ... | |
471 | 471 |
|
472 | 472 |
def reject(self): |
473 | 473 |
if self.ui.lineEditHMBArea.tag is not None: |
474 |
self.parent().graphicsView.scene.removeItem(self.ui.lineEditHMBArea.tag) |
|
474 |
self.parent().graphicsView.scene().removeItem(self.ui.lineEditHMBArea.tag)
|
|
475 | 475 |
|
476 | 476 |
QDialog.reject(self) |
DTI_PID/DTI_PID/ItemPropertyTableWidget.py | ||
---|---|---|
838 | 838 |
@date 2018.07.20 |
839 | 839 |
''' |
840 | 840 |
def onStreamNoChanged(self, param): |
841 |
items = self.mainWindow.graphicsView.scene.selectedItems() |
|
841 |
items = self.mainWindow.graphicsView.scene().selectedItems()
|
|
842 | 842 |
if items is not None and len(items) == 1: |
843 | 843 |
if type(items[0]) is QEngineeringLineNoTextItem: |
844 | 844 |
stream_no = self.streamNoComboBox.itemText(param) |
... | ... | |
867 | 867 |
from SymbolAttr import SymbolAttr |
868 | 868 |
|
869 | 869 |
if event.key() == Qt.Key_Delete: |
870 |
items = self.mainWindow.graphicsView.scene.selectedItems() |
|
870 |
items = self.mainWindow.graphicsView.scene().selectedItems()
|
|
871 | 871 |
selectedIndexes = self.selectedIndexes() |
872 | 872 |
if selectedIndexes and selectedIndexes[0].column() == 3 and self.item(selectedIndexes[0].row(), 1).text() == 'OWNER': |
873 | 873 |
items[0].owner = None |
... | ... | |
882 | 882 |
items[0].connectors[connNum - 1].connectedItem = None |
883 | 883 |
self.show_item_property(items[0]) |
884 | 884 |
|
885 |
for sceneItem in self.mainWindow.graphicsView.scene.items(): |
|
885 |
for sceneItem in self.mainWindow.graphicsView.scene().items():
|
|
886 | 886 |
if hasattr(sceneItem, 'uid') and str(sceneItem.uid) == selectedUID and hasattr(sceneItem, 'connectors'): |
887 | 887 |
for sceneConnector in sceneItem.connectors: |
888 | 888 |
if sceneConnector.connectedItem is not None and items[0].uid == sceneConnector.connectedItem.uid: |
... | ... | |
966 | 966 |
from SymbolAttr import SymbolProp |
967 | 967 |
|
968 | 968 |
if column == 2: |
969 |
items = self.mainWindow.graphicsView.scene.selectedItems() |
|
969 |
items = self.mainWindow.graphicsView.scene().selectedItems()
|
|
970 | 970 |
keyCell = self.item(row, 1) |
971 | 971 |
attr = keyCell.data(Qt.UserRole) |
972 | 972 |
if hasattr(keyCell, 'tag') and type(items[0]) is not QEngineeringSpecBreakItem: |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
258 | 258 |
self.actionImport_Text_From_CAD.triggered.connect(self.onImportTextFromCAD) |
259 | 259 |
self.actionSymbol_Thickness_Reinforcement.triggered.connect(self.onSymbolThickness) |
260 | 260 |
self.actionHelp.triggered.connect(self.on_help) |
261 |
self.graphicsView.scene.selectionChanged.connect(self.onSelectionChanged) |
|
261 |
self.graphicsView.scene().selectionChanged.connect(self.onSelectionChanged)
|
|
262 | 262 |
self.actionInitialize.triggered.connect(self.onInitializeScene) |
263 | 263 |
self.actionSave.triggered.connect(self.actionSaveCliked) |
264 | 264 |
self.addMessage.connect(self.onAddMessage) |
265 | 265 |
self.actionFindReplaceText.triggered.connect(self.findReplaceTextClicked) |
266 | 266 |
self.actionEditRecognizeLine.triggered.connect(self.on_recognize_line) |
267 | 267 |
self.pushButtonDetectSymbol.clicked.connect(self.show_detect_symbol_dialog) |
268 |
# self.graphicsView.scene.contents_changed.connect(self.scene_changed) |
|
268 |
# self.graphicsView.scene().contents_changed.connect(self.scene_changed)
|
|
269 | 269 |
|
270 | 270 |
configs = docData.getAppConfigs('app', 'mode') |
271 | 271 |
if configs and 1 == len(configs) and 'advanced' == configs[0].value: |
... | ... | |
405 | 405 |
dlg = QValidationDialog(self) |
406 | 406 |
if QDialog.Accepted == dlg.exec_(): |
407 | 407 |
# remove error items |
408 |
for item in self.graphicsView.scene.items(): |
|
408 |
for item in self.graphicsView.scene().items():
|
|
409 | 409 |
if type(item) is QEngineeringErrorItem: |
410 | 410 |
item.transfer.onRemoved.emit(item) |
411 | 411 |
# up to here |
412 | 412 |
|
413 |
self.progress_bar.setMaximum(len(self.graphicsView.scene.items())) |
|
413 |
self.progress_bar.setMaximum(len(self.graphicsView.scene().items()))
|
|
414 | 414 |
self.progress_bar.setValue(0) |
415 | 415 |
|
416 | 416 |
cmd = ValidateCommand(self.graphicsView) |
417 | 417 |
cmd.show_progress.connect(self.progress_bar.setValue) |
418 |
errors = cmd.execute(self.graphicsView.scene.items()) |
|
418 |
errors = cmd.execute(self.graphicsView.scene().items())
|
|
419 | 419 |
for error in errors: |
420 | 420 |
error.transfer.onRemoved.connect(self.itemRemoved) |
421 |
self.graphicsView.scene.addItem(error) |
|
421 |
self.graphicsView.scene().addItem(error)
|
|
422 | 422 |
|
423 | 423 |
self.tableWidgetInconsistency.clearContents() |
424 | 424 |
self.tableWidgetInconsistency.setRowCount(len(errors)) |
... | ... | |
672 | 672 |
for line in lines: |
673 | 673 |
vertices = [[line[0][0] + x, line[0][1] + y], [line[1][0] + x, line[1][1] + y]] |
674 | 674 |
line_item = QEngineeringGraphicsLineItem(vertices) |
675 |
self.graphicsView.scene.addItem(line_item) |
|
675 |
self.graphicsView.scene().addItem(line_item)
|
|
676 | 676 |
|
677 | 677 |
except Exception as ex: |
678 | 678 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
... | ... | |
682 | 682 |
def display_number_of_items(self): |
683 | 683 |
"""display count of symbol, line, text""" |
684 | 684 |
|
685 |
items = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringUnknownItem] |
|
685 |
items = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringUnknownItem]
|
|
686 | 686 |
if len(items) > 0: |
687 | 687 |
self.labelStatus.setText( |
688 | 688 |
"<font color='red'>" + self.tr('Unrecognition') + " : {}</font>".format(len(items))) |
... | ... | |
690 | 690 |
self.labelStatus.setText( |
691 | 691 |
"<font color='black'>" + self.tr('Unrecognition') + " : {}</font>".format(len(items))) |
692 | 692 |
|
693 |
items = [item for item in self.graphicsView.scene.items() if |
|
693 |
items = [item for item in self.graphicsView.scene().items() if
|
|
694 | 694 |
issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringErrorItem] |
695 | 695 |
self.labelSymbolStatus.setText("<font color='blue'>" + self.tr('Symbol') + " : {}</font>".format(len(items))) |
696 | 696 |
|
697 |
items = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringLineItem] |
|
697 |
items = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringLineItem]
|
|
698 | 698 |
self.labelLineStatus.setText("<font color='blue'>" + self.tr('Line') + " : {}</font>".format(len(items))) |
699 | 699 |
|
700 |
items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)] |
|
700 |
items = [item for item in self.graphicsView.scene().items() if issubclass(type(item), QEngineeringTextItem)]
|
|
701 | 701 |
self.labelTextStatus.setText("<font color='blue'>" + self.tr('Text') + " : {}</font>".format(len(items))) |
702 | 702 |
|
703 |
self.itemTreeWidget.sceneChanged(self.graphicsView.scene.items()) |
|
703 |
self.itemTreeWidget.sceneChanged(self.graphicsView.scene().items())
|
|
704 | 704 |
|
705 | 705 |
def dbUpdate(self): |
706 | 706 |
''' |
... | ... | |
789 | 789 |
|
790 | 790 |
app_doc_data.clearItemList(False) |
791 | 791 |
|
792 |
items = self.graphicsView.scene.items() |
|
792 |
items = self.graphicsView.scene().items()
|
|
793 | 793 |
|
794 | 794 |
# for check line disappear bug |
795 | 795 |
disappear_lines = [line for line in app_doc_data.lines if line not in items] |
... | ... | |
848 | 848 |
''' |
849 | 849 |
|
850 | 850 |
def refreshResultPropertyTableWidget(self): |
851 |
items = self.graphicsView.scene.selectedItems() |
|
851 |
items = self.graphicsView.scene().selectedItems()
|
|
852 | 852 |
if len(items) == 1: |
853 | 853 |
self.resultPropertyTableWidget.show_item_property(items[0]) |
854 | 854 |
|
... | ... | |
892 | 892 |
''' |
893 | 893 |
|
894 | 894 |
def onRotate(self, action): |
895 |
selected = [item for item in self.graphicsView.scene.selectedItems() if issubclass(type(item), SymbolSvgItem)] |
|
895 |
selected = [item for item in self.graphicsView.scene().selectedItems() if issubclass(type(item), SymbolSvgItem)]
|
|
896 | 896 |
if len(selected) == 1: |
897 | 897 |
selected[0].rotateSymbol() |
898 | 898 |
|
... | ... | |
938 | 938 |
item = QEngineeringVendorItem(polygon, pack_type=self.packageComboBox.currentText()) |
939 | 939 |
item.area = 'Drawing' |
940 | 940 |
item.transfer.onRemoved.connect(self.itemRemoved) |
941 |
self.graphicsView.scene.addItem(item) |
|
941 |
self.graphicsView.scene().addItem(item)
|
|
942 | 942 |
finally: |
943 |
self.graphicsView.scene.removeItem(self.actionVendor.tag._polyline) |
|
943 |
self.graphicsView.scene().removeItem(self.actionVendor.tag._polyline)
|
|
944 | 944 |
self.actionVendor.tag.reset() |
945 | 945 |
|
946 | 946 |
''' |
... | ... | |
1013 | 1013 |
|
1014 | 1014 |
def onSelectionChanged(self): |
1015 | 1015 |
"""selection changed""" |
1016 |
items = [item for item in self.graphicsView.scene.selectedItems() if issubclass(type(item), SymbolSvgItem) or |
|
1016 |
items = [item for item in self.graphicsView.scene().selectedItems() if issubclass(type(item), SymbolSvgItem) or
|
|
1017 | 1017 |
type(item) is QEngineeringLineItem or issubclass(type(item), QEngineeringTextItem) or |
1018 | 1018 |
type(item) is QEngineeringUnknownItem or type(item) is QEngineeringVendorItem] |
1019 | 1019 |
if items: |
... | ... | |
1056 | 1056 |
appDocData = AppDocData.instance() |
1057 | 1057 |
appDocData.clearItemList(True) |
1058 | 1058 |
|
1059 |
items = self.graphicsView.scene.items() |
|
1059 |
items = self.graphicsView.scene().items()
|
|
1060 | 1060 |
for item in items: |
1061 | 1061 |
if type(item) is not QGraphicsPixmapItem and item.scene() is not None: |
1062 | 1062 |
# if hasattr(item, 'tranfer'): |
1063 | 1063 |
# item.tranfer.onRemoved.emit(item) |
1064 | 1064 |
# else: |
1065 |
# self.graphicsView.scene.removeItem(item) |
|
1066 |
self.graphicsView.scene.removeItem(item) |
|
1065 |
# self.graphicsView.scene().removeItem(item)
|
|
1066 |
self.graphicsView.scene().removeItem(item)
|
|
1067 | 1067 |
|
1068 | 1068 |
''' |
1069 | 1069 |
if type(item) is QEngineeringLineNoTextItem: |
... | ... | |
1187 | 1187 |
(res, textInfoList) = dialog.showDialog() |
1188 | 1188 |
if QDialog.Accepted == res and textInfoList: |
1189 | 1189 |
for textInfo in textInfoList: |
1190 |
item = QEngineeringTextItem.create_text_with(self.graphicsView.scene, textInfo) |
|
1190 |
item = QEngineeringTextItem.create_text_with(self.graphicsView.scene(), textInfo)
|
|
1191 | 1191 |
if item: |
1192 | 1192 |
item.setDefaultTextColor(Qt.blue) |
1193 | 1193 |
item.transfer.onRemoved.connect(self.itemRemoved) |
... | ... | |
1296 | 1296 |
dlg.exec_() |
1297 | 1297 |
if dlg.code_area: |
1298 | 1298 |
if dlg.code_area.scene(): |
1299 |
self.graphicsView.scene.removeItem(dlg.code_area) |
|
1299 |
self.graphicsView.scene().removeItem(dlg.code_area)
|
|
1300 | 1300 |
if dlg.desc_area: |
1301 | 1301 |
if dlg.desc_area.scene(): |
1302 |
self.graphicsView.scene.removeItem(dlg.desc_area) |
|
1302 |
self.graphicsView.scene().removeItem(dlg.desc_area)
|
|
1303 | 1303 |
self.graphicsView.useDefaultCommand() |
1304 | 1304 |
|
1305 | 1305 |
def onShowCustomCodeTable(self): |
... | ... | |
1371 | 1371 |
|
1372 | 1372 |
def onLineTypeChanged(self, param): |
1373 | 1373 |
lineType = self.lineComboBox.itemText(param) |
1374 |
selected = [item for item in self.graphicsView.scene.selectedItems() if type(item) is QEngineeringLineItem] |
|
1374 |
selected = [item for item in self.graphicsView.scene().selectedItems() if type(item) is QEngineeringLineItem]
|
|
1375 | 1375 |
if selected: |
1376 | 1376 |
for item in selected: |
1377 | 1377 |
item.lineType = lineType |
... | ... | |
1383 | 1383 |
|
1384 | 1384 |
DisplayColors.instance().option = DisplayOptions.DisplayByLineNo if value is True else DisplayOptions.DisplayByLineType |
1385 | 1385 |
if hasattr(self, 'graphicsView'): |
1386 |
self.graphicsView.scene.update(self.graphicsView.sceneRect()) |
|
1386 |
self.graphicsView.scene().update(self.graphicsView.sceneRect())
|
|
1387 | 1387 |
DisplayColors.instance().save_data() |
1388 | 1388 |
|
1389 | 1389 |
def open_image_drawing(self, drawing): |
... | ... | |
1431 | 1431 |
self.show_Progress_bar() |
1432 | 1432 |
|
1433 | 1433 |
# disconnect scene changed if signal is connected |
1434 |
if self.graphicsView.scene.receivers(self.graphicsView.scene.contents_changed) > 0:
|
|
1435 |
self.graphicsView.scene.contents_changed.disconnect() |
|
1434 |
if self.graphicsView.scene().receivers(self.graphicsView.scene().contents_changed) > 0:
|
|
1435 |
self.graphicsView.scene().contents_changed.disconnect()
|
|
1436 | 1436 |
|
1437 | 1437 |
SymbolSvgItem.DOCUMENTS.clear() |
1438 | 1438 |
|
... | ... | |
1446 | 1446 |
|
1447 | 1447 |
self.display_number_of_items() |
1448 | 1448 |
# connect scene changed signal |
1449 |
self.graphicsView.scene.contents_changed.connect(self.scene_changed) |
|
1450 |
#self.graphicsView.setScene(self.graphicsView.scene) |
|
1449 |
self.graphicsView.scene().contents_changed.connect(self.scene_changed)
|
|
1450 |
#self.graphicsView.setScene(self.graphicsView.scene())
|
|
1451 | 1451 |
finally: |
1452 | 1452 |
if hasattr(self, 'progress'): |
1453 | 1453 |
self.progress.setValue(self.progress.maximum()) |
... | ... | |
1471 | 1471 |
file_path, _ = QFileDialog.getSaveFileName(self, "Export as svg", os.getcwd(), "svg file(*.svg)", |
1472 | 1472 |
options=options) |
1473 | 1473 |
if file_path: |
1474 |
cmd = ExportCommand(self.graphicsView.scene, 'svg') |
|
1474 |
cmd = ExportCommand(self.graphicsView.scene(), 'svg')
|
|
1475 | 1475 |
cmd.display_message.connect(self.onAddMessage) |
1476 | 1476 |
if cmd.execute(file_path): |
1477 | 1477 |
QMessageBox.information(self, self.tr('Information'), self.tr('Successfully export to svg file')) |
... | ... | |
1494 | 1494 |
# hide image drawing |
1495 | 1495 |
self.onViewImageDrawing(False) |
1496 | 1496 |
|
1497 |
cmd = ExportCommand(self.graphicsView.scene, 'image') |
|
1497 |
cmd = ExportCommand(self.graphicsView.scene(), 'image')
|
|
1498 | 1498 |
cmd.display_message.connect(self.onAddMessage) |
1499 | 1499 |
|
1500 | 1500 |
if cmd.execute(file_path): |
... | ... | |
1544 | 1544 |
@date 2019.04.22 |
1545 | 1545 |
''' |
1546 | 1546 |
self.changeViewCheckedState(not isChecked, False) |
1547 |
for item in self.graphicsView.scene.items(): |
|
1547 |
for item in self.graphicsView.scene().items():
|
|
1548 | 1548 |
if type(item) is not QGraphicsPixmapItem: |
1549 | 1549 |
item.setVisible(not isChecked) |
1550 | 1550 |
|
... | ... | |
1555 | 1555 |
''' |
1556 | 1556 |
|
1557 | 1557 |
def onViewImageDrawing(self, isChecked): |
1558 |
for item in self.graphicsView.scene.items(): |
|
1558 |
for item in self.graphicsView.scene().items():
|
|
1559 | 1559 |
if type(item) is QGraphicsPixmapItem: |
1560 | 1560 |
item.setVisible(isChecked) |
1561 | 1561 |
break |
... | ... | |
1567 | 1567 |
''' |
1568 | 1568 |
|
1569 | 1569 |
def onViewText(self, isChecked): |
1570 |
selected = [item for item in self.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)] |
|
1570 |
selected = [item for item in self.graphicsView.scene().items() if issubclass(type(item), QEngineeringTextItem)]
|
|
1571 | 1571 |
for item in selected: |
1572 | 1572 |
item.setVisible(isChecked) |
1573 | 1573 |
|
... | ... | |
1578 | 1578 |
''' |
1579 | 1579 |
|
1580 | 1580 |
def onViewSymbol(self, isChecked): |
1581 |
selected = [item for item in self.graphicsView.scene.items() if |
|
1581 |
selected = [item for item in self.graphicsView.scene().items() if
|
|
1582 | 1582 |
(issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringErrorItem)] |
1583 | 1583 |
for item in selected: |
1584 | 1584 |
item.setVisible(isChecked) |
... | ... | |
1590 | 1590 |
''' |
1591 | 1591 |
|
1592 | 1592 |
def onViewLine(self, isChecked): |
1593 |
selected = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringLineItem] |
|
1593 |
selected = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringLineItem]
|
|
1594 | 1594 |
for item in selected: |
1595 | 1595 |
item.setVisible(isChecked) |
1596 | 1596 |
|
... | ... | |
1600 | 1600 |
@author euisung |
1601 | 1601 |
@date 2019.04.03 |
1602 | 1602 |
''' |
1603 |
selected = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringErrorItem] |
|
1603 |
selected = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringErrorItem]
|
|
1604 | 1604 |
for item in selected: |
1605 | 1605 |
item.setVisible(isChecked) |
1606 | 1606 |
|
... | ... | |
1611 | 1611 |
''' |
1612 | 1612 |
|
1613 | 1613 |
def onViewUnknown(self, isChecked): |
1614 |
selected = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringUnknownItem] |
|
1614 |
selected = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringUnknownItem]
|
|
1615 | 1615 |
for item in selected: |
1616 | 1616 |
item.setVisible(isChecked) |
1617 | 1617 |
|
... | ... | |
1621 | 1621 |
@author euisung |
1622 | 1622 |
@date 2019.04.29 |
1623 | 1623 |
''' |
1624 |
selected = [item for item in self.graphicsView.scene.items() if type(item) is QEngineeringVendorItem] |
|
1624 |
selected = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringVendorItem]
|
|
1625 | 1625 |
for item in selected: |
1626 | 1626 |
item.setVisible(isChecked) |
1627 | 1627 |
|
... | ... | |
1671 | 1671 |
newSym.getAdditionalSymbol(), newSym.getHasInstrumentLabel) |
1672 | 1672 |
|
1673 | 1673 |
svg.transfer.onRemoved.connect(self.itemTreeWidget.itemRemoved) |
1674 |
svg.addSvgItemToScene(self.graphicsView.scene) |
|
1674 |
svg.addSvgItemToScene(self.graphicsView.scene())
|
|
1675 | 1675 |
for connector in svg.connectors: |
1676 |
self.graphicsView.scene.addItem(connector) |
|
1676 |
self.graphicsView.scene().addItem(connector)
|
|
1677 | 1677 |
finally: |
1678 | 1678 |
self.onCommandRejected() |
1679 | 1679 |
QApplication.restoreOverrideCursor() |
... | ... | |
1729 | 1729 |
lineItem.connect_if_possible(items[-1], 5) |
1730 | 1730 |
else: |
1731 | 1731 |
pt = lineItem.startPoint() |
1732 |
selected = [item for item in self.graphicsView.scene.items(QPointF(pt[0], pt[1])) if |
|
1732 |
selected = [item for item in self.graphicsView.scene().items(QPointF(pt[0], pt[1])) if
|
|
1733 | 1733 |
type(item) is QEngineeringConnectorItem or type(item) is QEngineeringLineItem] |
1734 | 1734 |
if selected and selected[0] is not lineItem: |
1735 | 1735 |
if type(selected[0]) is QEngineeringConnectorItem: |
... | ... | |
1738 | 1738 |
detector.connectLineToLine(selected[0], lineItem, 5) |
1739 | 1739 |
|
1740 | 1740 |
items.append(lineItem) |
1741 |
self.graphicsView.scene.addItem(lineItem) |
|
1741 |
self.graphicsView.scene().addItem(lineItem)
|
|
1742 | 1742 |
app_doc_data.lines.append(lineItem) |
1743 | 1743 |
|
1744 | 1744 |
pt = items[-1].endPoint() |
1745 |
selected = [item for item in self.graphicsView.scene.items(QPointF(pt[0], pt[1])) if |
|
1745 |
selected = [item for item in self.graphicsView.scene().items(QPointF(pt[0], pt[1])) if
|
|
1746 | 1746 |
(type(item) is QEngineeringConnectorItem and item.parent is not items[-1]) or |
1747 | 1747 |
type(item) is QEngineeringLineItem] |
1748 | 1748 |
if selected and selected[0] is not items[-1]: |
... | ... | |
1752 | 1752 |
detector.connectLineToLine(selected[0], items[-1], 5) |
1753 | 1753 |
|
1754 | 1754 |
finally: |
1755 |
self.graphicsView.scene.removeItem(self.actionLine.tag._polyline) |
|
1755 |
self.graphicsView.scene().removeItem(self.actionLine.tag._polyline)
|
|
1756 | 1756 |
self.actionLine.tag.reset() |
1757 | 1757 |
|
1758 | 1758 |
''' |
... | ... | |
1765 | 1765 |
try: |
1766 | 1766 |
if type(cmd) is PlaceLineCommand.PlaceLineCommand: |
1767 | 1767 |
if self.actionLine.tag._polyline: |
1768 |
self.graphicsView.scene.removeItem(self.actionLine.tag._polyline) |
|
1769 |
self.graphicsView.scene.update() |
|
1768 |
self.graphicsView.scene().removeItem(self.actionLine.tag._polyline)
|
|
1769 |
self.graphicsView.scene().update()
|
|
1770 | 1770 |
self.actionLine.tag.reset() |
1771 | 1771 |
|
1772 | 1772 |
self.actionLine.setChecked(False) |
... | ... | |
1778 | 1778 |
self.actionVendor.setChecked(False) |
1779 | 1779 |
else: |
1780 | 1780 |
if hasattr(self.actionLine, 'tag') and self.actionLine.tag._polyline: |
1781 |
self.graphicsView.scene.removeItem(self.actionLine.tag._polyline) |
|
1782 |
self.graphicsView.scene.update() |
|
1781 |
self.graphicsView.scene().removeItem(self.actionLine.tag._polyline)
|
|
1782 |
self.graphicsView.scene().update()
|
|
1783 | 1783 |
self.actionLine.tag.reset() |
1784 | 1784 |
if hasattr(self.actionVendor, 'tag') and self.actionVendor.tag._polyline: |
1785 |
self.graphicsView.scene.removeItem(self.actionVendor.tag._polyline) |
|
1786 |
self.graphicsView.scene.update() |
|
1785 |
self.graphicsView.scene().removeItem(self.actionVendor.tag._polyline)
|
|
1786 |
self.graphicsView.scene().update()
|
|
1787 | 1787 |
self.actionVendor.tag.reset() |
1788 | 1788 |
self.actionLine.setChecked(False) |
1789 | 1789 |
self.actionZoom.setChecked(False) |
... | ... | |
1865 | 1865 |
elif event.key() == Qt.Key_M: # merge text as vertical |
1866 | 1866 |
from TextInfo import TextInfo |
1867 | 1867 |
|
1868 |
textItems = [text for text in self.graphicsView.scene.selectedItems() if |
|
1868 |
textItems = [text for text in self.graphicsView.scene().selectedItems() if
|
|
1869 | 1869 |
type(text) is QEngineeringTextItem] |
1870 | 1870 |
if not textItems or len(textItems) is 1: |
1871 | 1871 |
return |
... | ... | |
1918 | 1918 |
item.size = (width, height) |
1919 | 1919 |
item.angle = angle |
1920 | 1920 |
item.setDefaultTextColor(Qt.blue) |
1921 |
item.addTextItemToScene(self.graphicsView.scene) |
|
1921 |
item.addTextItemToScene(self.graphicsView.scene())
|
|
1922 | 1922 |
item.transfer.onRemoved.connect(self.itemRemoved) |
1923 | 1923 |
elif event.key() == Qt.Key_D: |
1924 | 1924 |
# pop up development toolkit dialog |
... | ... | |
1937 | 1937 |
else: |
1938 | 1938 |
return |
1939 | 1939 |
|
1940 |
symbolItems = [symbol for symbol in self.graphicsView.scene.selectedItems() if |
|
1940 |
symbolItems = [symbol for symbol in self.graphicsView.scene().selectedItems() if
|
|
1941 | 1941 |
issubclass(type(symbol), SymbolSvgItem)] |
1942 | 1942 |
old_symbol = None |
1943 | 1943 |
if symbolItems and len(symbolItems) is 1: |
... | ... | |
1957 | 1957 |
configs = app_doc_data.getAppConfigs('app', 'mode') |
1958 | 1958 |
if configs and 1 == len(configs) and 'advanced' == configs[0].value: |
1959 | 1959 |
advanced = True |
1960 |
items = self.graphicsView.scene.selectedItems() |
|
1960 |
items = self.graphicsView.scene().selectedItems()
|
|
1961 | 1961 |
if items: |
1962 | 1962 |
item = self.symbolTreeWidget.currentItem() |
1963 | 1963 |
if item: |
... | ... | |
2112 | 2112 |
else: |
2113 | 2113 |
self.itemTreeWidget.itemRemoved(item) |
2114 | 2114 |
|
2115 |
matches = [_item for _item in self.graphicsView.scene.items() if |
|
2115 |
matches = [_item for _item in self.graphicsView.scene().items() if
|
|
2116 | 2116 |
hasattr(_item, 'connectors') and [connector for connector in _item.connectors if |
2117 | 2117 |
connector.connectedItem is item]] |
2118 | 2118 |
for match in matches: |
... | ... | |
2121 | 2121 |
connector.connectedItem = None |
2122 | 2122 |
connector.highlight(False) |
2123 | 2123 |
|
2124 |
# matches = [_item for _item in self.graphicsView.scene.items() if hasattr(_item, 'remove_assoc_item')] |
|
2124 |
# matches = [_item for _item in self.graphicsView.scene().items() if hasattr(_item, 'remove_assoc_item')]
|
|
2125 | 2125 |
# for _item in matches: |
2126 | 2126 |
# _item.remove_assoc_item(item) |
2127 | 2127 |
|
... | ... | |
2132 | 2132 |
if type(item) is QEngineeringLineItem and item in app_doc_data.lines: |
2133 | 2133 |
app_doc_data.lines.remove(item) |
2134 | 2134 |
|
2135 |
matches = [_item for _item in self.graphicsView.scene.items() if |
|
2135 |
matches = [_item for _item in self.graphicsView.scene().items() if
|
|
2136 | 2136 |
type(_item) is QEngineeringLineNoTextItem] |
2137 | 2137 |
matches.extend([lineNo for lineNo in app_doc_data.tracerLineNos if |
2138 | 2138 |
type(lineNo) is QEngineeringTrimLineNoTextItem]) |
... | ... | |
2153 | 2153 |
app_doc_data.tracerLineNos.pop(app_doc_data.tracerLineNos.index(match)) |
2154 | 2154 |
# break |
2155 | 2155 |
|
2156 |
matches = [_item for _item in self.graphicsView.scene.items() if hasattr(_item, 'owner')] |
|
2156 |
matches = [_item for _item in self.graphicsView.scene().items() if hasattr(_item, 'owner')]
|
|
2157 | 2157 |
for match in matches: |
2158 | 2158 |
if match.owner is item: |
2159 | 2159 |
match.owner = None |
2160 | 2160 |
|
2161 |
matches = [_item for _item in self.graphicsView.scene.items() if hasattr(_item, 'attrs')] |
|
2161 |
matches = [_item for _item in self.graphicsView.scene().items() if hasattr(_item, 'attrs')]
|
|
2162 | 2162 |
# done = False |
2163 | 2163 |
for match in matches: |
2164 | 2164 |
assocs = match.associations() |
... | ... | |
2200 | 2200 |
return |
2201 | 2201 |
|
2202 | 2202 |
try: |
2203 |
dlg = QConnectAttrDialog(self, self.graphicsView.scene) |
|
2203 |
dlg = QConnectAttrDialog(self, self.graphicsView.scene())
|
|
2204 | 2204 |
dlg.setWindowFlags(self.windowFlags() & ~Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint) |
2205 | 2205 |
dlg.exec_() |
2206 | 2206 |
if dlg.isRunned: |
... | ... | |
2255 | 2255 |
self.createDetectedTitleBlockTextItem(titleBlockTextInfoList) |
2256 | 2256 |
|
2257 | 2257 |
# update scene |
2258 |
# self.graphicsView.scene.update(self.graphicsView.sceneRect()) |
|
2258 |
# self.graphicsView.scene().update(self.graphicsView.sceneRect())
|
|
2259 | 2259 |
except Exception as ex: |
2260 | 2260 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
2261 | 2261 |
sys.exc_info()[-1].tb_lineno) |
... | ... | |
2274 | 2274 |
if issubclass(type(symbol), SymbolSvgItem): |
2275 | 2275 |
self.addSvgItemToScene(symbol) |
2276 | 2276 |
else: |
2277 |
self.graphicsView.scene.addItem(symbol) |
|
2277 |
self.graphicsView.scene().addItem(symbol)
|
|
2278 | 2278 |
|
2279 | 2279 |
for text in appDocData.texts: |
2280 | 2280 |
self.addTextItemToScene(text) |
... | ... | |
2283 | 2283 |
self.addTextItemToScene(lineNo) |
2284 | 2284 |
|
2285 | 2285 |
for line in appDocData.lines: |
2286 |
self.graphicsView.scene.addItem(line) |
|
2286 |
self.graphicsView.scene().addItem(line)
|
|
2287 | 2287 |
line.transfer.onRemoved.connect(self.itemRemoved) |
2288 | 2288 |
for conn in line.connectors: |
2289 | 2289 |
conn.transfer.onPosChanged.connect(line.onConnectorPosChaned) |
2290 | 2290 |
|
2291 | 2291 |
for unknown in appDocData.unknowns + appDocData.lineIndicators: |
2292 |
self.graphicsView.scene.addItem(unknown) |
|
2292 |
self.graphicsView.scene().addItem(unknown)
|
|
2293 | 2293 |
finally: |
2294 | 2294 |
# update scene |
2295 |
self.graphicsView.scene.update(self.graphicsView.sceneRect()) |
|
2295 |
self.graphicsView.scene().update(self.graphicsView.sceneRect())
|
|
2296 | 2296 |
|
2297 | 2297 |
def postDetectLineProcess(self): |
2298 | 2298 |
''' |
... | ... | |
2311 | 2311 |
tableNameFormat = tableName.replace(' ', '').replace('&&', 'n') |
2312 | 2312 |
tableDatas.append(appDocData.getCodeTable(tableNameFormat)) |
2313 | 2313 |
|
2314 |
items = self.graphicsView.scene.items() |
|
2314 |
items = self.graphicsView.scene().items()
|
|
2315 | 2315 |
for item in items: |
2316 | 2316 |
if type(item) is not QEngineeringTextItem: |
2317 | 2317 |
continue |
... | ... | |
2331 | 2331 |
lineItem.size = item.size |
2332 | 2332 |
lineItem.angle = item.angle |
2333 | 2333 |
lineItem.area = item.area |
2334 |
# lineItem.addTextItemToScene(self.graphicsView.scene) |
|
2334 |
# lineItem.addTextItemToScene(self.graphicsView.scene())
|
|
2335 | 2335 |
lineItem.transfer.onRemoved.connect(self.itemRemoved) |
2336 | 2336 |
item.transfer.onRemoved.emit(item) |
2337 | 2337 |
appDocData.lineNos.append(lineItem) |
... | ... | |
2395 | 2395 |
for pts in lineList: |
2396 | 2396 |
processLine = QEngineeringLineItem(vertices=[(area.x + param[0], area.y + param[1]) for param in pts]) |
2397 | 2397 |
processLine.area = 'Drawing' |
2398 |
# self.graphicsView.scene.addItem(processLine) |
|
2398 |
# self.graphicsView.scene().addItem(processLine)
|
|
2399 | 2399 |
appDocData.lines.append(processLine) |
2400 | 2400 |
appDocData.allItems.append(processLine) |
2401 | 2401 |
|
... | ... | |
2473 | 2473 |
item.isSymbol = True |
2474 | 2474 |
item.angle = angle |
2475 | 2475 |
item.setPen(QPen(Qt.red, 5, Qt.SolidLine)) |
2476 |
# self.graphicsView.scene.addItem(item) |
|
2476 |
# self.graphicsView.scene().addItem(item)
|
|
2477 | 2477 |
# appDocData.symbols.append(item) |
2478 | 2478 |
appDocData.allItems.append(item) |
2479 | 2479 |
# up to here |
... | ... | |
2895 | 2895 |
item.isSymbol = True |
2896 | 2896 |
item.angle = angle |
2897 | 2897 |
item.setPen(QPen(Qt.red, 5, Qt.SolidLine)) |
2898 |
self.graphicsView.scene.addItem(item) |
|
2898 |
self.graphicsView.scene().addItem(item)
|
|
2899 | 2899 |
item.transfer.onRemoved.connect(self.itemRemoved) |
2900 | 2900 |
|
2901 | 2901 |
self.progress.setValue(self.progress.value() + 1) |
... | ... | |
2937 | 2937 |
item = QEngineeringLineItem.from_database(line) |
2938 | 2938 |
if item: |
2939 | 2939 |
item.transfer.onRemoved.connect(self.itemRemoved) |
2940 |
self.graphicsView.scene.addItem(item) |
|
2940 |
self.graphicsView.scene().addItem(item)
|
|
2941 | 2941 |
lines.append(item) |
2942 | 2942 |
|
2943 | 2943 |
self.progress.setValue(self.progress.value() + 1) |
... | ... | |
2950 | 2950 |
item.transfer.onRemoved.connect(self.itemRemoved) |
2951 | 2951 |
if item is not None: |
2952 | 2952 |
item.transfer.onRemoved.connect(self.itemRemoved) |
2953 |
self.graphicsView.scene.addItem(item) |
|
2953 |
self.graphicsView.scene().addItem(item)
|
|
2954 | 2954 |
|
2955 | 2955 |
self.progress.setValue(self.progress.value() + 1) |
2956 | 2956 |
|
... | ... | |
3020 | 3020 |
item = QEngineeringVendorItem.from_database(component) |
3021 | 3021 |
if item is not None: |
3022 | 3022 |
item.transfer.onRemoved.connect(self.itemRemoved) |
3023 |
self.graphicsView.scene.addItem(item) |
|
3023 |
self.graphicsView.scene().addItem(item)
|
|
3024 | 3024 |
|
3025 | 3025 |
# connect flow item to line |
3026 | 3026 |
for line in lines: |
... | ... | |
3095 | 3095 |
|
3096 | 3096 |
def update_items(items): |
3097 | 3097 |
for item in items: |
3098 |
up_progress = False |
|
3099 | 3098 |
# binding items |
3100 |
if hasattr(item, 'owner'): |
|
3101 |
item.owner |
|
3102 |
if hasattr(item, 'connectors'): |
|
3103 |
for connector in item.connectors: |
|
3104 |
connector.connectedItem |
|
3099 |
item.owner |
|
3100 |
for connector in item.connectors: |
|
3101 |
connector.connectedItem |
|
3105 | 3102 |
|
3106 | 3103 |
return items |
3107 | 3104 |
|
... | ... | |
3115 | 3112 |
docData = AppDocData.instance() |
3116 | 3113 |
|
3117 | 3114 |
try: |
3118 |
# self.graphicsView.scene.blockSignals(True)
|
|
3115 |
self.graphicsView.scene().blockSignals(True)
|
|
3119 | 3116 |
|
3120 | 3117 |
symbols = [] |
3121 | 3118 |
lines = [] |
... | ... | |
3175 | 3172 |
item.transfer.onRemoved.connect(self.itemRemoved) |
3176 | 3173 |
symbols.append(item) |
3177 | 3174 |
docData.symbols.append(item) |
3178 |
self.addSvgItemToScene(item)
|
|
3175 |
item.addSvgItemToScene(self.graphicsView.scene())
|
|
3179 | 3176 |
else: |
3180 | 3177 |
pt = [float(x) for x in symbol.find('LOCATION').text.split(',')] |
3181 | 3178 |
size = [float(x) for x in symbol.find('SIZE').text.split(',')] |
... | ... | |
3184 | 3181 |
item.isSymbol = True |
3185 | 3182 |
item.angle = angle |
3186 | 3183 |
item.setPen(QPen(Qt.red, 5, Qt.SolidLine)) |
3187 |
self.graphicsView.scene.addItem(item) |
|
3184 |
self.graphicsView.scene().addItem(item)
|
|
3188 | 3185 |
item.transfer.onRemoved.connect(self.itemRemoved) |
3189 | 3186 |
|
3190 | 3187 |
self.progress.setValue(self.progress.value() + 1) |
... | ... | |
3233 | 3230 |
item = QEngineeringLineItem.fromXml(line) |
3234 | 3231 |
if item: |
3235 | 3232 |
item.transfer.onRemoved.connect(self.itemRemoved) |
3236 |
self.graphicsView.scene.addItem(item) |
|
3233 |
self.graphicsView.scene().addItem(item)
|
|
3237 | 3234 |
lines.append(item) |
3238 | 3235 |
|
3239 | 3236 |
self.progress.setValue(self.progress.value() + 1) |
... | ... | |
3244 | 3241 |
item = QEngineeringUnknownItem.fromXml(unknown) |
3245 | 3242 |
if item is not None: |
3246 | 3243 |
item.transfer.onRemoved.connect(self.itemRemoved) |
3247 |
self.graphicsView.scene.addItem(item) |
|
3244 |
self.graphicsView.scene().addItem(item)
|
|
3248 | 3245 |
|
3249 | 3246 |
self.progress.setValue(self.progress.value() + 1) |
3250 | 3247 |
|
... | ... | |
3323 | 3320 |
for vendor in root.find('VENDORS').iter('VENDOR'): |
3324 | 3321 |
item = QEngineeringVendorItem.fromXml(vendor) |
3325 | 3322 |
item.transfer.onRemoved.connect(self.itemRemoved) |
3326 |
self.graphicsView.scene.addItem(item) |
|
3323 |
self.graphicsView.scene().addItem(item)
|
|
3327 | 3324 |
|
3328 | 3325 |
# connect flow item to line |
3329 | 3326 |
for line in lines: |
... | ... | |
3337 | 3334 |
# up to here |
3338 | 3335 |
|
3339 | 3336 |
""" update scene """ |
3340 |
self.graphicsView.scene.update(self.graphicsView.sceneRect()) |
|
3341 |
for item in self.graphicsView.scene.items(): |
|
3337 |
self.addMessage.emit(MessageType.Normal, 'update scene') |
|
3338 |
_items = [_item for _item in self.graphicsView.scene().items() if hasattr(_item, 'owner') or hasattr(_item, 'connectors')] |
|
3339 |
items = divide_chunks(_items, App.THREAD_MAX_WORKER if len(_items) > App.THREAD_MAX_WORKER else len(_items)) |
|
3340 |
with futures.ThreadPoolExecutor(max_workers=App.THREAD_MAX_WORKER) as pool: |
|
3341 |
future_items = {pool.submit(update_items, _items): _items for _items in items} |
|
3342 |
for future in futures.as_completed(future_items): |
|
3343 |
_items = future.result() |
|
3344 |
self.progress.setValue(self.progress.value() + len(_items)) |
|
3345 |
|
|
3346 |
""" |
|
3347 |
for item in [_item for _item in self.graphicsView.scene().items() if hasattr(_item, 'owner') or hasattr(_item, 'connectors')]: |
|
3342 | 3348 |
up_progress = False |
3343 | 3349 |
# binding items |
3344 |
if hasattr(item, 'owner'): |
|
3345 |
item.owner |
|
3346 |
up_progress = True |
|
3347 |
if hasattr(item, 'connectors'): |
|
3348 |
for connector in item.connectors: |
|
3349 |
connector.connectedItem |
|
3350 |
up_progress = True |
|
3350 |
item.owner |
|
3351 |
for connector in item.connectors: |
|
3352 |
connector.connectedItem |
|
3351 | 3353 |
|
3352 |
if up_progress:
|
|
3353 |
self.progress.setValue(self.progress.value() + 1)
|
|
3354 |
self.progress.setValue(self.progress.value() + 1)
|
|
3355 |
"""
|
|
3354 | 3356 |
|
3355 |
for item in self.graphicsView.scene.items(): |
|
3357 |
self.addMessage.emit(MessageType.Normal, 'set visible') |
|
3358 |
for item in self.graphicsView.scene().items(): |
|
3356 | 3359 |
item.setVisible(True) |
3357 | 3360 |
|
3361 |
self.graphicsView.scene().update(self.graphicsView.sceneRect()) |
|
3358 | 3362 |
except Exception as ex: |
3359 | 3363 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
3360 | 3364 |
sys.exc_info()[-1].tb_lineno) |
... | ... | |
3362 | 3366 |
finally: |
3363 | 3367 |
self.itemTreeWidget.update_item_count() |
3364 | 3368 |
self.itemTreeWidget.expandAll() |
3365 |
# self.graphicsView.scene.blockSignals(False)
|
|
3369 |
self.graphicsView.scene().blockSignals(False)
|
|
3366 | 3370 |
|
3367 | 3371 |
''' |
3368 | 3372 |
@brief Remove added item on same place and Add GraphicsItem |
... | ... | |
3373 | 3377 |
''' |
3374 | 3378 |
|
3375 | 3379 |
def addSvgItemToScene(self, svgItem): |
3376 |
svgItem.addSvgItemToScene(self.graphicsView.scene) |
|
3380 |
svgItem.addSvgItemToScene(self.graphicsView.scene())
|
|
3377 | 3381 |
|
3378 | 3382 |
''' |
3379 | 3383 |
@brief Remove added item on same place and Add GraphicsItem |
... | ... | |
3385 | 3389 |
''' |
3386 | 3390 |
|
3387 | 3391 |
def addTextItemToScene(self, textItem): |
3388 |
textItem.addTextItemToScene(self.graphicsView.scene) |
|
3392 |
textItem.addTextItemToScene(self.graphicsView.scene())
|
|
3389 | 3393 |
|
3390 | 3394 |
''' |
3391 | 3395 |
@brief Remove added item on same place and Add GraphicsItem |
... | ... | |
3395 | 3399 |
''' |
3396 | 3400 |
|
3397 | 3401 |
def addLineItemToScene(self, lineItem): |
3398 |
self.graphicsView.scene.addItem(lineItem) |
|
3402 |
self.graphicsView.scene().addItem(lineItem)
|
|
3399 | 3403 |
|
3400 | 3404 |
''' |
3401 | 3405 |
@brief generate output xml file |
... | ... | |
3414 | 3418 |
try: |
3415 | 3419 |
appDocData = AppDocData.instance() |
3416 | 3420 |
|
3417 |
## collect items
|
|
3421 |
# collect items |
|
3418 | 3422 |
appDocData.lines.clear() |
3419 |
appDocData.lines = [item for item in self.graphicsView.scene.items() if |
|
3423 |
appDocData.lines = [item for item in self.graphicsView().scene.items() if
|
|
3420 | 3424 |
type(item) is QEngineeringLineItem and item.owner is None] |
3421 | 3425 |
|
3422 | 3426 |
appDocData.symbols.clear() |
3423 |
appDocData.symbols = [item for item in self.graphicsView.scene.items() if |
|
3427 |
appDocData.symbols = [item for item in self.graphicsView.scene().items() if
|
|
3424 | 3428 |
issubclass(type(item), SymbolSvgItem) and item.owner is None] |
3425 | 3429 |
|
3426 | 3430 |
appDocData.equipments.clear() |
3427 |
for item in self.graphicsView.scene.items(): |
|
3431 |
for item in self.graphicsView.scene().items():
|
|
3428 | 3432 |
if type(item) is QEngineeringEquipmentItem: |
3429 | 3433 |
appDocData.equipments.append(item) |
3430 | 3434 |
|
3431 | 3435 |
appDocData.texts.clear() |
3432 |
appDocData.texts = [item for item in self.graphicsView.scene.items() if |
|
3436 |
appDocData.texts = [item for item in self.graphicsView.scene().items() if
|
|
3433 | 3437 |
issubclass(type(item), QEngineeringTextItem) and type( |
3434 | 3438 |
item) is not QEngineeringLineNoTextItem] |
3435 |
## up to here
|
|
3439 |
# up to here |
|
3436 | 3440 |
|
3437 | 3441 |
appDocData.imgOutput = np.ones((appDocData.activeDrawing.height, appDocData.activeDrawing.width), |
3438 | 3442 |
np.uint8) * 255 |
DTI_PID/DTI_PID/OcrResultDialog.py | ||
---|---|---|
131 | 131 |
|
132 | 132 |
def display_text_rect(self): |
133 | 133 |
"""display text bounding rectangle""" |
134 |
for item in self.graphicsView.scene.items(): |
|
134 |
for item in self.graphicsView.scene().items():
|
|
135 | 135 |
if type(item) is not QGraphicsPixmapItem: |
136 |
self.graphicsView.scene.removeItem(item) |
|
136 |
self.graphicsView.scene().removeItem(item)
|
|
137 | 137 |
|
138 | 138 |
for text_info in self.textInfoList: |
139 |
self.graphicsView.scene.addRect(text_info.getX(), text_info.getY(), |
|
139 |
self.graphicsView.scene().addRect(text_info.getX(), text_info.getY(),
|
|
140 | 140 |
text_info.getW(), text_info.getH(), QPen(Qt.red, 1, Qt.SolidLine)) |
141 | 141 |
|
142 | 142 |
''' |
... | ... | |
182 | 182 |
text_info.setW(rect.width()) |
183 | 183 |
text_info.setH(rect.height()) |
184 | 184 |
|
185 |
self.graphicsView.scene.addRect(QRectF(text_info.getX(), text_info.getY(), text_info.getW(), text_info.getH()), |
|
185 |
self.graphicsView.scene().addRect(QRectF(text_info.getX(), text_info.getY(), text_info.getW(), text_info.getH()),
|
|
186 | 186 |
QPen(Qt.red, 1, Qt.SolidLine)) |
187 | 187 |
|
188 | 188 |
''' |
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
64 | 64 |
self.mainWindow = mainWindow |
65 | 65 |
# Image is displayed as a QPixmap in a QGraphicsScene attached to this QGraphicsView. |
66 | 66 |
self.command = None |
67 |
self.scene = QtImageViewerScene(self) |
|
68 |
self.setScene(self.scene) |
|
67 |
self._scene = QtImageViewerScene(self)
|
|
68 |
self.setScene(self._scene)
|
|
69 | 69 |
|
70 | 70 |
self.scaleFactor = 1.0 |
71 | 71 |
self.numScheduledScalings = 0 |
... | ... | |
136 | 136 |
""" Removes the current image pixmap from the scene if it exists. |
137 | 137 |
""" |
138 | 138 |
if self.hasImage(): |
139 |
self.scene.removeItem(self._pixmapHandle) |
|
139 |
self.scene().removeItem(self._pixmapHandle)
|
|
140 | 140 |
self._pixmapHandle = None |
141 | 141 |
|
142 | 142 |
def pixmap(self): |
... | ... | |
169 | 169 |
raise RuntimeError("ImageViewer.setImage: Argument must be a QImage or QPixmap.") |
170 | 170 |
|
171 | 171 |
self.clearImage() |
172 |
self.scene.clear() |
|
172 |
self.scene().clear()
|
|
173 | 173 |
|
174 | 174 |
if self.hasImage(): |
175 | 175 |
self._pixmapHandle.setPixmap(pixmap) |
176 | 176 |
else: |
177 |
self._pixmapHandle = self.scene.addPixmap(pixmap) |
|
177 |
self._pixmapHandle = self.scene().addPixmap(pixmap)
|
|
178 | 178 |
self._pixmapHandle.setFlags(QGraphicsItem.ItemClipsChildrenToShape) |
179 | 179 |
|
180 | 180 |
self.setSceneRect(QRectF(pixmap.rect())) # Set scene size to image size. |
... | ... | |
295 | 295 |
right_bottom = self.mapToScene(clickPos.x() + HALF_SIZE // adjust, clickPos.y() + HALF_SIZE // adjust) |
296 | 296 |
|
297 | 297 |
zoomArea = QRectF(left_top, right_bottom) |
298 |
self.scene.setSelectionArea(QPainterPath()) # Clear current selection area. |
|
298 |
self.scene().setSelectionArea(QPainterPath()) # Clear current selection area.
|
|
299 | 299 |
if zoomArea.isValid(): |
300 | 300 |
self.zoomStack.append(zoomArea) |
301 | 301 |
self.updateViewer(zoomArea) |
302 | 302 |
else: |
303 | 303 |
zoomNewRect = None |
304 | 304 |
clickPos = self.mapToScene(clickPos.x() // adjust, clickPos.y() // adjust) |
305 |
self.scene.clearSelection() |
|
305 |
self.scene().clearSelection()
|
|
306 | 306 |
if self.zoomStack: |
307 | 307 |
zoomNewRect = self.zoomStack.pop() |
308 | 308 |
zoomNewRect = QRectF(clickPos.x() - zoomNewRect.width() / 2, clickPos.y() - zoomNewRect.height() / 2, zoomNewRect.width(), zoomNewRect.height()) |
... | ... | |
325 | 325 |
print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
326 | 326 |
sys.exc_info()[-1].tb_lineno)) |
327 | 327 |
|
328 |
if self.scene.guidesEnabled: |
|
329 |
self.scene.coords = self.mapToScene(event.pos()) |
|
330 |
self.scene.invalidate() |
|
328 |
if self.scene().guidesEnabled:
|
|
329 |
self.scene().coords = self.mapToScene(event.pos())
|
|
330 |
self.scene().invalidate()
|
|
331 | 331 |
|
332 | 332 |
QGraphicsView.mouseMoveEvent(self, event) |
333 | 333 |
|
... | ... | |
365 | 365 |
scenePos = self.mapToScene(event.pos()) |
366 | 366 |
instance = self.command.execute(['mouseReleaseEvent', event, scenePos]) |
367 | 367 |
if instance is not None: |
368 |
self.scene.addItem(instance) |
|
368 |
self.scene().addItem(instance)
|
|
369 | 369 |
|
370 | 370 |
if self.command is not None and self.command.isTreated == True: |
371 | 371 |
if self.command.name == 'Default' and self.command.isCopy: |
... | ... | |
415 | 415 |
|
416 | 416 |
try: |
417 | 417 |
if event.key() == Qt.Key_Delete: |
418 |
for item in [item for item in self.scene.selectedItems() if hasattr(item, 'transfer')]: |
|
418 |
for item in [item for item in self.scene().selectedItems() if hasattr(item, 'transfer')]:
|
|
419 | 419 |
item.transfer.onRemoved.emit(item) |
420 | 420 |
elif event.key() == Qt.Key_Escape: |
421 | 421 |
if self.command is not None: |
... | ... | |
429 | 429 |
self.mainWindow.keyPressEvent(event) |
430 | 430 |
|
431 | 431 |
if event.key() == Qt.Key_Up or event.key() == Qt.Key_Down or event.key() == Qt.Key_Left or event.key() == Qt.Key_Right: |
432 |
items = [text for text in self.scene.selectedItems() if |
|
432 |
items = [text for text in self.scene().selectedItems() if
|
|
433 | 433 |
issubclass(type(text), QEngineeringTextItem) or issubclass(type(text), SymbolSvgItem)] |
434 |
if len(items) > 1:
|
|
434 |
if items:
|
|
435 | 435 |
for item in items: |
436 | 436 |
item.keyPressEvent(event) |
437 | 437 |
return |
... | ... | |
497 | 497 |
pen.setStyle(Qt.DashLine) |
498 | 498 |
pen.setWidthF(0.5) |
499 | 499 |
if isShow: |
500 |
items = self.scene.items() |
|
500 |
items = self.scene().items()
|
|
501 | 501 |
for item in self.GUIDELINE_ITEMS: |
502 | 502 |
if item in items: |
503 |
self.scene.removeItem(item) |
|
503 |
self.scene().removeItem(item)
|
|
504 | 504 |
self.GUIDELINE_ITEMS.clear() |
505 | 505 |
|
506 | 506 |
if pos is not None: |
507 |
verticalLine = self.scene.addLine(pos.x(), 0, pos.x(), height, pen) |
|
508 |
horizontalLine = self.scene.addLine(0, pos.y(), width, pos.y(), pen) |
|
507 |
verticalLine = self.scene().addLine(pos.x(), 0, pos.x(), height, pen)
|
|
508 |
horizontalLine = self.scene().addLine(0, pos.y(), width, pos.y(), pen)
|
|
509 | 509 |
else: |
510 |
verticalLine = self.scene.addLine(round(width * 0.5), 0, round(width * 0.5), height, pen) |
|
511 |
horizontalLine = self.scene.addLine(0, round(height * 0.5), width, round(height * 0.5), pen) |
|
510 |
verticalLine = self.scene().addLine(round(width * 0.5), 0, round(width * 0.5), height, pen)
|
|
511 |
horizontalLine = self.scene().addLine(0, round(height * 0.5), width, round(height * 0.5), pen)
|
|
512 | 512 |
|
513 | 513 |
self.GUIDELINE_ITEMS.append(verticalLine) |
514 | 514 |
self.GUIDELINE_ITEMS.append(horizontalLine) |
515 | 515 |
else: |
516 |
items = self.scene.items() |
|
516 |
items = self.scene().items()
|
|
517 | 517 |
for item in self.GUIDELINE_ITEMS: |
518 | 518 |
if item in items: |
519 |
self.scene.removeItem(item) |
|
519 |
self.scene().removeItem(item)
|
|
520 | 520 |
self.GUIDELINE_ITEMS.clear() |
521 | 521 |
|
522 | 522 |
''' |
... | ... | |
537 | 537 |
|
538 | 538 |
def dragMoveEvent(self, event): |
539 | 539 |
scenePos = self.mapToScene(event.pos()) |
540 |
items = [item for item in self.scene.items(scenePos) if |
|
540 |
items = [item for item in self.scene().items(scenePos) if
|
|
541 | 541 |
type(item) is not QGraphicsPixmapItem and type(item) is not QGraphicsTextItem] |
542 | 542 |
if len(items) > 0: |
543 | 543 |
if not hasattr(self, '_underItem') or self._underItem is not items[0]: |
544 | 544 |
if hasattr(self, '_underItem') and self._underItem is not None: |
545 |
if hasattr(self._underItem, 'highlight') and self._underItem in self.scene.items(): |
|
545 |
if hasattr(self._underItem, 'highlight') and self._underItem in self.scene().items():
|
|
546 | 546 |
self._underItem.highlight(False) |
547 | 547 |
else: |
548 | 548 |
self._underItem = None |
... | ... | |
568 | 568 |
from AppDocData import AppDocData |
569 | 569 |
import symbol |
570 | 570 |
|
571 |
if len(self.scene.items()) is 0: |
|
571 |
if len(self.scene().items()) is 0:
|
|
572 | 572 |
return |
573 |
if hasattr(self, '_underItem') and self._underItem is not None and self._underItem in self.scene.items(): |
|
573 |
if hasattr(self, '_underItem') and self._underItem is not None and self._underItem in self.scene().items():
|
|
574 | 574 |
self._underItem.hoverLeaveEvent(event) |
575 | 575 |
self._underItem = None |
576 | 576 |
else: |
... | ... | |
627 | 627 |
|
628 | 628 |
svg.transfer.onRemoved.connect(self.mainWindow.itemRemoved) |
629 | 629 |
|
630 |
items = [item for item in self.scene.items(scenePos) if |
|
630 |
items = [item for item in self.scene().items(scenePos) if
|
|
631 | 631 |
type(item) is not QGraphicsPixmapItem and type(item) is not QGraphicsTextItem] |
632 | 632 |
connectors = [] |
633 | 633 |
if len(items) > 0 and type(items[0]) is QEngineeringConnectorItem: |
634 | 634 |
scenePos = QPointF(items[0].center()[0], items[0].center()[1]) |
635 | 635 |
connectors = [connector for connector in items if issubclass(type(connector.parentItem()), SymbolSvgItem)] |
636 | 636 |
|
637 |
matches = [item for item in self.scene.items() if |
|
637 |
matches = [item for item in self.scene().items() if
|
|
638 | 638 |
(type(item) is QEngineeringLineItem) and (item.distanceTo((scenePos.x(), scenePos.y())) < 20)] |
639 | 639 |
allowed_error = 0.00001 |
640 | 640 |
if False: # len(matches) == 1: |
... | ... | |
697 | 697 |
0].sceneBoundingRect().center().y() + dy |
698 | 698 |
svg.loc = [x - svg.symbolOrigin[0], y - svg.symbolOrigin[1]] |
699 | 699 |
svg.origin = [x, y] |
700 |
svg.addSvgItemToScene(self.scene) |
|
700 |
svg.addSvgItemToScene(self.scene())
|
|
701 | 701 |
|
702 | 702 |
items = [item for item in self.scene.items(scenePos) if |
703 | 703 |
type(item) is not QGraphicsPixmapItem and type(item) is not QGraphicsTextItem] |
... | ... | |
730 | 730 |
svg.origin = [round(scenePos.x(), 1), round(scenePos.y(), 1)] |
731 | 731 |
if len(svg.connectors) == 1: |
732 | 732 |
# single connection item assistant |
733 |
items = [item for item in self.scene.items(scenePos) if |
|
733 |
items = [item for item in self.scene().items(scenePos) if
|
|
734 | 734 |
type(item) is QEngineeringConnectorItem and item.parentItem() is not svg and issubclass( |
735 | 735 |
type(item.parentItem()), SymbolSvgItem) and not item.connectedItem] |
736 | 736 |
if items: |
... | ... | |
751 | 751 |
items[0].connectedItem = svg |
752 | 752 |
items[0].highlight(False) |
753 | 753 |
|
754 |
svg.addSvgItemToScene(self.scene) |
|
754 |
svg.addSvgItemToScene(self.scene())
|
|
755 | 755 |
|
756 | 756 |
# svg.reSettingConnetors() |
757 | 757 |
|
758 |
self.scene.clearFocus() |
|
759 |
for item in self.scene.selectedItems(): |
|
758 |
self.scene().clearFocus()
|
|
759 |
for item in self.scene().selectedItems():
|
|
760 | 760 |
item.setSelected(False) |
761 | 761 |
|
762 | 762 |
self.setFocus() |
763 | 763 |
svg.setSelected(True) |
764 |
self.scene.setFocusItem(svg) |
|
764 |
self.scene()()()()()()()()().setFocusItem(svg)
|
|
765 | 765 |
|
766 | 766 |
''' |
767 | 767 |
@brief find item by uid (SymbolSvgItem 기반, QEngineeringConnectorItem 제외, QEngineeringLineItem 포함) |
... | ... | |
772 | 772 |
def findItemByUid(self, uid): |
773 | 773 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
774 | 774 |
|
775 |
items = [item for item in self.scene.items() if hasattr(item, 'uid') and str(item.uid) == str(uid)] |
|
775 |
items = [item for item in self.scene().items() if hasattr(item, 'uid') and str(item.uid) == str(uid)]
|
|
776 | 776 |
return items[0] if items else None |
777 | 777 |
|
778 | 778 |
def convertQImageToMat(self, incomingImage): |
DTI_PID/DTI_PID/Shapes/GraphicsBoundingBoxItem.py | ||
---|---|---|
36 | 36 |
self.isCreated = False |
37 | 37 |
self._vertices = [] |
38 | 38 |
|
39 |
## create connectors for corner
|
|
39 |
# create connectors for corner |
|
40 | 40 |
connector = QEngineeringConnectorItem(parent=self, symbol=False) |
41 | 41 |
connector.setPos((x, y)) |
42 | 42 |
connector.setParentItem(self) |
... | ... | |
72 | 72 |
connector.setAcceptTouchEvents(True) |
73 | 73 |
connector.transfer.onPosChanged.connect(self.onConnectorPosChaned) |
74 | 74 |
self.connectors.append(connector) |
75 |
## up to here
|
|
75 |
# up to here |
|
76 | 76 |
|
77 | 77 |
self.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable) |
78 | 78 |
self.transfer = Transfer() |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
135 | 135 |
""" return string represent uuid """ |
136 | 136 |
return str(self.uid) |
137 | 137 |
|
138 |
''' |
|
139 |
@breif getter owner |
|
140 |
@author humkyung |
|
141 |
@date 2018.05.10 |
|
142 |
''' |
|
143 |
|
|
144 | 138 |
@property |
145 | 139 |
def owner(self): |
140 |
"""get owner""" |
|
146 | 141 |
import uuid |
147 | 142 |
|
148 | 143 |
if self._owner and type(self._owner) is uuid.UUID: |
149 | 144 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self._owner)] |
150 |
if matches: self._owner = matches[0] |
|
145 |
if matches: |
|
146 |
self._owner = matches[0] |
|
151 | 147 |
|
152 | 148 |
if type(self._owner) is not uuid.UUID and type(self._owner) is not str: |
153 | 149 |
return self._owner |
... | ... | |
1607 | 1603 |
_attr.AttrAt = matchAttr.AttrAt |
1608 | 1604 |
_attr.Expression = matchAttr.Expression |
1609 | 1605 |
_attr.Length = matchAttr.Length |
1610 |
## up to here 2
|
|
1606 |
# up to here 2 |
|
1611 | 1607 |
if _attr.AttributeType == 'Spec': |
1612 | 1608 |
item.attrs[_attr] = [attr.text.split(',')[0], attr.text.split(',')[1]] |
1613 | 1609 |
else: |
1614 |
## for old spec break item that has not uid currectly, may not necessary new data
|
|
1610 |
# for old spec break item that has not uid currectly, may not necessary new data |
|
1615 | 1611 |
_attr.AssocItem = uuid.UUID(attr.text) if attr.text and attr.text != 'None' else None |
1616 |
## up to here 3
|
|
1612 |
# up to here 3 |
|
1617 | 1613 |
item.attrs[_attr] = attr.text |
1618 | 1614 |
''' |
1619 | 1615 |
elif _attr.Attribute == 'UpStream': |
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py | ||
---|---|---|
130 | 130 |
graphicsView = App.mainWnd().graphicsView |
131 | 131 |
if dialog.code_area: |
132 | 132 |
if dialog.code_area.scene(): |
133 |
graphicsView.scene.removeItem(dialog.code_area) |
|
133 |
graphicsView.scene().removeItem(dialog.code_area)
|
|
134 | 134 |
if dialog.desc_area: |
135 | 135 |
if dialog.desc_area.scene(): |
136 |
graphicsView.scene.removeItem(dialog.desc_area) |
|
136 |
graphicsView.scene().removeItem(dialog.desc_area)
|
|
137 | 137 |
graphicsView.useDefaultCommand() |
138 | 138 |
# target setting |
139 | 139 |
elif column == 6: |
DTI_PID/DTI_PID/TextItemEditDialog.py | ||
---|---|---|
60 | 60 |
|
61 | 61 |
text_items = [] |
62 | 62 |
if int(self.ui.checkBoxUID.checkState()) is int(Qt.Checked): |
63 |
text_items = [item for item in self.mainWindow.graphicsView.scene.items() |
|
63 |
text_items = [item for item in self.mainWindow.graphicsView.scene().items()
|
|
64 | 64 |
if hasattr(item, 'uid') and str(item.uid).count(text)] |
65 | 65 |
else: |
66 |
text_items = [item for item in self.mainWindow.graphicsView.scene.items() |
|
66 |
text_items = [item for item in self.mainWindow.graphicsView.scene().items()
|
|
67 | 67 |
if issubclass(type(item), QEngineeringTextItem) and item.text().count(text)] |
68 | 68 |
|
69 | 69 |
if not text_items: |
내보내기 Unified diff