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