개정판 9fc444fb
issue #000: 도면 오픈시 개체간에 연결 되어있는 ConnectedItem 매핑
Change-Id: Iff78dbdf25c645fddf4d939146df76cedcd00a00
HYTOS/HYTOS/Commands/PlaceStreamlineCommand.py | ||
---|---|---|
74 | 74 |
self._streamline._vertices[-1] = selected.center() if type(selected) is QEngineeringConnectorItem else selected.parentItem().center() |
75 | 75 |
|
76 | 76 |
#QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
77 |
self._streamline.build_connectors(self.connectorItems) |
|
77 |
connectorItems = [] |
|
78 |
for connectorItem in self.connectorItems: |
|
79 |
connectorItems.append(connectorItem.uid) |
|
80 |
|
|
81 |
self._streamline.build_connectors(connectorItems) |
|
82 |
|
|
83 |
#self._streamline.build_connectors(self.connectorItems) |
|
78 | 84 |
self._streamline.update() |
79 | 85 |
self.onSuccess.emit() |
80 | 86 |
self.connectorItems.clear() |
HYTOS/HYTOS/Commands/SaveWorkCommand.py | ||
---|---|---|
63 | 63 |
|
64 | 64 |
return resultStr |
65 | 65 |
|
66 |
@staticmethod |
|
67 |
def save(): |
|
68 |
""" do given work""" |
|
69 |
from datetime import datetime |
|
70 |
from AppDocData import AppDocData |
|
71 |
from AppDocData import MessageType |
|
72 |
from SymbolSvgItem import SymbolSvgItem |
|
73 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
|
66 | 74 |
|
67 |
|
|
75 |
try: |
|
76 |
appDocData = AppDocData.instance() |
|
77 |
items = appDocData.allItems |
|
78 |
|
|
79 |
dbItems = [item for item in items if type(item) is SymbolSvgItem or type(item) is QEngineeringStreamlineItem] |
|
80 |
appDocData.saveToDatabase(dbItems) |
|
81 |
|
|
82 |
except Exception as ex: |
|
83 |
from AppDocData import MessageType |
|
84 |
|
|
85 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
86 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
87 |
self.display_message.emit(MessageType.Error, message) |
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
48 | 48 |
from EngineeringEndBreakItem import QEngineeringEndBreakItem |
49 | 49 |
from EngineeringReducerItem import QEngineeringReducerItem |
50 | 50 |
from AppDocData import * |
51 |
import SymbolTreeWidget, SymbolPropertyTableWidget
|
|
51 |
import SymbolTreeWidget |
|
52 | 52 |
import SymbolEditorDialog |
53 |
import ItemTreeWidget |
|
54 |
import DrawingUnitTableWidget |
|
55 |
import ItemPropertyTableWidget |
|
56 | 53 |
from UserInputAttribute import UserInputAttribute |
57 | 54 |
from TextItemFactory import TextItemFactory |
58 | 55 |
from TextDataListDialog import QTextDataListDialog |
... | ... | |
107 | 104 |
|
108 | 105 |
self.graphicsView = QtImageViewer.QtImageViewer(self) |
109 | 106 |
self.graphicsView.setParent(self.centralwidget) |
110 |
self.graphicsView.useDefaultCommand() ##### USE DEFAULT COMMAND
|
|
107 |
self.graphicsView.useDefaultCommand() |
|
111 | 108 |
self.graphicsView.setMouseTracking(True) |
112 | 109 |
self.graphicsView.viewport().installEventFilter(self) |
113 | 110 |
|
... | ... | |
118 | 115 |
self.symbolTreeWidget.header().hide() |
119 | 116 |
self.verticalLayoutSymbolList.addWidget(self.symbolTreeWidget) |
120 | 117 |
|
121 |
# Add property TreeWidget |
|
122 |
self.itemPropertyTableWidget = ItemPropertyTableWidget.QItemPropertyTableWidget(self) |
|
123 |
self.verticalLayoutProperty.addWidget(self.itemPropertyTableWidget) |
|
124 |
|
|
125 |
# tabifyDockWidget |
|
126 |
self.tabifyDockWidget(self.dockWidgetSymbolExplorer, self.dockWidgetPropertyExplorer) |
|
127 |
self.dockWidgetSymbolExplorer.setVisible (True) |
|
128 |
self.dockWidgetSymbolExplorer.setFocus () |
|
129 |
self.dockWidgetSymbolExplorer.raise_ () |
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
# Add Custom Result Tree Widget (Symbol Explorer) |
|
134 |
#self.itemTreeWidget = ItemTreeWidget.QItemTreeWidget(self.graphicsView) |
|
135 |
#self.itemTreeWidget.header().hide() |
|
136 |
|
|
137 |
self.drawingUnitTableWidget = DrawingUnitTableWidget.QDrawingUnitTableWidget(self.graphicsView) |
|
138 |
|
|
139 | 118 |
self.treeWidgetDrawingList.setHeaderHidden(False) |
140 | 119 |
self.treeWidgetDrawingList.header().setStretchLastSection(True) |
141 | 120 |
self.treeWidgetDrawingList.header().setDefaultAlignment(Qt.AlignCenter) |
... | ... | |
146 | 125 |
self.treeWidgetDrawingList.hideColumn(2) |
147 | 126 |
|
148 | 127 |
self.treeWidgetDrawingList.itemDoubleClicked.connect(self.open_selected_drawing) |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
# add splitter widget |
|
153 |
splitter = QSplitter(Qt.Vertical) |
|
154 |
splitter.addWidget(self.treeWidgetDrawingList) |
|
155 |
splitter.addWidget(self.drawingUnitTableWidget) |
|
156 |
self.verticalLayoutDrawingList.addWidget(splitter) |
|
157 |
# up to here |
|
158 |
|
|
128 |
|
|
159 | 129 |
# Initialize Action group |
160 | 130 |
self.actionGroup = QActionGroup(self) |
161 | 131 |
self.actionGroup.addAction(self.actionLine) |
... | ... | |
295 | 265 |
|
296 | 266 |
def clear_data(self): |
297 | 267 |
self.clear_HMB() |
298 |
self.drawingUnitTableWidget.clear_units() |
|
299 | 268 |
|
300 | 269 |
def eventFilter(self, source, event): |
301 | 270 |
""" |
... | ... | |
515 | 484 |
items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)] |
516 | 485 |
self.labelTextStatus.setText("<font color='blue'>" + self.tr('Text') + " : {}</font>".format(len(items))) |
517 | 486 |
|
518 |
#self.itemTreeWidget.sceneChanged(self.graphicsView.scene.items()) |
|
519 |
|
|
520 | 487 |
def dbUpdate(self): |
521 | 488 |
''' |
522 | 489 |
@brief db update when save or recognition |
... | ... | |
591 | 558 |
itemTypes.append(type(item)) |
592 | 559 |
## |
593 | 560 |
|
594 |
#SaveWorkCommand.save_to_database() |
|
561 |
#SaveWorkCommand.save() |
|
562 |
|
|
595 | 563 |
self._save_work_cmd = SaveWorkCommand() |
596 | 564 |
self._save_work_cmd.display_message.connect(self.onAddMessage) |
597 | 565 |
self._save_work_cmd.finished.connect(self.save_finished) |
... | ... | |
605 | 573 |
self._movie.start() |
606 | 574 |
|
607 | 575 |
self._save_work_cmd.start() |
576 |
|
|
608 | 577 |
|
609 | 578 |
except Exception as ex: |
610 | 579 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
... | ... | |
685 | 654 |
items = [item for item in self.graphicsView.scene.selectedItems() if issubclass(type(item), SymbolSvgItem) or type(item) is QEngineeringStreamlineItem ] |
686 | 655 |
if items: |
687 | 656 |
item = items[-1] |
688 |
#self.itemTreeWidget.findItem(item) |
|
689 |
self.itemPropertyTableWidget.show_item_property(item) |
|
657 |
|
|
690 | 658 |
if type(item) is QEngineeringErrorItem: |
691 | 659 |
for index in range(self.tableWidgetHMB.rowCount()): |
692 | 660 |
|
... | ... | |
905 | 873 |
self.path = os.path.join(project.getDrawingFilePath(), drawing + '.png') |
906 | 874 |
appDocData.setImgFilePath(self.path) |
907 | 875 |
appDocData.activeDrawing = Drawing(appDocData.imgName) |
908 |
self.drawingUnitTableWidget.load_units(drawing) |
|
909 |
#self.itemTreeWidget.setCurrentDrawing(appDocData.activeDrawing.name) |
|
910 |
|
|
876 |
|
|
911 | 877 |
## Load data on database |
912 | 878 |
|
913 | 879 |
components = appDocData.getComponentListByDrawingUID(appDocData.activeDrawing.UID) |
914 | 880 |
count = len(components) |
915 | 881 |
|
916 | 882 |
if count > 0: |
917 |
self.load_components(components) |
|
883 |
try: |
|
884 |
self.progress = QProgressDialog(self.tr("Please wait for a while"), self.tr("Cancel"), 0, 100, self) if not hasattr(self, 'progress') else self.progress |
|
885 |
self.progress.setWindowModality(Qt.WindowModal) |
|
886 |
self.progress.setAutoReset(True) |
|
887 |
self.progress.setAutoClose(True) |
|
888 |
self.progress.setMinimum(0) |
|
889 |
self.progress.resize(600,100) |
|
890 |
self.progress.setWindowTitle(self.tr("Load data...")) |
|
891 |
self.progress.show() |
|
892 |
|
|
893 |
self.load_components(components) |
|
894 |
self.load_HMB() |
|
895 |
finally: |
|
896 |
self.progress.setValue(self.progress.maximum()) |
|
897 |
self.progress.hide() |
|
918 | 898 |
|
919 | 899 |
self.changeViewCheckedState(True) |
920 |
self.load_HMB() |
|
900 |
|
|
921 | 901 |
except Exception as ex: |
922 | 902 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
923 | 903 |
self.addMessage.emit(MessageType.Error, message) |
... | ... | |
1079 | 1059 |
_chan, w, h = img.shape[::-1] |
1080 | 1060 |
svg = SymbolSvgItem(svgPath) |
1081 | 1061 |
svg.buildItem(newSym.getName(), newSym.getType(), 0, [offsetX, offsetY], [w, h], [float(x) for x in newSym.getOriginalPoint().split(',')], [(float(x.split(',')[0]), float(x.split(',')[1])) for x in newSym.getConnectionPoint().split('/')], newSym.getBaseSymbol(), newSym.getAdditionalSymbol(), newSym.getHasInstrumentLabel) |
1082 |
|
|
1083 |
#svg.transfer.onRemoved.connect(self.itemTreeWidget.itemRemoved) |
|
1062 |
|
|
1084 | 1063 |
svg.addSvgItemToScene(self.graphicsView.scene) |
1085 | 1064 |
for connector in svg.connectors: |
1086 | 1065 |
self.graphicsView.scene.addItem(connector) |
... | ... | |
1286 | 1265 |
''' |
1287 | 1266 |
def itemRemoved(self, item): |
1288 | 1267 |
try: |
1289 |
#self.itemTreeWidget.itemRemoved(item) |
|
1290 |
|
|
1291 | 1268 |
matches = [_item for _item in self.graphicsView.scene.items() if hasattr(_item, 'connectors') and \ |
1292 | 1269 |
[connector for connector in _item.connectors if connector.connectedItem is not None and connector.connectedItem.parentItem() is item]] |
1293 | 1270 |
for match in matches: |
... | ... | |
1551 | 1528 |
childSymbol = symbol.getAdditionalSymbol() |
1552 | 1529 |
hasInstrumentLabel = symbol.getHasInstrumentLabel() |
1553 | 1530 |
|
1554 |
svgFilePath = os.path.join(project.getSvgFilePath(), category, _type, name + '.svg') |
|
1531 |
svgFilePath = os.path.join(project.getSvgFilePath(s), category, _type, name + '.svg')
|
|
1555 | 1532 |
if os.path.isfile(svgFilePath): |
1556 | 1533 |
svg = SymbolSvgItem.createItem(_type, svgFilePath, owner=None, flip=flip) |
1557 | 1534 |
#print(pt) |
... | ... | |
1965 | 1942 |
for componentUID in componentsUID: |
1966 | 1943 |
componentInfos = appDocData.getComponentByComponentUID(componentUID) |
1967 | 1944 |
if (len(componentInfos)) > 0: |
1968 |
category = componentInfos[0][3] |
|
1945 |
category = componentInfos[0][3] # Category@SymbolType |
|
1946 |
|
|
1969 | 1947 |
if category == 'Stream Line': |
1970 | 1948 |
item = QEngineeringStreamlineItem.fromDatabase(componentInfos) |
1971 | 1949 |
if item is not None: |
HYTOS/HYTOS/MainWindow_UI.py | ||
---|---|---|
110 | 110 |
self.toolBar.setIconSize(QtCore.QSize(32, 32)) |
111 | 111 |
self.toolBar.setObjectName("toolBar") |
112 | 112 |
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) |
113 |
self.dockWidgetPropertyExplorer = QtWidgets.QDockWidget(MainWindow) |
|
114 |
self.dockWidgetPropertyExplorer.setObjectName("dockWidgetPropertyExplorer") |
|
115 |
self.dockWidgetContents_4 = QtWidgets.QWidget() |
|
116 |
self.dockWidgetContents_4.setObjectName("dockWidgetContents_4") |
|
117 |
self.gridLayout_3 = QtWidgets.QGridLayout(self.dockWidgetContents_4) |
|
118 |
self.gridLayout_3.setObjectName("gridLayout_3") |
|
119 |
self.verticalLayoutProperty = QtWidgets.QVBoxLayout() |
|
120 |
self.verticalLayoutProperty.setObjectName("verticalLayoutProperty") |
|
121 |
self.gridLayout_3.addLayout(self.verticalLayoutProperty, 1, 0, 1, 1) |
|
122 |
self.horizontalLayout_2 = QtWidgets.QHBoxLayout() |
|
123 |
self.horizontalLayout_2.setObjectName("horizontalLayout_2") |
|
124 |
self.label = QtWidgets.QLabel(self.dockWidgetContents_4) |
|
125 |
font = QtGui.QFont() |
|
126 |
font.setBold(False) |
|
127 |
font.setWeight(50) |
|
128 |
self.label.setFont(font) |
|
129 |
self.label.setObjectName("label") |
|
130 |
self.horizontalLayout_2.addWidget(self.label) |
|
131 |
self.lineEdit = QtWidgets.QLineEdit(self.dockWidgetContents_4) |
|
132 |
font = QtGui.QFont() |
|
133 |
font.setBold(False) |
|
134 |
font.setWeight(50) |
|
135 |
self.lineEdit.setFont(font) |
|
136 |
self.lineEdit.setText("") |
|
137 |
self.lineEdit.setAlignment(QtCore.Qt.AlignCenter) |
|
138 |
self.lineEdit.setObjectName("lineEdit") |
|
139 |
self.horizontalLayout_2.addWidget(self.lineEdit) |
|
140 |
self.gridLayout_3.addLayout(self.horizontalLayout_2, 0, 0, 1, 1) |
|
141 |
self.gridLayout_3.setRowStretch(0, 20) |
|
142 |
self.gridLayout_3.setRowStretch(1, 80) |
|
143 |
self.dockWidgetPropertyExplorer.setWidget(self.dockWidgetContents_4) |
|
144 |
MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockWidgetPropertyExplorer) |
|
145 | 113 |
self.actionOpen = QtWidgets.QAction(MainWindow) |
146 | 114 |
icon = QtGui.QIcon() |
147 | 115 |
icon.addPixmap(QtGui.QPixmap(":/newPrefix/file.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
... | ... | |
441 | 409 |
self.treeWidgetDrawingList.setSortingEnabled(True) |
442 | 410 |
self.dockWidgetHMBList.setWindowTitle(_translate("MainWindow", "HMB List")) |
443 | 411 |
self.toolBar.setWindowTitle(_translate("MainWindow", "Main Toolbar")) |
444 |
self.dockWidgetPropertyExplorer.setWindowTitle(_translate("MainWindow", "Property Explorer")) |
|
445 |
self.label.setText(_translate("MainWindow", "Tag No. ")) |
|
446 | 412 |
self.actionOpen.setText(_translate("MainWindow", "Open")) |
447 | 413 |
self.actionOpen.setToolTip(_translate("MainWindow", "Open(Ctrl + O)")) |
448 | 414 |
self.actionOpen.setShortcut(_translate("MainWindow", "Ctrl+O")) |
HYTOS/HYTOS/Shapes/EngineeringConnectorItem.py | ||
---|---|---|
67 | 67 |
self._font.setPointSizeF(5) |
68 | 68 |
self._conn_index = index |
69 | 69 |
|
70 |
@staticmethod |
|
71 |
def find_connector(uid): |
|
72 |
""" find a connector which has given uid """ |
|
73 |
from App import App |
|
74 |
import uuid |
|
75 |
|
|
76 |
res = None |
|
77 |
if type(uid) is uuid.UUID or type(uid) is str: |
|
78 |
scene = App.mainWnd().graphicsView.scene |
|
79 |
matches = [x for x in scene.items() if hasattr(x, 'uid') and str(x.uid) == str(uid)] |
|
80 |
res = matches[0] if matches else None |
|
81 |
|
|
82 |
return res |
|
83 |
|
|
70 | 84 |
@property |
71 | 85 |
def connectedItem(self): |
72 | 86 |
""" getter of connectedItem """ |
73 | 87 |
import uuid |
74 | 88 |
|
75 |
if type(self._connectedItem) is uuid.UUID:
|
|
89 |
if self.scene() and (type(self._connectedItem) is uuid.UUID or type(self._connectedItem) is str):
|
|
76 | 90 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self._connectedItem)] |
77 | 91 |
if matches: |
78 | 92 |
self._connectedItem = matches[0] |
... | ... | |
499 | 513 |
|
500 | 514 |
def toSql(self, index): |
501 | 515 |
""" generate sql string to save connectors to database """ |
502 |
|
|
503 | 516 |
cols = ['UID', 'Components_UID', '[Index]', 'X', 'Y'] |
504 | 517 |
values = ['?', '?', '?', '?', '?'] |
505 |
param = [str(self.uid), str(self.parent.uid), index, self.center()[0], self.center()[1]] |
|
506 |
|
|
518 |
|
|
519 |
param = [str(self.uid), str(self.parent.uid), index, self.center()[0], self.center()[1]] |
|
507 | 520 |
sql = 'insert or replace into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
508 | 521 |
|
509 | 522 |
return (sql, tuple(param)) |
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py | ||
---|---|---|
56 | 56 |
except Exception as ex: |
57 | 57 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
58 | 58 |
|
59 |
def build_connectors(self, connected): |
|
59 |
def build_connectors(self, connected, pointsUids=None):
|
|
60 | 60 |
""" build connectors for stream line |
61 | 61 |
connected is target connector |
62 | 62 |
""" |
... | ... | |
64 | 64 |
from SymbolSvgItem import SymbolSvgItem |
65 | 65 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
66 | 66 |
|
67 |
targets = [] |
|
67 | 68 |
index = 0 |
68 |
for vertex in [self._vertices[0],self._vertices[-1]]: |
|
69 |
connector = QEngineeringConnectorItem(parent=self, index=index+1) |
|
69 |
for vertex in [self._vertices[0],self._vertices[-1]]: |
|
70 |
if pointsUids: |
|
71 |
connector = QEngineeringConnectorItem(pointsUids[index], parent=self, index=index+1) |
|
72 |
else: |
|
73 |
connector = QEngineeringConnectorItem(uid=None, parent=self, index=index+1) |
|
74 |
|
|
70 | 75 |
connector.setPos(vertex) |
71 | 76 |
connector.setParentItem(self) |
72 | 77 |
connector.connectPoint = vertex |
... | ... | |
81 | 86 |
self.connectors.append(connector) |
82 | 87 |
if len(connected) > index: |
83 | 88 |
connector.connect(connected[index]) |
84 |
connected[index].connect(connector) |
|
89 |
target = QEngineeringConnectorItem.find_connector(connected[index]) |
|
90 |
if target: |
|
91 |
target.connect(connector) |
|
92 |
targets.append(target) |
|
85 | 93 |
|
86 | 94 |
index = index + 1 |
87 | 95 |
|
88 | 96 |
""" connect symbol's on_pos_changed signal """ |
89 |
for symbol in [conn.parentItem() for conn in connected if type(conn.parentItem()) is SymbolSvgItem]:
|
|
97 |
for symbol in [conn.parentItem() for conn in targets if type(conn.parentItem()) is SymbolSvgItem]:
|
|
90 | 98 |
symbol.transfer.on_pos_changed.connect(self.on_symbol_pos_changed) |
91 | 99 |
|
92 | 100 |
self.update_arrow() |
... | ... | |
381 | 389 |
|
382 | 390 |
# save vertices to database |
383 | 391 |
index = 1 |
384 |
for vertex in self._vertices: |
|
385 |
uuid.uuid4() |
|
386 |
cols = ['UID', 'Components_UID', '[Index]', 'X', 'Y'] |
|
387 |
values = ['?', '?', '?', '?', '?'] |
|
388 |
param = [str(uuid.uuid4()), str(uid), index, vertex[0], vertex[1]] |
|
392 |
for vertex in self._vertices: |
|
393 |
if index == 1 and self.connectors[0].connectedItem is not None: |
|
394 |
cols = ['UID', 'Components_UID', '[Index]', 'X', 'Y', 'ConnectedItem_UID'] |
|
395 |
values = ['?', '?', '?', '?', '?', '?'] |
|
396 |
param = [str(uuid.uuid4()), str(uid), index, vertex[0], vertex[1], str(self.connectors[0].connectedItem.uid)] |
|
397 |
elif index == 4 and self.connectors[1].connectedItem is not None: |
|
398 |
cols = ['UID', 'Components_UID', '[Index]', 'X', 'Y', 'ConnectedItem_UID'] |
|
399 |
values = ['?', '?', '?', '?', '?', '?'] |
|
400 |
param = [str(uuid.uuid4()), str(uid), index, vertex[0], vertex[1], str(self.connectors[1].connectedItem.uid)] |
|
401 |
else: |
|
402 |
cols = ['UID', 'Components_UID', '[Index]', 'X', 'Y'] |
|
403 |
values = ['?', '?', '?', '?', '?'] |
|
404 |
param = [str(uuid.uuid4()), str(uid), index, vertex[0], vertex[1]] |
|
389 | 405 |
|
390 | 406 |
sql = 'insert or replace into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
391 | 407 |
|
... | ... | |
393 | 409 |
index += 1 |
394 | 410 |
# up to here |
395 | 411 |
|
412 |
|
|
413 |
|
|
396 | 414 |
return res |
397 | 415 |
|
398 | 416 |
@staticmethod |
399 | 417 |
def fromDatabase(componentInfos): |
400 | 418 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
401 |
#from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
|
402 |
#from EngineeringEndBreakItem import QEngineeringEndBreakItem |
|
403 |
#from SymbolAttr import SymbolAttr |
|
404 |
item = None |
|
405 | 419 |
|
420 |
item = None |
|
406 | 421 |
try: |
407 |
uid = componentInfos[0][0] #Components_UID
|
|
422 |
uid = componentInfos[0][0] #uid@Components
|
|
408 | 423 |
|
409 | 424 |
item = QEngineeringStreamlineItem(uid) |
410 |
for componentInfo in componentInfos: |
|
411 |
item._vertices.append((componentInfo[12], componentInfo[13])) |
|
412 |
|
|
425 |
|
|
413 | 426 |
connectorItems = [] |
414 |
start_connector = QEngineeringConnectorItem() |
|
415 |
start_connector.setPos((componentInfos[0][12],componentInfos[0][13])) |
|
416 |
|
|
417 |
end_connector = QEngineeringConnectorItem() |
|
418 |
end_connector.setPos((componentInfos[-1][12],componentInfos[-1][13])) |
|
427 |
pointsUids = [] |
|
428 |
for componentInfo in componentInfos: |
|
429 |
pointsUid = componentInfo[11] # uid@Points |
|
430 |
x = componentInfo[13] # X@Points |
|
431 |
y = componentInfo[14] # Y@Points |
|
432 |
ConnectedItem_UID = componentInfo[15] # ConnectedItem_UID@Points |
|
433 |
|
|
434 |
pointsUids.append(pointsUid) |
|
435 |
item._vertices.append((x, y)) |
|
436 |
if ConnectedItem_UID: |
|
437 |
connectorItems.append(ConnectedItem_UID) |
|
438 |
|
|
419 | 439 |
|
420 |
connectorItems.append(start_connector) |
|
421 |
connectorItems.append(end_connector) |
|
422 | 440 |
|
423 | 441 |
item.setVisible(False) |
424 | 442 |
item.__buildItem() |
425 |
item.build_connectors(connectorItems) |
|
426 |
item.update_arrow() |
|
443 |
item.build_connectors(connectorItems, pointsUids)
|
|
444 |
|
|
427 | 445 |
item.update() |
428 | 446 |
|
429 | 447 |
except Exception as ex: |
HYTOS/HYTOS/Shapes/SymbolSvgItem.py | ||
---|---|---|
345 | 345 |
@history 2018.05.09 Jeongwoo Clear self.connectors |
346 | 346 |
2018.05.30 Jeongwoo Add parameters (parentSymbol, childSymbol) |
347 | 347 |
''' |
348 |
def buildItem(self, name, _type, angle, loc, origin, connPts, dbUid=None): |
|
348 |
def buildItem(self, name, _type, angle, loc, origin, connPts, dbUid=None, pointsUids=None):
|
|
349 | 349 |
try: |
350 | 350 |
docData = AppDocData.instance() |
351 | 351 |
self.name = name |
... | ... | |
369 | 369 |
break |
370 | 370 |
tokens = connectionPoints[index].split(',') |
371 | 371 |
|
372 |
direction = 'AUTO' |
|
372 |
direction = 'AUTO'
|
|
373 | 373 |
symbol_idx = '0' |
374 |
|
|
374 | 375 |
if len(tokens) == 2: |
375 | 376 |
x = float(tokens[0]) |
376 | 377 |
y = float(tokens[1]) |
... | ... | |
384 | 385 |
y = float(tokens[2]) |
385 | 386 |
symbol_idx = tokens[3] |
386 | 387 |
|
387 |
self.setConnector(index+1) |
|
388 |
if pointsUids: |
|
389 |
self.setConnector(pointsUids[index], index+1) |
|
390 |
else: |
|
391 |
self.setConnector(None, index+1) |
|
392 |
|
|
388 | 393 |
self.connectors[index].direction = direction |
389 | 394 |
self.connectors[index].symbol_idx = symbol_idx |
390 | 395 |
self.connectors[index].setPos((x, y)) |
391 | 396 |
self.connectors[index].connectPoint = (x, y) |
392 |
self.connectors[index].sceneConnectPoint = (connPts[index][0], connPts[index][1]) if len(connPts[index]) == 2 else \ |
|
393 |
(connPts[index][1], connPts[index][2]) if len(connPts[index]) == 3 else \ |
|
394 |
(connPts[index][1], connPts[index][2]) if len(connPts[index]) == 4 else None |
|
395 |
|
|
397 |
#self.connectors[index].sceneConnectPoint = (connPts[index][0], connPts[index][1]) if len(connPts[index]) == 2 else \
|
|
398 |
# (connPts[index][1], connPts[index][2]) if len(connPts[index]) == 3 else \
|
|
399 |
# (connPts[index][1], connPts[index][2]) if len(connPts[index]) == 4 else None
|
|
400 |
|
|
396 | 401 |
tooltip = '<b>{}</b><br>{}={}'.format(str(self.uid), self.type, self.name) |
397 | 402 |
self.setToolTip(tooltip) |
398 | 403 |
except Exception as ex: |
... | ... | |
786 | 791 |
|
787 | 792 |
@staticmethod |
788 | 793 |
def fromDatabase(componentInfos): |
789 |
#from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
|
790 |
#from EngineeringEndBreakItem import QEngineeringEndBreakItem |
|
791 |
#from SymbolAttr import SymbolAttr |
|
792 | 794 |
item = None |
793 | 795 |
|
794 | 796 |
try: |
795 |
uid = componentInfos[0][0] #Components_UID |
|
797 |
uid = componentInfos[0][0] # uid@Components |
|
798 |
dbUid = componentInfos[0][2] # Symbol_UID@Components |
|
799 |
category = componentInfos[0][3] # Category@SymbolType |
|
800 |
_type = componentInfos[0][4] # Type@SymbolType |
|
801 |
name = componentInfos[0][5] # Name@Symbols |
|
802 |
originalPoint = componentInfos[0][6] # OriginalPoint@Symbols |
|
803 |
x = componentInfos[0][7] # X@Components |
|
804 |
y = componentInfos[0][8] # Y@Components |
|
805 |
angle = componentInfos[0][9] # Rotation@Components |
|
796 | 806 |
|
797 | 807 |
pt = [] |
798 |
pt.append(float(componentInfos[0][7])) |
|
799 |
pt.append(float(componentInfos[0][8])) |
|
800 |
|
|
801 |
dbUid = componentInfos[0][2] #Symbols_UID |
|
802 |
name = componentInfos[0][5] #Symbols_Name |
|
808 |
pt.append(float(x)) |
|
809 |
pt.append(float(y)) |
|
803 | 810 |
|
804 |
angle = float(componentInfos[0][9]) |
|
805 |
category = componentInfos[0][3] |
|
806 |
_type = componentInfos[0][4] |
|
807 |
origin = [float(x) for x in str(componentInfos[0][6]).split(',')] |
|
811 |
origin = [float(x) for x in str(originalPoint).split(',')] |
|
808 | 812 |
|
809 | 813 |
connPts = [] |
814 |
|
|
815 |
pointsUids = [] |
|
810 | 816 |
for componentInfo in componentInfos: |
811 |
connPts.append(('AUTO', float(componentInfo[12]), float(componentInfo[13]), '0')) |
|
817 |
pointsUid = componentInfo[11] # uid@Points |
|
818 |
pointsUids.append(pointsUid) |
|
812 | 819 |
|
813 | 820 |
appDocData = AppDocData.instance() |
814 | 821 |
project = appDocData.getCurrentProject() |
... | ... | |
816 | 823 |
if os.path.isfile(svgFilePath): |
817 | 824 |
item = SymbolSvgItem.createItem(_type, svgFilePath, uid) |
818 | 825 |
item.setVisible(False) |
819 |
item.buildItem(name, _type, angle, pt, origin, connPts, dbUid=dbUid)
|
|
826 |
item.buildItem(name, _type, float(angle), pt, origin, connPts, dbUid, pointsUids)
|
|
820 | 827 |
|
821 | 828 |
for area in appDocData.getAreaList(): |
822 | 829 |
if area.contains(pt): |
... | ... | |
1048 | 1055 |
@author kyouho |
1049 | 1056 |
@date 2018.07.26 |
1050 | 1057 |
''' |
1051 |
def setConnector(self, index):
|
|
1052 |
connector = QEngineeringConnectorItem(parent=self, index=index) |
|
1058 |
def setConnector(self, uid, index=None):
|
|
1059 |
connector = QEngineeringConnectorItem(uid, parent=self, index=index)
|
|
1053 | 1060 |
connector.setParentItem(self) |
1054 | 1061 |
self.connectors.append(connector) |
1055 | 1062 |
|
내보내기 Unified diff