프로젝트

일반

사용자정보

개정판 7999cd9f

ID7999cd9f0ffa16fa163c36ae0afa3a65ab91c09d
상위 6fa89e72
하위 57f4eba4, 4e6b2414

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

issue #000: arranging props and attrs

Change-Id: Ieab2ea0522f23b2bf8a4d2500be1db975a325f48

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
1933 1933
            # Get a cursor object
1934 1934
            cursor = conn.cursor()
1935 1935

  
1936
            sql = 'select a.UID, a.Attribute, a.DisplayAttribute, a.AttributeType, a.[AttrAt], a.[Expression], a.[index], a.[Target] from SymbolAttribute a inner join SymbolType t on a.SymbolType_UID = t.UID and t.type = ? order by a.[index]'
1936
            sql = 'select a.UID, a.Attribute, a.DisplayAttribute, a.AttributeType, a.[AttrAt], a.[Expression], a.[index], a.[Target], a.[Property] from SymbolAttribute a inner join SymbolType t on a.SymbolType_UID = t.UID and t.type = ? order by a.[index]'
1937 1937
            param = (_type,)
1938 1938
            cursor.execute(sql, param)
1939 1939
            rows = cursor.fetchall()
......
1946 1946
                attr.AttrAt = row[4]
1947 1947
                attr.Expression = row[5]
1948 1948
                attr.Target = row[7]
1949
                attr.IsProp = bool(row[8])
1949 1950
                result.append(attr)
1950 1951
            # Catch the exception
1951 1952
        except Exception as ex:
......
1980 1981
            # Get a cursor object
1981 1982
            cursor = conn.cursor()
1982 1983

  
1983
            sql = 'select Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, target from SymbolAttribute where uid = "{}"'.format(UID)
1984
            sql = 'select Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, Target, Property from SymbolAttribute where uid = "{}"'.format(UID)
1984 1985
            cursor.execute(sql)
1985 1986
            rows = cursor.fetchall()
1986 1987
            if len(rows):
......
1992 1993
                res.AttrAt = rows[0][3]
1993 1994
                res.Expression = rows[0][4]
1994 1995
                res.Target = rows[0][5]
1996
                res.IsProp = bool(row[0][6])
1995 1997
            # Catch the exception
1996 1998
        except Exception as ex:
1997 1999
            from App import App
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py
193 193
        _attrs = {}
194 194
        try:
195 195
            from AppDocData import AppDocData
196
            from EngineeringAbstractItem import QEngineeringAbstractItem
196
            from SymbolSvgItem import SymbolSvgItem
197 197
            from EngineeringTextItem import QEngineeringTextItem
198 198
            from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem
199 199
            from EngineeringLineItem import QEngineeringLineItem
......
219 219
                    _attrs[attr] = ''
220 220
 
221 221
                if attr.Freeze: continue    ### do not evalulate value if attribute is frozen
222
                if attr.AttributeType == 'Size Text Item' or attr.AttributeType == 'Text Item' or attr.AttributeType == 'Valve Oper Code':
222
                if attr.AttributeType == 'Text Item' or attr.AttributeType == 'Valve Oper Code':
223 223
                    at = int(attr.AttrAt)
224 224
                    items = [text for text in _texts if QEngineeringAbstractItem.assoc_type(text) == attr.AttributeType]
225 225
                    if not attr.AssocItem and len(items) > at:
......
231 231
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
232 232
                    else:
233 233
                        _attrs[attr] = ''
234
                if attr.AttributeType == 'Size Text Item':
235
                    at = int(attr.AttrAt)
236
                    items = [text for text in _texts if QEngineeringAbstractItem.assoc_type(text) == attr.AttributeType]
237
                    if not attr.AssocItem and len(items) > at:
238
                        attr.AssocItem = items[at]
239
                        item = attr.AssocItem
240
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
241
                    else:
242
                        item = attr.AssocItem
243
                        _attrs[attr] = eval(attr.Expression) if attr.Expression and ((item and 'item' in attr.Expression) or 'self' in attr.Expression) else ''
234 244
                elif attr.AttributeType == 'Symbol Item':
235 245
                    at = int(attr.AttrAt)
236 246
                    if not attr.AssocItem and len(_symbols) > at:
