프로젝트

일반

사용자정보

개정판 c5e51d41

IDc5e51d41a096a120ca48f03e1a2b419d5f8a3d00
상위 0e1cee66
하위 aea96e14, 8ade1db1

함의성이(가) 5년 이상 전에 추가함

issue #000: now can editting spec break attribute

Change-Id: I9948e5119d7621dd0fc0014b6ac35fa5d75791cc

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
2158 2158
                        if row[index] != '' and result.count(row[index].replace("'", '"')) == 0:
2159 2159
                            result.append(row[index].replace("'", '"'))
2160 2160
            else:
2161
                sql = 'select uid, code, description, Allowables from [{}] order by length(code) DESC'.format(property)
2161
                sql = "select name from sqlite_master where type='table'"# AND name={}".format(property)
2162 2162
                cursor.execute(sql)
2163 2163
                rows = cursor.fetchall()
2164
                for row in rows:
2165
                    if forCheckLineNumber:
2166
                        data = row[1]
2167
                    else:
2168
                        data = (row[0], row[1], row[2], row[3])
2169
                    result.append(data)
2164
                if property in [name[0] for name in rows]:
2165
                    sql = 'select uid, code, description, Allowables from [{}] order by length(code) DESC'.format(property)
2166
                    cursor.execute(sql)
2167
                    rows = cursor.fetchall()
2168
                    for row in rows:
2169
                        if forCheckLineNumber:
2170
                            data = row[1]
2171
                        else:
2172
                            data = (row[0], row[1], row[2], row[3])
2173
                        result.append(data)
2174
                else:
2175
                    result = None
2170 2176
            # Catch the exception
2171 2177
        except Exception as ex:
2178
            from App import App 
2179

  
2172 2180
            # Roll back any change if something goes wrong
2173 2181
            conn.rollback()
2174
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
2182
            
2183
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
2184
            App.mainWnd().addMessage.emit(MessageType.Error, message)
2175 2185
        finally:
2176 2186
            # Close the db connection
2177 2187
            conn.close()
DTI_PID/DTI_PID/ItemPropertyTableWidget.py
600 600

  
601 601
                if type(self._item) is QEngineeringSpecBreakItem:
602 602
                    row = self.rowCount()
603
                    setSpecsItem = QTableWidgetItem('Open')
603
                    setSpecsItem = QTableWidgetItem('')
604 604
                    icon = QtGui.QIcon()
605 605
                    icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
606 606
                    setSpecsItem.setIcon(icon)
607 607
                    self.setItem(row - 1, 2, setSpecsItem)
608
                    self.setItem(row - 1, 3, QTableWidgetItem('Open'))
608 609

  
609 610
                if type(self._item) is QEngineeringErrorItem:
610 611
                    errType = 'None'
DTI_PID/DTI_PID/SpecBreakDialog.py
44 44
                self.ui.tableWidgetSpec.setCellWidget(row, 0, propertyComboBox)
45 45
                propertyComboBox.setCurrentText(attr.Attribute)
46 46

  
47
                upStreamComboBox = self.makeValueComboBox(attr.Attribute)
48
                downStreamComboBox = self.makeValueComboBox(attr.Attribute)
49
                self.ui.tableWidgetSpec.setCellWidget(row, 1, upStreamComboBox)
50
                upStreamComboBox.setCurrentText(value[0])
51
                self.ui.tableWidgetSpec.setCellWidget(row, 2, downStreamComboBox)
52
                downStreamComboBox.setCurrentText(value[1])
53

  
47
                upStreamComboBox = self.makeValueWidget(attr.Attribute)
48
                downStreamComboBox = self.makeValueWidget(attr.Attribute)
49
                if type(upStreamComboBox) is QComboBox:
50
                    self.ui.tableWidgetSpec.setCellWidget(row, 1, upStreamComboBox)
51
                    upStreamComboBox.setCurrentText(value[0])
52
                else:
53
                    self.ui.tableWidgetSpec.setItem(row, 1, upStreamComboBox)
54
                    self.ui.tableWidgetSpec.item(row, 1).setText(value[0])
