프로젝트

일반

사용자정보

개정판 9168f672

ID9168f6720f7e78b3a00e397971e823b412645819
상위 90edbe1a
하위 5ddb142e, bd43d199

백흠경이(가) 4년 이상 전에 추가함

issue #597: HMB 테이블 연계

Change-Id: I9c77c32f94d3fe2b90a124195ab001fff08a799d

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
457 457

  
458 458
        if self._hmbTable is None:
459 459
            self._hmbTable = HMBTable()
460
            self._hmbTable.loadData()
460
            self._hmbTable.load_data()
461 461

  
462 462
        return self._hmbTable
463 463

  
......
2285 2285
            self._attributeByType = {}
2286 2286
            CodeTable.clearTables()
2287 2287

  
2288
    def get_hmb_attributes(self):
2289
        """get hmb attributes"""
2290
        from SymbolAttr import SymbolAttr
2291

  
2292
        attrs = []
2293
        with self.project.database.connect() as conn:
2294
            try:
2295
                # Get a cursor object
2296
                cursor = conn.cursor()
2297

  
2298
                sql = f"select * from SymbolAttribute where SymbolType_UID = " \
2299
                      f"(select UID from SymbolType where Type='HMB') order by [index]"
2300
                sql = self.project.database.to_sql(sql)
2301
                cursor.execute(sql)
2302
                rows = cursor.fetchall()
2303
                for row in rows:
2304
                    attr = SymbolAttr(row['UID'])
2305
                    attr.Attribute = row['Attribute']
2306
                    attr.DisplayAttribute = row['DisplayAttribute']
2307
                    attr.AttributeType = row['AttributeType']
2308
                    attr.AttrAt = row['AttrAt']
2309
                    attr.Expression = row['Expression']
2310
                    attr.Target = row['Target']
2311
                    attr.IsProp = row['Property']
2312

  
2313
                    attrs.append(attr)
2314

  
2315
            # Catch the exception
2316
            except Exception as ex:
2317
                # Roll back any change if something goes wrong
2318
                conn.rollback()
2319

  
2320
                from App import App
2321
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
2322
                                                               sys.exc_info()[-1].tb_lineno)
2323
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2324

  
2325
        return attrs
2326

  
2327
    def save_hmb_attributes(self, attrs):
2328
        """save hmb attributes"""
2329
        from CodeTables import CodeTable
2330

  
2331
        with self.project.database.connect() as conn:
2332
            try:
2333
                # Get a cursor object
2334
                cursor = conn.cursor()
2335

  
2336
                # delete hmb attributes
2337
                sql = f"delete from SymbolAttribute where SymbolType_UID = (select UID from SymbolType where Type='HMB')"
2338
                sql = self.project.database.to_sql(sql)
2339
                cursor.execute(sql)
2340
                # up to here
2341

  
2342
                for idx, attr in enumerate(attrs):
2343
                    sql = self.project.database.to_sql(
2344
                        'insert into SymbolAttribute(UID, SymbolType_UID, Attribute, DisplayAttribute, AttributeType, '
2345
                        'AttrAt, Expression, Target, [index], [Property]) values(?, '
2346
                        '(select uid from SymbolType where Type=\'HMB\'), ?, ?, ?, ?, ?, ?, ?, ?)')
2347
                    params = (str(attr.UID), attr.Attribute, attr.Attribute, 'String', attr.AttrAt,
2348
                              attr.Expression, attr.Target, idx, attr.IsProp)
2349

  
2350
                    cursor.execute(sql, params)
2351
                # up to here
2352

  
2353
                conn.commit()
2354

  
2355
            # Catch the exception
2356
            except Exception as ex:
2357
                # Roll back any change if something goes wrong
2358
                conn.rollback()
2359

  
2360
                from App import App
2361
                message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
2362
                                                               sys.exc_info()[-1].tb_lineno)
2363
                App.mainWnd().addMessage.emit(MessageType.Error, message)
2364

  
2365

  
2288 2366
    def saveCustomCodes(self, tables):
2289 2367
        ''' save custom code tables and codes '''
2290 2368

  
DTI_PID/DTI_PID/Commands/DefaultCommand.py
146 146
                    self.isSpecBreak = False
147 147

  
148 148
            else:
149
                """
149 150
                if 'mouseReleaseEvent' == param[0] and event.button() == Qt.LeftButton:
150 151
                    from EngineeringConnectorItem import QEngineeringConnectorItem
151 152

  
......
175 176
                    currentPt = self.symbol.getCurrentPoint()
176 177
                    transform.translate(scenePos.x() - currentPt[0], scenePos.y() - currentPt[1])
177 178
                    self.symbol.setTransform(transform)
178
                elif 'keyPressEvent' == param[0] and event.key() == Qt.Key_Escape:
179
                """
180
                if 'keyPressEvent' == param[0] and event.key() == Qt.Key_Escape:
179 181
                    self.imageViewer.scene().removeItem(self.symbol)
180 182
                    self.symbol = None
181 183
                    self.isCopy = False
DTI_PID/DTI_PID/HMBDialog.py
14 14
import sqlite3
15 15

  
16 16
from AppDocData import AppDocData, Config
17
import Area
18 17

  
19 18
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '\\Shapes')
20
import EngineeringPolylineItem
21
from EngineeringLineItem import QEngineeringLineItem
22 19
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
23
import Configuration_Area_UI
24 20

  
25 21

  
26 22
class Worker(QObject):
......
54 50
class QHMBDialog(QDialog):
55 51
    def __init__(self, parent):
56 52
        from HMB_UI import Ui_HMBDialog
53
        from TableWidgetEx import QTableWidgetEx
57 54

  
58 55
        QDialog.__init__(self, parent)
59 56
        self.ui = Ui_HMBDialog()
60 57
        self.ui.setupUi(self)
61
        self.ui.tableWidgetHMBRecord.setHorizontalHeaderLabels(['Name', 'Unit'])
58
        self.ui.tableWidgetHMBRecord = QTableWidgetEx(self.ui.groupBoxHMBRecord)
59
        self.ui.horizontalLayoutHMBColTableWidget.addWidget(self.ui.tableWidgetHMBRecord)
60

  
61
        self.ui.tableWidgetHMBData = QTableWidgetEx(self.ui.groupBoxHMBData)
62
        self.ui.horizontalLayoutHMBTableWidget.addWidget(self.ui.tableWidgetHMBData)
63

  
64
        self.ui.tableWidgetHMBRecord.setColumnCount(3)
65
        self.ui.tableWidgetHMBRecord.setHorizontalHeaderLabels(['UID', 'Name', 'Unit'])
62 66
        self.ui.tableWidgetHMBRecord.horizontalHeaderItem(0).setSizeHint(QSize(25, 25))
63 67

  
64 68
        # add splitter widget
......
73 77
        self.ui.pushButtonDelRecord.clicked.connect(self.onDelRecord)
74 78
        self.ui.pushButtonHMBArea.clicked.connect(self.onSelectHMBArea)
75 79
        self.ui.pushButtonRecognizeText.clicked.connect(self.onRecognizeText)
80
        self.ui.pushButtonAddHMBData.clicked.connect(self.on_add_hmb_data)
76 81
        self.ui.pushButtonDelHMBData.clicked.connect(self.onDelHMBData)
77 82

  
78 83
        self._cmd = FenceCommand.FenceCommand(self.parent().graphicsView)
79 84
        self._cmd.onSuccess.connect(self.onAreaSelected)
80 85

  
81
        appDocData = AppDocData.instance()
82
        configs = appDocData.getConfigs('HMB Record', 'Count')
83
        rows = int(configs[0].value) if configs else 0
86
        app_doc_data = AppDocData.instance()
87
        attrs = app_doc_data.get_hmb_attributes()
88
        configs = app_doc_data.getConfigs('HMB Record', 'Count')
