개정판 2a6d202c
issue #000: change project unit setting into configuration
Change-Id: I88fc9f7d89ddae70a5c5c7ea79384700115c0f4c
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
1503 | 1503 |
print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1504 | 1504 |
sys.exc_info()[-1].tb_lineno)) |
1505 | 1505 |
|
1506 |
def updateProjectUnit(self, unit): |
|
1507 |
"""save project configurations""" |
|
1508 |
|
|
1509 |
# Creates or opens a file called mydb with a SQLite3 DB |
|
1510 |
dbPath = self.getPrjDatabasePath() |
|
1511 |
with sqlite3.connect(dbPath) as conn: |
|
1512 |
try: |
|
1513 |
# Get a cursor object |
|
1514 |
cursor = conn.cursor() |
|
1515 |
|
|
1516 |
sql = "update Projects set [Unit]=? where [Id]=?" |
|
1517 |
param = (unit, self.project.getId()) |
|
1518 |
|
|
1519 |
cursor.execute(sql, param) |
|
1520 |
conn.commit() |
|
1521 |
# Catch the exception |
|
1522 |
except Exception as ex: |
|
1523 |
# Roll back any change if something goes wrong |
|
1524 |
conn.rollback() |
|
1525 |
|
|
1526 |
from App import App |
|
1527 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1528 |
sys.exc_info()[-1].tb_lineno) |
|
1529 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
1530 |
|
|
1506 | 1531 |
''' |
1507 | 1532 |
@brief delete configurations |
1508 | 1533 |
@author humkyung |
1509 | 1534 |
@date 2018.06.29 |
1510 | 1535 |
''' |
1511 |
|
|
1512 | 1536 |
def deleteConfigs(self, section, key=None): |
1513 | 1537 |
conn = self.project.database.connect() |
1514 | 1538 |
with conn: |
DTI_PID/DTI_PID/ConfigurationDialog.py | ||
---|---|---|
98 | 98 |
self.ui.maxTextSizeSpinBox.setValue(int(configs[0].value)) if 1 == len(configs) else \ |
99 | 99 |
self.ui.maxTextSizeSpinBox.setValue(60) |
100 | 100 |
|
101 |
configs = docData.getConfigs('Project', 'Unit') |
|
102 |
sizeUnit = configs[0].value if 1 == len(configs) else None |
|
103 |
self.ui.radioButtonSizeUnitImaperial.setChecked(True if sizeUnit == 'Imperial' else False) |
|
104 |
self.ui.radioButtonSizeUnitMetric.setChecked(True if sizeUnit == 'Metric' else False) |
|
105 |
|
|
101 | 106 |
configs = docData.getConfigs('Size', 'Delimiter') |
102 | 107 |
self.ui.lineEditSizeDelimiter.setText(configs[0].value if 1 == len(configs) else 'X') |
103 | 108 |
configs = docData.getConfigs('Range', 'Detection Ratio') |
... | ... | |
982 | 987 |
configs.append(Config('Text Size', 'Min Text Size', self.ui.minTextSizeSpinBox.value())) |
983 | 988 |
configs.append(Config('Text Size', 'Max Text Size', self.ui.maxTextSizeSpinBox.value())) |
984 | 989 |
|
990 |
configs.append(Config('Project', 'Unit', 'Imperial' if self.ui.radioButtonSizeUnitImaperial.isChecked() else 'Metric')) |
|
985 | 991 |
configs.append(Config('Size', 'Delimiter', self.ui.lineEditSizeDelimiter.text())) |
986 | 992 |
configs.append(Config('Range', 'Detection Ratio', self.ui.doubleSpinBoxDetectionRange.value())) |
987 | 993 |
configs.append(Config('Flow Mark', 'Position', self.ui.spinBoxFlowMarkPosition.value())) |
... | ... | |
1120 | 1126 |
configs.append(Config('Engine', 'OCR', '1' if self.ui.radioButtonOCRLocal.isChecked() else '-1')) |
1121 | 1127 |
|
1122 | 1128 |
docData.saveConfigs(configs) |
1129 |
docData.updateProjectUnit('Imperial' if self.ui.radioButtonSizeUnitImaperial.isChecked() else 'Metric') |
|
1123 | 1130 |
docData.lineTypeConfigs = None # clear line type configurations |
1124 | 1131 |
NominalPipeSizeTable.instance().pipe_sizes = None # clear nominal pipe size table |
1125 | 1132 |
|
DTI_PID/DTI_PID/Configuration_UI.py | ||
---|---|---|
226 | 226 |
self.gridLayout_6.setObjectName("gridLayout_6") |
227 | 227 |
self.gridLayout_26 = QtWidgets.QGridLayout() |
228 | 228 |
self.gridLayout_26.setObjectName("gridLayout_26") |
229 |
self.spinBoxFlowMarkPosition = QtWidgets.QSpinBox(self.groupBoxAttribute) |
|
230 |
self.spinBoxFlowMarkPosition.setMaximum(100) |
|
231 |
self.spinBoxFlowMarkPosition.setObjectName("spinBoxFlowMarkPosition") |
|
232 |
self.gridLayout_26.addWidget(self.spinBoxFlowMarkPosition, 2, 1, 1, 1) |
|
233 | 229 |
self.lineEditSizeDelimiter = QtWidgets.QLineEdit(self.groupBoxAttribute) |
234 | 230 |
self.lineEditSizeDelimiter.setObjectName("lineEditSizeDelimiter") |
235 |
self.gridLayout_26.addWidget(self.lineEditSizeDelimiter, 0, 1, 1, 1) |
|
236 |
self.doubleSpinBoxDetectionRange = QtWidgets.QDoubleSpinBox(self.groupBoxAttribute) |
|
237 |
self.doubleSpinBoxDetectionRange.setSingleStep(0.1) |
|
238 |
self.doubleSpinBoxDetectionRange.setProperty("value", 1.0) |
|
239 |
self.doubleSpinBoxDetectionRange.setObjectName("doubleSpinBoxDetectionRange") |
|
240 |
self.gridLayout_26.addWidget(self.doubleSpinBoxDetectionRange, 1, 1, 1, 1) |
|
231 |
self.gridLayout_26.addWidget(self.lineEditSizeDelimiter, 1, 1, 1, 1) |
|
241 | 232 |
self.label_6 = QtWidgets.QLabel(self.groupBoxAttribute) |
242 | 233 |
self.label_6.setObjectName("label_6") |
243 |
self.gridLayout_26.addWidget(self.label_6, 0, 0, 1, 1) |
|
244 |
self.label_24 = QtWidgets.QLabel(self.groupBoxAttribute) |
|
245 |
self.label_24.setMaximumSize(QtCore.QSize(190, 16777215)) |
|
246 |
self.label_24.setObjectName("label_24") |
|
247 |
self.gridLayout_26.addWidget(self.label_24, 2, 0, 1, 1) |
|
234 |
self.gridLayout_26.addWidget(self.label_6, 1, 0, 1, 1) |
|
248 | 235 |
self.label_15 = QtWidgets.QLabel(self.groupBoxAttribute) |
249 | 236 |
self.label_15.setMaximumSize(QtCore.QSize(190, 16777215)) |
250 | 237 |
self.label_15.setObjectName("label_15") |
251 |
self.gridLayout_26.addWidget(self.label_15, 1, 0, 1, 1) |
|
238 |
self.gridLayout_26.addWidget(self.label_15, 2, 0, 1, 1) |
|
239 |
self.doubleSpinBoxDetectionRange = QtWidgets.QDoubleSpinBox(self.groupBoxAttribute) |
|
240 |
self.doubleSpinBoxDetectionRange.setSingleStep(0.1) |
|
241 |
self.doubleSpinBoxDetectionRange.setProperty("value", 1.0) |
|
242 |
self.doubleSpinBoxDetectionRange.setObjectName("doubleSpinBoxDetectionRange") |
|
243 |
self.gridLayout_26.addWidget(self.doubleSpinBoxDetectionRange, 2, 1, 1, 1) |
|
252 | 244 |
self.label_26 = QtWidgets.QLabel(self.groupBoxAttribute) |
253 | 245 |
self.label_26.setMaximumSize(QtCore.QSize(220, 16777215)) |
254 | 246 |
self.label_26.setObjectName("label_26") |
255 |
self.gridLayout_26.addWidget(self.label_26, 3, 0, 1, 1)
|
|
247 |
self.gridLayout_26.addWidget(self.label_26, 4, 0, 1, 1)
|
|
256 | 248 |
self.spinBoxFlowMarkLength = QtWidgets.QSpinBox(self.groupBoxAttribute) |
257 | 249 |
self.spinBoxFlowMarkLength.setMinimum(1) |
258 | 250 |
self.spinBoxFlowMarkLength.setMaximum(99999) |
259 | 251 |
self.spinBoxFlowMarkLength.setObjectName("spinBoxFlowMarkLength") |
260 |
self.gridLayout_26.addWidget(self.spinBoxFlowMarkLength, 3, 1, 1, 1) |
|
252 |
self.gridLayout_26.addWidget(self.spinBoxFlowMarkLength, 4, 1, 1, 1) |
|
253 |
self.spinBoxFlowMarkPosition = QtWidgets.QSpinBox(self.groupBoxAttribute) |
|
254 |
self.spinBoxFlowMarkPosition.setMaximum(100) |
|
255 |
self.spinBoxFlowMarkPosition.setObjectName("spinBoxFlowMarkPosition") |
|
256 |
self.gridLayout_26.addWidget(self.spinBoxFlowMarkPosition, 3, 1, 1, 1) |
|
257 |
self.label_24 = QtWidgets.QLabel(self.groupBoxAttribute) |
|
258 |
self.label_24.setMaximumSize(QtCore.QSize(190, 16777215)) |
|
259 |
self.label_24.setObjectName("label_24") |
|
260 |
self.gridLayout_26.addWidget(self.label_24, 3, 0, 1, 1) |
|
261 |
self.label_54 = QtWidgets.QLabel(self.groupBoxAttribute) |
|
262 |
self.label_54.setObjectName("label_54") |
|
263 |
self.gridLayout_26.addWidget(self.label_54, 0, 0, 1, 1) |
|
264 |
self.horizontalLayout_11 = QtWidgets.QHBoxLayout() |
|
265 |
self.horizontalLayout_11.setObjectName("horizontalLayout_11") |
|
266 |
self.radioButtonSizeUnitImaperial = QtWidgets.QRadioButton(self.groupBoxAttribute) |
|
267 |
self.radioButtonSizeUnitImaperial.setObjectName("radioButtonSizeUnitImaperial") |
|
268 |
self.buttonGroup_9 = QtWidgets.QButtonGroup(ConfigurationDialog) |
|
269 |
self.buttonGroup_9.setObjectName("buttonGroup_9") |
|
270 |
self.buttonGroup_9.addButton(self.radioButtonSizeUnitImaperial) |
|
271 |
self.horizontalLayout_11.addWidget(self.radioButtonSizeUnitImaperial) |
|
272 |
self.radioButtonSizeUnitMetric = QtWidgets.QRadioButton(self.groupBoxAttribute) |
|
273 |
self.radioButtonSizeUnitMetric.setObjectName("radioButtonSizeUnitMetric") |
|
274 |
self.buttonGroup_9.addButton(self.radioButtonSizeUnitMetric) |
|
275 |
self.horizontalLayout_11.addWidget(self.radioButtonSizeUnitMetric) |
|
276 |
self.gridLayout_26.addLayout(self.horizontalLayout_11, 0, 1, 1, 1) |
|
261 | 277 |
self.gridLayout_6.addLayout(self.gridLayout_26, 0, 0, 1, 1) |
262 | 278 |
self.gridLayout_2.addWidget(self.groupBoxAttribute, 1, 1, 1, 1) |
263 | 279 |
self.tabWidget.addTab(self.Recognition, "") |
... | ... | |
929 | 945 |
self.label_50.setText(_translate("ConfigurationDialog", "Allowable Pair : ")) |
930 | 946 |
self.groupBoxAttribute.setTitle(_translate("ConfigurationDialog", "Attribute")) |
931 | 947 |
self.label_6.setText(_translate("ConfigurationDialog", "Size Delimiter : ")) |
932 |
self.label_24.setText(_translate("ConfigurationDialog", "Line Flow Mark Position(Percent) : ")) |
|
933 | 948 |
self.label_15.setText(_translate("ConfigurationDialog", "Attribute Detection Range(Ratio) : ")) |
934 | 949 |
self.label_26.setText(_translate("ConfigurationDialog", "Line Flow Mark Minimum Line Length : ")) |
950 |
self.label_24.setText(_translate("ConfigurationDialog", "Line Flow Mark Position(Percent) : ")) |
|
951 |
self.label_54.setText(_translate("ConfigurationDialog", "Size Unit : ")) |
|
952 |
self.radioButtonSizeUnitImaperial.setText(_translate("ConfigurationDialog", "Imperial")) |
|
953 |
self.radioButtonSizeUnitMetric.setText(_translate("ConfigurationDialog", "Metric")) |
|
935 | 954 |
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Recognition), _translate("ConfigurationDialog", "Recognition")) |
936 | 955 |
self.groupBoxLineNo.setTitle(_translate("ConfigurationDialog", "Line No")) |
937 | 956 |
self.pushButtonAddProperty.setText(_translate("ConfigurationDialog", "Add")) |
DTI_PID/DTI_PID/Project_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file '.\UI\Project.ui'
|
|
3 |
# Form implementation generated from reading ui file './UI/Project.ui'
|
|
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.13.0
|
|
5 |
# Created by: PyQt5 UI code generator 5.11.3
|
|
6 | 6 |
# |
7 | 7 |
# WARNING! All changes made in this file will be lost! |
8 | 8 |
|
9 |
|
|
10 | 9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
11 | 10 |
|
12 |
|
|
13 | 11 |
class Ui_ProjectDialog(object): |
14 | 12 |
def setupUi(self, ProjectDialog): |
15 | 13 |
ProjectDialog.setObjectName("ProjectDialog") |
... | ... | |
79 | 77 |
self.gridLayout_4 = QtWidgets.QGridLayout() |
80 | 78 |
self.gridLayout_4.setObjectName("gridLayout_4") |
81 | 79 |
self.comboBoxProjectUnit = QtWidgets.QComboBox(ProjectDialog) |
80 |
self.comboBoxProjectUnit.setEnabled(False) |
|
82 | 81 |
self.comboBoxProjectUnit.setObjectName("comboBoxProjectUnit") |
83 | 82 |
self.gridLayout_4.addWidget(self.comboBoxProjectUnit, 2, 1, 1, 1) |
84 | 83 |
self.comboBox = QtWidgets.QComboBox(ProjectDialog) |
... | ... | |
164 | 163 |
self.label_2.setText(_translate("ProjectDialog", "Project Desc")) |
165 | 164 |
self.toolButtonDelete.setText(_translate("ProjectDialog", "-")) |
166 | 165 |
self.label_3.setText(_translate("ProjectDialog", "Project Unit")) |
166 |
|
|
167 | 167 |
import MainWindow_rc |
168 |
|
|
169 |
if __name__ == "__main__": |
|
170 |
import sys |
|
171 |
app = QtWidgets.QApplication(sys.argv) |
|
172 |
ProjectDialog = QtWidgets.QDialog() |
|
173 |
ui = Ui_ProjectDialog() |
|
174 |
ui.setupUi(ProjectDialog) |
|
175 |
ProjectDialog.show() |
|
176 |
sys.exit(app.exec_()) |
|
177 |
|
DTI_PID/DTI_PID/UI/Configuration.ui | ||
---|---|---|
453 | 453 |
<layout class="QGridLayout" name="gridLayout_6"> |
454 | 454 |
<item row="0" column="0"> |
455 | 455 |
<layout class="QGridLayout" name="gridLayout_26"> |
456 |
<item row="2" column="1"> |
|
457 |
<widget class="QSpinBox" name="spinBoxFlowMarkPosition"> |
|
458 |
<property name="maximum"> |
|
459 |
<number>100</number> |
|
460 |
</property> |
|
461 |
</widget> |
|
462 |
</item> |
|
463 |
<item row="0" column="1"> |
|
464 |
<widget class="QLineEdit" name="lineEditSizeDelimiter"/> |
|
465 |
</item> |
|
466 | 456 |
<item row="1" column="1"> |
467 |
<widget class="QDoubleSpinBox" name="doubleSpinBoxDetectionRange"> |
|
468 |
<property name="singleStep"> |
|
469 |
<double>0.100000000000000</double> |
|
470 |
</property> |
|
471 |
<property name="value"> |
|
472 |
<double>1.000000000000000</double> |
|
473 |
</property> |
|
474 |
</widget> |
|
457 |
<widget class="QLineEdit" name="lineEditSizeDelimiter"/> |
|
475 | 458 |
</item> |
476 |
<item row="0" column="0">
|
|
459 |
<item row="1" column="0">
|
|
477 | 460 |
<widget class="QLabel" name="label_6"> |
478 | 461 |
<property name="text"> |
479 | 462 |
<string>Size Delimiter : </string> |
... | ... | |
481 | 464 |
</widget> |
482 | 465 |
</item> |
483 | 466 |
<item row="2" column="0"> |
484 |
<widget class="QLabel" name="label_24">
|
|
467 |
<widget class="QLabel" name="label_15">
|
|
485 | 468 |
<property name="maximumSize"> |
486 | 469 |
<size> |
487 | 470 |
<width>190</width> |
... | ... | |
489 | 472 |
</size> |
490 | 473 |
</property> |
491 | 474 |
<property name="text"> |
492 |
<string>Line Flow Mark Position(Percent) : </string>
|
|
475 |
<string>Attribute Detection Range(Ratio) : </string>
|
|
493 | 476 |
</property> |
494 | 477 |
</widget> |
495 | 478 |
</item> |
496 |
<item row="1" column="0"> |
|
497 |
<widget class="QLabel" name="label_15"> |
|
498 |
<property name="maximumSize"> |
|
499 |
<size> |
|
500 |
<width>190</width> |
|
501 |
<height>16777215</height> |
|
502 |
</size> |
|
479 |
<item row="2" column="1"> |
|
480 |
<widget class="QDoubleSpinBox" name="doubleSpinBoxDetectionRange"> |
|
481 |
<property name="singleStep"> |
|
482 |
<double>0.100000000000000</double> |
|
503 | 483 |
</property> |
504 |
<property name="text">
|
|
505 |
<string>Attribute Detection Range(Ratio) : </string>
|
|
484 |
<property name="value">
|
|
485 |
<double>1.000000000000000</double>
|
|
506 | 486 |
</property> |
507 | 487 |
</widget> |
508 | 488 |
</item> |
509 |
<item row="3" column="0">
|
|
489 |
<item row="4" column="0">
|
|
510 | 490 |
<widget class="QLabel" name="label_26"> |
511 | 491 |
<property name="maximumSize"> |
512 | 492 |
<size> |
... | ... | |
519 | 499 |
</property> |
520 | 500 |
</widget> |
521 | 501 |
</item> |
522 |
<item row="3" column="1">
|
|
502 |
<item row="4" column="1">
|
|
523 | 503 |
<widget class="QSpinBox" name="spinBoxFlowMarkLength"> |
524 | 504 |
<property name="minimum"> |
525 | 505 |
<number>1</number> |
... | ... | |
529 | 509 |
</property> |
530 | 510 |
</widget> |
531 | 511 |
</item> |
512 |
<item row="3" column="1"> |
|
513 |
<widget class="QSpinBox" name="spinBoxFlowMarkPosition"> |
|
514 |
<property name="maximum"> |
|
515 |
<number>100</number> |
|
516 |
</property> |
|
517 |
</widget> |
|
518 |
</item> |
|
519 |
<item row="3" column="0"> |
|
520 |
<widget class="QLabel" name="label_24"> |
|
521 |
<property name="maximumSize"> |
|
522 |
<size> |
|
523 |
<width>190</width> |
|
524 |
<height>16777215</height> |
|
525 |
</size> |
|
526 |
</property> |
|
527 |
<property name="text"> |
|
528 |
<string>Line Flow Mark Position(Percent) : </string> |
|
529 |
</property> |
|
530 |
</widget> |
|
531 |
</item> |
|
532 |
<item row="0" column="0"> |
|
533 |
<widget class="QLabel" name="label_54"> |
|
534 |
<property name="text"> |
|
535 |
<string>Size Unit : </string> |
|
536 |
</property> |
|
537 |
</widget> |
|
538 |
</item> |
|
539 |
<item row="0" column="1"> |
|
540 |
<layout class="QHBoxLayout" name="horizontalLayout_11"> |
|
541 |
<item> |
|
542 |
<widget class="QRadioButton" name="radioButtonSizeUnitImaperial"> |
|
543 |
<property name="text"> |
|
544 |
<string>Imperial</string> |
|
545 |
</property> |
|
546 |
<attribute name="buttonGroup"> |
|
547 |
<string notr="true">buttonGroup_9</string> |
|
548 |
</attribute> |
|
549 |
</widget> |
|
550 |
</item> |
|
551 |
<item> |
|
552 |
<widget class="QRadioButton" name="radioButtonSizeUnitMetric"> |
|
553 |
<property name="text"> |
|
554 |
<string>Metric</string> |
|
555 |
</property> |
|
556 |
<attribute name="buttonGroup"> |
|
557 |
<string notr="true">buttonGroup_9</string> |
|
558 |
</attribute> |
|
559 |
</widget> |
|
560 |
</item> |
|
561 |
</layout> |
|
562 |
</item> |
|
532 | 563 |
</layout> |
533 | 564 |
</item> |
534 | 565 |
</layout> |
... | ... | |
1868 | 1899 |
</connection> |
1869 | 1900 |
</connections> |
1870 | 1901 |
<buttongroups> |
1871 |
<buttongroup name="buttonGroup_2"/> |
|
1872 |
<buttongroup name="buttonGroup_7"/> |
|
1873 |
<buttongroup name="buttonGroup_6"/> |
|
1902 |
<buttongroup name="buttonGroup_3"/> |
|
1903 |
<buttongroup name="buttonGroup_8"/> |
|
1874 | 1904 |
<buttongroup name="buttonGroup_4"/> |
1875 | 1905 |
<buttongroup name="buttonGroup_5"/> |
1876 |
<buttongroup name="buttonGroup_8"/> |
|
1877 |
<buttongroup name="buttonGroup_3"/> |
|
1906 |
<buttongroup name="buttonGroup_7"/> |
|
1907 |
<buttongroup name="buttonGroup_6"/> |
|
1908 |
<buttongroup name="buttonGroup_2"/> |
|
1878 | 1909 |
<buttongroup name="buttonGroup"/> |
1910 |
<buttongroup name="buttonGroup_9"/> |
|
1879 | 1911 |
</buttongroups> |
1880 | 1912 |
</ui> |
DTI_PID/DTI_PID/UI/Project.ui | ||
---|---|---|
139 | 139 |
<item row="0" column="0"> |
140 | 140 |
<layout class="QGridLayout" name="gridLayout_4"> |
141 | 141 |
<item row="2" column="1"> |
142 |
<widget class="QComboBox" name="comboBoxProjectUnit"/> |
|
142 |
<widget class="QComboBox" name="comboBoxProjectUnit"> |
|
143 |
<property name="enabled"> |
|
144 |
<bool>false</bool> |
|
145 |
</property> |
|
146 |
</widget> |
|
143 | 147 |
</item> |
144 | 148 |
<item row="0" column="1"> |
145 | 149 |
<widget class="QComboBox" name="comboBox"> |
내보내기 Unified diff