개정판 2f83b2d6
line type add on going
Change-Id: I5276b73a20571987d4fe8d0c0b5dffba62b013f0
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
1437 | 1437 |
kyouho 2018.07.09 change query method |
1438 | 1438 |
''' |
1439 | 1439 |
def saveConfigs(self, configs): |
1440 |
from LineTypeConditions import LineTypeConditions |
|
1441 |
|
|
1440 | 1442 |
with self.project.database.connect() as conn: |
1441 | 1443 |
try: |
1442 | 1444 |
# Get a cursor object |
... | ... | |
1468 | 1470 |
if sql is not None and 2 == len(sql): |
1469 | 1471 |
cursor.execute(self.project.database.to_sql(sql[0]), sql[1]) |
1470 | 1472 |
self._configs = None # reset config table |
1473 |
LineTypeConditions.CONDITIONS = None |
|
1471 | 1474 |
|
1472 | 1475 |
if self.project.database.db_type == 'SQLite': |
1473 | 1476 |
cursor.execute('commit') |
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
346 | 346 |
row = 0 |
347 | 347 |
for _condition in line_type_conditions: |
348 | 348 |
item = QTableWidgetItem(_condition.name) |
349 |
item.setFlags(Qt.ItemIsEnabled) |
|
349 |
if _condition.name in LineTypeConditions.DEFAULT_LINE_TYPES: |
|
350 |
item.setFlags(Qt.ItemIsEnabled) |
|
351 |
else: |
|
352 |
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable) |
|
350 | 353 |
item.setData(Qt.UserRole, _condition) |
351 | 354 |
self.ui.tableWidgetLineTypes.setItem(row, 0, item) |
352 | 355 |
|
... | ... | |
382 | 385 |
lineStyleComboBox.setCurrentText(tokens[2] if len(tokens) == 4 else tokens[1]) |
383 | 386 |
else: |
384 | 387 |
lineStyleComboBox.setCurrentText('SolidLine') |
385 |
lineStyleComboBox.setCurrentText( |
|
386 |
matches[0].value.split(',')[1]) if matches else lineStyleComboBox.setCurrentText('SolidLine') |
|
387 | 388 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 3, lineStyleComboBox) |
388 | 389 |
|
389 | 390 |
""" line transparent """ |
... | ... | |
394 | 395 |
tokens = matches[0].value.split(',') |
395 | 396 |
lineTransparentSpinBox.setValue(int(tokens[3]) if len(tokens) == 4 else 100) |
396 | 397 |
else: |
397 |
lineTransparentSpinBox.setValue(100)
|
|
398 |
lineTransparentSpinBox.setValue(50)
|
|
398 | 399 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 4, lineTransparentSpinBox) |
399 | 400 |
|
400 | 401 |
""" line type conditions """ |
... | ... | |
579 | 580 |
self.ui.pushButtonInstrumentColor.clicked.connect(self.change_instrument_color) |
580 | 581 |
self.ui.pushButtonEquipColor.clicked.connect(self.change_equipment_color) |
581 | 582 |
self.ui.tableWidgetLineTypes.cellDoubleClicked.connect(self.cell_double_clicked) |
583 |
self.ui.pushButtonLineTypeAdd.clicked.connect(self.line_type_add_clicked) |
|
584 |
self.ui.pushButtonLineTypeDelete.clicked.connect(self.line_type_delete_clicked) |
|
582 | 585 |
self.ui.tableWidgetColorProperty.cellDoubleClicked.connect(self.cellDoubleClick) |
583 | 586 |
self.ui.comboBoxColorOption.currentIndexChanged.connect(self.currentIndexChanged) |
584 | 587 |
self.ui.radioButtonRandom.toggled.connect(self.onPropertyToggled) |
... | ... | |
945 | 948 |
if color.isValid(): |
946 | 949 |
item = self.ui.pushButtonEquipColor.setStyleSheet('background-color:{}'.format(color.name())) |
947 | 950 |
|
951 |
def line_type_delete_clicked(self): # need fix |
|
952 |
""" delete line type """ |
|
953 |
from LineTypeConditions import LineTypeConditions |
|
954 |
|
|
955 |
selectedIdex = self.ui.tableWidgetLineTypes.currentIndex() |
|
956 |
if selectedIdex != -1: |
|
957 |
item = self.ui.tableWidgetLineTypes.item(selectedIdex.row(), 0) |
|
958 |
|
|
959 |
if item.text() not in LineTypeConditions.DEFAULT_LINE_TYPES: |
|
960 |
self.ui.tableWidgetLineTypes.removeRow(selectedIdex.row()) |
|
961 |
|
|
962 |
def line_type_add_clicked(self): |
|
963 |
""" add line type for custom line type """ |
|
964 |
import uuid |
|
965 |
from LineTypeConditions import LineTypeConditions |
|
966 |
|
|
967 |
row = self.ui.tableWidgetLineTypes.rowCount() |
|
968 |
self.ui.tableWidgetLineTypes.setRowCount(row + 1) |
|
969 |
|
|
970 |
_condition = LineTypeConditions(str(uuid.uuid4()), "temp") |
|
971 |
_condition._conditions[0][0] = "" |
|
972 |
_condition._conditions[0][1] = "" |
|
973 |
_condition._conditions[1][0] = "" |
|
974 |
_condition._conditions[1][1] = "" |
|
975 |
|
|
976 |
item = QTableWidgetItem("") |
|
977 |
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable) |
|
978 |
item.setData(Qt.UserRole, _condition) |
|
979 |
self.ui.tableWidgetLineTypes.setItem(row, 0, item) |
|
980 |
|
|
981 |
"""" Color """ |
|
982 |
color_cell = QTableWidgetItem('') |
|
983 |
color_cell.setFlags(Qt.ItemIsEnabled) |
|
984 |
color_cell.setBackground(Qt.blue) |
|
985 |
self.ui.tableWidgetLineTypes.setItem(row, 1, color_cell) |
|
986 |
|
|
987 |
""" line width """ |
|
988 |
lineWidthSpinBox = QSpinBox() |
|
989 |
lineWidthSpinBox.setRange(1, 25) |
|
990 |
lineWidthSpinBox.setSingleStep(1) |
|
991 |
lineWidthSpinBox.setValue(15) |
|
992 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 2, lineWidthSpinBox) |
|
993 |
|
|
994 |
""" line style """ |
|
995 |
lineStyleComboBox = QComboBox() |
|
996 |
lineStyleComboBox.addItems( |
|
997 |
['SolidLine', 'DashLine', 'DotLine', 'DashDotLine', 'DashDotDotLine', 'CustomDashLine']) |
|
998 |
lineStyleComboBox.setCurrentText('SolidLine') |
|
999 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 3, lineStyleComboBox) |
|
1000 |
|
|
1001 |
""" line transparent """ |
|
1002 |
lineTransparentSpinBox = QSpinBox() |
|
1003 |
lineTransparentSpinBox.setRange(10, 100) |
|
1004 |
lineTransparentSpinBox.setSingleStep(10) |
|
1005 |
lineTransparentSpinBox.setValue(50) |
|
1006 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 4, lineTransparentSpinBox) |
|
1007 |
|
|
1008 |
""" line type conditions """ |
|
1009 |
condition_cell = QTableWidgetItem('...') |
|
1010 |
condition_cell.setTextAlignment(Qt.AlignHCenter) |
|
1011 |
condition_cell.setFlags(Qt.ItemIsEnabled) |
|
1012 |
self.ui.tableWidgetLineTypes.setItem(row, 5, condition_cell) |
|
1013 |
|
|
1014 |
row += 1 |
|
1015 |
|
|
948 | 1016 |
def cell_double_clicked(self, row, column): |
949 | 1017 |
""" change line type's color or change line type's conditions """ |
950 | 1018 |
if column == 1: |
... | ... | |
1156 | 1224 |
configs.append(Config('LineTypes', lineType, '{},{},{},{}'.format(color, width, style, transparent))) |
1157 | 1225 |
""" add line type condition to configs """ |
1158 | 1226 |
data = self.ui.tableWidgetLineTypes.item(row, 0).data(Qt.UserRole) |
1227 |
if data.line_type not in LineTypeConditions.DEFAULT_LINE_TYPES: |
|
1228 |
data.line_type = lineType |
|
1159 | 1229 |
configs.append(data) |
1160 | 1230 |
|
1161 |
docData = AppDocData.instance() |
|
1162 |
|
|
1163 | 1231 |
selectedIndex = self.ui.comboBoxColorOption.currentIndex() |
1164 | 1232 |
name = self.tempLineColorUID[selectedIndex] |
1165 | 1233 |
lineProp = [prop for prop in docData.getLineProperties() if prop.Attribute == name] |
DTI_PID/DTI_PID/Configuration_UI.py | ||
---|---|---|
623 | 623 |
self.tableWidgetLineTypes.setObjectName("tableWidgetLineTypes") |
624 | 624 |
self.tableWidgetLineTypes.setRowCount(0) |
625 | 625 |
self.tableWidgetLineTypes.verticalHeader().setVisible(False) |
626 |
self.gridLayout_16.addWidget(self.tableWidgetLineTypes, 0, 0, 1, 1) |
|
626 |
self.gridLayout_16.addWidget(self.tableWidgetLineTypes, 1, 0, 1, 1) |
|
627 |
self.horizontalLayout_17 = QtWidgets.QHBoxLayout() |
|
628 |
self.horizontalLayout_17.setObjectName("horizontalLayout_17") |
|
629 |
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) |
|
630 |
self.horizontalLayout_17.addItem(spacerItem5) |
|
631 |
self.pushButtonLineTypeAdd = QtWidgets.QPushButton(self.groupBox_6) |
|
632 |
self.pushButtonLineTypeAdd.setText("") |
|
633 |
self.pushButtonLineTypeAdd.setIcon(icon1) |
|
634 |
self.pushButtonLineTypeAdd.setObjectName("pushButtonLineTypeAdd") |
|
635 |
self.horizontalLayout_17.addWidget(self.pushButtonLineTypeAdd) |
|
636 |
self.pushButtonLineTypeDelete = QtWidgets.QPushButton(self.groupBox_6) |
|
637 |
self.pushButtonLineTypeDelete.setText("") |
|
638 |
self.pushButtonLineTypeDelete.setIcon(icon2) |
|
639 |
self.pushButtonLineTypeDelete.setObjectName("pushButtonLineTypeDelete") |
|
640 |
self.horizontalLayout_17.addWidget(self.pushButtonLineTypeDelete) |
|
641 |
self.gridLayout_16.addLayout(self.horizontalLayout_17, 0, 0, 1, 1) |
|
627 | 642 |
self.verticalLayout.addWidget(self.groupBox_6) |
628 | 643 |
self.groupBox_2 = QtWidgets.QGroupBox(self.tabDisplayOption) |
629 | 644 |
self.groupBox_2.setObjectName("groupBox_2") |
... | ... | |
682 | 697 |
self.fontComboBox = QtWidgets.QFontComboBox(self.groupBox_5) |
683 | 698 |
self.fontComboBox.setObjectName("fontComboBox") |
684 | 699 |
self.gridLayout_29.addWidget(self.fontComboBox, 0, 1, 1, 2) |
685 |
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
686 |
self.gridLayout_29.addItem(spacerItem5, 0, 3, 1, 1)
|
|
700 |
spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
701 |
self.gridLayout_29.addItem(spacerItem6, 0, 3, 1, 1)
|
|
687 | 702 |
self.gridLayout_15.addLayout(self.gridLayout_29, 0, 0, 1, 1) |
688 | 703 |
self.verticalLayout.addWidget(self.groupBox_5) |
689 | 704 |
self.gridLayout_4.addLayout(self.verticalLayout, 0, 0, 1, 1) |
... | ... | |
736 | 751 |
self.gridLayout_23.setObjectName("gridLayout_23") |
737 | 752 |
self.gridLayout_31 = QtWidgets.QGridLayout() |
738 | 753 |
self.gridLayout_31.setObjectName("gridLayout_31") |
739 |
spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
740 |
self.gridLayout_31.addItem(spacerItem6, 1, 2, 1, 1)
|
|
754 |
spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
755 |
self.gridLayout_31.addItem(spacerItem7, 1, 2, 1, 1)
|
|
741 | 756 |
self.horizontalLayout_4 = QtWidgets.QHBoxLayout() |
742 | 757 |
self.horizontalLayout_4.setObjectName("horizontalLayout_4") |
743 | 758 |
self.radioButtonSaveUnknownYes = QtWidgets.QRadioButton(self.groupBox_11) |
... | ... | |
817 | 832 |
self.gridLayout_24.setObjectName("gridLayout_24") |
818 | 833 |
self.gridLayout_32 = QtWidgets.QGridLayout() |
819 | 834 |
self.gridLayout_32.setObjectName("gridLayout_32") |
820 |
spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
821 |
self.gridLayout_32.addItem(spacerItem7, 0, 2, 1, 1)
|
|
835 |
spacerItem8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
836 |
self.gridLayout_32.addItem(spacerItem8, 0, 2, 1, 1)
|
|
822 | 837 |
self.label_36 = QtWidgets.QLabel(self.groupBox_12) |
823 | 838 |
self.label_36.setMinimumSize(QtCore.QSize(200, 0)) |
824 | 839 |
self.label_36.setObjectName("label_36") |
... | ... | |
892 | 907 |
self.spinBoxServerSymbol = QtWidgets.QSpinBox(self.groupBox_13) |
893 | 908 |
self.spinBoxServerSymbol.setObjectName("spinBoxServerSymbol") |
894 | 909 |
self.gridLayout_37.addWidget(self.spinBoxServerSymbol, 2, 2, 1, 1) |
895 |
spacerItem8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
896 |
self.gridLayout_37.addItem(spacerItem8, 1, 2, 1, 1)
|
|
910 |
spacerItem9 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
911 |
self.gridLayout_37.addItem(spacerItem9, 1, 2, 1, 1)
|
|
897 | 912 |
self.label_51 = QtWidgets.QLabel(self.groupBox_13) |
898 | 913 |
self.label_51.setObjectName("label_51") |
899 | 914 |
self.gridLayout_37.addWidget(self.label_51, 2, 0, 1, 1) |
... | ... | |
935 | 950 |
self.label_55.setMinimumSize(QtCore.QSize(200, 0)) |
936 | 951 |
self.label_55.setObjectName("label_55") |
937 | 952 |
self.gridLayout_36.addWidget(self.label_55, 0, 0, 1, 1) |
938 |
spacerItem9 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
939 |
self.gridLayout_36.addItem(spacerItem9, 0, 2, 1, 1)
|
|
953 |
spacerItem10 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
|
954 |
self.gridLayout_36.addItem(spacerItem10, 0, 2, 1, 1)
|
|
940 | 955 |
self.horizontalLayout_12 = QtWidgets.QHBoxLayout() |
941 | 956 |
self.horizontalLayout_12.setObjectName("horizontalLayout_12") |
942 | 957 |
self.radioButtonOpModeGenenal = QtWidgets.QRadioButton(self.groupBox_14) |
... | ... | |
949 | 964 |
self.gridLayout_41.addLayout(self.gridLayout_36, 0, 0, 1, 1) |
950 | 965 |
self.gridLayout_21.addWidget(self.groupBox_14, 3, 0, 1, 1) |
951 | 966 |
self.gridLayout_22.addLayout(self.gridLayout_21, 0, 0, 1, 1) |
952 |
spacerItem10 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
|
953 |
self.gridLayout_22.addItem(spacerItem10, 3, 0, 1, 1)
|
|
967 |
spacerItem11 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
|
968 |
self.gridLayout_22.addItem(spacerItem11, 3, 0, 1, 1)
|
|
954 | 969 |
self.tabWidget.addTab(self.tabETC, "") |
955 | 970 |
self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1) |
956 | 971 |
|
... | ... | |
1108 | 1123 |
self.lineEditOPCFromPrefix.setText(_translate("ConfigurationDialog", "FROM")) |
1109 | 1124 |
self.lineEditOPCToPrefix.setText(_translate("ConfigurationDialog", "TO")) |
1110 | 1125 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tabTagNoRule), _translate("ConfigurationDialog", "Tag Rule")) |
1111 |
self.groupBox_6.setTitle(_translate("ConfigurationDialog", "Line Style"))
|
|
1126 |
self.groupBox_6.setTitle(_translate("ConfigurationDialog", "Line Setting"))
|
|
1112 | 1127 |
self.groupBox_2.setTitle(_translate("ConfigurationDialog", "Symbol Style")) |
1113 | 1128 |
self.label_3.setText(_translate("ConfigurationDialog", "Instrument Color : ")) |
1114 | 1129 |
self.label_23.setText(_translate("ConfigurationDialog", "Equipment Color : ")) |
DTI_PID/DTI_PID/LineTypeConditions.py | ||
---|---|---|
9 | 9 |
|
10 | 10 |
CONDITIONS = None |
11 | 11 |
|
12 |
DEFAULT_LINE_TYPES = ["Capillary", "Connect To Process", "Electric", "Electric Binary", "Guided Electromagnetic", "Hydraulic", |
|
13 |
"Mechanical", "Pneumatic", "Pneumatic Binary", "Software", "Primary", "Secondary"] |
|
14 |
|
|
12 | 15 |
def __init__(self, uid, line_type): |
13 | 16 |
self.uid = uid |
14 | 17 |
self.line_type = line_type |
DTI_PID/DTI_PID/UI/Configuration.ui | ||
---|---|---|
1270 | 1270 |
<item> |
1271 | 1271 |
<widget class="QGroupBox" name="groupBox_6"> |
1272 | 1272 |
<property name="title"> |
1273 |
<string>Line Style</string>
|
|
1273 |
<string>Line Setting</string>
|
|
1274 | 1274 |
</property> |
1275 | 1275 |
<layout class="QGridLayout" name="gridLayout_16"> |
1276 |
<item row="0" column="0">
|
|
1276 |
<item row="1" column="0">
|
|
1277 | 1277 |
<widget class="QTableWidget" name="tableWidgetLineTypes"> |
1278 | 1278 |
<property name="columnCount"> |
1279 | 1279 |
<number>4</number> |
... | ... | |
1287 | 1287 |
<column/> |
1288 | 1288 |
</widget> |
1289 | 1289 |
</item> |
1290 |
<item row="0" column="0"> |
|
1291 |
<layout class="QHBoxLayout" name="horizontalLayout_17"> |
|
1292 |
<item> |
|
1293 |
<spacer name="horizontalSpacer_8"> |
|
1294 |
<property name="orientation"> |
|
1295 |
<enum>Qt::Horizontal</enum> |
|
1296 |
</property> |
|
1297 |
<property name="sizeHint" stdset="0"> |
|
1298 |
<size> |
|
1299 |
<width>40</width> |
|
1300 |
<height>20</height> |
|
1301 |
</size> |
|
1302 |
</property> |
|
1303 |
</spacer> |
|
1304 |
</item> |
|
1305 |
<item> |
|
1306 |
<widget class="QPushButton" name="pushButtonLineTypeAdd"> |
|
1307 |
<property name="text"> |
|
1308 |
<string/> |
|
1309 |
</property> |
|
1310 |
<property name="icon"> |
|
1311 |
<iconset resource="../res/MainWindow.qrc"> |
|
1312 |
<normaloff>:/newPrefix/Add.svg</normaloff>:/newPrefix/Add.svg</iconset> |
|
1313 |
</property> |
|
1314 |
</widget> |
|
1315 |
</item> |
|
1316 |
<item> |
|
1317 |
<widget class="QPushButton" name="pushButtonLineTypeDelete"> |
|
1318 |
<property name="text"> |
|
1319 |
<string/> |
|
1320 |
</property> |
|
1321 |
<property name="icon"> |
|
1322 |
<iconset resource="../res/MainWindow.qrc"> |
|
1323 |
<normaloff>:/newPrefix/Remove.svg</normaloff>:/newPrefix/Remove.svg</iconset> |
|
1324 |
</property> |
|
1325 |
</widget> |
|
1326 |
</item> |
|
1327 |
</layout> |
|
1328 |
</item> |
|
1290 | 1329 |
</layout> |
1291 | 1330 |
</widget> |
1292 | 1331 |
</item> |
... | ... | |
2096 | 2135 |
</connection> |
2097 | 2136 |
</connections> |
2098 | 2137 |
<buttongroups> |
2099 |
<buttongroup name="buttonGroup_3"/> |
|
2100 |
<buttongroup name="buttonGroup"/> |
|
2101 |
<buttongroup name="buttonGroup_8"/> |
|
2138 |
<buttongroup name="buttonGroup_4"/> |
|
2102 | 2139 |
<buttongroup name="buttonGroup_11"/> |
2103 |
<buttongroup name="buttonGroup_6"/> |
|
2104 |
<buttongroup name="buttonGroup_12"/> |
|
2105 |
<buttongroup name="buttonGroup_7"/> |
|
2106 | 2140 |
<buttongroup name="buttonGroup_10"/> |
2141 |
<buttongroup name="buttonGroup_13"/> |
|
2107 | 2142 |
<buttongroup name="buttonGroup_9"/> |
2143 |
<buttongroup name="buttonGroup"/> |
|
2144 |
<buttongroup name="buttonGroup_7"/> |
|
2145 |
<buttongroup name="buttonGroup_8"/> |
|
2146 |
<buttongroup name="buttonGroup_3"/> |
|
2108 | 2147 |
<buttongroup name="buttonGroup_2"/> |
2109 |
<buttongroup name="buttonGroup_4"/> |
|
2110 | 2148 |
<buttongroup name="buttonGroup_5"/> |
2111 |
<buttongroup name="buttonGroup_13"/> |
|
2149 |
<buttongroup name="buttonGroup_12"/> |
|
2150 |
<buttongroup name="buttonGroup_6"/> |
|
2112 | 2151 |
</buttongroups> |
2113 | 2152 |
</ui> |
내보내기 Unified diff