89
        rows = len(attrs)
84 90
        self.ui.tableWidgetHMBRecord.setRowCount(rows)
85 91
        for row in range(rows):
86
            configs = appDocData.getConfigs('HMB Record{}'.format(row))
87
            if configs:
88
                item = QTableWidgetItem([config.value for config in configs if config.key == 'Name'][0])
89
                self.ui.tableWidgetHMBRecord.setItem(row, 0, item)
90
                item = QTableWidgetItem([config.value for config in configs if config.key == 'Unit'][0])
91
                self.ui.tableWidgetHMBRecord.setItem(row, 1, item)
92

  
93
        configs = appDocData.getConfigs('HMB Data', 'Column Width')
92
            self.ui.tableWidgetHMBRecord.setItem(row, 0, QTableWidgetItem(str(attrs[row].UID)))
93
            self.ui.tableWidgetHMBRecord.setItem(row, 1, QTableWidgetItem(attrs[row].Attribute))
94
            self.ui.tableWidgetHMBRecord.setItem(row, 2, QTableWidgetItem(attrs[row].Expression))
95
        self.ui.tableWidgetHMBRecord.hideColumn(0)  # hide UID
96
        self.ui.tableWidgetHMBRecord.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeToContents)
97

  
98
        configs = app_doc_data.getConfigs('HMB Data', 'Column Width')
94 99
        self.ui.lineEditColumnWidth.setText(configs[0].value if 1 == len(configs) else '0')
95
        configs = appDocData.getConfigs('HMB Data', 'Row Height')
100
        configs = app_doc_data.getConfigs('HMB Data', 'Row Height')
96 101
        self.ui.lineEditRowHeight.setText(configs[0].value if 1 == len(configs) else '0')
97
        configs = appDocData.getConfigs('HMB Data', 'Record Direction')
102
        configs = app_doc_data.getConfigs('HMB Data', 'Record Direction')
98 103
        if 0 == len(configs) or 'Horizontal' == configs[0].value:
99 104
            self.ui.radioButtonHorizontal.setChecked(True)
100 105
            self.ui.radioButtonVertical.setChecked(False)
......
102 107
            self.ui.radioButtonHorizontal.setChecked(False)
103 108
            self.ui.radioButtonVertical.setChecked(True)
104 109

  
110
        self.ui.tableWidgetHMBData.setColumnCount(2)
105 111
        self.ui.tableWidgetHMBData.setRowCount(self.ui.tableWidgetHMBRecord.rowCount())
106 112
        for row in range(self.ui.tableWidgetHMBData.rowCount()):
107
            name = self.ui.tableWidgetHMBRecord.item(row, 0).text()
113
            uid = self.ui.tableWidgetHMBRecord.item(row, 0).text()
114
            name = self.ui.tableWidgetHMBRecord.item(row, 1).text()
108 115
            item = QTableWidgetItem(name)
116
            item.setData(Qt.UserRole, uid)
109 117
            item.setFlags(Qt.ItemIsEnabled)
110 118
            item.setBackground(QColor(220, 220, 220))
111 119
            self.ui.tableWidgetHMBData.setItem(row, 0, item)
112
            unit = self.ui.tableWidgetHMBRecord.item(row, 1).text()
120
            unit = self.ui.tableWidgetHMBRecord.item(row, 2).text()
113 121
            item = QTableWidgetItem(unit)
114 122
            item.setFlags(Qt.ItemIsEnabled)
115 123
            item.setBackground(QColor(220, 220, 220))
116 124
            self.ui.tableWidgetHMBData.setItem(row, 1, item)
117 125

  
118 126
        # display HMB Data
119
        fixedCols = self.ui.tableWidgetHMBRecord.columnCount()
120
        streamNos = sorted(list(appDocData.hmbTable.streamNos()))
127
        fixedCols = self.ui.tableWidgetHMBRecord.columnCount() - 1
128
        streamNos = sorted(list(app_doc_data.hmbTable.streamNos()))
121 129
        self.ui.tableWidgetHMBData.setColumnCount(fixedCols + len(streamNos))
122 130
        for col in range(2, self.ui.tableWidgetHMBData.columnCount()):
123
            streamNo = streamNos[col - 2]
124
            datas = appDocData.hmbTable.dataOfStreamNo(streamNo)
125
            for data in datas:
126
                selectedRow = -1
127
                for row in range(self.ui.tableWidgetHMBData.rowCount()):
128
                    name = self.ui.tableWidgetHMBData.item(row, 0).text()
129
                    unit = self.ui.tableWidgetHMBData.item(row, 1).text()
130
                    if data.name == name and data.unit == unit:
131
                        selectedRow = row
132
                        break
131
            stream_no = streamNos[col - 2]
132
            datas = app_doc_data.hmbTable.dataOfStreamNo(stream_no)
133 133

  
134
                if selectedRow != -1:
135
                    item = QTableWidgetItem(data.value)
136
                    item.setData(Qt.UserRole, data)
137
                    self.ui.tableWidgetHMBData.setItem(selectedRow, col, item)
134
            for row in range(self.ui.tableWidgetHMBData.rowCount()):
135
                matches = [data for data in datas if data.name == self.ui.tableWidgetHMBData.item(row, 0).text()]
136
                if matches:
137
                    item = QTableWidgetItem(matches[0].value)
138
                    item.setData(Qt.UserRole, matches[0])
139
                    self.ui.tableWidgetHMBData.setItem(row, col, item)
138 140

  
139 141
        self.ui.tableWidgetHMBData.setHorizontalHeaderLabels(['Name', 'Unit'] + streamNos)
140
        self.ui.tableWidgetHMBData.horizontalHeaderItem(0).setSizeHint(QSize(25, 25))
142
        self.ui.tableWidgetHMBData.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents)
141 143
        # up to here
142 144
        self.ui.tableWidgetHMBData.cellChanged.connect(self.cellValueChanged)  # connect to slot after setting data
143 145

  
......
162 164
                data.value = self.ui.tableWidgetHMBData.item(row, column).text()
163 165
                item.setData(Qt.UserRole, data)
164 166

  
165
            if data.name == 'STREAM NO':
167
            if data.name.upper() == 'STREAM NO':
166 168
                streamNo = data.value
167 169
                header = self.ui.tableWidgetHMBData.horizontalHeaderItem(column)
168 170
                if header is not None:
......
175 177
                    item = self.ui.tableWidgetHMBData.item(row, column)
176 178
                    if item is not None:
177 179
                        data = item.data(Qt.UserRole)
178
                        data.streamNo = streamNo
179
            elif data.streamNo is None:
180
                data.streamNo = self.ui.tableWidgetHMBData.item(0, column).data(Qt.UserRole).streamNo
180
                        data.stream_no = streamNo
181
            elif data.stream_no is None:
182
                data.stream_no = self.ui.tableWidgetHMBData.item(0, column).data(Qt.UserRole).stream_no
181 183
        except Exception as ex:
182 184
            print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
183 185
                                                       sys.exc_info()[-1].tb_lineno))
......
251 253
            self.ui.progressBar.setValue(0)
252 254
            self.startThread()
253 255

  
256
    def on_add_hmb_data(self):
257
        self.ui.tableWidgetHMBData.setColumnCount(self.ui.tableWidgetHMBData.columnCount() + 1)
258

  
254 259
    '''
255 260
        @brief  delete selected data 
256 261
        @author humkyung
......
416 421
            csv.writer(stream).writerows(table)
417 422
            QApplication.clipboard().setText(stream.getvalue())
418 423

  
419
    '''
420
        @brief  accept dialog