DTI_PID/DTI_PID/Shapes/EngineeringReducerItem.py
24 24

  
25 25
        SymbolSvgItem.__init__(self, path, uid, flip)
26 26
        
27
        '''
27 28
        self._properties = \
28 29
            {\
29 30
                SymbolProp(None, 'Main Size', 'Size Text Item', Expression='self.EvaluatedMainSize'):None, 
30 31
                SymbolProp(None, 'Sub Size', 'Size Text Item', Expression='self.EvaluatedSubSize'):None, 
31 32
                SymbolProp(None, 'Supplied By', 'String'):None
32 33
            }
34
        '''
33 35

  
34 36
        self.setZValue(QEngineeringReducerItem.ZVALUE)
35 37

  
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
54 54
        self.flip = flip
55 55
        # attributeType uid
56 56
        self.attribute = ''
57
        self._properties = {SymbolProp(None, 'Size', 'Size Text Item', Expression='self.EvaluatedSize'):None, SymbolProp(None, 'Supplied By', 'String'):None}
58
        
57
        #self._properties = {SymbolProp(None, 'Size', 'Size Text Item', Expression='self.EvaluatedSize'):None, SymbolProp(None, 'Supplied By', 'String'):None}
58
        self._properties = {SymbolProp(None, 'Supplied By', 'String'):None}
59

  
59 60
        self.setAcceptDrops(True)
60 61
        self.setAcceptHoverEvents(True)
61 62
        self.setAcceptedMouseButtons(Qt.LeftButton)
......
182 183
        from QEngineeringSizeTextItem import QEngineeringSizeTextItem
183 184

  
184 185
        matches = [assoc for assoc in self.associations() if type(assoc) is QEngineeringSizeTextItem]
185
        return matches[0].text() if matches else None
186
        if matches:
187
            return matches[0].text()
188
        else:
189
            return None
186 190
    
187 191
    @property
188 192
    def EvaluatedSize(self):
189 193
        from EngineeringReducerItem import QEngineeringReducerItem
190
        
191
        if self.Size: return self.Size
192
        if self.owner:
193
            matches = [run for run in self.owner.runs if self in run.items]
194
            if matches:
195
                at = matches[0].items.index(self)
196
                upstream = matches[0].items[:at]
197
                upstream.reverse()
198
                prev = self 
199
                for item in upstream:
200
                    if type(item) is QEngineeringReducerItem:
201
                        if item.connectors[0].connectedItem is prev:    ### Main Size
202
                            if item.MainSize: return item.MainSize
203
                        elif item.connectors[1].connectedItem is prev:  ### Sub Size
204
                            if item.SubSize: return item.SubSize
205
                    else:
206
                        if item.Size: return item.Size
207
                    prev = item
208

  
209
                downstream = matches[0].items[at:]
210
                prev = self
211
                for item in downstream:
212
                    if type(item) is QEngineeringReducerItem:
213
                        if item.connectors[0].connectedItem is prev:    ### Main Size
214
                            if item.MainSize: return item.MainSize
215
                        elif item.connectors[1].connectedItem is prev:  ### Sub Size
216
                            if item.SubSize: return item.SubSize
217
                    else:
218
                        if item.Size: return item.Size
219
                    prev = item
194
        try:
195
            if self.Size: return self.Size
196
            if self.owner:
197
                matches = [run for run in self.owner.runs if self in run.items]
198
                if matches:
199
                    at = matches[0].items.index(self)
200
                    upstream = matches[0].items[:at]
201
                    upstream.reverse()
202
                    prev = self 
203
                    for item in upstream:
204
                        if type(item) is QEngineeringReducerItem:
205
                            if item.connectors[0].connectedItem is prev:    ### Main Size
206
                                if item.MainSize: return item.MainSize
207
                            elif item.connectors[1].connectedItem is prev:  ### Sub Size
208
                                if item.SubSize: return item.SubSize
209
                        else:
210
                            if item.Size: return item.Size
211
                        prev = item
212

  
213
                    downstream = matches[0].items[at:]
214
                    prev = self
215
                    for item in downstream:
216
                        if type(item) is QEngineeringReducerItem:
217
                            if item.connectors[0].connectedItem is prev:    ### Main Size
218
                                if item.MainSize: return item.MainSize
219
                            elif item.connectors[1].connectedItem is prev:  ### Sub Size
