개정판 bbb7f7da
issue #000: Comment 반영
1. Connect시 기존에 Connect가 되어있는지 확인
2. ConnectorItem 연결시 심벌과 Stream Line이 연결 되도록 수정
3. 변수명 변경 : 소문자, _로
4. HMB 테이블에서 HMB 데이터 삭제
Change-Id: Ic12b77422bf1866dd35d643fc27ad5949deb809c
HYTOS/HYTOS/Commands/PlaceStreamlineCommand.py | ||
---|---|---|
42 | 42 |
def reset(self): |
43 | 43 |
self._streamline = None |
44 | 44 |
|
45 |
|
|
45 | 46 |
''' |
46 | 47 |
@brief place a line |
47 | 48 |
@author humkyung |
... | ... | |
58 | 59 |
event = param[1] |
59 | 60 |
if 'mousePressEvent' == param[0] and event.button() == Qt.LeftButton: |
60 | 61 |
selected = self.imageViewer.scene.itemAt(param[2], QTransform()) |
61 |
|
|
62 |
if self._streamline is None: |
|
62 |
|
|
63 |
if self._streamline is None:
|
|
63 | 64 |
if selected is not None and (type(selected) is QEngineeringConnectorItem or type(selected.parentItem()) is QEngineeringConnectorItem): |
64 |
self._streamline = QEngineeringStreamlineItem() |
|
65 |
self._streamline._vertices.append(selected.center() if type(selected) is QEngineeringConnectorItem else selected.parentItem().center()) |
|
66 |
self.imageViewer.scene.addItem(self._streamline) |
|
67 |
self.imageViewer.scene.setFocusItem(self._streamline) |
|
65 |
if selected.hasConnectedItem() == False: |
|
66 |
self._streamline = QEngineeringStreamlineItem() |
|
67 |
self._streamline._vertices.append(selected.center() if type(selected) is QEngineeringConnectorItem else selected.parentItem().center()) |
|
68 |
self.imageViewer.scene.addItem(self._streamline) |
|
69 |
self.imageViewer.scene.setFocusItem(self._streamline) |
|
68 | 70 |
|
69 |
self.connectorItems.append(selected if type(selected) is QEngineeringConnectorItem else selected.parentItem()) |
|
71 |
self.connectorItems.append(selected if type(selected) is QEngineeringConnectorItem else selected.parentItem())
|
|
70 | 72 |
else: |
71 | 73 |
try: |
72 | 74 |
if selected is not None and (type(selected) is QEngineeringConnectorItem or type(selected.parentItem()) is QEngineeringConnectorItem): |
73 |
self.connectorItems.append(selected if type(selected) is QEngineeringConnectorItem else selected.parentItem()) |
|
74 |
self._streamline._vertices[-1] = selected.center() if type(selected) is QEngineeringConnectorItem else selected.parentItem().center() |
|
75 |
if selected.hasConnectedItem() == False: |
|
76 |
self.connectorItems.append(selected if type(selected) is QEngineeringConnectorItem else selected.parentItem()) |
|
77 |
self._streamline._vertices[-1] = selected.center() if type(selected) is QEngineeringConnectorItem else selected.parentItem().center() |
|
78 |
else: |
|
79 |
return |
|
75 | 80 |
|
76 | 81 |
#QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
77 | 82 |
connectorItems = [] |
HYTOS/HYTOS/HMBTable.py | ||
---|---|---|
102 | 102 |
return hmb |
103 | 103 |
|
104 | 104 |
''' |
105 |
@brief delete hmb data by uid |
|
106 |
@author yeonjin |
|
107 |
@date 2019.08.19 |
|
108 |
''' |
|
109 |
def deleteByUID(self, uid): |
|
110 |
hmbs = self._hmbs |
|
111 |
if hmbs is not None: |
|
112 |
for hmb in hmbs: |
|
113 |
if str(hmb.components_uid) == str(uid): |
|
114 |
hmb.isDeleted = True |
|
115 |
break |
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
''' |
|
105 | 120 |
@brief load hmb data from database |
106 | 121 |
@author humkyung |
107 | 122 |
@date 2018.07.12 |
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
480 | 480 |
""" stop movie and hide label after finishing save """ |
481 | 481 |
self._movie.stop() |
482 | 482 |
self.label_spinner.hide() |
483 |
#QMessageBox.about(self.graphicsView, self.tr('Notice'), self._save_work_cmd.resultStr) |
|
484 |
|
|
485 |
msg = QMessageBox() |
|
486 |
msg.setIcon(QMessageBox.Information) |
|
487 |
msg.setText(self.tr(self._save_work_cmd.resultStr)) |
|
488 |
msg.setWindowTitle(self.tr("Notice")) |
|
489 |
msg.setStandardButtons(QMessageBox.Ok) |
|
490 |
msg.exec_() |
|
491 |
|
|
483 |
QMessageBox.information(self, self.tr('Notice'), self._save_work_cmd.resultStr) |
|
484 |
|
|
492 | 485 |
self.load_drawing_list() |
493 | 486 |
|
494 | 487 |
|
... | ... | |
851 | 844 |
if hmbs is not None: |
852 | 845 |
self.tableWidgetHMB.setColumnCount(2) |
853 | 846 |
|
854 |
for hmb in hmbs: |
|
855 |
if hmb.isDeleted == True: |
|
856 |
continue |
|
857 |
|
|
847 |
for hmb in hmbs: |
|
858 | 848 |
columnCount = self.tableWidgetHMB.columnCount() |
859 | 849 |
self.tableWidgetHMB.setColumnCount(columnCount + 1) |
860 | 850 |
stream_no = QTableWidgetItem(str(hmb.stream_no)) |
861 | 851 |
stream_no.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) |
852 |
|
|
853 |
if hmb.isDeleted == True: |
|
854 |
stream_no.setForeground(Qt.darkGray) |
|
855 |
else: |
|
856 |
stream_no.setForeground(Qt.black) |
|
857 |
|
|
862 | 858 |
self.tableWidgetHMB.setItem(0, columnCount, stream_no) |
863 | 859 |
|
860 |
|
|
864 | 861 |
''' |
865 | 862 |
@brief refresh scene |
866 | 863 |
@author humkyung |
HYTOS/HYTOS/Shapes/EngineeringConnectorItem.py | ||
---|---|---|
282 | 282 |
from EngineeringTextItem import QEngineeringTextItem |
283 | 283 |
|
284 | 284 |
try: |
285 |
if self.hasConnectedItem() == True: |
|
286 |
return |
|
287 |
|
|
285 | 288 |
if self.parentItem() is not None and self._savedPos is not None: |
286 | 289 |
items = [item for item in self.scene().items(event.scenePos()) if item is not self and item is not self.parentItem() and \ |
287 | 290 |
(issubclass(type(item), SymbolSvgItem) or issubclass(type(item), QEngineeringTextItem) or type(item) is QEngineeringConnectorItem)] |
... | ... | |
322 | 325 |
## up to here |
323 | 326 |
|
324 | 327 |
for symbol in [self.parentItem() for self in items if type(self.parentItem()) is SymbolSvgItem]: |
325 |
symbol.transfer.on_pos_changed.connect(self.on_symbol_pos_changed) |
|
328 |
symbol.transfer.on_pos_changed.connect(self.parent.on_symbol_pos_changed)
|
|
326 | 329 |
|
327 | 330 |
if self.parentItem() is not None: |
328 | 331 |
self._savedPos = None |
... | ... | |
334 | 337 |
|
335 | 338 |
QGraphicsEllipseItem.mouseReleaseEvent(self, event) |
336 | 339 |
|
337 |
def on_symbol_pos_changed(self, symbol): |
|
338 |
""" rebuild stream line because symbol position is changed """ |
|
339 |
stremline = self.parent |
|
340 |
|
|
341 |
if stremline.connectors[0].connectedItem is not None : stremline.connectors[0].setPos(stremline.connectors[0].connectedItem.center()) |
|
342 |
if stremline.connectors[-1].connectedItem is not None : stremline.connectors[-1].setPos(stremline.connectors[-1].connectedItem.center()) |
|
343 |
self.on_connector_pos_changed(None) |
|
344 |
|
|
345 |
def on_connector_pos_changed(self, connector): |
|
346 |
""" rebuild stream line """ |
|
347 |
stremline = self.parent |
|
348 |
|
|
349 |
stremline._vertices = [] |
|
350 |
|
|
351 |
stremline._vertices.append(stremline.connectors[0].center()) |
|
352 |
dx = stremline.connectors[-1].center()[0] - stremline._vertices[0][0] |
|
353 |
dy = stremline.connectors[-1].center()[1] - stremline._vertices[0][1] |
|
354 |
stremline._vertices.append((stremline._vertices[0][0] + dx*0.5, stremline._vertices[0][1])) |
|
355 |
stremline._vertices.append((stremline._vertices[-1][0], stremline._vertices[-1][1] + dy)) |
|
356 |
stremline._vertices.append(stremline.connectors[-1].center()) |
|
357 |
stremline.buildItem() |
|
358 |
stremline.update_arrow() |
|
359 |
stremline.update() |
|
360 | 340 |
''' |
361 | 341 |
@brief move connector's position while mouse drag |
362 | 342 |
@author humkyung |
... | ... | |
408 | 388 |
|
409 | 389 |
QGraphicsEllipseItem.mouseMoveEvent(self, event) |
410 | 390 |
|
391 |
|
|
392 |
def hasConnectedItem(self): |
|
393 |
if self.connectedItem is not None: |
|
394 |
return True |
|
395 |
|
|
396 |
return False |
|
411 | 397 |
''' |
412 | 398 |
@brief reject if user press Escape key |
413 | 399 |
@author humkyung |
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py | ||
---|---|---|
85 | 85 |
connector.setZValue(self.zValue() + 1) |
86 | 86 |
self.connectors.append(connector) |
87 | 87 |
if len(connected) > index: |
88 |
connectedItemUid = connected[index]
|
|
89 |
if connectedItemUid:
|
|
90 |
connector.connect(connectedItemUid)
|
|
91 |
target = QEngineeringConnectorItem.find_connector(connectedItemUid)
|
|
88 |
connected_item_uid = connected[index]
|
|
89 |
if connected_item_uid:
|
|
90 |
connector.connect(connected_item_uid)
|
|
91 |
target = QEngineeringConnectorItem.find_connector(connected_item_uid)
|
|
92 | 92 |
if target: |
93 | 93 |
target.connect(connector) |
94 | 94 |
targets.append(target) |
... | ... | |
374 | 374 |
|
375 | 375 |
def keyPressEvent(self, event): |
376 | 376 |
from App import App |
377 |
from AppDocData import AppDocData |
|
377 | 378 |
if not self.isSelected(): return |
378 | 379 |
|
379 | 380 |
if event.key() == Qt.Key_Delete: |
380 | 381 |
self.deleteStreamlineItemFromScene() |
381 |
self.deleteHMBDataByUID() |
|
382 |
|
|
383 |
appDocData = AppDocData.instance() |
|
384 |
activeDrawing = appDocData.activeDrawing |
|
385 |
if activeDrawing: |
|
386 |
activeDrawing.hmbTable.deleteByUID(self.uid) |
|
387 |
|
|
382 | 388 |
App.mainWnd().load_HMB() |
383 | 389 |
elif event.key() == Qt.Key_QuoteLeft: |
384 | 390 |
self.mouseDoubleClickEvent(event) |
385 |
|
|
386 |
def deleteHMBDataByUID(self): |
|
387 |
from AppDocData import AppDocData |
|
388 |
|
|
389 |
deleteUid = str(self.uid) |
|
390 |
|
|
391 |
appDocData = AppDocData.instance() |
|
392 |
activeDrawing = appDocData.activeDrawing |
|
393 |
if activeDrawing: |
|
394 |
hmbs = activeDrawing.hmbTable._hmbs |
|
395 |
if hmbs is not None: |
|
396 |
for hmb in hmbs: |
|
397 |
if str(hmb.components_uid) == str(deleteUid): |
|
398 |
hmb.isDeleted = True |
|
399 |
break |
|
400 |
|
|
391 |
|
|
401 | 392 |
def deleteStreamlineItemFromScene(self): |
402 | 393 |
""" remove self from scene """ |
403 | 394 |
try: |
... | ... | |
469 | 460 |
|
470 | 461 |
item = QEngineeringStreamlineItem(uid) |
471 | 462 |
|
472 |
connectorItems = [] |
|
473 | 463 |
pointsUids = [] |
474 | 464 |
for componentInfo in componentInfos: |
475 | 465 |
pointsUid = componentInfo[11] # uid@Points |
476 |
index = componentInfo[12] # Index@Points |
|
477 | 466 |
x = componentInfo[13] # X@Points |
478 | 467 |
y = componentInfo[14] # Y@Points |
479 |
ConnectedItem_UID = componentInfo[15] # ConnectedItem_UID@Points |
|
480 | 468 |
|
481 | 469 |
pointsUids.append(pointsUid) |
482 | 470 |
item._vertices.append((x, y)) |
483 | 471 |
|
484 |
if index == 1 or index == 4: |
|
485 |
connectorItems.append(ConnectedItem_UID) |
|
472 |
connectorItems = [componentInfos[0][15], componentInfos[-1][15]] |
|
486 | 473 |
|
487 | 474 |
item.setVisible(False) |
488 | 475 |
item.__buildItem() |
내보내기 Unified diff