개정판 7e77874e
issue #481: Line No, Line Type별 Color를 설정할 수 있다
Change-Id: Idfcf7ff00ed782115e6f405508a7687220ba5f47
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
92 | 92 |
class AppDocData(SingletonInstane): |
93 | 93 |
DATABASE = 'ITI_PID.db' |
94 | 94 |
def __init__(self): |
95 |
from DisplayColors import DisplayColors |
|
96 | ||
95 | 97 |
self._imgFilePath = None |
96 | 98 |
self.imgName = None |
97 | 99 |
self.imgWidth = 0 |
... | ... | |
118 | 120 |
self._titleBlockProperties = None |
119 | 121 |
self.needReOpening = None |
120 | 122 | |
121 | ||
122 | 123 |
def clearItemList(self, trim): |
123 | 124 |
''' |
124 | 125 |
@brief clear item list |
... | ... | |
331 | 332 | |
332 | 333 |
configs = self.getConfigs('LineTypes') |
333 | 334 |
for config in configs: |
334 |
width, _style, transparent = config.value.split(',') |
|
335 |
color, width, _style, transparent = config.value.split(',')
|
|
335 | 336 |
matches = [param for param in styleMap if param[0] == _style] |
336 | 337 |
style = matches[0][1] if matches else Qt.SolidLine |
337 |
self._lineTypeConfigs.append((config.key, int(width), style, float(transparent))) |
|
338 |
self._lineTypeConfigs.append((config.key, color, int(width), style, float(transparent)))
|
|
338 | 339 |
|
339 | 340 |
return self._lineTypeConfigs |
340 | 341 | |
... | ... | |
380 | 381 |
from PyQt5.QtCore import Qt |
381 | 382 | |
382 | 383 |
matches = [config for config in self.lineTypeConfigs if config[0] == lineType] |
383 |
return matches[0] if matches else (lineType, 5, Qt.SolidLine)
|
|
384 |
return matches[0] if matches else (lineType, '#0000FF', 5, Qt.SolidLine, 50)
|
|
384 | 385 | |
385 | 386 |
def setCurrentPidSource(self, image): |
386 | 387 |
self.imgWidth, self.imgHeight = image.size |
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
137 | 137 |
configs = docData.getConfigs('LineTypes') |
138 | 138 | |
139 | 139 |
lineTypes = docData.getLineTypes() |
140 |
self.ui.tableWidgetLineTypes.setColumnCount(4)
|
|
141 |
self.ui.tableWidgetLineTypes.setHorizontalHeaderLabels(['Name', 'Width', 'Style', 'Opacity']) |
|
140 |
self.ui.tableWidgetLineTypes.setColumnCount(5)
|
|
141 |
self.ui.tableWidgetLineTypes.setHorizontalHeaderLabels(['Name', 'Color', 'Width', 'Style', 'Opacity'])
|
|
142 | 142 |
self.ui.tableWidgetLineTypes.setRowCount(len(lineTypes)) |
143 | 143 |
row = 0 |
144 | 144 |
for lineType in lineTypes: |
... | ... | |
146 | 146 |
item.setFlags(Qt.ItemIsEnabled) |
147 | 147 |
self.ui.tableWidgetLineTypes.setItem(row, 0, item) |
148 | 148 | |
149 |
matches = [config for config in configs if config.key == lineType] |
|
150 | ||
151 |
# Color |
|
152 |
color_cell = QTableWidgetItem('') |
|
153 |
color_cell.setFlags(Qt.ItemIsEnabled) |
|
154 |
if matches: |
|
155 |
tokens = matches[0].value.split(',') |
|
156 |
color_cell.setBackground(QColor(tokens[0]) if len(tokens) == 4 else Qt.blue) |
|
157 |
else: |
|
158 |
color_cell.setBackground(Qt.blue) |
|
159 |
self.ui.tableWidgetLineTypes.setItem(row, 1, color_cell) |
|
160 | ||
149 | 161 |
### line width |
150 | 162 |
lineWidthSpinBox = QSpinBox() |
151 | 163 |
lineWidthSpinBox.setRange(1, 25) |
152 | 164 |
lineWidthSpinBox.setSingleStep(1) |
153 |
matches = [config for config in configs if config.key == lineType] |
|
154 |
lineWidthSpinBox.setValue(int(matches[0].value.split(',')[0])) if matches else lineWidthSpinBox.setValue(5) |
|
155 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 1, lineWidthSpinBox) |
|
165 |
if matches: |
|
166 |
tokens = matches[0].value.split(',') |
|
167 |
lineWidthSpinBox.setValue(int(tokens[1]) if len(tokens) == 4 else int(tokens[0])) |
|
168 |
else: |
|
169 |
lineWidthSpinBox.setValue(5) |
|
170 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 2, lineWidthSpinBox) |
|
156 | 171 | |
157 | 172 |
## line style |
158 | 173 |
lineStyleComboBox = QComboBox() |
159 | 174 |
lineStyleComboBox.addItems(['SolidLine', 'DashLine', 'DotLine', 'DashDotLine', 'DashDotDotLine', 'CustomDashLine']) |
175 |
if matches: |
|
176 |
tokens = matches[0].value.split(',') |
|
177 |
lineStyleComboBox.setCurrentText(tokens[2] if len(tokens) == 4 else tokens[1]) |
|
178 |
else: |
|
179 |
lineStyleComboBox.setCurrentText('SolidLine') |
|
160 | 180 |
lineStyleComboBox.setCurrentText(matches[0].value.split(',')[1]) if matches else lineStyleComboBox.setCurrentText('SolidLine') |
161 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 2, lineStyleComboBox)
|
|
181 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 3, lineStyleComboBox)
|
|
162 | 182 | |
163 | 183 |
### line transparent |
164 | 184 |
lineTransparentSpinBox = QSpinBox() |
165 | 185 |
lineTransparentSpinBox.setRange(10, 100) |
166 | 186 |
lineTransparentSpinBox.setSingleStep(10) |
167 |
lineTransparentSpinBox.setValue(int(matches[0].value.split(',')[2])) if matches else lineTransparentSpinBox.setValue(100) |
|
168 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 3, lineTransparentSpinBox) |
|
187 |
if matches: |
|
188 |
tokens = matches[0].value.split(',') |
|
189 |
lineTransparentSpinBox.setValue(int(tokens[3]) if len(tokens) == 4 else int(tokens[2])) |
|
190 |
else: |
|
191 |
lineTransparentSpinBox.setValue(100) |
|
192 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 4, lineTransparentSpinBox) |
|
169 | 193 | |
170 | 194 |
row += 1 |
171 | 195 | |
... | ... | |
227 | 251 |
self.ui.pushButtonAddProperty.clicked.connect(self.addLineProperty) |
228 | 252 |
self.ui.pushButtonDeleteProperty.clicked.connect(self.removeSelectedItem) |
229 | 253 |
self.ui.radioButtonFixedSize.toggled.connect(self.onFixedSizeToggled) |
254 |
self.ui.tableWidgetLineTypes.cellDoubleClicked.connect(self.change_line_type_color) |
|
230 | 255 |
self.ui.tableWidgetColorProperty.cellDoubleClicked.connect(self.cellDoubleClick) |
231 | 256 |
self.ui.comboBoxColorOption.currentIndexChanged.connect(self.currentIndexChanged) |
232 | 257 |
self.ui.radioButtonRandom.toggled.connect(self.onPropertyToggled) |
... | ... | |
427 | 452 |
#Table Color Setting |
428 | 453 |
self.settingColorCell() |
429 | 454 | |
455 |
def change_line_type_color(self, row, column): |
|
456 |
""" change line type's color """ |
|
457 |
if column == 1: |
|
458 |
color = QColorDialog.getColor() |
|
459 |
if color.isValid(): |
|
460 |
item = self.ui.tableWidgetLineTypes.item(row, column) |
|
461 |
item.setBackground(color) |
|
462 | ||
430 | 463 |
''' |
431 | 464 |
@brief Cell Double Click Event |
432 | 465 |
@author kyouho |
... | ... | |
547 | 580 | |
548 | 581 |
for row in range(self.ui.tableWidgetLineTypes.rowCount()): |
549 | 582 |
lineType = self.ui.tableWidgetLineTypes.item(row, 0).text() |
550 |
width = self.ui.tableWidgetLineTypes.cellWidget(row, 1).text() |
|
551 |
style = self.ui.tableWidgetLineTypes.cellWidget(row, 2).currentText() |
|
552 |
transparent = self.ui.tableWidgetLineTypes.cellWidget(row, 3).text() |
|
553 |
configs.append(Config('LineTypes', lineType, '{},{},{}'.format(width, style,transparent))) |
|
583 |
color = self.ui.tableWidgetLineTypes.item(row, 1).background().color().name() |
|
584 |
width = self.ui.tableWidgetLineTypes.cellWidget(row, 2).text() |
|
585 |
style = self.ui.tableWidgetLineTypes.cellWidget(row, 3).currentText() |
|
586 |
transparent = self.ui.tableWidgetLineTypes.cellWidget(row, 4).text() |
|
587 |
configs.append(Config('LineTypes', lineType, '{},{},{},{}'.format(color, width, style,transparent))) |
|
554 | 588 | |
555 | 589 |
docData = AppDocData.instance() |
556 | 590 |
|
DTI_PID/DTI_PID/Configuration_UI.py | ||
---|---|---|
2 | 2 | |
3 | 3 |
# Form implementation generated from reading ui file './UI/Configuration.ui' |
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.11.3
|
|
5 |
# Created by: PyQt5 UI code generator 5.12
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 | |
9 | 9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
10 | 10 | |
11 | ||
11 | 12 |
class Ui_ConfigurationDialog(object): |
12 | 13 |
def setupUi(self, ConfigurationDialog): |
13 | 14 |
ConfigurationDialog.setObjectName("ConfigurationDialog") |
... | ... | |
303 | 304 |
self.gridLayout_16 = QtWidgets.QGridLayout(self.groupBox_6) |
304 | 305 |
self.gridLayout_16.setObjectName("gridLayout_16") |
305 | 306 |
self.tableWidgetLineTypes = QtWidgets.QTableWidget(self.groupBox_6) |
306 |
self.tableWidgetLineTypes.setColumnCount(3)
|
|
307 |
self.tableWidgetLineTypes.setColumnCount(4)
|
|
307 | 308 |
self.tableWidgetLineTypes.setObjectName("tableWidgetLineTypes") |
308 | 309 |
self.tableWidgetLineTypes.setRowCount(0) |
309 | 310 |
self.tableWidgetLineTypes.verticalHeader().setVisible(False) |
... | ... | |
476 | 477 |
self.label_25.setText(_translate("ConfigurationDialog", "Color Representation")) |
477 | 478 |
self.radioButtonRandom.setText(_translate("ConfigurationDialog", "Random")) |
478 | 479 |
self.radioButtonProperty.setText(_translate("ConfigurationDialog", "Property")) |
479 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabLineColor), _translate("ConfigurationDialog", "Line Color")) |
|
480 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabLineColor), _translate("ConfigurationDialog", "Line No Color")) |
|
481 | ||
480 | 482 | |
481 | 483 |
import MainWindow_rc |
482 | 484 | |
485 | ||
483 | 486 |
if __name__ == "__main__": |
484 | 487 |
import sys |
485 | 488 |
app = QtWidgets.QApplication(sys.argv) |
... | ... | |
488 | 491 |
ui.setupUi(ConfigurationDialog) |
489 | 492 |
ConfigurationDialog.show() |
490 | 493 |
sys.exit(app.exec_()) |
491 |
DTI_PID/DTI_PID/DisplayColors.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
""" |
|
3 |
This is DisplayColors module |
|
4 |
""" |
|
5 | ||
6 |
import sys |
|
7 |
from enum import Enum |
|
8 |
from AppDocData import AppDocData |
|
9 |
from AppDocData import Config |
|
10 |
from SingletonInstance import SingletonInstane |
|
11 | ||
12 |
class DisplayOptions(Enum): |
|
13 |
""" This is display options class """ |
|
14 |
DisplayByLineNo = 1 |
|
15 |
DisplayByLineType = 2 |
|
16 | ||
17 |
class DisplayColors(SingletonInstane): |
|
18 |
""" |
|
19 |
This is display colors class |
|
20 |
""" |
|
21 | ||
22 |
def __init__(self, option=DisplayOptions.DisplayByLineNo): |
|
23 |
self._option = option |
|
24 |
self.load_data() |
|
25 | ||
26 |
@property |
|
27 |
def option(self): |
|
28 |
""" return display option """ |
|
29 |
return self._option |
|
30 | ||
31 |
@option.setter |
|
32 |
def option(self, value): |
|
33 |
""" set display option""" |
|
34 |
self._option = value |
|
35 | ||
36 |
def load_data(self): |
|
37 |
""" load display option from database """ |
|
38 |
app_doc_data = AppDocData.instance() |
|
39 |
configs = app_doc_data.getAppConfigs('app', 'display_option') |
|
40 |
if configs: |
|
41 |
self.option = DisplayOptions.DisplayByLineNo if configs[0].value == str(DisplayOptions.DisplayByLineNo) else DisplayOptions.DisplayByLineType |
|
42 | ||
43 |
def save_data(self): |
|
44 |
""" save display option to database """ |
|
45 |
try: |
|
46 |
configs = [] |
|
47 |
configs.append(Config('app', 'display_option', str(self._option))) |
|
48 |
AppDocData.instance().saveAppConfigs(configs) |
|
49 |
except Exception as ex: |
|
50 |
from App import App |
|
51 |
from AppDocData import MessageType |
|
52 | ||
53 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
54 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
DTI_PID/DTI_PID/ItemTreeWidget.py | ||
---|---|---|
260 | 260 |
item = None |
261 | 261 |
appDocData = AppDocData.instance() |
262 | 262 | |
263 |
if (not hasattr(child, 'treeItem')) or (child.treeItem is None): |
|
264 |
if issubclass(type(child), SymbolSvgItem): |
|
265 |
if appDocData.isEquipmentType(child.type): |
|
266 |
item = QTreeWidgetItem(self.SymbolsTreeItem, [child.name]) |
|
267 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
268 |
elif child.type == 'Nozzles': |
|
269 |
for i in range(self.EqpTreeItem.childCount()): |
|
270 |
eqpTreeItem = eqpRootTreeItem[0].child(i) |
|
271 |
eqpSymbol = eqpTreeItem.data(0, self.TREE_DATA_ROLE) |
|
272 |
if child.owner is eqpSymbol: |
|
273 |
symbolsRootItem = eqpTreeItem |
|
274 |
item = QTreeWidgetItem(eqpTreeItem, [child.name]) |
|
275 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
276 |
break |
|
277 |
|
|
278 |
if item is None: |
|
263 |
try: |
|
264 |
if (not hasattr(child, 'treeItem')) or (child.treeItem is None): |
|
265 |
if issubclass(type(child), SymbolSvgItem): |
|
266 |
if appDocData.isEquipmentType(child.type): |
|
279 | 267 |
item = QTreeWidgetItem(self.SymbolsTreeItem, [child.name]) |
280 |
elif child.type == 'Notes': |
|
281 |
return item |
|
282 |
else: |
|
283 |
item = QTreeWidgetItem(self.SymbolsTreeItem, [child.name]) |
|
284 |
|
|
285 |
if item is not None: |
|
286 |
iconPath = os.path.join(AppDocData.instance().getCurrentProject().getSvgFilePath(), child.type , child.name + ".svg") |
|
287 |
item.setIcon(0, QIcon(iconPath)) |
|
268 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
269 |
elif child.type == 'Nozzles': |
|
270 |
for i in range(self.EqpTreeItem.childCount()): |
|
271 |
eqpTreeItem = eqpRootTreeItem[0].child(i) |
|
272 |
eqpSymbol = eqpTreeItem.data(0, self.TREE_DATA_ROLE) |
|
273 |
if child.owner is eqpSymbol: |
|
274 |
symbolsRootItem = eqpTreeItem |
|
275 |
item = QTreeWidgetItem(eqpTreeItem, [child.name]) |
|
276 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
277 |
break |
|
278 |
|
|
279 |
if item is None: |
|
280 |
item = QTreeWidgetItem(self.SymbolsTreeItem, [child.name]) |
|
281 |
elif child.type == 'Notes': |
|
282 |
return item |
|
283 |
else: |
|
284 |
item = QTreeWidgetItem(self.SymbolsTreeItem, [child.name]) |
|
285 |
|
|
286 |
if item is not None: |
|
287 |
iconPath = os.path.join(AppDocData.instance().getCurrentProject().getSvgFilePath(), child.type , child.name + ".svg") |
|
288 |
item.setIcon(0, QIcon(iconPath)) |
|
289 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
290 |
brush = QBrush() |
|
291 |
brush.setColor(QColor(child.getColor())) |
|
292 |
item.setForeground(0, brush) |
|
293 |
item.setFont(0, item.font(0)) |
|
294 |
child.treeItem = item |
|
295 |
self.SymbolsTreeItem.addChild(item) |
|
296 |
self.SymbolsTreeItem.sortChildren(0, Qt.AscendingOrder) # sort childrens |
|
297 |
elif type(child) is QEngineeringLineNoTextItem: |
|
298 |
item = CustomTreeWidgetItem([child.text()]) |
|
299 |
item.setFlags(item.flags() | Qt.ItemIsUserCheckable) |
|
288 | 300 |
item.setData(0, self.TREE_DATA_ROLE, child) |
301 |
item.setCheckState(0, Qt.Checked if child.isVisible() else Qt.Unchecked) |
|
289 | 302 |
brush = QBrush() |
290 | 303 |
brush.setColor(QColor(child.getColor())) |
291 | 304 |
item.setForeground(0, brush) |
292 | 305 |
item.setFont(0, item.font(0)) |
293 | 306 |
child.treeItem = item |
294 |
self.SymbolsTreeItem.addChild(item) |
|
295 |
self.SymbolsTreeItem.sortChildren(0, Qt.AscendingOrder) # sort childrens |
|
307 |
self.LineNoTreeItem.addChild(item) |
|
308 |
elif type(child) is QEngineeringTrimLineNoTextItem: |
|
309 |
item = CustomTreeWidgetItem(['Trim Line']) |
|
310 |
item.setFlags(item.flags() | Qt.ItemIsUserCheckable) |
|
311 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
312 |
item.setCheckState(0, Qt.Checked if child.isVisible() else Qt.Unchecked) |
|
313 |
brush = QBrush() |
|
314 |
brush.setColor(QColor(child.getColor())) |
|
315 |
item.setForeground(0, brush) |
|
316 |
item.setFont(0, item.font(0)) |
|
317 |
child.treeItem = item |
|
318 |
self.LineNoTreeItem.addChild(item) |
|
319 |
elif (type(child) is QEngineeringNoteItem): |
|
320 |
founds = None |
|
321 |
for i in range(self.NotesTreeItem.childCount()): |
|
322 |
item = self.NotesTreeItem.child(i) |
|
323 |
notes = item.data(0, self.TREE_DATA_ROLE) |
|
324 |
founds = [note for note in notes if note.text() == child.text()] |
|
325 |
if founds: break |
|
326 | ||
327 |
if founds: |
|
328 |
item.setData(0, self.TREE_DATA_ROLE, founds + [child, ]) |
|
329 |
else: |
|
330 |
item = QTreeWidgetItem([child.text()]) |
|
331 |
item.setData(0, self.TREE_DATA_ROLE, [child, ]) |
|
332 |
if parent is not None: |
|
333 |
parent.addChild(item) |
|
334 |
parent.sortChildren(0, Qt.AscendingOrder) # sort childrens |
|
335 |
child.treeItem = item |
|
336 |
item.setText(0, '{}({})'.format(child.text(), len(item.data(0, self.TREE_DATA_ROLE)))) |
|
337 | ||
338 |
# show note icon if note icon is setted |
|
339 |
if child.symbol: |
|
340 |
iconPath = os.path.join(appDocData.getCurrentProject().getSvgFilePath(), 'Notes' , child.symbol.name + '.svg') |
|
341 |
item.setIcon(0, QIcon(iconPath)) |
|
342 |
elif (type(child) is QEngineeringUnknownItem): |
|
343 |
item = QTreeWidgetItem(['Unknown']) |
|
344 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
345 |
child.treeItem = item |
|
346 |
self.UnknownTreeItem.addChild(item) |
|
347 |
if child.lineIndicator == 'Match': |
|
348 |
item.setHidden(True) |
|
349 |
elif issubclass(type(child), SymbolSvgItem): # change item's parent |
|
350 |
foundItems = self.findItems(child.name, Qt.MatchExactly|Qt.MatchRecursive, 0) |
|
351 |
if foundItems is not None: |
|
352 |
for item in foundItems: |
|
353 |
data = item.data(0, self.TREE_DATA_ROLE) |
|
354 |
if data is not None and (data == child) and (parent is not item.parent()): |
|
355 |
parentData = parent.data(0, self.TREE_DATA_ROLE) |
|
356 |
if issubclass(type(parentData), QEngineeringLineNoTextItem): |
|
357 |
for index in range(len(parentData.runs)): |
|
358 |
runGroup = parentData.runs[index] |
|
359 |
if data in runGroup.items: |
|
360 |
item.parent().removeChild(item) # remove item from original parent |
|
361 |
runItem = self.addPipeRunTreeItemIfNeed(parent, runGroup) #parent.child(index) |
|
362 |
brush = QBrush() |
|
363 |
brush.setColor(QColor(item.data(0, self.TREE_DATA_ROLE).getColor())) |
|
364 |
item.setForeground(0, brush) |
|
365 |
#item.data(0, self.TREE_DATA_ROLE).setColor(brush.color().name()) |
|
366 |
item.setFont(0, item.font(0)) |
|
367 |
runItem.addChild(item) |
|
368 |
break |
|
369 |
else: |
|
370 |
pass |
|
371 |
break |
|
296 | 372 |
elif type(child) is QEngineeringLineNoTextItem: |
297 |
item = CustomTreeWidgetItem([child.text()]) |
|
298 |
item.setFlags(item.flags() | Qt.ItemIsUserCheckable) |
|
299 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
300 |
item.setCheckState(0, Qt.Checked if child.isVisible() else Qt.Unchecked) |
|
301 |
brush = QBrush() |
|
302 |
brush.setColor(QColor(child.getColor())) |
|
303 |
item.setForeground(0, brush) |
|
304 |
item.setFont(0, item.font(0)) |
|
305 |
child.treeItem = item |
|
306 |
self.LineNoTreeItem.addChild(item) |
|
307 |
elif type(child) is QEngineeringTrimLineNoTextItem: |
|
308 |
item = CustomTreeWidgetItem(['Trim Line']) |
|
309 |
item.setFlags(item.flags() | Qt.ItemIsUserCheckable) |
|
310 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
311 |
item.setCheckState(0, Qt.Checked if child.isVisible() else Qt.Unchecked) |
|
312 |
brush = QBrush() |
|
313 |
brush.setColor(QColor(child.getColor())) |
|
314 |
item.setForeground(0, brush) |
|
315 |
item.setFont(0, item.font(0)) |
|
316 |
child.treeItem = item |
|
317 |
self.LineNoTreeItem.addChild(item) |
|
318 |
elif (type(child) is QEngineeringNoteItem): |
|
319 |
founds = None |
|
320 |
for i in range(self.NotesTreeItem.childCount()): |
|
321 |
item = self.NotesTreeItem.child(i) |
|
322 |
notes = item.data(0, self.TREE_DATA_ROLE) |
|
323 |
founds = [note for note in notes if note.text() == child.text()] |
|
324 |
if founds: break |
|
373 |
foundItems = self.findItems(child.text(), Qt.MatchExactly|Qt.MatchRecursive, 0) |
|
374 |
if foundItems is not None: |
|
375 |
for item in foundItems: |
|
376 |
data = item.data(0, self.TREE_DATA_ROLE) |
|
377 |
if data is not None and (data == child): |
|
378 |
connectedItems = data.getConnectedItems() |
|
379 |
color = data.getColor() |
|
380 |
for connectedItem in connectedItems: |
|
381 |
connectedItem.setColor(color) |
|
382 |
return item |
|
383 |
except Exception as ex: |
|
384 |
from App import App |
|
385 |
from AppDocData import MessageType |
|
325 | 386 | |
326 |
if founds: |
|
327 |
item.setData(0, self.TREE_DATA_ROLE, founds + [child, ]) |
|
328 |
else: |
|
329 |
item = QTreeWidgetItem([child.text()]) |
|
330 |
item.setData(0, self.TREE_DATA_ROLE, [child, ]) |
|
331 |
if parent is not None: |
|
332 |
parent.addChild(item) |
|
333 |
parent.sortChildren(0, Qt.AscendingOrder) # sort childrens |
|
334 |
child.treeItem = item |
|
335 |
item.setText(0, '{}({})'.format(child.text(), len(item.data(0, self.TREE_DATA_ROLE)))) |
|
336 | ||
337 |
# show note icon if note icon is setted |
|
338 |
if child.symbol: |
|
339 |
iconPath = os.path.join(appDocData.getCurrentProject().getSvgFilePath(), 'Notes' , child.symbol.name + '.svg') |
|
340 |
item.setIcon(0, QIcon(iconPath)) |
|
341 |
elif (type(child) is QEngineeringUnknownItem): |
|
342 |
item = QTreeWidgetItem(['Unknown']) |
|
343 |
item.setData(0, self.TREE_DATA_ROLE, child) |
|
344 |
child.treeItem = item |
|
345 |
self.UnknownTreeItem.addChild(item) |
|
346 |
if child.lineIndicator == 'Match': |
|
347 |
item.setHidden(True) |
|
348 |
elif issubclass(type(child), SymbolSvgItem): # change item's parent |
|
349 |
foundItems = self.findItems(child.name, Qt.MatchExactly|Qt.MatchRecursive, 0) |
|
350 |
if foundItems is not None: |
|
351 |
for item in foundItems: |
|
352 |
data = item.data(0, self.TREE_DATA_ROLE) |
|
353 |
if data is not None and (data == child) and (parent is not item.parent()): |
|
354 |
parentData = parent.data(0, self.TREE_DATA_ROLE) |
|
355 |
if issubclass(type(parentData), QEngineeringLineNoTextItem): |
|
356 |
for index in range(len(parentData.runs)): |
|
357 |
runGroup = parentData.runs[index] |
|
358 |
if data in runGroup.items: |
|
359 |
item.parent().removeChild(item) # remove item from original parent |
|
360 |
runItem = self.addPipeRunTreeItemIfNeed(parent, runGroup) #parent.child(index) |
|
361 |
brush = QBrush() |
|
362 |
brush.setColor(QColor(item.data(0, self.TREE_DATA_ROLE).getColor())) |
|
363 |
item.setForeground(0, brush) |
|
364 |
#item.data(0, self.TREE_DATA_ROLE).setColor(brush.color().name()) |
|
365 |
item.setFont(0, item.font(0)) |
|
366 |
runItem.addChild(item) |
|
367 |
break |
|
368 |
else: |
|
369 |
pass |
|
370 |
break |
|
371 |
elif type(child) is QEngineeringLineNoTextItem: |
|
372 |
foundItems = self.findItems(child.text(), Qt.MatchExactly|Qt.MatchRecursive, 0) |
|
373 |
if foundItems is not None: |
|
374 |
for item in foundItems: |
|
375 |
data = item.data(0, self.TREE_DATA_ROLE) |
|
376 |
if data is not None and (data == child): |
|
377 |
connectedItems = data.getConnectedItems() |
|
378 |
color = data.getColor() |
|
379 |
for connectedItem in connectedItems: |
|
380 |
connectedItem.setColor(color) |
|
381 |
return item |
|
387 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
388 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
382 | 389 | |
383 | 390 |
return item |
384 | 391 |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
55 | 55 |
from TextItemFactory import TextItemFactory |
56 | 56 |
from TrainingImageListDialog import QTrainingImageListDialog |
57 | 57 |
from TextDataListDialog import QTextDataListDialog |
58 |
from DisplayColors import DisplayColors |
|
59 |
from DisplayColors import DisplayOptions |
|
58 | 60 | |
59 | 61 |
class MainWindow(QMainWindow, MainWindow_UI.Ui_MainWindow, SingletonInstane): |
60 | 62 |
""" |
... | ... | |
109 | 111 | |
110 | 112 |
self.toolBar.insertWidget(self.actionOCR, self.lineComboBox) |
111 | 113 |
self.toolBar.insertSeparator(self.actionOCR) |
114 |
|
|
115 |
self.graphicsView = QtImageViewer.QtImageViewer(self) |
|
116 |
self.graphicsView.setParent(self.centralwidget) |
|
117 |
self.graphicsView.useDefaultCommand() ##### USE DEFAULT COMMAND |
|
118 |
self.graphicsView.setMouseTracking(True) |
|
119 |
self.graphicsView.viewport().installEventFilter(self) |
|
120 | ||
112 | 121 |
self._display_widget = QWidget() |
113 | 122 |
layout = QVBoxLayout() |
114 | 123 |
self._by_line_no = QRadioButton() |
... | ... | |
121 | 130 |
layout.addWidget(self._by_line_type) |
122 | 131 |
self._display_widget.setLayout(layout) |
123 | 132 |
self.EditToolbar.insertWidget(None, self._display_widget) |
124 | ||
125 |
self.graphicsView = QtImageViewer.QtImageViewer(self) |
|
126 |
self.graphicsView.setParent(self.centralwidget) |
|
127 |
self.graphicsView.useDefaultCommand() ##### USE DEFAULT COMMAND |
|
128 |
self.graphicsView.setMouseTracking(True) |
|
129 |
self.graphicsView.viewport().installEventFilter(self) |
|
133 |
self._by_line_no.setChecked(True) if DisplayColors.instance().option == DisplayOptions.DisplayByLineNo else self._by_line_type.setChecked(True) |
|
130 | 134 | |
131 | 135 |
self.verticalLayout.addWidget(self.graphicsView) |
132 | 136 | |
... | ... | |
1016 | 1020 |
item.lineType = lineType |
1017 | 1021 | |
1018 | 1022 |
def display_colors(self, value): |
1019 |
""" |
|
1020 |
display colors |
|
1021 |
""" |
|
1022 |
print('display colors') |
|
1023 |
pass |
|
1023 |
""" display colors """ |
|
1024 |
from DisplayColors import DisplayColors |
|
1025 |
from DisplayColors import DisplayOptions |
|
1026 | ||
1027 |
DisplayColors.instance().option = DisplayOptions.DisplayByLineNo if value == True else DisplayOptions.DisplayByLineType |
|
1028 |
if hasattr(self, 'graphicsView'): |
|
1029 |
self.graphicsView.scene.update() |
|
1030 |
DisplayColors.instance().save_data() |
|
1024 | 1031 | |
1025 | 1032 |
''' |
1026 | 1033 |
@brief Open image drawing file and then display it |
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
147 | 147 |
configs = docData.getLineTypeConfig(self._lineType) |
148 | 148 |
if configs: |
149 | 149 |
_pen = self.pen() |
150 |
_pen.setWidth(configs[1])
|
|
151 |
_pen.setStyle(configs[2])
|
|
150 |
_pen.setWidth(configs[2])
|
|
151 |
_pen.setStyle(configs[3])
|
|
152 | 152 |
self.setPen(_pen) |
153 |
self.setOpacity(float(configs[3]) / 100)
|
|
153 |
self.setOpacity(float(configs[4]) / 100)
|
|
154 | 154 |
self.update() |
155 | 155 | |
156 | 156 |
''' |
... | ... | |
1053 | 1053 | |
1054 | 1054 |
iterIndex += 1 |
1055 | 1055 |
except Exception as ex: |
1056 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1056 |
from App import App |
|
1057 |
from AppDocData import MessageType |
|
1058 | ||
1059 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1060 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
1057 | 1061 | |
1058 | 1062 |
return item |
1059 | 1063 | |
... | ... | |
1110 | 1114 | |
1111 | 1115 |
# up to here |
1112 | 1116 |
except Exception as ex: |
1113 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1117 |
from App import App |
|
1118 |
from AppDocData import MessageType |
|
1119 | ||
1120 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1121 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
1114 | 1122 |
return str(self.uid) |
1115 | 1123 | |
1116 | 1124 |
return node |
... | ... | |
1125 | 1133 |
self.scene().removeItem(self) |
1126 | 1134 |
|
1127 | 1135 |
''' |
1136 |
@brief return color |
|
1137 |
@author Jeongwoo |
|
1138 |
@date 2018.05.11 |
|
1139 |
''' |
|
1140 |
def getColor(self): |
|
1141 |
from AppDocData import AppDocData |
|
1142 |
from DisplayColors import DisplayColors |
|
1143 |
from DisplayColors import DisplayOptions |
|
1144 | ||
1145 |
if DisplayOptions.DisplayByLineType == DisplayColors.instance().option: |
|
1146 |
app_doc_data = AppDocData.instance() |
|
1147 |
configs = app_doc_data.getConfigs('LineTypes', self.lineType) |
|
1148 |
if configs: |
|
1149 |
tokens = configs[0].value.split(',') |
|
1150 |
return tokens[0] if len(tokens) == 4 else '#0000FF' |
|
1151 |
else: |
|
1152 |
return '#0000FF' |
|
1153 |
else: |
|
1154 |
return QEngineeringAbstractItem.getColor(self) |
|
1155 | ||
1156 |
''' |
|
1128 | 1157 |
@brief Set Color. Override QEngineeringAbstractItem's |
1129 | 1158 |
@author Jeongwoo |
1130 | 1159 |
@date 2018.05.11 |
DTI_PID/DTI_PID/UI/Configuration.ui | ||
---|---|---|
651 | 651 |
<item row="0" column="0"> |
652 | 652 |
<widget class="QTableWidget" name="tableWidgetLineTypes"> |
653 | 653 |
<property name="columnCount"> |
654 |
<number>3</number>
|
|
654 |
<number>4</number>
|
|
655 | 655 |
</property> |
656 | 656 |
<attribute name="verticalHeaderVisible"> |
657 | 657 |
<bool>false</bool> |
... | ... | |
659 | 659 |
<column/> |
660 | 660 |
<column/> |
661 | 661 |
<column/> |
662 |
<column/> |
|
662 | 663 |
</widget> |
663 | 664 |
</item> |
664 | 665 |
</layout> |
... | ... | |
758 | 759 |
</widget> |
759 | 760 |
<widget class="QWidget" name="tabLineColor"> |
760 | 761 |
<attribute name="title"> |
761 |
<string>Line Color</string> |
|
762 |
<string>Line No Color</string>
|
|
762 | 763 |
</attribute> |
763 | 764 |
<layout class="QGridLayout" name="gridLayout_18"> |
764 | 765 |
<item row="0" column="0"> |
내보내기 Unified diff