421
    '''
422

  
423 424
    def accept(self):
425
        """accept dialog"""
424 426
        from HMBTable import HMBTable, HMBData
427
        from SymbolAttr import SymbolAttr
425 428

  
426 429
        try:
427 430
            configs = []
428 431

  
432
            app_doc_data = AppDocData.instance()
433

  
429 434
            configs.append(Config('HMB Record', 'Count', self.ui.tableWidgetHMBRecord.rowCount()))
435
            attrs = []
430 436
            for row in range(self.ui.tableWidgetHMBRecord.rowCount()):
431 437
                item = self.ui.tableWidgetHMBRecord.item(row, 0)
432
                name = item.text() if item is not None else ''
438
                attr = SymbolAttr(item.text() if item else None)
433 439
                item = self.ui.tableWidgetHMBRecord.item(row, 1)
434
                unit = item.text() if item is not None else ''
435
                configs.append(Config('HMB Record{}'.format(row), 'Name', name))
436
                configs.append(Config('HMB Record{}'.format(row), 'Unit', unit))
440
                attr.Attribute = item.text() if item is not None else ''
441
                item = self.ui.tableWidgetHMBRecord.item(row, 2)
442
                attr.Expression = item.text() if item is not None else ''
443
                attrs.append(attr)
444
            app_doc_data.save_hmb_attributes(attrs)
437 445

  
438 446
            configs.append(Config('HMB Data', 'Column Width', self.ui.lineEditColumnWidth.text()))
439 447
            configs.append(Config('HMB Data', 'Row Height', self.ui.lineEditRowHeight.text()))
440 448
            configs.append(Config('HMB Data', 'Record Direction',
441 449
                                  'Horizontal' if self.ui.radioButtonHorizontal.isChecked() else 'Vertical'))
442 450

  
443
            appDocData = AppDocData.instance()
444
            appDocData.saveConfigs(configs)
451
            app_doc_data.saveConfigs(configs)
445 452

  
446 453
            # save hmb data
447
            appDocData.hmbTable.reset()
454
            app_doc_data.hmbTable.reset()
448 455
            for col in range(2, self.ui.tableWidgetHMBData.columnCount()):
449 456
                item = self.ui.tableWidgetHMBData.item(0, col)
450 457
                if item is not None:
......
452 459
                        item = self.ui.tableWidgetHMBData.item(row, col)
453 460
                        if item is not None:
454 461
                            data = item.data(Qt.UserRole)
455
                            appDocData.hmbTable.append(data)
462
                            app_doc_data.hmbTable.append(data)
456 463

  
457
            appDocData.hmbTable.saveData()
464
            app_doc_data.hmbTable.save_data()
458 465
            # up to here
459 466
        except Exception as ex:
460 467
            print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
DTI_PID/DTI_PID/HMBTable.py
5 5
import sqlite3
6 6
from SingletonInstance import SingletonInstance
7 7

  
8
'''
9
    @brief      HMB data
10
'''
8

  
11 9
class HMBData:
10
    """HMB data class"""
12 11
    def __init__(self, uid=None):
13 12
        self._uid = uid
14 13
        self._stream_no = None
......
39 38
        @date   2018.07.12
40 39
    '''
41 40
    @property
42
    def streamNo(self):
41
    def stream_no(self):
43 42
        return self._stream_no
44 43

  
45 44
    '''
46 45
        @author humkyung
47 46
        @date   2018.07.12
48 47
    '''
49
    @streamNo.setter
50
    def streamNo(self, value):
48
    @stream_no.setter
49
    def stream_no(self, value):
51 50
        self._stream_no = value
52 51

  
53 52
    '''
......
98 97
    def value(self, value):
99 98
        self._value = value
100 99

  
101
    '''
102
        @brief      create hmb data from database record
103
        @author     humkyung
104
        @date       2018.07.12
105
    '''
106 100
    @staticmethod
107
    def fromRow(row):
101
    def from_row(row):
102
        """create hmb data from database record"""
108 103
        hmb = HMBData()
109 104
        hmb._uid = row[0]
110 105
        hmb._stream_no = row[1]
......
114 109

  
115 110
        return hmb
116 111

  
112

  
117 113
class HMBTable:
118
    '''
119
        @brief  constructor
120
        @author humkyung
121
        @date   2018.07.12
122
    '''
114
    """HMB table class"""
123 115
    def __init__(self):
124 116
        self._hmbs = None
125 117

  
126
    '''
127
        @brief      load hmb data from database
128
        @author     humkyung
129
        @date       2018.07.12
130
    '''
131
    def loadData(self):
118
    def load_data(self):
119
        """load hmb data from database"""
132 120
        from AppDocData import AppDocData
133 121

  
134 122
        try:
135 123
            if self._hmbs is None:
136 124
                self._hmbs = []
137 125

  
138
                appDocData = AppDocData.instance()
139

  
140
                dbPath = os.path.join(appDocData.getCurrentProject().getDbFilePath() , 'ITI_PID.db')
141

  
142
                conn = sqlite3.connect(dbPath)
143
                cursor = conn.cursor()
144
                sql = 'SELECT UID,STREAM_NO,NAME,UNIT,VALUE FROM HMB ORDER BY STREAM_NO'
145
                cursor.execute(sql)
146
                rows = cursor.fetchall()
147
                for row in rows:
148
                    hmb = HMBData.fromRow(row)
149
                    self._hmbs.append(hmb)
126
                app_doc_data = AppDocData.instance()
127
                db_path = os.path.join(app_doc_data.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
128

  
129
                with sqlite3.connect(db_path) as conn:
130
                    cursor = conn.cursor()
131
                    sql = 'SELECT A.UID,A.STREAM_NO,B.Attribute as Name,A.UNIT,A.VALUE FROM HMB A join ' \
132
                          'SymbolAttribute B on A.SymbolAttribute_UID=B.UID ORDER BY A.STREAM_NO'
133
                    cursor.execute(sql)
134
                    rows = cursor.fetchall()
135
                    for row in rows:
136
                        hmb = HMBData.from_row(row)
137
                        self._hmbs.append(hmb)
150 138
        # Catch the exception
151 139
        except Exception as ex:
152 140
            # Roll back any change if something goes wrong
153 141
            conn.rollback()
154 142
            print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
155
        finally:
156
            conn.close()
157 143

  
158 144
        return self._hmbs
159 145
        
160
    '''
161
        @brief      save hmb data 
162
        @author     humkyung
163
        @date       2018.07.12