55
                if type(downStreamComboBox) is QComboBox:
56
                    self.ui.tableWidgetSpec.setCellWidget(row, 2, downStreamComboBox)
57
                    downStreamComboBox.setCurrentText(value[1])
58
                else:
59
                    self.ui.tableWidgetSpec.setItem(row, 2, downStreamComboBox)
60
                    self.ui.tableWidgetSpec.item(row, 2).setText(value[1])
54 61
                row += 1
55 62

  
56 63
            self.ui.tableWidgetSpec.resizeColumnsToContents()
......
75 82
                valueComboBox.addItem('' if pipeSize.inchStr is None else pipeSize.inchStr)
76 83
        return valueComboBox
77 84

  
78
    def makeValueComboBox(self, tableName):
85
    def makeValueWidget(self, tableName):
79 86
        '''
80 87
            @brief  return Value combobox
81 88
            @author euisung
......
84 91
        if tableName == 'NominalDiameter':
85 92
            return self.makeNominalDiameterComboBox()
86 93
        
87
        valueComboBox = QComboBox(self)
88 94
        docData = AppDocData.instance()
89 95
        tableDatas = docData.getCodeTable(tableName)
90
        for value in tableDatas:
91
            valueComboBox.addItem(value[1])
92

  
93
        return valueComboBox
96
        if tableDatas is not None:
97
            valueComboBox = QComboBox(self)
98
            for value in tableDatas:
99
                valueComboBox.addItem(value[1])
100
            return valueComboBox
101
        else:
102
            return QTableWidgetItem('')
103
        
94 104

  
95 105
    def makePropertyComboBox(self):
96 106
        '''
......
99 109
            @date   2019.01.17
100 110
        '''
101 111
        propertyComboBox = QComboBox(self)
102
        propertyComboBox.addItem('NominalDiameter')
103
        propertyComboBox.addItem('FluidCode')
104
        propertyComboBox.addItem('InsulationPurpose')
105
        propertyComboBox.addItem('PnIDNumber')
106
        propertyComboBox.addItem('PipingMaterialsClass')
107
        propertyComboBox.addItem('UnitNumber')
112
        attrs = AppDocData.instance().getSymbolAttribute('Segment Breaks')
113
        for attr in attrs:
114
            propertyComboBox.addItem(attr.DisplayAttribute)   
115
        #propertyComboBox.addItem('NominalDiameter')
116
        #propertyComboBox.addItem('FluidCode')
117
        #propertyComboBox.addItem('InsulationPurpose')
118
        #propertyComboBox.addItem('PnIDNumber')
119
        #propertyComboBox.addItem('PipingMaterialsClass')
120
        #propertyComboBox.addItem('UnitNumber')
108 121
        propertyComboBox.currentTextChanged.connect(self.currentPropertyChangeEvent)
109 122
        return propertyComboBox
110 123

  
......
116 129
        '''
117 130
        row = self.ui.tableWidgetSpec.currentRow()
118 131
        if row is -1: return
119
        upStreamComboBox = self.makeValueComboBox(text)
120
        downStreamComboBox = self.makeValueComboBox(text)
121
        self.ui.tableWidgetSpec.setCellWidget(row, 1, upStreamComboBox)
122
        self.ui.tableWidgetSpec.setCellWidget(row, 2, downStreamComboBox)
123

  
132
        upStreamComboBox = self.makeValueWidget(text)
133
        downStreamComboBox = self.makeValueWidget(text)
134
        if type(upStreamComboBox) is QComboBox:
135
            self.ui.tableWidgetSpec.setCellWidget(row, 1, upStreamComboBox)
136
        else:
137
            self.ui.tableWidgetSpec.removeCellWidget(row, 1)
138
            self.ui.tableWidgetSpec.setItem(row, 1, upStreamComboBox)
139
        if type(downStreamComboBox) is QComboBox:
140
            self.ui.tableWidgetSpec.setCellWidget(row, 2, downStreamComboBox)
141
        else:
142
            self.ui.tableWidgetSpec.removeCellWidget(row, 2)
