hytos / DTI_PID / DTI_PID / ConfigurationDialog.py @ 8578ac84
이력 | 보기 | 이력해설 | 다운로드 (23.4 KB)
1 |
# coding: utf-8
|
---|---|
2 |
import os |
3 |
import sys |
4 |
from PyQt5.QtCore import * |
5 |
from PyQt5.QtGui import * |
6 |
from PyQt5.QtWidgets import * |
7 |
import sqlite3 |
8 |
from AppDocData import AppDocData |
9 |
from AppDocData import Config |
10 |
from AppDocData import Color |
11 |
import Configuration_UI |
12 |
|
13 |
class ListView(QListView): |
14 |
def __init__(self, *args, **kwargs): |
15 |
super(ListView, self).__init__(*args, **kwargs) |
16 |
|
17 |
'''
|
18 |
@brief deleted selected item
|
19 |
@author humkyung
|
20 |
@date 2018.04.09
|
21 |
'''
|
22 |
def removeSelectedItem(self): |
23 |
selectedIndexes = self.selectedIndexes()
|
24 |
selectedRows = [item.row() for item in selectedIndexes] |
25 |
model = self.model()
|
26 |
# iterates each selected row in descending order
|
27 |
for row in sorted(selectedRows, reverse=True): |
28 |
# remove the row from the model
|
29 |
model.removeRow(row) |
30 |
|
31 |
'''
|
32 |
@brief key press event
|
33 |
@author humkyung
|
34 |
@date 2018.04.09
|
35 |
'''
|
36 |
def keyPressEvent(self, event): |
37 |
if event.key() == Qt.Key_Delete:
|
38 |
self.removeSelectedItem()
|
39 |
return
|
40 |
|
41 |
super(ListView, self).keyPressEvent(event) |
42 |
|
43 |
class QConfigurationDialog(QDialog): |
44 |
'''
|
45 |
@history humkyung 2018.05.05 read configuration for instrument and opc tag no rule
|
46 |
humkyung 2018.05.09 read line no tag rule configuration
|
47 |
Jeongwoo 2018.05.18 read Small Line Minimum Length
|
48 |
Jeongwoo 2018.06.04 read Min/Max Text Size
|
49 |
Jeongwoo 2018.06.05 read Text Area Detection Method
|
50 |
humkyung 2018.06.20 add expand,shrink and merge size for recognizing text
|
51 |
humkyung 2018.06.29 add line type table
|
52 |
kyouho 2018.07.04 add self.delimiter = '"'
|
53 |
'''
|
54 |
def __init__(self, parent): |
55 |
QDialog.__init__(self, parent)
|
56 |
|
57 |
self.ui = Configuration_UI.Ui_ConfigurationDialog()
|
58 |
self.ui.setupUi(self) |
59 |
self.ui.listViewProperties = ListView(self.ui.groupBoxLineNo) |
60 |
self.ui.listViewProperties.setObjectName('listViewProperties') |
61 |
self.ui.horizontalLayout_3.addWidget(self.ui.listViewProperties) |
62 |
self.isAccepted = False |
63 |
self.itemModel = QStandardItemModel()
|
64 |
self.delimiter = '"' |
65 |
self.defaultColor = Color(0, 0, 0, 255) |
66 |
self.currentIndex = 0 |
67 |
|
68 |
docData = AppDocData.instance() |
69 |
configs = docData.getConfigs('Text Area', 'Text Area') |
70 |
value = int(configs[0].value) if 1 == len(configs) else 0 |
71 |
if value == 0: |
72 |
self.ui.textAreaTypeARadioButton.setChecked(True) |
73 |
else:
|
74 |
self.ui.textAreaTypeBRadioButton.setChecked(True) |
75 |
|
76 |
configs = docData.getConfigs('Text Recognition', 'Expand Size') |
77 |
self.ui.spinBoxExpandSize.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxExpandSize.setValue(10) |
78 |
configs = docData.getConfigs('Text Recognition', 'Shrink Size') |
79 |
self.ui.spinBoxShrinkSize.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxShrinkSize.setValue(0) |
80 |
configs = docData.getConfigs('Text Recognition', 'Merge Size') |
81 |
self.ui.spinBoxMergeSize.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxMergeSize.setValue(10) |
82 |
# text replace options - 2018.07.03 added by humkyung
|
83 |
configs = docData.getConfigs('Text Recognition', 'Remove White Space') |
84 |
self.ui.checkBoxRemoveWhiteSpace.setChecked(('True' == configs[0].value) if 1 == len(configs) else False) |
85 |
configs = docData.getConfigs('Text Recognition', 'OldStr') |
86 |
self.ui.lineEditOldStr.setText(configs[0].value if 1 == len(configs) else '') |
87 |
configs = docData.getConfigs('Text Recognition', 'NewStr') |
88 |
self.ui.lineEditNewStr.setText(configs[0].value if 1 == len(configs) else '') |
89 |
# up to here
|
90 |
|
91 |
configs = docData.getConfigs('Text Size', 'Min Text Size') |
92 |
self.ui.minTextSizeSpinBox.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.minTextSizeSpinBox.setValue(30) |
93 |
configs = docData.getConfigs('Text Size', 'Max Text Size') |
94 |
self.ui.maxTextSizeSpinBox.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.maxTextSizeSpinBox.setValue(60) |
95 |
|
96 |
configs = docData.getConfigs('Size', 'Delimiter') |
97 |
self.ui.lineEditSizeDelimiter.setText(configs[0].value if 1 == len(configs) else 'X') |
98 |
|
99 |
# set min,max area for small object
|
100 |
configs = docData.getConfigs('Small Object Size', 'Min Area') |
101 |
self.ui.spinBoxMinArea.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxMinArea.setValue(20) |
102 |
configs = docData.getConfigs('Small Object Size', 'Max Area') |
103 |
self.ui.spinBoxMaxArea.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxMaxArea.setValue(50) |
104 |
# up to here
|
105 |
|
106 |
windowSize = docData.getSlidingWindowSize() |
107 |
self.ui.spinBoxWidth.setValue(windowSize[0]) |
108 |
self.ui.spinBoxHeight.setValue(windowSize[1]) |
109 |
|
110 |
configs = docData.getConfigs('Small Line Minimum Length', 'Min Length') |
111 |
self.ui.smallLineMinLengthSpinBox.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.smallLineMinLengthSpinBox.setValue(10) |
112 |
|
113 |
configs = docData.getConfigs('Line No', 'Size Unit') |
114 |
if 1 == len(configs): |
115 |
self.ui.radioButtonMetric.setChecked(True) if 'Metric' == configs[0].value else self.ui.radioButtonInch.setChecked(True) |
116 |
else:
|
117 |
self.ui.radioButtonMetric.setChecked(True) |
118 |
|
119 |
configs = docData.getConfigs('Line No', 'Delimiter') |
120 |
if 1 == len(configs): |
121 |
self.ui.lineEdit.setText(configs[0].value) |
122 |
|
123 |
properties = docData.getLineProperties() |
124 |
for prop in properties: |
125 |
self.ui.comboBoxProperties.addItem(prop)
|
126 |
if prop != "Tag Seq No": |
127 |
self.ui.comboBoxColorOption.addItem(prop)
|
128 |
|
129 |
configs = docData.getConfigs('Line No', 'Configuration') |
130 |
if len(configs) == 1 and configs[0].value is not None: |
131 |
for value in configs[0].value.split(self.delimiter): |
132 |
#for value in configs[0].value.split(self.ui.lineEdit.text()):
|
133 |
self.itemModel.appendRow(QStandardItem(value))
|
134 |
self.ui.listViewProperties.setModel(self.itemModel) |
135 |
|
136 |
configs = docData.getConfigs('Line No Tag Rule', 'Tag Seq No') |
137 |
self.ui.lineEditLineNoTagSeqNo.setText(configs[0].value if configs else '') |
138 |
|
139 |
configs = docData.getConfigs('Instrument Tag No Rule', 'Measured Variable Code') |
140 |
self.ui.lineEditMeasuredVariableCode.setText(configs[0].value if configs else '') |
141 |
configs = docData.getConfigs('Instrument Tag No Rule', 'Type Modifier') |
142 |
self.ui.lineEditTypeModifier.setText(configs[0].value if configs else '') |
143 |
configs = docData.getConfigs('Instrument Tag No Rule', 'Tag Seq No') |
144 |
self.ui.lineEditTagSeqNo.setText(configs[0].value if configs else '') |
145 |
configs = docData.getConfigs('Instrument Tag No Rule', 'Tag Suffix') |
146 |
self.ui.lineEditTagSuffix.setText(configs[0].value if configs else '') |
147 |
|
148 |
configs = docData.getConfigs('OPC Tag No Rule', 'Description') |
149 |
self.ui.lineEditDescription.setText(configs[0].value if configs else '') |
150 |
configs = docData.getConfigs('OPC Tag No Rule', 'OPC Tag') |
151 |
self.ui.lineEditOPCTag.setText(configs[0].value if configs else '') |
152 |
|
153 |
configs = docData.getConfigs('LineTypes')
|
154 |
|
155 |
lineTypes = docData.getLineTypes() |
156 |
self.ui.tableWidgetLineTypes.setColumnCount(3) |
157 |
self.ui.tableWidgetLineTypes.setHorizontalHeaderLabels(['Name', 'Width', 'Style']) |
158 |
self.ui.tableWidgetLineTypes.setRowCount(len(lineTypes)) |
159 |
row = 0
|
160 |
for lineType in lineTypes: |
161 |
item = QTableWidgetItem(lineType) |
162 |
item.setFlags(Qt.ItemIsEnabled) |
163 |
self.ui.tableWidgetLineTypes.setItem(row, 0, item) |
164 |
|
165 |
### line width
|
166 |
lineWidthSpinBox = QSpinBox() |
167 |
lineWidthSpinBox.setRange(1, 10) |
168 |
lineWidthSpinBox.setSingleStep(1)
|
169 |
matches = [config for config in configs if config.key == lineType] |
170 |
lineWidthSpinBox.setValue(int(matches[0].value.split(',')[0])) if matches else lineWidthSpinBox.setValue(1) |
171 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 1, lineWidthSpinBox) |
172 |
|
173 |
## line style
|
174 |
lineStyleComboBox = QComboBox() |
175 |
lineStyleComboBox.addItems(['SolidLine', 'DashLine', 'DotLine', 'DashDotLine', 'DashDotDotLine', 'CustomDashLine']) |
176 |
lineStyleComboBox.setCurrentText(matches[0].value.split(',')[1]) if matches else lineStyleComboBox.setCurrentText('SolidLine') |
177 |
self.ui.tableWidgetLineTypes.setCellWidget(row, 2, lineStyleComboBox) |
178 |
|
179 |
row += 1
|
180 |
|
181 |
self.ui.tableWidgetLineTypes.horizontalHeaderItem(0).setSizeHint(QSize(30, 30)) |
182 |
|
183 |
self.ui.labelFontName.setBuddy(self.ui.fontComboBox) |
184 |
configs = docData.getConfigs('Text Style', 'Font Name') |
185 |
if configs:
|
186 |
self.ui.fontComboBox.setCurrentFont(QFont(configs[0].value, 10)) |
187 |
configs = docData.getConfigs('Text Style', 'Font Size') |
188 |
if configs:
|
189 |
size = int(configs[0].value) |
190 |
self.ui.radioButtonAutoSize.setChecked(True if size == -1 else False) |
191 |
self.ui.radioButtonFixedSize.setChecked(True if size != -1 else False) |
192 |
self.ui.spinBoxFontSize.setValue(size if size != -1 else 10) |
193 |
self.ui.spinBoxFontSize.setEnabled(self.ui.radioButtonFixedSize.isChecked()) |
194 |
else:
|
195 |
self.ui.radioButtonAutoSize.setChecked(True) |
196 |
self.ui.radioButtonFixedSize.setChecked(False) |
197 |
self.ui.spinBoxFontSize.setValue(10) |
198 |
self.ui.spinBoxFontSize.setEnabled(self.ui.radioButtonFixedSize.isChecked()) |
199 |
|
200 |
# Line Color Visible Option 가져옴
|
201 |
configs = docData.getConfigs('Line Color', 'Visible Option') |
202 |
if configs:
|
203 |
data = configs[0].value
|
204 |
self.ui.radioButtonRandom.setChecked(True if data == 'Random' else False) |
205 |
self.ui.radioButtonProperty.setChecked(True if data == 'Property' else False) |
206 |
else:
|
207 |
self.ui.radioButtonRandom.setChecked(True) |
208 |
self.ui.radioButtonProperty.setChecked(False) |
209 |
|
210 |
# Color Property 선택값 가져옴
|
211 |
table = self.ui.tableWidgetColorProperty
|
212 |
configs = docData.getConfigs('Color Property', 'State') |
213 |
selectedOption = configs[0].value if configs and self.ui.comboBoxColorOption.findText(configs[0].value) >= 0 else 'Nominal Diameter' |
214 |
self.ui.tableWidgetColorProperty.setHorizontalHeaderLabels(['Value', 'Color', 'ref', 'colorStr']) |
215 |
|
216 |
index = self.ui.comboBoxColorOption.findText(selectedOption)
|
217 |
self.ui.comboBoxColorOption.setCurrentIndex(index)
|
218 |
self.currentIndex = index
|
219 |
|
220 |
table.hideColumn(2)
|
221 |
table.hideColumn(3)
|
222 |
#Column Header Size
|
223 |
self.ui.tableWidgetColorProperty.horizontalHeaderItem(0).setSizeHint(QSize(30, 30)) |
224 |
|
225 |
self.setPropertyToggle(self.ui.radioButtonProperty.isChecked()) |
226 |
|
227 |
# connect signals and slots
|
228 |
self.ui.pushButtonAddProperty.clicked.connect(self.addLineProperty) |
229 |
self.ui.radioButtonFixedSize.toggled.connect(self.onFixedSizeToggled) |
230 |
self.ui.pushButtonAddDelimiter.clicked.connect(self.addDelimiter) |
231 |
self.ui.tableWidgetColorProperty.cellDoubleClicked.connect(self.cellDoubleClick) |
232 |
self.ui.comboBoxColorOption.currentIndexChanged.connect(self.currentIndexChanged) |
233 |
self.ui.radioButtonRandom.toggled.connect(self.onPropertyToggled) |
234 |
|
235 |
'''
|
236 |
@brief Clear Table
|
237 |
@author kyouho
|
238 |
@date 2018.07.10
|
239 |
'''
|
240 |
def clearColorPropertyTable(self): |
241 |
table = self.ui.tableWidgetColorProperty
|
242 |
model = table.model() |
243 |
|
244 |
while table.rowCount():
|
245 |
model.removeRow(table.rowCount() - 1)
|
246 |
|
247 |
'''
|
248 |
@brief setting default table
|
249 |
@author kyouho
|
250 |
@date 2018.07.09
|
251 |
'''
|
252 |
def settingDefaultColorTable(self, property): |
253 |
docData = AppDocData.instance() |
254 |
table = self.ui.tableWidgetColorProperty
|
255 |
self.clearColorPropertyTable()
|
256 |
|
257 |
dic = {} |
258 |
|
259 |
if property == "Nominal Diameter": |
260 |
#중복 체크 배열
|
261 |
checkRepeat = [] |
262 |
# Size 표기 가져옴
|
263 |
configs = docData.getConfigs('Line No', 'Size Unit') |
264 |
# Size 관련 Table 가져옴
|
265 |
result = docData.getNomialPipeSizeData(False, "Metric") |
266 |
|
267 |
for pipeSize in result: |
268 |
if not pipeSize.inchStr or not pipeSize.metricStr: |
269 |
continue
|
270 |
else:
|
271 |
replaceInchStr = pipeSize.inchStr.replace("'", '"') |
272 |
if checkRepeat.count(replaceInchStr):
|
273 |
continue
|
274 |
else:
|
275 |
checkRepeat.append(replaceInchStr) |
276 |
|
277 |
if configs[0].value == 'Inch': |
278 |
dic[replaceInchStr] = pipeSize.metricStr |
279 |
else:
|
280 |
dic[pipeSize.metricStr] = pipeSize.metricStr |
281 |
|
282 |
elif property != "Tag Seq No": |
283 |
result = docData.getCodeTable(property.replace(' ','').replace('&', 'n'), True) |
284 |
for fluidCode in result: |
285 |
dic[fluidCode] = fluidCode |
286 |
|
287 |
if dic:
|
288 |
table.setRowCount(len(dic))
|
289 |
|
290 |
row = 0
|
291 |
for i in dic.keys(): |
292 |
table.setItem(row, 0, QTableWidgetItem(i))
|
293 |
table.setItem(row, 1, QTableWidgetItem('')) |
294 |
table.setItem(row, 2, QTableWidgetItem(dic[i]))
|
295 |
table.setItem(row, 3, QTableWidgetItem('')) |
296 |
row += 1
|
297 |
|
298 |
'''
|
299 |
@brief setting Color String Cell
|
300 |
@author kyouho
|
301 |
@date 2018.07.09
|
302 |
'''
|
303 |
def settingColorStringCell(self, property): |
304 |
docData = AppDocData.instance() |
305 |
table = self.ui.tableWidgetColorProperty
|
306 |
rowCount = table.rowCount() |
307 |
for j in range(rowCount): |
308 |
ref = table.item(j, 2)
|
309 |
|
310 |
configs = docData.getConfigs(property, ref.text())
|
311 |
if configs:
|
312 |
colorStr = table.item(j, 3)
|
313 |
colorStr.setText(configs[0].value)
|
314 |
|
315 |
'''
|
316 |
@brief setting color cell
|
317 |
@author kyouho
|
318 |
@date 2018.07.09
|
319 |
'''
|
320 |
def settingColorCell(self): |
321 |
table = self.ui.tableWidgetColorProperty
|
322 |
rowCount = table.rowCount() |
323 |
|
324 |
for i in range(rowCount): |
325 |
colorCell = table.item(i, 1)
|
326 |
colorDataCell = table.item(i, 3)
|
327 |
colorStr = colorDataCell.text() |
328 |
|
329 |
if colorStr:
|
330 |
split = colorStr.split(',')
|
331 |
r = split[0]
|
332 |
g = split[1]
|
333 |
b = split[2]
|
334 |
|
335 |
colorCell.setBackground(QColor(int(r), int(g), int(b))) |
336 |
else:
|
337 |
colorCell.setBackground(QColor(self.defaultColor.red, self.defaultColor.green, self.defaultColor.blue)) |
338 |
|
339 |
'''
|
340 |
@brief Cell Double Click Event
|
341 |
@author kyouho
|
342 |
@date 2018.07.09
|
343 |
'''
|
344 |
def currentIndexChanged(self, index): |
345 |
if self.currentIndex != index: |
346 |
self.currentIndex = index
|
347 |
selectedOption = self.ui.comboBoxColorOption.currentText()
|
348 |
# 기본 테이블 셋팅
|
349 |
self.settingDefaultColorTable(selectedOption)
|
350 |
# 설정된 색상 가져옴
|
351 |
self.settingColorStringCell(selectedOption)
|
352 |
#Table Color Setting
|
353 |
self.settingColorCell()
|
354 |
|
355 |
|
356 |
'''
|
357 |
@brief Cell Double Click Event
|
358 |
@author kyouho
|
359 |
@date 2018.07.09
|
360 |
'''
|
361 |
def cellDoubleClick(self, row, column): |
362 |
if column == 1: |
363 |
color = QColorDialog.getColor() |
364 |
if color.isValid():
|
365 |
self.ui.tableWidgetColorProperty.setItem(row, 3, QTableWidgetItem(str(color.red()) + ',' + str(color.green()) + ',' + str(color.blue()))) |
366 |
#Table Color Setting
|
367 |
self.settingColorCell()
|
368 |
|
369 |
'''
|
370 |
@brief add delimiter
|
371 |
@author kyouho
|
372 |
@date 2018.07.04
|
373 |
'''
|
374 |
def addDelimiter(self): |
375 |
text = self.ui.lineEdit.text()
|
376 |
if text != self.delimiter: |
377 |
self.itemModel.appendRow(QStandardItem(text))
|
378 |
else:
|
379 |
pass
|
380 |
|
381 |
'''
|
382 |
@brief add line property
|
383 |
@author humkyung
|
384 |
@date 2018.04.09
|
385 |
'''
|
386 |
def addLineProperty(self): |
387 |
index = self.ui.comboBoxProperties.currentIndex()
|
388 |
prop = self.ui.comboBoxProperties.itemText(index)
|
389 |
self.itemModel.appendRow(QStandardItem(prop))
|
390 |
|
391 |
'''
|
392 |
@brief enable/disable font size spinbox
|
393 |
@author humkyung
|
394 |
@date 2018.06.30
|
395 |
'''
|
396 |
def onFixedSizeToggled(self, radioButton): |
397 |
self.ui.spinBoxFontSize.setEnabled(self.ui.radioButtonFixedSize.isChecked()) |
398 |
|
399 |
'''
|
400 |
@brief property radio button toggle event
|
401 |
@author kyouho
|
402 |
@date 2018.07.10
|
403 |
'''
|
404 |
def onPropertyToggled(self, radioButton): |
405 |
self.setPropertyToggle(self.ui.radioButtonProperty.isChecked()) |
406 |
'''
|
407 |
@brief enable/disable font size spinbox
|
408 |
@author kyouho
|
409 |
@date 2018.07.10
|
410 |
'''
|
411 |
def setPropertyToggle(self, enable): |
412 |
if enable:
|
413 |
selectedOption = self.ui.comboBoxColorOption.currentText()
|
414 |
# 기본 테이블 셋팅
|
415 |
self.settingDefaultColorTable(selectedOption)
|
416 |
# 설정된 색상 가져옴
|
417 |
self.settingColorStringCell(selectedOption)
|
418 |
#Table Color Setting
|
419 |
self.settingColorCell()
|
420 |
else:
|
421 |
self.clearColorPropertyTable()
|
422 |
self.ui.comboBoxColorOption.setEnabled(enable)
|
423 |
|
424 |
'''
|
425 |
@brief insert or update configurations modified by user
|
426 |
@author humkyung
|
427 |
@date 2018.??.??
|
428 |
@history humkyung 2018.04.24 save size unit of line no
|
429 |
humkyung 2018.04.26 save min,max area for small object
|
430 |
humkyung 2018.05.02 save size delimiter
|
431 |
humkyung 2018.05.05 save instrument and opc tag no rule
|
432 |
humkyung 2018.05.09 save line no tag rule
|
433 |
Jeongwoo 2018.05.18 save Small Line Minimum Length
|
434 |
Jeongwoo 2018.06.04 save Min/Max Text Size
|
435 |
Jeongwoo 2018.06.05 save Text Area Detection Method
|
436 |
humkyung 2018.06.20 save Expand and Shrink size for recognizing text
|
437 |
kyouho 2018.07.04 edit cofiguration new delimiter (self.delimiter)
|
438 |
'''
|
439 |
def accept(self): |
440 |
try:
|
441 |
docData = AppDocData.instance() |
442 |
|
443 |
self.isAccepted = True |
444 |
|
445 |
configs = [] |
446 |
configs.append(Config('Text Area', 'Text Area', 0 if self.ui.textAreaTypeARadioButton.isChecked() else 1)) |
447 |
configs.append(Config('Text Recognition', 'Expand Size', self.ui.spinBoxExpandSize.value())) |
448 |
configs.append(Config('Text Recognition', 'Shrink Size', self.ui.spinBoxShrinkSize.value())) |
449 |
configs.append(Config('Text Recognition', 'Merge Size', self.ui.spinBoxMergeSize.value())) |
450 |
# save text replace options - 2018.07.03 added by humkyung
|
451 |
configs.append(Config('Text Recognition', 'Remove White Space', 'True' if self.ui.checkBoxRemoveWhiteSpace.isChecked() else 'False')) |
452 |
configs.append(Config('Text Recognition', 'OldStr', self.ui.lineEditOldStr.text())) |
453 |
configs.append(Config('Text Recognition', 'NewStr', self.ui.lineEditNewStr.text())) |
454 |
# up to here
|
455 |
configs.append(Config('Text Size', 'Min Text Size', self.ui.minTextSizeSpinBox.value())) |
456 |
configs.append(Config('Text Size', 'Max Text Size', self.ui.maxTextSizeSpinBox.value())) |
457 |
configs.append(Config('Size', 'Delimiter', self.ui.lineEditSizeDelimiter.text())) |
458 |
configs.append(Config('Small Object Size', 'Min Area', self.ui.spinBoxMinArea.value())) |
459 |
configs.append(Config('Small Object Size', 'Max Area', self.ui.spinBoxMaxArea.value())) |
460 |
configs.append(Config('Sliding Window', 'Width', self.ui.spinBoxWidth.value())) |
461 |
configs.append(Config('Sliding Window', 'Height', self.ui.spinBoxHeight.value())) |
462 |
configs.append(Config('Small Line Minimum Length', 'Min Length', self.ui.smallLineMinLengthSpinBox.value())) |
463 |
configs.append(Config('Line No', 'Size Unit', 'Metric' if self.ui.radioButtonMetric.isChecked() else 'Inch')) |
464 |
configs.append(Config('Line No', 'Delimiter', self.ui.lineEdit.text())) |
465 |
configs.append(Config('Line No Tag Rule', 'Tag Seq No', self.ui.lineEditLineNoTagSeqNo.text())) |
466 |
configs.append(Config('Instrument Tag No Rule', 'Measured Variable Code', self.ui.lineEditMeasuredVariableCode.text())) |
467 |
configs.append(Config('Instrument Tag No Rule', 'Type Modifier', self.ui.lineEditTypeModifier.text())) |
468 |
configs.append(Config('Instrument Tag No Rule', 'Tag Seq No', self.ui.lineEditTagSeqNo.text())) |
469 |
configs.append(Config('Instrument Tag No Rule', 'Tag Suffix', self.ui.lineEditTagSuffix.text())) |
470 |
configs.append(Config('OPC Tag No Rule', 'Description', self.ui.lineEditDescription.text())) |
471 |
configs.append(Config('OPC Tag No Rule', 'OPC Tag', self.ui.lineEditOPCTag.text())) |
472 |
|
473 |
# Add Line Color Option - 2018.07.06 by kyouho
|
474 |
rbRandomValue = self.ui.radioButtonRandom.isChecked()
|
475 |
cbColorOptionValue = self.ui.comboBoxColorOption.currentText()
|
476 |
configs.append(Config('Line Color', 'Visible Option', 'Random' if rbRandomValue else 'Property')) |
477 |
configs.append(Config('Color Property', 'State', cbColorOptionValue)) |
478 |
|
479 |
for row in range(self.ui.tableWidgetLineTypes.rowCount()): |
480 |
lineType = self.ui.tableWidgetLineTypes.item(row, 0).text() |
481 |
width = self.ui.tableWidgetLineTypes.cellWidget(row, 1).text() |
482 |
style = self.ui.tableWidgetLineTypes.cellWidget(row, 2).currentText() |
483 |
configs.append(Config('LineTypes', lineType, '{},{}'.format(width, style))) |
484 |
|
485 |
if not rbRandomValue: |
486 |
table = self.ui.tableWidgetColorProperty
|
487 |
rowCount = self.ui.tableWidgetColorProperty.rowCount()
|
488 |
for i in range(rowCount): |
489 |
refStr = table.item(i, 2).text()
|
490 |
colorStr = table.item(i, 3).text()
|
491 |
if colorStr:
|
492 |
configs.append(Config(cbColorOptionValue, refStr, colorStr)) |
493 |
|
494 |
#Configuration
|
495 |
configuration = None
|
496 |
self.ui.listViewProperties.model()
|
497 |
for i in range(self.itemModel.rowCount()): |
498 |
item = self.ui.listViewProperties.model().item(i).text()
|
499 |
if configuration is None: |
500 |
configuration = item |
501 |
else:
|
502 |
configuration += self.delimiter + item
|
503 |
#configuration += self.ui.lineEdit.text() + item
|
504 |
configs.append(Config('Line No', 'Configuration', configuration)) |
505 |
|
506 |
font = self.ui.fontComboBox.currentFont()
|
507 |
configs.append(Config('Text Style', 'Font Name', font.family())) |
508 |
configs.append(Config('Text Style', 'Font Size', str(self.ui.spinBoxFontSize.value()) if self.ui.radioButtonFixedSize.isChecked() else '-1')) |
509 |
|
510 |
|
511 |
docData.saveConfigs(configs) |
512 |
docData.lineTypeConfigs = None # clear line type configurations |
513 |
except Exception as ex: |
514 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
515 |
|
516 |
QDialog.accept(self)
|