164
    '''
165
    def saveData(self):
146
    def save_data(self):
147
        """save hmb data"""
166 148
        import uuid
167 149
        from AppDocData import AppDocData
168 150

  
169 151
        try:
170 152
            if self._hmbs is not None:
171
                appDocData = AppDocData.instance()
172
                # Creates or opens a file called mydb with a SQLite3 DB
173
                dbPath = os.path.join(appDocData.getCurrentProject().getDbFilePath(), "ITI_PID.db")
174
                conn = sqlite3.connect(dbPath)
175
                # Get a cursor object
176
                cursor = conn.cursor()
177

  
178
                for data in self._hmbs:
179
                    if data.isDeleted == False:
180
                        if data.uid is None:
181
                            sql = "insert or replace into HMB values(?,?,?,?,?)"
182
                            param = (str(uuid.uuid4()), data.streamNo, data.name, data.unit, data.value)
183
                            cursor.execute(sql, param)
153
                app_doc_data = AppDocData.instance()
154
                with app_doc_data.getCurrentProject().database.connect() as conn:
155
                    cursor = conn.cursor()
156

  
157
                    for data in self._hmbs:
158
                        if not data.isDeleted:
159
                            if data.uid is None:
160
                                sql = f"insert into HMB(UID,STREAM_NO,NAME,SymbolAttribute_UID,UNIT,VALUE) " \
161
                                      f"values(?,?,?," \
162
                                      f"(select A.UID from SymbolAttribute A join SymbolType B on " \
163
                                      f"A.SymbolType_UID=B.UID " \
164
                                      f"where B.Type='HMB' and A.Attribute='{data.name}'),?,?)"
165
                                param = (str(uuid.uuid4()), data.stream_no, data.name, data.unit, data.value)
166
                                cursor.execute(sql, param)
167
                            else:
168
                                sql = f"update HMB set STREAM_NO=?,NAME=?," \
169
                                      f"SymbolAttribute_UID=" \
170
                                      f"(select A.UID from SymbolAttribute A join SymbolType B on A.SymbolType_UID=B.UID " \
171
                                      f"where B.Type='HMB' and A.Attribute='{data.name}'),UNIT=?,VALUE=? where UID=?"
172
                                param = (data.stream_no, data.name, data.unit, data.value, data.uid)
173
                                cursor.execute(sql, param)
184 174
                        else:
185
                            sql = "update HMB set STREAM_NO=?,NAME=?,UNIT=?,VALUE=? where UID=?"
186
                            param = (data.streamNo, data.name, data.unit, data.value, data.uid)
175
                            sql = "delete from HMB where UID=?"
176
                            param = (data.uid,)
187 177
                            cursor.execute(sql, param)
188
                    else:
189
                        sql = "delete from HMB where uid=?"
190
                        param = (data.uid,)
191
                        cursor.execute(sql, param)
192 178

  
193 179
                conn.commit()
194 180
        # Catch the exception
195 181
        except Exception as ex:
196 182
            # Roll back any change if something goes wrong
197 183
            conn.rollback()
198
            print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
199
        finally:
200
            # Close the db connection
201
            conn.close()
184
            message = f"error occurred({ex}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
185
                      f"{sys.exc_info()[-1].tb_lineno}"
186
            print(message)
187

  
188
    @property
189
    def names(self):
190
        """return hmb attribute names"""
191
        return set([hmb.name for hmb in self._hmbs if not hmb.isDeleted]) if self._hmbs is not None else {}
202 192

  
203 193
    '''
204 194
        @brief      return stream no collection which are not duplicated 
......
206 196
        @date       2018.07.12
207 197
    '''
208 198
    def streamNos(self):
209
        return set([hmb.streamNo for hmb in self._hmbs if hmb.isDeleted == False]) if self._hmbs is not None else {}
199
        return set([hmb.stream_no for hmb in self._hmbs if not hmb.isDeleted]) if self._hmbs is not None else {}
210 200

  
211 201
    '''
212 202
        @brief      return given index's data
......
214 204
        @date       2018.07.12
215 205
    '''
216 206
    def dataOfStreamNo(self, streamNo):
217
        return [hmb for hmb in self._hmbs if hmb.streamNo == streamNo and hmb.isDeleted == False] if self._hmbs is not None else None
207
        return [hmb for hmb in self._hmbs if hmb.stream_no == streamNo and not hmb.isDeleted] if self._hmbs is not None else None
218 208

  
219 209
    '''
220 210
        @brief      append hmb data
DTI_PID/DTI_PID/HMB_UI.py
2 2

  
3 3
# Form implementation generated from reading ui file '.\UI\HMB.ui'
4 4
#
5
# Created by: PyQt5 UI code generator 5.13.0
5
# Created by: PyQt5 UI code generator 5.14.2
6 6
#
7 7
# WARNING! All changes made in this file will be lost!
8 8

  
......
28 28
        self.groupBoxHMBRecord.setObjectName("groupBoxHMBRecord")
29 29
        self.gridLayout_4 = QtWidgets.QGridLayout(self.groupBoxHMBRecord)
30 30
        self.gridLayout_4.setObjectName("gridLayout_4")
31
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
32
        self.horizontalLayout_3.setSizeConstraint(QtWidgets.QLayout.SetFixedSize)
33
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
31
        self.gridLayout_2 = QtWidgets.QGridLayout()
32
        self.gridLayout_2.setObjectName("gridLayout_2")
34 33
        self.pushButtonAddRecord = QtWidgets.QPushButton(self.groupBoxHMBRecord)
35 34
        self.pushButtonAddRecord.setMaximumSize(QtCore.QSize(24, 16777215))
36 35
        self.pushButtonAddRecord.setObjectName("pushButtonAddRecord")
37
        self.horizontalLayout_3.addWidget(self.pushButtonAddRecord, 0, QtCore.Qt.AlignRight)
36
        self.gridLayout_2.addWidget(self.pushButtonAddRecord, 0, 1, 1, 1)
38 37
        self.pushButtonDelRecord = QtWidgets.QPushButton(self.groupBoxHMBRecord)
39 38
        self.pushButtonDelRecord.setMaximumSize(QtCore.QSize(24, 16777215))
40 39
        self.pushButtonDelRecord.setObjectName("pushButtonDelRecord")
41
        self.horizontalLayout_3.addWidget(self.pushButtonDelRecord)
42
        self.gridLayout_4.addLayout(self.horizontalLayout_3, 0, 0, 1, 1)
43
        self.tableWidgetHMBRecord = QtWidgets.QTableWidget(self.groupBoxHMBRecord)
44
        self.tableWidgetHMBRecord.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
45
        self.tableWidgetHMBRecord.setColumnCount(2)
46
        self.tableWidgetHMBRecord.setObjectName("tableWidgetHMBRecord")
47
        self.tableWidgetHMBRecord.setRowCount(0)
48
        self.tableWidgetHMBRecord.verticalHeader().setVisible(False)
49
        self.gridLayout_4.addWidget(self.tableWidgetHMBRecord, 1, 0, 1, 1)
40
        self.gridLayout_2.addWidget(self.pushButtonDelRecord, 0, 2, 1, 1)
41
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
42
        self.gridLayout_2.addItem(spacerItem, 0, 0, 1, 1)
43
        self.horizontalLayoutHMBColTableWidget = QtWidgets.QHBoxLayout()
44
        self.horizontalLayoutHMBColTableWidget.setObjectName("horizontalLayoutHMBColTableWidget")
45
        self.gridLayout_2.addLayout(self.horizontalLayoutHMBColTableWidget, 1, 0, 1, 3)
46
        self.gridLayout_4.addLayout(self.gridLayout_2, 0, 0, 1, 1)
50 47
        self.verticalLayoutHMB.addWidget(self.groupBoxHMBRecord)
51 48
        self.groupBoxHMBData = QtWidgets.QGroupBox(HMBDialog)
52 49
        self.groupBoxHMBData.setObjectName("groupBoxHMBData")
53 50
        self.gridLayout_3 = QtWidgets.QGridLayout(self.groupBoxHMBData)
54 51
        self.gridLayout_3.setObjectName("gridLayout_3")
55
        self.formLayout = QtWidgets.QFormLayout()
56
        self.formLayout.setObjectName("formLayout")
52
        self.gridLayout_8 = QtWidgets.QGridLayout()
53
        self.gridLayout_8.setObjectName("gridLayout_8")
54
        self.lineEditHMBArea = QtWidgets.QLineEdit(self.groupBoxHMBData)
55
        self.lineEditHMBArea.setMaximumSize(QtCore.QSize(150, 16777215))
56
        self.lineEditHMBArea.setObjectName("lineEditHMBArea")
57
        self.gridLayout_8.addWidget(self.lineEditHMBArea, 3, 0, 1, 1)
57 58
        self.label = QtWidgets.QLabel(self.groupBoxHMBData)
58 59
        self.label.setMaximumSize(QtCore.QSize(100, 16777215))
59 60
        self.label.setObjectName("label")
60
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label)
61
        self.label_2 = QtWidgets.QLabel(self.groupBoxHMBData)
62
        self.label_2.setMaximumSize(QtCore.QSize(100, 16777215))
63
        self.label_2.setObjectName("label_2")
64
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2)
65
        self.lineEditColumnWidth = QtWidgets.QLineEdit(self.groupBoxHMBData)
66
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
67
        sizePolicy.setHorizontalStretch(0)