143
            self.ui.tableWidgetSpec.setItem(row, 2, downStreamComboBox)
124 144

  
125 145
    def onAddSpec(self):
126 146
        '''
......
133 153
        propertyComboBox = self.makePropertyComboBox()
134 154
        self.ui.tableWidgetSpec.setCellWidget(row, 0, propertyComboBox)
135 155
        propertyComboBox.setCurrentIndex(0)
136
        upStreamComboBox = self.makeValueComboBox(propertyComboBox.currentText())
137
        downStreamComboBox = self.makeValueComboBox(propertyComboBox.currentText())
156
        upStreamComboBox = self.makeValueWidget(propertyComboBox.currentText())
157
        downStreamComboBox = self.makeValueWidget(propertyComboBox.currentText())
138 158
        self.ui.tableWidgetSpec.setCellWidget(row, 1, upStreamComboBox)
139 159
        self.ui.tableWidgetSpec.setCellWidget(row, 2, downStreamComboBox)
140 160

  
......
150 170
                return
151 171
            self.ui.tableWidgetSpec.removeRow(row)
152 172
        except Exception as ex:
153
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
173
            from App import App 
174
            from AppDocData import MessageType
154 175

  
176
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
177
            App.mainWnd().addMessage.emit(MessageType.Error, message)
155 178
    
156 179
    '''
157 180
        @brief  accept dialog
......
164 187
                    del self.attrs[key]
165 188
            row = 0
166 189
            for rowIndex in range(self.ui.tableWidgetSpec.rowCount()):
167
                attr = SymbolAttr()
168
                attr.Attribute = self.ui.tableWidgetSpec.cellWidget(row, 0).currentText()
169
                attr.AttributeType = 'Spec'
170
                attr.DisplayAttribute = 'Spec'
171
                self.attrs[attr] = [self.ui.tableWidgetSpec.cellWidget(row, 1).currentText(), self.ui.tableWidgetSpec.cellWidget(row, 2).currentText()]
190
                attrs = AppDocData.instance().getSymbolAttribute('Segment Breaks')
191
                for attr in attrs:
192
                    if attr.DisplayAttribute == self.ui.tableWidgetSpec.cellWidget(row, 0).currentText():
193
                        attr.AttributeType = 'Spec'
194
                        attr.DisplayAttribute = 'Spec'
195
                        up = self.ui.tableWidgetSpec.cellWidget(row, 1).currentText() if self.ui.tableWidgetSpec.cellWidget(row, 1) else self.ui.tableWidgetSpec.item(row, 1).text()
196
                        down = self.ui.tableWidgetSpec.cellWidget(row, 2).currentText() if self.ui.tableWidgetSpec.cellWidget(row, 2) else self.ui.tableWidgetSpec.item(row, 2).text()
197
                        self.attrs[attr] = [up, down]
172 198
                row += 1
173 199

  
174 200
        except Exception as ex:
175
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
201
            from App import App 
202
            from AppDocData import MessageType
203

  
204
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
205
            App.mainWnd().addMessage.emit(MessageType.Error, message)
176 206
        finally:
177 207
            pass
178 208

  
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py
146 146
            item.tag = attr
147 147
            self.ui.tableWidgetAttr.setItem(row, 0, item)
148 148
            item = QTableWidgetItem(attr.Attribute)             # Name
149
            if attr.IsProp == 2:
149
            if attr.IsProp >= 2:
150 150
                item.setFlags(Qt.ItemIsEnabled)
151 151
                item.setBackground(Qt.lightGray)
152 152
            self.ui.tableWidgetAttr.setItem(row, 1, item)
......
157 157
            for key,value in QSymbolAttrEditorDialog.SYMBOL_ATTR_DATA_TYPES.items():
158 158
                attrTypeComboBox.addItem(key)
159 159

  
160
            self.ui.tableWidgetAttr.setCellWidget(row, 3, attrTypeComboBox)
161
            if attr.IsProp:
160
            if attr.IsProp  >= 2:
162 161
                attrTypeComboBox.setEnabled(False)
