개정판 1f9e0182
issue #663: symbol preset testing
Change-Id: I96abd6390c3697c16f45fe495a5a2d91801be0a1
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
612 | 612 |
@history humkyung 2018.08.23 change scenePos to connector's center when symbol is placed on connector |
613 | 613 |
''' |
614 | 614 |
@staticmethod |
615 |
def matchSymbolToLine(scene, svg, scenePos, angle=None, flip=None, strict=False): |
|
615 |
def matchSymbolToLine(scene, svg, scenePos, angle=None, flip=None, strict=False, auto=False):
|
|
616 | 616 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
617 | 617 |
from EngineeringLineItem import QEngineeringLineItem |
618 | 618 |
from SymbolSvgItem import SymbolSvgItem |
... | ... | |
665 | 665 |
connectors[0].sceneBoundingRect().center().y() + dy |
666 | 666 |
svg.loc = [x - svg.symbolOrigin[0], y - svg.symbolOrigin[1]] |
667 | 667 |
svg.origin = [x, y] |
668 |
svg.addSvgItemToScene(scene, True if not strict else False)
|
|
668 |
svg.addSvgItemToScene(scene, True if not auto else False)
|
|
669 | 669 |
|
670 | 670 |
items = [item for item in scene.items(scenePos) if |
671 | 671 |
type(item) is not QGraphicsPixmapItem and type(item) is not QGraphicsTextItem] |
... | ... | |
715 | 715 |
connectors[0].connect(svg) |
716 | 716 |
#items[0].highlight(False) |
717 | 717 |
|
718 |
svg.addSvgItemToScene(scene, True if not strict else False)
|
|
718 |
svg.addSvgItemToScene(scene, True if not auto else False)
|
|
719 | 719 |
|
720 | 720 |
# svg.reSettingConnetors() |
721 | 721 |
|
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
87 | 87 |
updateBatchProgress = pyqtSignal(int, int) |
88 | 88 |
displayLog = pyqtSignal(MessageType, str) |
89 | 89 |
add_detected_items_to_scene = pyqtSignal(QGraphicsScene, list) |
90 |
save_scene = pyqtSignal(QGraphicsScene) |
|
90 | 91 |
add_predata_to_scene = pyqtSignal(Drawing, QGraphicsScene, bool, bool, bool, bool, bool) |
91 | 92 |
clear_scene = pyqtSignal(QGraphicsScene, QGraphicsScene, QGraphicsScene) |
93 |
preset_execute = pyqtSignal(QGraphicsScene, str, str, str, str) |
|
92 | 94 |
|
93 | 95 |
def __init__(self, mutex, cond): |
94 | 96 |
super(Worker, self).__init__() |
... | ... | |
1306 | 1308 |
worker.add_detected_items_to_scene.emit(worker.scene, flange_list) |
1307 | 1309 |
worker.cond.wait(worker.mutex) |
1308 | 1310 |
|
1311 |
# run preset |
|
1312 |
presets = app_doc_data.getSymbolPreset() |
|
1313 |
for preset in presets: |
|
1314 |
worker.preset_execute.emit(worker.scene, preset[0], preset[1], preset[2], preset[3]) |
|
1315 |
worker.cond.wait(worker.mutex) |
|
1316 |
|
|
1317 |
worker.save_scene.emit(worker.scene) |
|
1318 |
worker.cond.wait(worker.mutex) |
|
1319 |
|
|
1309 | 1320 |
worker.scene._end = False |
1310 | 1321 |
# clear drawing |
1311 | 1322 |
app_doc_data.activeDrawing.image = None |
... | ... | |
3038 | 3049 |
self.obj.displayLog.connect(App.mainWnd().addMessage) |
3039 | 3050 |
self.obj.displayTitle.connect(self.displayTitle) |
3040 | 3051 |
self.obj.add_detected_items_to_scene.connect(self.add_detected_items_to_scene) |
3052 |
self.obj.save_scene.connect(self.save_scene) |
|
3053 |
self.obj.preset_execute.connect(self.preset_execute) |
|
3041 | 3054 |
self.obj.add_predata_to_scene.connect(self.add_predata_to_scene) |
3042 | 3055 |
self.obj.clear_scene.connect(self.clear_scene) |
3043 | 3056 |
|
... | ... | |
3156 | 3169 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
3157 | 3170 |
finally: |
3158 | 3171 |
self.cond.wakeAll() |
3172 |
|
|
3173 |
def preset_execute(self, scene, find_symbol, replace_symbol, replace_action, condition): |
|
3174 |
""" run preset """ |
|
3175 |
try: |
|
3176 |
from ReplaceInsertCommand import ReplaceInsertCommand |
|
3177 |
from App import App |
|
3178 |
|
|
3179 |
cmd = ReplaceInsertCommand() |
|
3180 |
cmd.display_message.connect(App.mainWnd().onAddMessage) |
|
3181 |
cmd.execute(scene, find_symbol, replace_symbol, replace_action, condition) |
|
3182 |
except Exception as ex: |
|
3183 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
3184 |
sys.exc_info()[-1].tb_lineno) |
|
3185 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
3186 |
finally: |
|
3187 |
self.cond.wakeAll() |
|
3188 |
|
|
3189 |
def save_scene(self, scene): |
|
3190 |
""" save scene """ |
|
3191 |
try: |
|
3192 |
from SaveWorkCommand import SaveWorkCommand |
|
3193 |
|
|
3194 |
save = SaveWorkCommand(scene) |
|
3195 |
save.run() |
|
3196 |
#SaveWorkCommand.save_to_database() |
|
3197 |
#SaveWorkCommand.save_to_xml() |
|
3198 |
except Exception as ex: |
|
3199 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
3200 |
sys.exc_info()[-1].tb_lineno) |
|
3201 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
3202 |
finally: |
|
3203 |
self.cond.wakeAll() |
|
3159 | 3204 |
|
3160 | 3205 |
def add_detected_items_to_scene(self, scene, flanges) -> None: |
3161 | 3206 |
"""add detected items to scene""" |
3162 |
from SaveWorkCommand import SaveWorkCommand |
|
3163 | 3207 |
from EngineeringVendorItem import QEngineeringVendorItem |
3208 |
from App import App |
|
3164 | 3209 |
|
3165 | 3210 |
app_doc_data = AppDocData.instance() |
3166 | 3211 |
|
... | ... | |
3172 | 3217 |
# symbol |
3173 | 3218 |
for symbol in app_doc_data.symbols: |
3174 | 3219 |
if issubclass(type(symbol), SymbolSvgItem): |
3220 |
symbol.transfer.onRemoved.connect(App.mainWnd().itemRemoved) |
|
3175 | 3221 |
symbol.addSvgItemToScene(scene) |
3176 | 3222 |
else: |
3177 | 3223 |
scene.addItem(symbol) |
... | ... | |
3206 | 3252 |
for flange in flanges: |
3207 | 3253 |
svg = QtImageViewer.createSymbolObject(flange_name) |
3208 | 3254 |
if svg: |
3209 |
QtImageViewer.matchSymbolToLine(scene, svg, QPointF(flange[0], flange[1]), strict=True) |
|
3255 |
QtImageViewer.matchSymbolToLine(scene, svg, QPointF(flange[0], flange[1]), strict=True, auto=True)
|
|
3210 | 3256 |
|
3211 | 3257 |
for unknown in app_doc_data.unknowns + app_doc_data.lineIndicators: |
3212 | 3258 |
scene.addItem(unknown) |
3213 | 3259 |
|
3214 |
# save scene |
|
3215 |
save = SaveWorkCommand(scene) |
|
3216 |
save.run() |
|
3217 |
#SaveWorkCommand.save_to_database() |
|
3218 |
#SaveWorkCommand.save_to_xml() |
|
3219 | 3260 |
except Exception as ex: |
3220 | 3261 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
3221 | 3262 |
sys.exc_info()[-1].tb_lineno) |
3222 |
self.displayLog.emit(MessageType.Error, message)
|
|
3263 |
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
|
3223 | 3264 |
finally: |
3224 | 3265 |
self.cond.wakeAll() |
3225 | 3266 |
scene._end = True |
DTI_PID/DTI_PID/ReplaceSymbolDialog.py | ||
---|---|---|
33 | 33 |
self.ui.buttonBox.button(QDialogButtonBox.Save).clicked.connect(self.save_preset) |
34 | 34 |
self.ui.pushButtonPreset.clicked.connect(self.add_preset) |
35 | 35 |
|
36 |
# hide custom condition |
|
37 |
self.ui.radioButtonCustom.setHidden(True) |
|
38 |
self.ui.plainTextEdit.setHidden(True) |
|
39 |
|
|
36 | 40 |
self.ui.tableWidgetPreset.horizontalHeader().setStretchLastSection(True) |
37 | 41 |
self.ui.tableWidgetPreset.setColumnCount(5) |
38 | 42 |
self.ui.tableWidgetPreset.setHorizontalHeaderLabels(['', 'Find', 'Target', 'Action', 'Condition']) |
... | ... | |
156 | 160 |
else: |
157 | 161 |
custom = None |
158 | 162 |
|
163 |
if condition == 'Preset': |
|
164 |
table = self.ui.tableWidgetPreset |
|
165 |
for index in range(table.rowCount()): |
|
166 |
if int(table.item(index, 0).checkState()) is int(Qt.Checked): |
|
167 |
find_symbol = table.item(index, 1).text() |
|
168 |
replace_symbol = table.item(index, 2).text() |
|
169 |
replace_action = table.item(index, 3).text() |
|
170 |
condition = table.item(index, 4).text() |
|
171 |
break |
|
172 |
|
|
159 | 173 |
cmd = ReplaceInsertCommand() |
160 | 174 |
cmd.display_message.connect(App.mainWnd().onAddMessage) |
161 | 175 |
cmd.execute(scene, find_symbol, replace_symbol, replace_action, condition, custom=custom) |
DTI_PID/DTI_PID/ReplaceSymbol_UI.py | ||
---|---|---|
72 | 72 |
self.radioButtonAll.setObjectName("radioButtonAll") |
73 | 73 |
self.buttonGroup_2.addButton(self.radioButtonAll) |
74 | 74 |
self.horizontalLayout_4.addWidget(self.radioButtonAll) |
75 |
self.radioButtonPreset = QtWidgets.QRadioButton(self.widget) |
|
76 |
self.radioButtonPreset.setObjectName("radioButtonPreset") |
|
77 |
self.buttonGroup_2.addButton(self.radioButtonPreset) |
|
78 |
self.horizontalLayout_4.addWidget(self.radioButtonPreset) |
|
75 | 79 |
self.radioButtonCustom = QtWidgets.QRadioButton(self.widget) |
76 | 80 |
self.radioButtonCustom.setObjectName("radioButtonCustom") |
77 | 81 |
self.buttonGroup_2.addButton(self.radioButtonCustom) |
... | ... | |
161 | 165 |
self.radioButtonHasNoCon.setText(_translate("ReplaceSymbolDialog", "has no connection")) |
162 | 166 |
self.radioButtonConLine.setText(_translate("ReplaceSymbolDialog", "connected with piping line(insert)")) |
163 | 167 |
self.radioButtonAll.setText(_translate("ReplaceSymbolDialog", "All")) |
168 |
self.radioButtonPreset.setText(_translate("ReplaceSymbolDialog", "Preset")) |
|
164 | 169 |
self.radioButtonCustom.setText(_translate("ReplaceSymbolDialog", "Custom")) |
165 | 170 |
self.pushButtonRun.setText(_translate("ReplaceSymbolDialog", "Run")) |
166 | 171 |
self.label.setText(_translate("ReplaceSymbolDialog", "Find : ")) |
DTI_PID/DTI_PID/Scripts/SQLite_Project.tables.sql | ||
---|---|---|
36 | 36 |
`UID` VARCHAR (37) PRIMARY KEY, |
37 | 37 |
`User` VARCHAR (256), |
38 | 38 |
`Symbol_UID` INTEGER REFERENCES Symbol (`UID`) |
39 |
); |
|
39 |
); |
|
40 |
|
|
41 |
CREATE TABLE IF NOT EXISTS `SymbolPreset` ( |
|
42 |
`UID` VARCHAR(37), `Find` VARCHAR(37), |
|
43 |
`Target` VARCHAR(37), `Action` VARCHAR(37), |
|
44 |
`Condition` VARCHAR(37), PRIMARY KEY(`UID`) |
|
45 |
); |
DTI_PID/DTI_PID/UI/ReplaceSymbol.ui | ||
---|---|---|
123 | 123 |
</widget> |
124 | 124 |
</item> |
125 | 125 |
<item> |
126 |
<widget class="QRadioButton" name="radioButtonPreset"> |
|
127 |
<property name="text"> |
|
128 |
<string>Preset</string> |
|
129 |
</property> |
|
130 |
<attribute name="buttonGroup"> |
|
131 |
<string notr="true">buttonGroup_2</string> |
|
132 |
</attribute> |
|
133 |
</widget> |
|
134 |
</item> |
|
135 |
<item> |
|
126 | 136 |
<widget class="QRadioButton" name="radioButtonCustom"> |
127 | 137 |
<property name="text"> |
128 | 138 |
<string>Custom</string> |
... | ... | |
266 | 276 |
<resources/> |
267 | 277 |
<connections/> |
268 | 278 |
<buttongroups> |
269 |
<buttongroup name="buttonGroup_2"/> |
|
270 | 279 |
<buttongroup name="buttonGroup"/> |
280 |
<buttongroup name="buttonGroup_2"/> |
|
271 | 281 |
</buttongroups> |
272 | 282 |
</ui> |
내보내기 Unified diff