68
        sizePolicy.setVerticalStretch(0)
69
        sizePolicy.setHeightForWidth(self.lineEditColumnWidth.sizePolicy().hasHeightForWidth())
70
        self.lineEditColumnWidth.setSizePolicy(sizePolicy)
71
        self.lineEditColumnWidth.setMaximumSize(QtCore.QSize(82, 16777215))
72
        self.lineEditColumnWidth.setObjectName("lineEditColumnWidth")
73
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.lineEditColumnWidth)
61
        self.gridLayout_8.addWidget(self.label, 0, 0, 1, 1)
62
        self.pushButtonHMBArea = QtWidgets.QPushButton(self.groupBoxHMBData)
63
        self.pushButtonHMBArea.setMaximumSize(QtCore.QSize(22, 16777215))
64
        self.pushButtonHMBArea.setObjectName("pushButtonHMBArea")
65
        self.gridLayout_8.addWidget(self.pushButtonHMBArea, 3, 1, 1, 1)
74 66
        self.lineEditRowHeight = QtWidgets.QLineEdit(self.groupBoxHMBData)
75 67
        self.lineEditRowHeight.setMaximumSize(QtCore.QSize(82, 16777215))
76 68
        self.lineEditRowHeight.setObjectName("lineEditRowHeight")
77
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.lineEditRowHeight)
78
        self.label_3 = QtWidgets.QLabel(self.groupBoxHMBData)
79
        self.label_3.setObjectName("label_3")
80
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_3)
69
        self.gridLayout_8.addWidget(self.lineEditRowHeight, 1, 3, 1, 1)
81 70
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
82 71
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
83 72
        self.radioButtonHorizontal = QtWidgets.QRadioButton(self.groupBoxHMBData)
......
88 77
        self.radioButtonVertical = QtWidgets.QRadioButton(self.groupBoxHMBData)
89 78
        self.radioButtonVertical.setObjectName("radioButtonVertical")
90 79
        self.horizontalLayout_5.addWidget(self.radioButtonVertical)
91
        self.formLayout.setLayout(2, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout_5)
92
        self.gridLayout_3.addLayout(self.formLayout, 2, 0, 1, 1)
93
        self.verticalLayout = QtWidgets.QVBoxLayout()
94
        self.verticalLayout.setObjectName("verticalLayout")
95
        self.horizontalLayout = QtWidgets.QHBoxLayout()
96
        self.horizontalLayout.setObjectName("horizontalLayout")
97
        self.lineEditHMBArea = QtWidgets.QLineEdit(self.groupBoxHMBData)
98
        self.lineEditHMBArea.setMaximumSize(QtCore.QSize(150, 16777215))
99
        self.lineEditHMBArea.setObjectName("lineEditHMBArea")
100
        self.horizontalLayout.addWidget(self.lineEditHMBArea)
101
        self.pushButtonHMBArea = QtWidgets.QPushButton(self.groupBoxHMBData)
102
        self.pushButtonHMBArea.setMaximumSize(QtCore.QSize(22, 16777215))
103
        self.pushButtonHMBArea.setObjectName("pushButtonHMBArea")
104
        self.horizontalLayout.addWidget(self.pushButtonHMBArea)
80
        self.gridLayout_8.addLayout(self.horizontalLayout_5, 2, 3, 1, 1)
81
        self.lineEditColumnWidth = QtWidgets.QLineEdit(self.groupBoxHMBData)
82
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
83
        sizePolicy.setHorizontalStretch(0)
84
        sizePolicy.setVerticalStretch(0)
85
        sizePolicy.setHeightForWidth(self.lineEditColumnWidth.sizePolicy().hasHeightForWidth())
86
        self.lineEditColumnWidth.setSizePolicy(sizePolicy)
87
        self.lineEditColumnWidth.setMaximumSize(QtCore.QSize(82, 16777215))
88
        self.lineEditColumnWidth.setObjectName("lineEditColumnWidth")
89
        self.gridLayout_8.addWidget(self.lineEditColumnWidth, 0, 3, 1, 1)
90
        self.label_2 = QtWidgets.QLabel(self.groupBoxHMBData)
91
        self.label_2.setMaximumSize(QtCore.QSize(100, 16777215))
92
        self.label_2.setObjectName("label_2")
93
        self.gridLayout_8.addWidget(self.label_2, 1, 0, 1, 1)
94
        self.label_3 = QtWidgets.QLabel(self.groupBoxHMBData)
95
        self.label_3.setObjectName("label_3")
96
        self.gridLayout_8.addWidget(self.label_3, 2, 0, 1, 1)
105 97
        self.pushButtonRecognizeText = QtWidgets.QPushButton(self.groupBoxHMBData)
106 98
        self.pushButtonRecognizeText.setMaximumSize(QtCore.QSize(84, 16777215))
107 99
        self.pushButtonRecognizeText.setObjectName("pushButtonRecognizeText")
108
        self.horizontalLayout.addWidget(self.pushButtonRecognizeText, 0, QtCore.Qt.AlignRight)
100
        self.gridLayout_8.addWidget(self.pushButtonRecognizeText, 3, 2, 1, 1)
101
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
102
        self.verticalLayout_2.setObjectName("verticalLayout_2")
103
        self.pushButtonAddHMBData = QtWidgets.QPushButton(self.groupBoxHMBData)
104
        self.pushButtonAddHMBData.setMinimumSize(QtCore.QSize(24, 24))
105
        self.pushButtonAddHMBData.setMaximumSize(QtCore.QSize(24, 24))
106
        self.pushButtonAddHMBData.setObjectName("pushButtonAddHMBData")
107
        self.verticalLayout_2.addWidget(self.pushButtonAddHMBData)
108
        self.pushButtonDelHMBData = QtWidgets.QPushButton(self.groupBoxHMBData)
109
        self.pushButtonDelHMBData.setMinimumSize(QtCore.QSize(24, 24))
110
        self.pushButtonDelHMBData.setMaximumSize(QtCore.QSize(24, 24))
111
        self.pushButtonDelHMBData.setObjectName("pushButtonDelHMBData")
112
        self.verticalLayout_2.addWidget(self.pushButtonDelHMBData)
113
        spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
114
        self.verticalLayout_2.addItem(spacerItem1)
115
        self.gridLayout_8.addLayout(self.verticalLayout_2, 7, 4, 1, 1)
109 116
        self.progressBar = QtWidgets.QProgressBar(self.groupBoxHMBData)
110 117
        self.progressBar.setProperty("value", 0)
111 118
        self.progressBar.setObjectName("progressBar")
112
        self.horizontalLayout.addWidget(self.progressBar)
113
        self.verticalLayout.addLayout(self.horizontalLayout)
114
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
115
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
116
        self.tableWidgetHMBData = QtWidgets.QTableWidget(self.groupBoxHMBData)
117
        self.tableWidgetHMBData.setSelectionMode(QtWidgets.QAbstractItemView.ContiguousSelection)
118
        self.tableWidgetHMBData.setColumnCount(2)
119
        self.tableWidgetHMBData.setObjectName("tableWidgetHMBData")
120
        self.tableWidgetHMBData.setRowCount(0)
121
        self.tableWidgetHMBData.verticalHeader().setVisible(False)
122
        self.horizontalLayout_2.addWidget(self.tableWidgetHMBData)
123
        self.pushButtonDelHMBData = QtWidgets.QPushButton(self.groupBoxHMBData)
124
        self.pushButtonDelHMBData.setMaximumSize(QtCore.QSize(24, 16777215))
125
        self.pushButtonDelHMBData.setObjectName("pushButtonDelHMBData")
126
        self.horizontalLayout_2.addWidget(self.pushButtonDelHMBData, 0, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop)
127
        self.verticalLayout.addLayout(self.horizontalLayout_2)
128
        self.gridLayout_3.addLayout(self.verticalLayout, 7, 0, 1, 1)
