프로젝트

일반

사용자정보

개정판 50439cf8

ID50439cf805d83ab2bd9770fc922121899e74bdae
상위 2a98fd30
하위 21540ad6

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

issue #563: prepare line no from to with equipment

Change-Id: I2defb496c1cc3dce51277f9a1a787bb20109eda4

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
257 257
                        matches = [attr for attr in self.attrs if attr.UID == prop.UID]
258 258
                        if len(matches) == 1:
259 259
                            _attrs[matches[0]] = self.attrs[matches[0]]
260
                        else:
261
                            _attrs[prop] = ''
260
                        #else:
261
                        #    _attrs[prop] = ''
262 262
        except Exception as ex:
263 263
            from App import App
264 264
            from AppDocData import MessageType
DTI_PID/DTI_PID/Shapes/EngineeringVendorItem.py
46 46
        self._pack_type = pack_type
47 47

  
48 48
        self.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable)
49
        self.setToolTip(str(self.uid))
49
        self.setToolTip(self.pack_type + ' : ' + str(self.uid))
50 50

  
51 51
        self.transfer = Transfer()
52 52

  
......
187 187
    def from_database(component):
188 188
        import uuid
189 189
        from AppDocData import AppDocData
190
        from SymbolAttr import SymbolAttr
190 191

  
191 192
        try:
192 193
            uidNode = component['UID']
......
205 206
            for key in item._properties.keys():
206 207
                item._properties[key] = key.parse_value(component[key.Attribute])
207 208

  
208
            item.setToolTip(str(item.uid))
209

  
210
            associations = app_doc_data.get_component_associations(str(uid))
209
            # get associations 
210
            associations = app_doc_data.get_component_associations(uid)
211 211
            if associations:
212 212
                for assoc in associations:
213
                    _type = assoc['Type']
214
                    if not _type in item._associations:
215
                        item._associations[_type] = []
216
                    item._associations[_type].append(assoc['Association'])
213
                    _attrType = assoc['Type']
214
                    if not _attrType in item._associations:
215
                        item._associations[_attrType] = []
216
                    item._associations[_attrType].append(
217
                        uuid.UUID(assoc['Association']) if assoc['Association'] != 'None' else None)
218
            # up to here
219

  
220
            attributes = app_doc_data.get_component_attributes(uid)
221
            if attributes:
222
                for attr in attributes:
223
                    _attr = SymbolAttr.from_record(attr)
224
                    item.attrs[_attr] = attr['Value']
217 225
        except Exception as ex:
218 226
            from App import App
219 227
            from AppDocData import MessageType
......
257 265
        resLater.append((sql, tuple(params)))
258 266
        # up to here
259 267

  
268
        _attrs = self.getAttributes()
269
        if _attrs:
270
            cols = ['UID', 'Components_UID', 'SymbolAttribute_UID', 'Value', 'Association_UID', 'Freeze']
271
            values = ['?', '?', '?', '?', '?', '?']
272
            params = []
273
            for key in _attrs.keys():
274
                if key.AttributeType != 'Spec':
275
                    params.append((str(uuid.uuid4()), str(self.uid), str(key.UID), str(_attrs[key]), str(key.AssocItem),
276
                                   str(key.Freeze)))
277
                elif key.AttributeType == 'Spec':
278
                    if type(_attrs[key]) is not list: continue
279
                    params.append((str(uuid.uuid4()), str(self.uid), str(key.UID), (str(_attrs[key][0]) + ',' + str(_attrs[key][1])), str(key.AssocItem),
280
                                   str(key.Freeze)))
281
            sql = 'insert into Attributes({}) values({})'.format(','.join(cols), ','.join(values))
282
            res.append((sql, tuple(params)))
283

  
284
        if self.associations():
285
            cols = ['UID', '[Type]', 'Components_UID', 'Association']
286
            values = ['?', '?', '?', '?']
287
            params = []
