개정판 3a9d8155
fixed issue #958: Line Style을 자동으로 설정할 조건들을 설정할 수 있다
Change-Id: I3581a2699b7fb56eac85e91b38784a8523abd428
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
153 | 153 |
self.lineIndicators.clear() |
154 | 154 |
self._colors = None |
155 | 155 |
self._lineNoProperties = None |
156 |
self._lineTypes = None |
|
157 | 156 |
self._lineTypeConfigs = None |
158 | 157 |
self._activeDrawing = None |
159 | 158 |
self._hmbTable = None |
... | ... | |
957 | 956 |
@date 2018.06.27 |
958 | 957 |
''' |
959 | 958 |
def getLineTypes(self): |
959 |
from LineTypeConditions import LineTypeConditions |
|
960 |
|
|
960 | 961 |
res = [] |
961 | 962 |
try: |
962 | 963 |
# Creates or opens a file called mydb with a SQLite3 DB |
... | ... | |
965 | 966 |
# Get a cursor object |
966 | 967 |
cursor = db.cursor() |
967 | 968 |
|
968 |
sql = "select Name from LineTypes order by Name"
|
|
969 |
sql = "select UID,Name,Type1,Conditions1,Type2,Conditions2 from LineTypes order by Name"
|
|
969 | 970 |
cursor.execute(sql) |
970 | 971 |
rows = cursor.fetchall() |
971 | 972 |
for row in rows: |
972 |
res.append(row[0]) |
|
973 |
line_type = LineTypeConditions(row[0], row[1]) |
|
974 |
line_type._conditions[0][0] = row[2] |
|
975 |
line_type._conditions[0][1] = row[3] |
|
976 |
line_type._conditions[1][0] = row[4] |
|
977 |
line_type._conditions[1][1] = row[5] |
|
978 |
res.append(line_type) |
|
973 | 979 |
# Catch the exception |
974 | 980 |
except Exception as ex: |
975 | 981 |
# Roll back any change if something goes wrong |
... | ... | |
1272 | 1278 |
def saveConfigs(self, configs): |
1273 | 1279 |
try: |
1274 | 1280 |
# Creates or opens a file called mydb with a SQLite3 DB |
1275 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), "ITI_PID.db")
|
|
1276 |
conn = sqlite3.connect(dbPath) |
|
1281 |
dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), AppDocData.DATABASE)
|
|
1282 |
conn = sqlite3.connect(dbPath, isolation_level=None)
|
|
1277 | 1283 |
# Get a cursor object |
1278 | 1284 |
cursor = conn.cursor() |
1279 | 1285 |
|
1280 | 1286 |
for config in configs: |
1281 |
value = config.value |
|
1282 |
if type(value) is str and "'" in value: |
|
1283 |
value = value.replace("'", "''") |
|
1287 |
if type(config) is Config: |
|
1288 |
value = config.value |
|
1289 |
if type(value) is str and "'" in value: |
|
1290 |
value = value.replace("'", "''") |
|
1284 | 1291 |
|
1285 |
sql = "insert or replace into configuration values(?,?,?)" |
|
1286 |
param = (config.section, config.key, value) |
|
1292 |
sql = "insert or replace into configuration values(?,?,?)" |
|
1293 |
param = (config.section, config.key, value) |
|
1294 |
|
|
1295 |
cursor.execute(sql, param) |
|
1296 |
elif hasattr(config, 'toSql'): |
|
1297 |
sql = config.toSql() |
|
1298 |
if type(sql) is list: |
|
1299 |
for item in sql: |
|
1300 |
if item is not None and 2 == len(item): |
|
1301 |
cursor.execute(item[0], item[1]) |
|
1302 |
else: |
|
1303 |
if sql is not None and 2 == len(sql): |
|
1304 |
cursor.execute(sql[0], sql[1]) |
|
1287 | 1305 |
|
1288 |
cursor.execute(sql, param) |
|
1289 | 1306 |
conn.commit() |
1290 | 1307 |
# Catch the exception |
1291 | 1308 |
except Exception as ex: |
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
30 | 30 |
kyouho 2018.07.04 add self.delimiter = '"' |
31 | 31 |
""" |
32 | 32 |
def __init__(self, parent): |
33 |
from LineTypeConditions import LineTypeConditions |
|
34 |
|
|
33 | 35 |
QDialog.__init__(self, parent) |
34 | 36 |
|
35 | 37 |
self.ui = Configuration_UI.Ui_ConfigurationDialog() |
... | ... | |
139 | 141 |
|
140 | 142 |
configs = docData.getConfigs('LineTypes') |
141 | 143 |
|
142 |
lineTypes = docData.getLineTypes()
|
|
144 |
line_type_conditions = LineTypeConditions.items()
|
|
143 | 145 |
self.ui.tableWidgetLineTypes.setColumnCount(6) |
144 | 146 |
self.ui.tableWidgetLineTypes.setHorizontalHeaderLabels([self.tr('Name'), self.tr('Color'), self.tr('Width'), self.tr('Style'), self.tr('Opacity'), self.tr('Conditions')]) |
145 |
self.ui.tableWidgetLineTypes.setRowCount(len(lineTypes))
|
|
147 |
self.ui.tableWidgetLineTypes.setRowCount(len(line_type_conditions))
|
|
146 | 148 |
row = 0 |
147 |
for lineType in lineTypes:
|
|
148 |
item = QTableWidgetItem(lineType)
|
|
149 |
for _condition in line_type_conditions:
|
|
150 |
item = QTableWidgetItem(_condition.name)
|
|
149 | 151 |
item.setFlags(Qt.ItemIsEnabled) |
152 |
item.setData(Qt.UserRole, _condition) |
|
150 | 153 |
self.ui.tableWidgetLineTypes.setItem(row, 0, item) |
151 | 154 |
|
152 |
matches = [config for config in configs if config.key == lineType]
|
|
155 |
matches = [config for config in configs if config.key == _condition.name]
|
|
153 | 156 |
|
154 | 157 |
"""" Color """ |
155 | 158 |
color_cell = QTableWidgetItem('') |
... | ... | |
194 | 197 |
lineTransparentSpinBox.setValue(100) |
195 | 198 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 4, lineTransparentSpinBox) |
196 | 199 |
|
197 |
conditions_button = QPushButton() |
|
198 |
conditions_button.setText('...') |
|
199 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 5, conditions_button) |
|
200 |
""" line type conditions """ |
|
201 |
condition_cell = QTableWidgetItem('...') |
|
202 |
condition_cell.setTextAlignment(Qt.AlignHCenter) |
|
203 |
condition_cell.setFlags(Qt.ItemIsEnabled) |
|
204 |
self.ui.tableWidgetLineTypes.setItem(row, 5, condition_cell) |
|
200 | 205 |
|
201 | 206 |
row += 1 |
202 | 207 |
|
203 | 208 |
self.ui.tableWidgetLineTypes.horizontalHeaderItem(0).setSizeHint(QSize(30, 30)) |
204 | 209 |
self.ui.tableWidgetLineTypes.setColumnWidth(2, 135) |
210 |
self.ui.tableWidgetLineTypes.resizeColumnsToContents() |
|
211 |
self.ui.tableWidgetLineTypes.horizontalHeader().setStretchLastSection(True) |
|
205 | 212 |
|
206 | 213 |
configs = docData.getConfigs('Instrument', 'Color') |
207 | 214 |
self.ui.pushButtonInstrumentColor.setStyleSheet('background-color:{}'.format(configs[0].value if configs else QEngineeringAbstractItem.DEFAULT_COLOR)) |
... | ... | |
253 | 260 |
table.hideColumn(3) |
254 | 261 |
#Column Header Size |
255 | 262 |
self.ui.tableWidgetColorProperty.horizontalHeaderItem(0).setSizeHint(QSize(30, 30)) |
256 |
|
|
257 | 263 |
self.setPropertyToggle(self.ui.radioButtonProperty.isChecked()) |
258 | 264 |
|
259 | 265 |
# connect signals and slots |
... | ... | |
261 | 267 |
self.ui.pushButtonDeleteProperty.clicked.connect(self.removeSelectedItem) |
262 | 268 |
self.ui.radioButtonFixedSize.toggled.connect(self.onFixedSizeToggled) |
263 | 269 |
self.ui.pushButtonInstrumentColor.clicked.connect(self.change_instrument_color) |
264 |
self.ui.tableWidgetLineTypes.cellDoubleClicked.connect(self.change_line_type_color)
|
|
270 |
self.ui.tableWidgetLineTypes.cellDoubleClicked.connect(self.cell_double_clicked)
|
|
265 | 271 |
self.ui.tableWidgetColorProperty.cellDoubleClicked.connect(self.cellDoubleClick) |
266 | 272 |
self.ui.comboBoxColorOption.currentIndexChanged.connect(self.currentIndexChanged) |
267 | 273 |
self.ui.radioButtonRandom.toggled.connect(self.onPropertyToggled) |
... | ... | |
468 | 474 |
if color.isValid(): |
469 | 475 |
item = self.ui.pushButtonInstrumentColor.setStyleSheet('background-color:{}'.format(color.name())) |
470 | 476 |
|
471 |
def change_line_type_color(self, row, column):
|
|
472 |
""" change line type's color """ |
|
477 |
def cell_double_clicked(self, row, column):
|
|
478 |
""" change line type's color or change line type's conditions """
|
|
473 | 479 |
if column == 1: |
474 | 480 |
color = QColorDialog.getColor() |
475 | 481 |
if color.isValid(): |
476 | 482 |
item = self.ui.tableWidgetLineTypes.item(row, column) |
477 | 483 |
item.setBackground(color) |
484 |
elif column == 5: |
|
485 |
""" pop up line type conditions dialog """ |
|
486 |
from LineTypeConditionsDialog import QLineTypeConditionsDialog |
|
487 |
|
|
488 |
try: |
|
489 |
data = self.ui.tableWidgetLineTypes.item(row, 0).data(Qt.UserRole) |
|
490 |
dlg = QLineTypeConditionsDialog(self, data) |
|
491 |
if QDialog.Accepted == dlg.exec_(): |
|
492 |
pass |
|
493 |
except Exception as ex: |
|
494 |
from App import App |
|
495 |
from AppDocData import MessageType |
|
496 |
|
|
497 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
498 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
478 | 499 |
|
479 | 500 |
''' |
480 | 501 |
@brief Cell Double Click Event |
... | ... | |
548 | 569 |
|
549 | 570 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
550 | 571 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
572 |
finally: |
|
573 |
self.ui.tableWidgetColorProperty.resizeColumnsToContents() |
|
574 |
self.ui.tableWidgetColorProperty.horizontalHeader().setStretchLastSection(True) |
|
551 | 575 |
|
552 | 576 |
''' |
553 | 577 |
@brief insert or update configurations modified by user |
... | ... | |
566 | 590 |
''' |
567 | 591 |
def accept(self): |
568 | 592 |
from NominalPipeSize import NominalPipeSizeTable |
593 |
from LineTypeConditions import LineTypeConditions |
|
594 |
|
|
569 | 595 |
try: |
570 | 596 |
docData = AppDocData.instance() |
571 | 597 |
|
... | ... | |
604 | 630 |
style = self.ui.tableWidgetLineTypes.cellWidget(row, 3).currentText() |
605 | 631 |
transparent = self.ui.tableWidgetLineTypes.cellWidget(row, 4).text() |
606 | 632 |
configs.append(Config('LineTypes', lineType, '{},{},{},{}'.format(color, width, style,transparent))) |
607 |
|
|
633 |
""" add line type condition to configs """ |
|
634 |
data = self.ui.tableWidgetLineTypes.item(row, 0).data(Qt.UserRole) |
|
635 |
configs.append(data) |
|
636 |
|
|
608 | 637 |
docData = AppDocData.instance() |
609 | 638 |
|
610 | 639 |
selectedIndex = self.ui.comboBoxColorOption.currentIndex() |
... | ... | |
624 | 653 |
if colorStr: |
625 | 654 |
configs.append(Config(lineProp[0].UID, refStr, colorStr)) |
626 | 655 |
|
627 |
|
|
628 | 656 |
#Configuration |
629 | 657 |
sizeUnit = None |
630 | 658 |
configuration = None |
... | ... | |
655 | 683 |
docData.saveConfigs(configs) |
656 | 684 |
docData.lineTypeConfigs = None # clear line type configurations |
657 | 685 |
NominalPipeSizeTable.instance().pipe_sizes = None # clear nominal pipe size table |
658 |
|
|
659 | 686 |
except Exception as ex: |
660 | 687 |
from App import App |
661 | 688 |
from AppDocData import MessageType |
DTI_PID/DTI_PID/ItemPropertyTableWidget.py | ||
---|---|---|
226 | 226 |
humkyung 2018.08.15 add combobox for line type |
227 | 227 |
''' |
228 | 228 |
def initTitleCell(self, item): |
229 |
from LineTypeConditions import LineTypeConditions |
|
230 |
|
|
229 | 231 |
try: |
230 | 232 |
self.clear() |
231 | 233 |
self.setHorizontalHeaderLabels(['Name', 'Value']) |
... | ... | |
273 | 275 |
self._lineTypeComboBox = QComboBox(self) |
274 | 276 |
self._lineTypeComboBox.tag = widgetItem |
275 | 277 |
appDocData = AppDocData.instance() |
276 |
lineTypes = appDocData.getLineTypes() |
|
277 |
for lineType in lineTypes: |
|
278 |
self._lineTypeComboBox.addItem(lineType) |
|
278 |
for lineType in LineTypeConditions.items(): |
|
279 |
self._lineTypeComboBox.addItem(lineType.name) |
|
279 | 280 |
self.setCellWidget(2, 1, self._lineTypeComboBox) |
280 | 281 |
self._lineTypeComboBox.setCurrentText(item.lineType) |
281 | 282 |
self._lineTypeComboBox.currentIndexChanged.connect(self.onLineTypeChanged) |
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
472 | 472 |
|
473 | 473 |
""" update line type """ |
474 | 474 |
if update_line_type == True: |
475 |
print(update_line_type) |
|
476 | 475 |
lines = [line for line in worker.graphicsView.scene.items() if type(line) is QEngineeringLineItem] |
477 | 476 |
for line in lines: line.update_line_type() |
478 | 477 |
|
DTI_PID/DTI_PID/LineTypeConditions.py | ||
---|---|---|
6 | 6 |
class LineTypeConditions: |
7 | 7 |
""" This is line type conditions class """ |
8 | 8 |
|
9 |
def __init__(self, line_type): |
|
9 |
CONDITIONS = None |
|
10 |
|
|
11 |
def __init__(self, uid, line_type): |
|
12 |
self.uid = uid |
|
10 | 13 |
self.line_type = line_type |
11 | 14 |
self._conditions = ([None,None],[None,None]) |
12 | 15 |
|
16 |
@staticmethod |
|
17 |
def items(): |
|
18 |
""" return line type conditions list """ |
|
19 |
from AppDocData import AppDocData |
|
20 |
|
|
21 |
if not LineTypeConditions.CONDITIONS: |
|
22 |
LineTypeConditions.CONDITIONS = AppDocData.instance().getLineTypes() |
|
23 |
|
|
24 |
return LineTypeConditions.CONDITIONS |
|
25 |
|
|
26 |
@property |
|
27 |
def name(self): |
|
28 |
""" getter of name """ |
|
29 |
return self.line_type |
|
30 |
|
|
13 | 31 |
@property |
14 | 32 |
def conditions(self): |
15 | 33 |
return self._conditions |
... | ... | |
24 | 42 |
from EngineeringLineItem import QEngineeringLineItem |
25 | 43 |
|
26 | 44 |
try: |
27 |
if len(items) == len([condition for condition in self.conditions if condition[0] is not None]):
|
|
45 |
if len(items) == len([condition for condition in self.conditions if condition[0] and condition[0] != '']):
|
|
28 | 46 |
for condition in self.conditions: |
29 | 47 |
if not condition[0]: continue |
30 | 48 |
if condition[0] == 'Instrument': |
... | ... | |
48 | 66 |
print(message) |
49 | 67 |
|
50 | 68 |
return False |
69 |
|
|
70 |
def toSql(self): |
|
71 |
""" convert line type conditions data to sql query """ |
|
72 |
res = [] |
|
73 |
|
|
74 |
cols = ['UID', 'Name', 'Type1', 'Conditions1', 'Type2', 'Conditions2'] |
|
75 |
values = ['?', '?', '?', '?', '?', '?'] |
|
76 |
param = [str(self.uid), self.name, self._conditions[0][0] if self._conditions[0][0] else '', self._conditions[0][1] if self._conditions[0][1] else '',\ |
|
77 |
self._conditions[1][0] if self._conditions[1][0] else '', self._conditions[1][1] if self._conditions[1][1] else ''] |
|
78 |
sql = 'insert or replace into LineTypes({}) values({})'.format(','.join(cols), ','.join(values)) |
|
79 |
res.append((sql, tuple(param))) |
|
80 |
|
|
81 |
return res |
DTI_PID/DTI_PID/LineTypeConditionsDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
""" This is line type conditions dialog module """ |
|
3 |
|
|
4 |
import os |
|
5 |
import sys |
|
6 |
from PyQt5.QtCore import * |
|
7 |
from PyQt5.QtGui import * |
|
8 |
from PyQt5.QtWidgets import * |
|
9 |
from AppDocData import AppDocData, Config |
|
10 |
from LineTypeConditions_UI import Ui_LineTypeConditions |
|
11 |
|
|
12 |
class QLineTypeConditionsDialog(QDialog): |
|
13 |
""" This is QItemDataFormatDialog class """ |
|
14 |
def __init__(self, parent, line_type_conditions): |
|
15 |
QDialog.__init__(self, parent) |
|
16 |
self._line_type_conditions = line_type_conditions |
|
17 |
self.setWindowFlag(Qt.WindowMinMaxButtonsHint) |
|
18 |
|
|
19 |
self.ui = Ui_LineTypeConditions() |
|
20 |
self.ui.setupUi(self) |
|
21 |
|
|
22 |
self.ui.tableWidgetLineTypeConditions.setHorizontalHeaderLabels([self.tr('Type'), self.tr('Conditions')]) |
|
23 |
self.ui.tableWidgetLineTypeConditions.horizontalHeader().setStretchLastSection(True) |
|
24 |
for row in range(self.ui.tableWidgetLineTypeConditions.rowCount()): |
|
25 |
""" Type """ |
|
26 |
combobox = QComboBox() |
|
27 |
combobox.addItems(['Instrument', 'Line', '']) |
|
28 |
combobox.setCurrentText(line_type_conditions._conditions[row][0] if line_type_conditions._conditions[row][0] else 'Instrument') |
|
29 |
self.ui.tableWidgetLineTypeConditions.setCellWidget(row, 0, combobox) |
|
30 |
|
|
31 |
item = QTableWidgetItem(line_type_conditions._conditions[row][1] if line_type_conditions._conditions[row][1] else '') |
|
32 |
self.ui.tableWidgetLineTypeConditions.setItem(row, 1, item) |
|
33 |
|
|
34 |
def accept(self): |
|
35 |
""" save line type conditions """ |
|
36 |
for row in range(self.ui.tableWidgetLineTypeConditions.rowCount()): |
|
37 |
self._line_type_conditions._conditions[row][0] = self.ui.tableWidgetLineTypeConditions.cellWidget(row, 0).currentText() |
|
38 |
self._line_type_conditions._conditions[row][1] = self.ui.tableWidgetLineTypeConditions.item(row, 1).text() |
|
39 |
|
|
40 |
QDialog.accept(self) |
DTI_PID/DTI_PID/LineTypeConditions_UI.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
# Form implementation generated from reading ui file '.\UI\LineTypeConditions.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.11.3 |
|
6 |
# |
|
7 |
# WARNING! All changes made in this file will be lost! |
|
8 |
|
|
9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
10 |
|
|
11 |
class Ui_LineTypeConditions(object): |
|
12 |
def setupUi(self, LineTypeConditions): |
|
13 |
LineTypeConditions.setObjectName("LineTypeConditions") |
|
14 |
LineTypeConditions.resize(533, 218) |
|
15 |
font = QtGui.QFont() |
|
16 |
font.setFamily("맑은 고딕") |
|
17 |
LineTypeConditions.setFont(font) |
|
18 |
self.gridLayout = QtWidgets.QGridLayout(LineTypeConditions) |
|
19 |
self.gridLayout.setObjectName("gridLayout") |
|
20 |
self.tableWidgetLineTypeConditions = QtWidgets.QTableWidget(LineTypeConditions) |
|
21 |
self.tableWidgetLineTypeConditions.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents) |
|
22 |
self.tableWidgetLineTypeConditions.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) |
|
23 |
self.tableWidgetLineTypeConditions.setRowCount(2) |
|
24 |
self.tableWidgetLineTypeConditions.setColumnCount(2) |
|
25 |
self.tableWidgetLineTypeConditions.setObjectName("tableWidgetLineTypeConditions") |
|
26 |
self.gridLayout.addWidget(self.tableWidgetLineTypeConditions, 0, 0, 1, 1) |
|
27 |
self.buttonBox = QtWidgets.QDialogButtonBox(LineTypeConditions) |
|
28 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
29 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
30 |
self.buttonBox.setObjectName("buttonBox") |
|
31 |
self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1) |
|
32 |
|
|
33 |
self.retranslateUi(LineTypeConditions) |
|
34 |
self.buttonBox.accepted.connect(LineTypeConditions.accept) |
|
35 |
self.buttonBox.rejected.connect(LineTypeConditions.reject) |
|
36 |
QtCore.QMetaObject.connectSlotsByName(LineTypeConditions) |
|
37 |
|
|
38 |
def retranslateUi(self, LineTypeConditions): |
|
39 |
_translate = QtCore.QCoreApplication.translate |
|
40 |
LineTypeConditions.setWindowTitle(_translate("LineTypeConditions", "Line Type Conditions")) |
|
41 |
|
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
81 | 81 |
Euisung 2018.10.22 delete Signal/Slot Connection 'oCRTrainingEdidorClicked' |
82 | 82 |
''' |
83 | 83 |
def __init__(self): |
84 |
from LineTypeConditions import LineTypeConditions |
|
85 |
|
|
84 | 86 |
super(self.__class__, self).__init__() |
85 | 87 |
self.setupUi(self) |
86 | 88 |
self._label_mouse = QLabel(self.statusbar) |
... | ... | |
105 | 107 |
self.setWindowTitle(_translate("Digital P&ID - {}".format(project.name), "Digital P&ID - {}".format(project.name))) |
106 | 108 |
|
107 | 109 |
self.lineComboBox = QComboBox(self.toolBar) |
108 |
lineTypes = docData.getLineTypes() |
|
109 |
for lineType in lineTypes: |
|
110 |
self.lineComboBox.addItem(lineType) |
|
110 |
for condition in LineTypeConditions.items(): |
|
111 |
self.lineComboBox.addItem(condition.name) |
|
111 | 112 |
self.lineComboBox.currentIndexChanged.connect(self.onLineTypeChanged) |
112 | 113 |
|
113 | 114 |
self.toolBar.insertWidget(self.actionOCR, self.lineComboBox) |
DTI_PID/DTI_PID/Scripts/LineTypes.sql | ||
---|---|---|
1 | 1 |
CREATE TABLE IF NOT EXISTS LineTypes ( |
2 |
UID TEXT NOT NULL, |
|
3 |
Name TEXT NOT NULL, |
|
4 |
CONSTRAINT LineTypes_PK PRIMARY KEY (UID) |
|
2 |
UID TEXT NOT NULL, |
|
3 |
Name TEXT NOT NULL UNIQUE, |
|
4 |
Type1 TEXT, |
|
5 |
Conditions1 TEXT, |
|
6 |
Type2 TEXT, |
|
7 |
Conditions2 TEXT, |
|
8 |
PRIMARY KEY ( |
|
9 |
UID |
|
10 |
) |
|
5 | 11 |
); |
6 |
CREATE UNIQUE INDEX IF NOT EXISTS LineTypes_Name_IDX ON LineTypes (Name); |
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
26 | 26 |
ZVALUE = 100 |
27 | 27 |
HIGHLIGHT = '#BC4438' |
28 | 28 |
LINE_TYPE_COLORS = {} |
29 |
LINE_TYPE_CONDITIONS = [] |
|
30 | 29 |
|
31 | 30 |
''' |
32 | 31 |
@history 2018.05.11 Jeongwoo Make Comments self.setPen() |
... | ... | |
49 | 48 |
self._owner = None |
50 | 49 |
self._flowMark = None |
51 | 50 |
self._lineType = 'Primary' # defulat line type is 'Primary' |
52 |
""" setup line type conditions """ |
|
53 |
if not QEngineeringLineItem.LINE_TYPE_CONDITIONS: |
|
54 |
condition = LineTypeConditions('Connect To Process') |
|
55 |
condition.conditions[0][0] = 'Line' |
|
56 |
condition.conditions[1][0] = 'Instrument' |
|
57 |
condition.conditions[1][1] = "not item.attrib('Type') in ['RO']" |
|
58 |
QEngineeringLineItem.LINE_TYPE_CONDITIONS.append(condition) |
|
59 |
condition = LineTypeConditions('Electric') |
|
60 |
condition.conditions[0][0] = 'Instrument' |
|
61 |
condition.conditions[1][0] = 'Instrument' |
|
62 |
QEngineeringLineItem.LINE_TYPE_CONDITIONS.append(condition) |
|
63 | 51 |
|
64 | 52 |
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable) |
65 | 53 |
|
... | ... | |
944 | 932 |
''' |
945 | 933 |
def update_line_type(self): |
946 | 934 |
import uuid |
935 |
from LineTypeConditions import LineTypeConditions |
|
947 | 936 |
|
948 | 937 |
try: |
949 | 938 |
pool,visited,items = [self],[],[] |
... | ... | |
960 | 949 |
""" add items not visited to pool """ |
961 | 950 |
pool.extend([item for item in lines if item not in visited]) |
962 | 951 |
|
963 |
for condition in QEngineeringLineItem.LINE_TYPE_CONDITIONS:
|
|
952 |
for condition in LineTypeConditions.items():
|
|
964 | 953 |
if condition.eval(items): |
965 |
self._lineType = condition.line_type
|
|
954 |
self._lineType = condition.name
|
|
966 | 955 |
break |
967 | 956 |
except Exception as ex: |
968 | 957 |
from App import App |
DTI_PID/DTI_PID/UI/LineTypeConditions.ui | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>LineTypeConditions</class> |
|
4 |
<widget class="QDialog" name="LineTypeConditions"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>533</width> |
|
10 |
<height>218</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="font"> |
|
14 |
<font> |
|
15 |
<family>맑은 고딕</family> |
|
16 |
</font> |
|
17 |
</property> |
|
18 |
<property name="windowTitle"> |
|
19 |
<string>Line Type Conditions</string> |
|
20 |
</property> |
|
21 |
<layout class="QGridLayout" name="gridLayout"> |
|
22 |
<item row="0" column="0"> |
|
23 |
<widget class="QTableWidget" name="tableWidgetLineTypeConditions"> |
|
24 |
<property name="sizeAdjustPolicy"> |
|
25 |
<enum>QAbstractScrollArea::AdjustToContents</enum> |
|
26 |
</property> |
|
27 |
<property name="selectionMode"> |
|
28 |
<enum>QAbstractItemView::ExtendedSelection</enum> |
|
29 |
</property> |
|
30 |
<property name="rowCount"> |
|
31 |
<number>2</number> |
|
32 |
</property> |
|
33 |
<property name="columnCount"> |
|
34 |
<number>2</number> |
|
35 |
</property> |
|
36 |
<row/> |
|
37 |
<row/> |
|
38 |
<column/> |
|
39 |
<column/> |
|
40 |
</widget> |
|
41 |
</item> |
|
42 |
<item row="1" column="0"> |
|
43 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
44 |
<property name="orientation"> |
|
45 |
<enum>Qt::Horizontal</enum> |
|
46 |
</property> |
|
47 |
<property name="standardButtons"> |
|
48 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
49 |
</property> |
|
50 |
</widget> |
|
51 |
</item> |
|
52 |
</layout> |
|
53 |
</widget> |
|
54 |
<resources/> |
|
55 |
<connections> |
|
56 |
<connection> |
|
57 |
<sender>buttonBox</sender> |
|
58 |
<signal>accepted()</signal> |
|
59 |
<receiver>LineTypeConditions</receiver> |
|
60 |
<slot>accept()</slot> |
|
61 |
<hints> |
|
62 |
<hint type="sourcelabel"> |
|
63 |
<x>248</x> |
|
64 |
<y>254</y> |
|
65 |
</hint> |
|
66 |
<hint type="destinationlabel"> |
|
67 |
<x>157</x> |
|
68 |
<y>274</y> |
|
69 |
</hint> |
|
70 |
</hints> |
|
71 |
</connection> |
|
72 |
<connection> |
|
73 |
<sender>buttonBox</sender> |
|
74 |
<signal>rejected()</signal> |
|
75 |
<receiver>LineTypeConditions</receiver> |
|
76 |
<slot>reject()</slot> |
|
77 |
<hints> |
|
78 |
<hint type="sourcelabel"> |
|
79 |
<x>316</x> |
|
80 |
<y>260</y> |
|
81 |
</hint> |
|
82 |
<hint type="destinationlabel"> |
|
83 |
<x>286</x> |
|
84 |
<y>274</y> |
|
85 |
</hint> |
|
86 |
</hints> |
|
87 |
</connection> |
|
88 |
</connections> |
|
89 |
</ui> |
내보내기 Unified diff