119
        self.gridLayout_8.addWidget(self.progressBar, 3, 3, 1, 1)
120
        self.horizontalLayoutHMBTableWidget = QtWidgets.QHBoxLayout()
121
        self.horizontalLayoutHMBTableWidget.setObjectName("horizontalLayoutHMBTableWidget")
122
        self.gridLayout_8.addLayout(self.horizontalLayoutHMBTableWidget, 7, 0, 1, 4)
123
        self.gridLayout_3.addLayout(self.gridLayout_8, 0, 0, 1, 1)
129 124
        self.verticalLayoutHMB.addWidget(self.groupBoxHMBData)
130 125
        self.gridLayout.addLayout(self.verticalLayoutHMB, 0, 0, 1, 1)
131 126
        self.buttonBox = QtWidgets.QDialogButtonBox(HMBDialog)
......
147 142
        self.pushButtonDelRecord.setText(_translate("HMBDialog", "-"))
148 143
        self.groupBoxHMBData.setTitle(_translate("HMBDialog", "HMB Data"))
149 144
        self.label.setText(_translate("HMBDialog", "Column Width : "))
150
        self.label_2.setText(_translate("HMBDialog", "Row Height : "))
151
        self.label_3.setText(_translate("HMBDialog", "Record Direction : "))
145
        self.pushButtonHMBArea.setText(_translate("HMBDialog", "..."))
152 146
        self.radioButtonHorizontal.setText(_translate("HMBDialog", "Horizontal"))
153 147
        self.radioButtonVertical.setText(_translate("HMBDialog", "Vertical"))
154
        self.pushButtonHMBArea.setText(_translate("HMBDialog", "..."))
148
        self.label_2.setText(_translate("HMBDialog", "Row Height : "))
149
        self.label_3.setText(_translate("HMBDialog", "Record Direction : "))
155 150
        self.pushButtonRecognizeText.setText(_translate("HMBDialog", "Text Recog."))
151
        self.pushButtonAddHMBData.setText(_translate("HMBDialog", "+"))
156 152
        self.pushButtonDelHMBData.setText(_translate("HMBDialog", "x"))
157 153
import MainWindow_rc
DTI_PID/DTI_PID/ItemPropertyTableWidget.py
540 540
    def show_item_attributes(self, item):
541 541
        """ show item's attributes on grid """
542 542
        from PyQt5 import QtGui
543
        from functools import partial
543 544

  
544 545
        row = self.rowCount()
545 546
        attrs = item.getAttributes()
......
551 552
            for key, value in attrs.items():
552 553
                try:
553 554
                    """ show freeze state """
554
                    checkbox = QCustomCheckBox(self, row, 0)
555
                    checkbox.setChecked(key.Freeze)
556
                    checkbox.stateChanged.connect(checkbox.state_changed)
557
                    self.setCellWidget(row, 0, checkbox)
555
                    if not key.IsProp:
556
                        checkbox = QCustomCheckBox(self, row, 0)
557
                        checkbox.setChecked(key.Freeze)
558
                        checkbox.stateChanged.connect(checkbox.state_changed)
559
                        self.setCellWidget(row, 0, checkbox)
560
                    else:
561
                        _item = QTableWidgetItem(None)
562
                        _item.setFlags(Qt.ItemIsEnabled)
563
                        self.setItem(row, 0, _item)
558 564

  
559
                    """ show property name """
565
                    """ show attribute name """
560 566
                    key_item = QTableWidgetItem(key.DisplayAttribute if key.DisplayAttribute else key.Attribute)
561 567
                    # key_item.setBackground(Qt.lightGray)
562 568
                    key_item.setData(Qt.UserRole, key)
563 569
                    self.setItem(row, 1, key_item)
570
                    if key.IsProp:
571
                        key_item.setFlags(Qt.ItemIsEnabled)
564 572

  
565 573
                    """ show icon item """
566
                    self.show_icon_item(row, 2, key)
574
                    if not key.IsProp:
575
                        self.show_icon_item(row, 2, key)
576
                    else:
577
                        _item = QTableWidgetItem(None)
578
                        _item.setFlags(Qt.ItemIsEnabled)
579
                        self.setItem(row, 2, _item)
567 580

  
568 581
                    value_item = QTableWidgetItem(str(value))
569 582
                    value_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable)
......
572 585
                        if key.Attribute == 'UpStream' or key.Attribute == 'DownStream':
573 586
                            UpDownItem = QTableWidgetItem('{}'.format('None' if value is None else value))
574 587
                            self.setItem(row, 3, UpDownItem)
575
                        else:  # elif key.AttributeType == 'Spec':
576
                            self.setItem(row, 3, QTableWidgetItem(str(value)[1:-1]))
577 588
                    else:
578 589
                        self.setItem(row, 3, value_item)
590
                        if key.Attribute.upper() == 'STREAM NO':
591
                            stream_no_combo = QComboBox()
592
                            stream_no_combo.tag = key
593

  
594
                            app_doc_data = AppDocData.instance()
595
                            streamNos = sorted(list(app_doc_data.hmbTable.streamNos()))
596
                            for streamNo in streamNos:
597
                                stream_no_combo.addItem(streamNo)
598
                            self.setCellWidget(row, 3, stream_no_combo)
599
                            stream_no_combo.setCurrentText(value)
600

  
601
                            stream_no_combo.currentIndexChanged.connect(
602
                                partial(self.on_stream_no_changed, item, stream_no_combo))
603
                        else:
604
                            self.setItem(row, 3, value_item)
579 605

  
580 606
                    checkbox.state_changed(checkbox.isChecked())
581 607

  
......
695 721
                self.show_icon_item(1, 2, attr)
696 722
                self.item(1, 1).setData(Qt.UserRole, attr)
697 723

  
698
                owner_item = QTableWidgetItem(
699
                    '{}'.format('None' if self._item.owner is None else str(self._item.owner)))
724
                owner_item = QTableWidgetItem(f"{'None' if self._item.owner is None else str(self._item.owner)}")
700 725
                self.setItem(1, 3, owner_item)
701 726

  
702 727
                self.show_item_properties(self._item)
......
841 866
                    if keyStr[0].UID in configs: valueCell.setFlags(Qt.ItemIsEnabled)
842 867
                else:
843 868
                    valueCell.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
844

  
845
                if key.Attribute.upper() == 'STREAM_NO':
846
                    self.streamNoComboBox = QComboBox()
847
                    self.streamNoComboBox.tag = key
848
                    self.streamNoComboBox.currentIndexChanged.connect(self.onStreamNoChanged)
849

  
850
                    streamNos = sorted(list(appDocData.hmbTable.streamNos()))
851
                    for streamNo in streamNos:
852
                        self.streamNoComboBox.addItem(streamNo)
853
                    self.setCellWidget(row, 3, self.streamNoComboBox)
854
                    self.streamNoComboBox.setCurrentText(value)
855
                else:
856 869
                    self.setItem(row, 3, valueCell)
857 870

  
858 871
                row = row + 1
859 872

  
860
    '''
861
        @brief  change selected lines' stream no by selected stream no
862
        @author humkyung
863
        @date   2018.07.20
864
    '''
865

  
866
    def onStreamNoChanged(self, param):
867
        items = self.mainWindow.graphicsView.scene().selectedItems()
868
        if items is not None and len(items) == 1:
869
            if type(items[0]) is QEngineeringLineNoTextItem:
870
                stream_no = self.streamNoComboBox.itemText(param)
871
                items[0].set_attrib(self.streamNoComboBox.tag, stream_no)
872
                return
873
    def on_stream_no_changed(self, item, combobox, index):
874
        """change selected lines' stream no by selected stream no"""
875
        stream_no = combobox.itemText(index)
876
        item.stream_no = stream_no