288
            for assoc in self.associations():
289
                params.append(
290
                    (str(uuid.uuid4()), QEngineeringAbstractItem.assoc_type(assoc), str(self.uid), str(assoc.uid)))
291
            sql = 'insert into Associations({}) values({})'.format(','.join(cols), ','.join(values))
292
            resLater.append((sql, tuple(params)))
293

  
260 294
        return res, resLater
261 295

  
262 296
    @staticmethod
263 297
    def fromXml(node):
264 298
        import uuid
299
        from SymbolAttr import SymbolAttr
265 300

  
266 301
        try:
267 302
            _type = node.attrib['Type'] if 'Type' in node.attrib else 'Vendor Package'
......
284 319
                if matches:
285 320
                    item._properties[matches[0]] = matches[0].parse_value(
286 321
                        prop_node.text) if prop_node.text else ''
287
            item.setToolTip(str(item.uid))
288 322

  
289 323
            attributeValue = node.find('ASSOCIATIONS')
290 324
            if attributeValue is not None:
291 325
                for assoc in attributeValue.iter('ASSOCIATION'):
292
                    _type = assoc.attrib['TYPE']
293
                    if not _type in item._associations:
294
                        item._associations[_type] = []
295
                    item._associations[_type].append(uuid.UUID(assoc.text))
326
                    _attrType = assoc.attrib['TYPE']
327
                    if not _attrType in item._associations:
328
                        item._associations[_attrType] = []
329
                    item._associations[_attrType].append(uuid.UUID(assoc.text) if assoc.text != 'None' else None)
330

  
331
            attributes = node.find('SYMBOLATTRIBUTES')
332
            if attributes is not None:
333
                for attr in attributes.iter('ATTRIBUTE'):
334
                    _attr = SymbolAttr.fromXml(attr)
335
                    item.attrs[_attr] = attr.text
336
                        
296 337
        except Exception as ex:
297 338
            from App import App
298 339
            from AppDocData import MessageType
......
305 346

  
306 347
    def toXml(self):
307 348
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
349
        from SymbolAttr import SymbolAttr
308 350

  
309 351
        try:
310 352
            node = Element('VENDOR')
......
326 368
            node.append(pointsNode)
327 369

  
328 370
            attributeValueNode = Element('ASSOCIATIONS')
329
            for assoc in self.associations():
330
                assoc_node = Element('ASSOCIATION')
331
                assoc_node.attrib['TYPE'] = QEngineeringAbstractItem.assoc_type(assoc)
332
                assoc_node.text = str(assoc.uid)
333
                attributeValueNode.append(assoc_node)
371
            for key, value in self._associations.items():
372
                for assoc in value:
373
                    assoc_node = Element('ASSOCIATION')
374
                    assoc_node.attrib['TYPE'] = str(key)
375
                    assoc_node.text = str(assoc)
376
                    attributeValueNode.append(assoc_node)
334 377
            node.append(attributeValueNode)
335 378

  
336 379
            properties_node = Element('PROPERTIES')
......
339 382
                prop_node.text = str(value) if value else ''
340 383
                properties_node.append(prop_node)
341 384
            node.append(properties_node)
385

  
386
            attributesNode = Element('SYMBOLATTRIBUTES')
387
            _attrs = self.getAttributes()
388
            for attr in _attrs:
389
                if type(attr) is SymbolAttr:
390
                    _node = attr.toXml()
391
                    if attr.AttributeType != 'Spec':
392
                        _node.text = str(_attrs[attr])
393
                    elif attr.AttributeType == 'Spec':
394
                        _node.text = str(self.attrs[attr][0]) + ',' + str(self.attrs[attr][1])
395
                    attributesNode.append(_node)
396

  
397
            node.append(attributesNode)
342 398
        except Exception as ex:
343 399
            from App import App
344 400
            from AppDocData import MessageType

내보내기 Unified diff

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