163
            result = attrTypeComboBox.findText(attr.AttributeType) # Type
164
            attrTypeComboBox.setCurrentIndex(result)
162
            if attr.AttributeType in [type for type , _ in QSymbolAttrEditorDialog.SYMBOL_ATTR_DATA_TYPES.items()]:
163
                self.ui.tableWidgetAttr.setCellWidget(row, 3, attrTypeComboBox)
164
                result = attrTypeComboBox.findText(attr.AttributeType) # Type
165
                attrTypeComboBox.setCurrentIndex(result)
166
            else:
167
                self.ui.tableWidgetAttr.setItem(row, 3, QTableWidgetItem(attr.AttributeType))
165 168

  
166 169
            item = QTableWidgetItem(str(attr.AttrAt))    # Attribute At
167
            if attr.IsProp == 2:
170
            if attr.IsProp >= 2:
168 171
                item.setFlags(Qt.ItemIsEnabled)
169 172
            self.ui.tableWidgetAttr.setItem(row, 4, item)
170 173

  
171 174
            item = QTableWidgetItem(attr.Expression)    # Expression
172
            if attr.IsProp == 2:
175
            if attr.IsProp >= 2:
173 176
                item.setFlags(Qt.ItemIsEnabled)
174 177
            self.ui.tableWidgetAttr.setItem(row, 5, item)
175 178

  
......
199 202
            attr.append(table.item(index, 0).text() if table.item(index, 0) is not None else '')
200 203
            attr.append(table.item(index, 1).text() if table.item(index, 1) is not None else '')
201 204
            attr.append(table.item(index, 2).text() if table.item(index, 2) is not None else '')
202
            attr.append(table.cellWidget(index, 3).currentText())
205
            attr.append(table.cellWidget(index, 3).currentText()) if table.cellWidget(index, 3) else attr.append(table.item(index, 1).text())
203 206
            attr.append(table.item(index, 4).text() if table.item(index, 4) is not None else '')     # Attribute At
204 207
            attr.append(table.item(index, 5).text() if table.item(index, 5) is not None else '')     # Expression
205 208
            attr.append(table.item(index, 6).tag if table.item(index, 6).tag is not None else 'ALL') # Target
DTI_PID/DTI_PID/TextDetector.py
93 93
        #cv2.imwrite(path, eroded)
94 94

  
95 95
        eroded = cv2.bitwise_not(eroded)
96
        #path = os.path.join(project.getTempPath(), 'bitwise_not_{}.png'.format(appDocData.imgName))
97
        #cv2.imwrite(path, eroded)
96 98
        
97 99
        image, contours, hierarchy = cv2.findContours(eroded, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
98 100
        for contour in contours:
DTI_PID/DTI_PID/TextItemFactory.py
114 114
                item = self.create_note_no_text(textInfo)
115 115
                if item:
116 116
                    pass
117
                elif self.is_reserved_word(text):
118
                    item = QEngineeringReservedWordTextItem()
119
                    item.setToolTip('Reserved Word = {}'.format(text))
120
                    item.setPlainText(text)
117 121
                elif self.isSizeText(text, sizeDelimiter):
118 122
                    item = QEngineeringSizeTextItem()
119 123
                    text = text.replace(' ', '')
......
127 131
                    item = QEngineeringValveOperCodeTextItem()
128 132
                    item.setToolTip('Valve Operation Code = {}'.format(text))
129 133
                    item.setPlainText(text)
130
                elif self.is_reserved_word(text):
131
                    item = QEngineeringReservedWordTextItem()
132
                    item.setToolTip('Reserved Word = {}'.format(text))
133
                    item.setPlainText(text)
134 134
                else:
135 135
                    item = QEngineeringTextItem()
136 136
                    item.setToolTip(text)
137 137
                    item.setPlainText(text)
138 138
                docData.texts.append(item)
139 139
        except Exception as ex:
140
            from App import App
140
            from App import App 
141
            from AppDocData import MessageType
141 142

  
142 143
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
143 144
            App.mainWnd().addMessage.emit(MessageType.Error, message)

내보내기 Unified diff

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