873 877

  
874 878
    '''
875 879
        @brief      Initialize Run Contents Cell
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
179 179
            self._owner = None
180 180
            return None
181 181

  
182
    @property
183
    def stream_no(self):
184
        matches = [attr for attr in self.attrs if attr.Attribute.upper() == 'STREAM NO']
185
        if matches:
186
            return self.attrs[matches[0]]
187

  
188
        return None
189

  
190
    @stream_no.setter
191
    def stream_no(self, value):
192
        from AppDocData import AppDocData
193

  
194
        matches = [attr for attr in self.attrs if attr.Attribute.upper() == 'STREAM NO']
195
        if matches:
196
            self.attrs[matches[0]] = value
197
            """reset attributes for hmb with given stream no"""
198

  
199
            app_doc_data = AppDocData.instance()
200
            stream_data = app_doc_data.hmbTable.dataOfStreamNo(value)
201
            for attr in self.attrs:
202
                if attr.AttributeType == 'HMB':
203
                    matches = [data for data in stream_data if data.name == attr.Attribute]
204
                    if matches:
205
                        self.attrs[attr] = matches[0].value
206

  
182 207
    '''
183 208
        @brief  setter owner
184 209
        @author humkyung
DTI_PID/DTI_PID/SymbolAttr.py
123 123
class SymbolAttr(SymbolProp):
124 124
    """ This is symbol attribute class """
125 125

  
126
    def __init__(self):
126
    def __init__(self, uid=None):
127 127
        import uuid
128
        SymbolProp.__init__(self, None, None, None)
128
        SymbolProp.__init__(self, uid, None, None)
129 129

  
130
        self.UID = uuid.uuid4()
131 130
        self.Freeze = False
132 131
        self.Attribute = None
133 132
        self.DisplayAttribute = None
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py
28 28
            editor = QLineEdit(parent)
29 29
            validator = QRegExpValidator(QRegExp('^(\\d+|)$'), parent)
30 30
            editor.setValidator(validator)
31
        elif index.column() == 5:
32
            combobox = self.parent().cellWidget(index.row(), 3)
33
            if combobox:
34
                if combobox.currentText() == 'HMB':
35
                    app_doc_data = AppDocData.instance()
36
                    editor = QComboBox(parent)
37
                    editor.addItems(app_doc_data.hmbTable.names)
31 38

  
32 39
        return editor
33 40

  
34
    """
35
    def setEditorData(self, editor, index):
36
        if index.column() == 4:
37
            m = 0 if index.column() == 1 else index.sibling(index.row(), 1).data()
38
            M = index.sibling(index.row(), 2).data() if index.column() == 1 else 360
39
            if hasattr(m, 'toPyObject'):
40
                m = m.toPyObject()
41
            if hasattr(M, 'toPyObject'):
42
                M = M.toPyObject()
43
            editor.setMinimum(m)
44
            editor.setMaximum(M)
45
        super(LimistDelegate, self).setEditorData(editor, index)
46
    """
47

  
48 41

  
49 42
class QSymbolAttrEditorDialog(QDialog):
50 43
    """ This is symbol attribute editor dialog class """
51 44

  
52 45
    SYMBOL_ATTR_DATA_TYPES = {'Symbol Item': -1, 'Size Text Item': -1, 'Text Item': -1, 'Tag No': -1,
53 46
                              'Valve Oper Code': -1, 'Line Item': -1, 'Comp Item': -1, 'EQ Item': -1, 'Int': 1,
54
                              'String': 1, 'Combined': 1}
47
                              'String': 1, 'Combined': 1, 'HMB': -1}
55 48
    LINE_NO_ATTR_TYPES = ['Code Table', 'Int', 'String', 'Symbol']
56 49

  
57 50
    def __init__(self, parent, symbolType = None):
......
186 179
    def changeSymbolType(self):
187 180
        self._symbolType = self.ui.comboBoxSymbolType.currentText()
188 181
        self.ui.tableWidgetAttr.setRowCount(0)
189
        self.loadData(self._symbolType)
182
        self.load_data(self._symbolType)
190 183

  
191
    def loadData(self, symbolType):
184
    def load_data(self, symbolType):
192 185
        """load data from database"""
193 186

  
194 187
        app_doc_data = AppDocData.instance()
......
240 233

  
241 234
            item = QTableWidgetItem('ALL') if attr.Target == 'ALL' or attr.Target is None else QTableWidgetItem('...')
242 235
            item.setData(Qt.UserRole, attr.Target)
243
            #item.tag = attr.Target
244
            item.setTextAlignment(Qt.AlignHCenter)
236
            item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
245 237
            item.setFlags(Qt.ItemIsEnabled)
246 238
            self.ui.tableWidgetAttr.setItem(row, 6, item)
247 239

  
248 240
            item = QTableWidgetItem('...')
249 241
            item.setData(Qt.UserRole, attr.Codes.values)
250
            #item.tag = attr.Codes.values
251
            item.setTextAlignment(Qt.AlignHCenter)
242
            item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
252 243
            item.setFlags(Qt.ItemIsEnabled)
253 244
            self.ui.tableWidgetAttr.setItem(row, 7, item)
254 245

  
246
            if attr.IsProp:
247
                self.ui.tableWidgetAttr.hideRow(row)
248

  
255 249
            row = row + 1
256 250

  
257 251
    def save_data(self):
DTI_PID/DTI_PID/UI/HMB.ui
32 32
       </property>
33 33
       <layout class="QGridLayout" name="gridLayout_4">
34 34
        <item row="0" column="0">
35
         <layout class="QHBoxLayout" name="horizontalLayout_3">
36
          <property name="sizeConstraint">
37
           <enum>QLayout::SetFixedSize</enum>
38
          </property>
39
          <item alignment="Qt::AlignRight">
35
         <layout class="QGridLayout" name="gridLayout_2">
36
          <item row="0" column="1">
40 37
           <widget class="QPushButton" name="pushButtonAddRecord">
41 38
            <property name="maximumSize">
42 39
             <size>
......
49 46
            </property>
50 47
           </widget>
51 48
          </item>
52
          <item>
49
          <item row="0" column="2">
53 50
           <widget class="QPushButton" name="pushButtonDelRecord">
54 51
            <property name="maximumSize">
55 52
             <size>
......
62 59
            </property>
63 60
           </widget>
64 61
          </item>
62
          <item row="0" column="0">
63
           <spacer name="horizontalSpacer">
64
            <property name="orientation">
65
             <enum>Qt::Horizontal</enum>
66
            </property>
67
            <property name="sizeHint" stdset="0">
68
             <size>
69
              <width>40</width>
70
              <height>20</height>
71
             </size>
72
            </property>
73
           </spacer>
74
          </item>
75
          <item row="1" column="0" colspan="3">
76
           <layout class="QHBoxLayout" name="horizontalLayoutHMBColTableWidget"/>
77
          </item>
65 78
         </layout>
66 79
        </item>
67
        <item row="1" column="0">
68
         <widget class="QTableWidget" name="tableWidgetHMBRecord">
69
          <property name="selectionMode">
70
           <enum>QAbstractItemView::SingleSelection</enum>
71
          </property>
72
          <property name="columnCount">
73
           <number>2</number>
74
          </property>
75
          <attribute name="verticalHeaderVisible">
76
           <bool>false</bool>
77
          </attribute>
78
          <column/>
79
          <column/>
80
         </widget>
81
        </item>
82 80
       </layout>
83 81
      </widget>
84 82
     </item>
......
88 86
        <string>HMB Data</string>
89 87
       </property>
90 88
       <layout class="QGridLayout" name="gridLayout_3">
91
        <item row="2" column="0">
92
         <layout class="QFormLayout" name="formLayout">
93
          <item row="0" column="0">
94
           <widget class="QLabel" name="label">
89
        <item row="0" column="0">
90
         <layout class="QGridLayout" name="gridLayout_8">