220
                                if item.SubSize: return item.SubSize
221
                        else:
222
                            if item.Size: return item.Size
223
                        prev = item
220 224

  
221
                if 'Drain' == matches[0].Type: return AppDocData.instance().drain_size
225
                    if 'Drain' == matches[0].Type: return AppDocData.instance().drain_size
222 226
                    
223
            return self.owner.Size
227
                return self.owner.Size
224 228

  
225
        return None
229
            return None
230
        except Exception as ex:
231
            from App import App 
232
            from AppDocData import MessageType
233

  
234
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
235
            App.mainWnd().addMessage.emit(MessageType.Error, message)
226 236
        
227 237
    def validate(self):
228 238
        '''
DTI_PID/DTI_PID/SymbolAttr.py
119 119
        self.Target = None
120 120
        self.Length = None
121 121
        self.AssocItem = None
122
        self.IsProp = None
122 123

  
123 124
    @staticmethod
124 125
    def fromXml(node):
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py
72 72
            self.ui.pushButtonDelAttr.clicked.connect(self.onDelLineNoAttr)
73 73

  
74 74
    def cell_double_clicked(self, row, column):
75
        if self._symbolType is None or column is not 6: return
75
        if self._symbolType is None or column is not 6 or self.ui.tableWidgetAttr.item(row, 1).tag.IsProp: return
76 76
    
77 77
        from SymbolAttrTargetDialog import SymbolAttrTargetDialog
78 78

  
......
142 142
        row = 0
143 143
        for attr in attrs:
144 144
            item = QTableWidgetItem(str(attr.UID))              # UID
145
            #item.tag = attr
145 146
            self.ui.tableWidgetAttr.setItem(row, 0, item)
146 147
            item = QTableWidgetItem(attr.Attribute)             # Name
148
            #if attr.IsProp:
149
            #    item.setFlags(Qt.ItemIsEnabled)
150
            #    item.setBackground(Qt.lightGray)
147 151
            self.ui.tableWidgetAttr.setItem(row, 1, item)
148 152
            item = QTableWidgetItem(attr.DisplayAttribute)      # Display Name
149 153
            self.ui.tableWidgetAttr.setItem(row, 2, item)
......
153 157
                attrTypeComboBox.addItem(key)
154 158

  
155 159
            self.ui.tableWidgetAttr.setCellWidget(row, 3, attrTypeComboBox)
160
            if attr.IsProp:
161
                attrTypeComboBox.setEnabled(False)
156 162
            result = attrTypeComboBox.findText(attr.AttributeType) # Type
157 163
            attrTypeComboBox.setCurrentIndex(result)
158 164

  
159 165
            item = QTableWidgetItem(str(attr.AttrAt))    # Attribute At
166
            #if attr.IsProp:
167
            #    item.setFlags(Qt.ItemIsEnabled)
160 168
            self.ui.tableWidgetAttr.setItem(row, 4, item)
161 169

  
162 170
            item = QTableWidgetItem(attr.Expression)    # Expression
171
            #if attr.IsProp:
172
            #    item.setFlags(Qt.ItemIsEnabled)
163 173
            self.ui.tableWidgetAttr.setItem(row, 5, item)
164 174

  
165 175
            item = QTableWidgetItem('ALL') if attr.Target == 'ALL' or attr.Target is None else QTableWidgetItem('...')
166 176
            item.tag = attr.Target
167 177
            item.setTextAlignment(Qt.AlignHCenter)
168
            item.setFlags(Qt.ItemIsEnabled)
178
            #item.setFlags(Qt.ItemIsEnabled)
169 179
            self.ui.tableWidgetAttr.setItem(row, 6, item)
170 180

  
171 181
            row = row + 1
......
228 238
    '''
229 239
    def onDelAttr(self):
230 240
        model = self.ui.tableWidgetAttr.model()
231
        row = self.ui.tableWidgetAttr.currentRow()
241
        #row = self.ui.tableWidgetAttr.currentRow()
232 242
        
233
        if row != -1:
234
            model.removeRow(row)
243
        #if row != -1 and not self.ui.tableWidgetAttr.item(row, 1).tag.IsProp:
244
        model.removeRow(row)
235 245

  
236 246
    '''
237 247
        @brief      save attributes

내보내기 Unified diff

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