91
          <item row="3" column="0">
92
           <widget class="QLineEdit" name="lineEditHMBArea">
95 93
            <property name="maximumSize">
96 94
             <size>
97
              <width>100</width>
95
              <width>150</width>
98 96
              <height>16777215</height>
99 97
             </size>
100 98
            </property>
101
            <property name="text">
102
             <string>Column Width : </string>
103
            </property>
104 99
           </widget>
105 100
          </item>
106
          <item row="1" column="0">
107
           <widget class="QLabel" name="label_2">
101
          <item row="0" column="0">
102
           <widget class="QLabel" name="label">
108 103
            <property name="maximumSize">
109 104
             <size>
110 105
              <width>100</width>
......
112 107
             </size>
113 108
            </property>
114 109
            <property name="text">
115
             <string>Row Height : </string>
110
             <string>Column Width : </string>
116 111
            </property>
117 112
           </widget>
118 113
          </item>
119
          <item row="0" column="1">
120
           <widget class="QLineEdit" name="lineEditColumnWidth">
121
            <property name="sizePolicy">
122
             <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
123
              <horstretch>0</horstretch>
124
              <verstretch>0</verstretch>
125
             </sizepolicy>
126
            </property>
114
          <item row="3" column="1">
115
           <widget class="QPushButton" name="pushButtonHMBArea">
127 116
            <property name="maximumSize">
128 117
             <size>
129
              <width>82</width>
118
              <width>22</width>
130 119
              <height>16777215</height>
131 120
             </size>
132 121
            </property>
122
            <property name="text">
123
             <string>...</string>
124
            </property>
133 125
           </widget>
134 126
          </item>
135
          <item row="1" column="1">
127
          <item row="1" column="3">
136 128
           <widget class="QLineEdit" name="lineEditRowHeight">
137 129
            <property name="maximumSize">
138 130
             <size>
......
142 134
            </property>
143 135
           </widget>
144 136
          </item>
145
          <item row="2" column="0">
146
           <widget class="QLabel" name="label_3">
147
            <property name="text">
148
             <string>Record Direction : </string>
149
            </property>
150
           </widget>
151
          </item>
152
          <item row="2" column="1">
137
          <item row="2" column="3">
153 138
           <layout class="QHBoxLayout" name="horizontalLayout_5">
154 139
            <item>
155 140
             <widget class="QRadioButton" name="radioButtonHorizontal">
......
176 161
            </item>
177 162
           </layout>
178 163
          </item>
179
         </layout>
180
        </item>
181
        <item row="7" column="0">
182
         <layout class="QVBoxLayout" name="verticalLayout">
183
          <item>
184
           <layout class="QHBoxLayout" name="horizontalLayout">
164
          <item row="0" column="3">
165
           <widget class="QLineEdit" name="lineEditColumnWidth">
166
            <property name="sizePolicy">
167
             <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
168
              <horstretch>0</horstretch>
169
              <verstretch>0</verstretch>
170
             </sizepolicy>
171
            </property>
172
            <property name="maximumSize">
173
             <size>
174
              <width>82</width>
175
              <height>16777215</height>
176
             </size>
177
            </property>
178
           </widget>
179
          </item>
180
          <item row="1" column="0">
181
           <widget class="QLabel" name="label_2">
182
            <property name="maximumSize">
183
             <size>
184
              <width>100</width>
185
              <height>16777215</height>
186
             </size>
187
            </property>
188
            <property name="text">
189
             <string>Row Height : </string>
190
            </property>
191
           </widget>
192
          </item>
193
          <item row="2" column="0">
194
           <widget class="QLabel" name="label_3">
195
            <property name="text">
196
             <string>Record Direction : </string>
197
            </property>
198
           </widget>
199
          </item>
200
          <item row="3" column="2">
201
           <widget class="QPushButton" name="pushButtonRecognizeText">
202
            <property name="maximumSize">
203
             <size>
204
              <width>84</width>
205
              <height>16777215</height>
206
             </size>
207
            </property>
208
            <property name="text">
209
             <string>Text Recog.</string>
210
            </property>
211
           </widget>
212
          </item>
213
          <item row="7" column="4">
214
           <layout class="QVBoxLayout" name="verticalLayout_2">
185 215
            <item>
186
             <widget class="QLineEdit" name="lineEditHMBArea">
187
              <property name="maximumSize">
216
             <widget class="QPushButton" name="pushButtonAddHMBData">
217
              <property name="minimumSize">
188 218
               <size>
189
                <width>150</width>
190
                <height>16777215</height>
219
                <width>24</width>
220
                <height>24</height>
191 221
               </size>
192 222
              </property>
193
             </widget>
194
            </item>
195
            <item>
196
             <widget class="QPushButton" name="pushButtonHMBArea">
197 223
              <property name="maximumSize">
198 224
               <size>
199
                <width>22</width>
200
                <height>16777215</height>
225
                <width>24</width>
226
                <height>24</height>
201 227
               </size>
202 228
              </property>
203 229
              <property name="text">
204
               <string>...</string>
230
               <string>+</string>
205 231
              </property>
206 232
             </widget>
207 233
            </item>
208
            <item alignment="Qt::AlignRight">
209
             <widget class="QPushButton" name="pushButtonRecognizeText">
234
            <item>
235
             <widget class="QPushButton" name="pushButtonDelHMBData">
236
              <property name="minimumSize">
237
               <size>
238
                <width>24</width>
239
                <height>24</height>
240
               </size>
241
              </property>
210 242
              <property name="maximumSize">
211 243
               <size>
212
                <width>84</width>
213
                <height>16777215</height>
244
                <width>24</width>
245
                <height>24</height>
214 246
               </size>
215 247
              </property>
216 248
              <property name="text">
217
               <string>Text Recog.</string>
218
              </property>
219
             </widget>
220
            </item>
221
            <item>
222
             <widget class="QProgressBar" name="progressBar">
223
              <property name="value">
224
               <number>0</number>
249
               <string>x</string>
225 250
              </property>
226 251
             </widget>
227 252
            </item>
228
           </layout>
229
          </item>
230
          <item>
231
           <layout class="QHBoxLayout" name="horizontalLayout_2">
232 253
            <item>
233
             <widget class="QTableWidget" name="tableWidgetHMBData">
234
              <property name="selectionMode">
235
               <enum>QAbstractItemView::ContiguousSelection</enum>
254
             <spacer name="verticalSpacer">
255
              <property name="orientation">
256
               <enum>Qt::Vertical</enum>
236 257
              </property>
237
              <property name="columnCount">
238
               <number>2</number>
239
              </property>
240
              <attribute name="verticalHeaderVisible">
241
               <bool>false</bool>
242
              </attribute>
243
              <column/>
244
              <column/>
245
             </widget>
246
            </item>
247
            <item alignment="Qt::AlignHCenter|Qt::AlignTop">
248
             <widget class="QPushButton" name="pushButtonDelHMBData">
249
              <property name="maximumSize">
258
              <property name="sizeHint" stdset="0">
250 259
               <size>
251
                <width>24</width>
252
                <height>16777215</height>
260
                <width>20</width>
261
                <height>40</height>
253 262
               </size>
254 263
              </property>
255
              <property name="text">
256
               <string>x</string>
257
              </property>
258
             </widget>
264
             </spacer>
259 265
            </item>
260 266
           </layout>
261 267
          </item>
268
          <item row="3" column="3">
269
           <widget class="QProgressBar" name="progressBar">
270
            <property name="value">
271
             <number>0</number>
272
            </property>
273
           </widget>
274
          </item>
275
          <item row="7" column="0" colspan="4">
276
           <layout class="QHBoxLayout" name="horizontalLayoutHMBTableWidget"/>
277
          </item>
262 278
         </layout>
263 279
        </item>
264 280
       </layout>

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)