프로젝트

일반

사용자정보

개정판 a208ed03

IDa208ed03f68e35bf12fafb4a77e9da346899cb9c
상위 9ff6820d
하위 4cb89626

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

issue #503: create properties of item for essential attributes(ex: supplied by)

Change-Id: I4599466b9ab8771c1aa939b7cfce472916b413e7

차이점 보기:

DTI_PID/DTI_PID/Commands/SelectAttributeCommand.py
1
# coding: utf-8
2
""" This is select attribute command module """
3

  
1 4
import os.path
2 5
import sys
3 6
import AbstractCommand
......
19 22
    @date       18.04.10
20 23
'''
21 24
class SelectAttributeCommand(AbstractCommand.AbstractCommand):
22

  
23 25
    onSuccess = pyqtSignal()
24 26

  
25 27
    def __init__(self, item, attr, imageViewer):
......
29 31
        self._item = item
30 32
        self._attr = attr
31 33

  
32

  
33 34
    '''
34 35
        @brief      Select Attribuew
35 36
        @author     kyouho
......
38 39
        @history    add Valve Oper Item 2019.04.15 by humkyung
39 40
    '''
40 41
    def execute(self, param):
42
        from SymbolAttr import SymbolAttr
43
        from SymbolAttr import SymbolProp
44

  
41 45
        event = param[1]
42 46
        scenePos = param[2]
43 47

  
......
54 58
                from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem
55 59
                from EngineeringConnectorItem import QEngineeringConnectorItem
56 60

  
57
                if self._attr is not None:
61
                if self._attr is not None and type(self._attr) is SymbolAttr:
58 62
                    item = self.imageViewer.scene.itemAt(scenePos, QTransform())
59 63
                    if item is not None and self._attr.AttributeType == 'Line Item' and issubclass(type(item), QEngineeringLineItem):
60 64
                        self._item.conns.clear()
61 65
                        self._item.conns.append(item)
62 66

  
63 67
                        self.onSuccess.emit()
64
                    elif item is not None and self._attr.AttributeType == 'Conn' and (issubclass(type(item), QEngineeringLineItem) or issubclass(type(item), SymbolSvgItem)):
68
                    elif item is not None and self._attr.AttributeType == 'CONN' and (issubclass(type(item), QEngineeringLineItem) or issubclass(type(item), SymbolSvgItem)):
65 69
                        self._item.connectors[self._attr.ConnNum - 1].connect(item, QEngineeringAbstractItem.CONNECTED_AT_BODY)
66 70
                        self.onSuccess.emit()
67
                    elif item is not None and self._attr.AttributeType == 'Conn' and (type(item) is QEngineeringConnectorItem):
71
                    elif item is not None and self._attr.AttributeType == 'CONN' and (type(item) is QEngineeringConnectorItem):
68 72
                        self._item.connectors[self._attr.ConnNum - 1].connect(item.parent, QEngineeringAbstractItem.CONNECTED_AT_PT)
69 73
                        self.onSuccess.emit()
70 74
                    elif item is not None and issubclass(type(self._item), QEngineeringSpecBreakItem) and self._attr.AttributeType == 'Comp Item':
......
88 92
                        self._item.add_assoc_item(item, self._attr.AttrAt)
89 93
                        
90 94
                        self.onSuccess.emit()
95
                elif self._attr is not None and type(self._attr) is SymbolProp:
96
                    item = self.imageViewer.scene.itemAt(scenePos, QTransform())
97
                    if item is not None and self._attr.match_type(item):
98
                        self._item._properties[self._attr] = item
99
                        self.onSuccess.emit()
91 100
        except Exception as ex:
92 101
            from App import App
93 102
            from AppDocData import MessageType
DTI_PID/DTI_PID/ItemPropertyTableWidget.py
44 44
class QItemPropertyTableWidget(QTableWidget):
45 45
    def __init__(self, mainWindow):
46 46
        QTableWidget.__init__(self)
47
        self.symData = None
47
        self._item = None
48 48
        self.initResultPropertyTableWidget()
49 49
        self.mainWindow = mainWindow
50 50

  
51
        self.attrValueList = []
52
        self.intCell = []
53
        self.stringCell = []
54

  
55 51
        self.cellChanged.connect(self.cellChangedEvent)
52
        self.cellDoubleClicked.connect(self.cellDoubleClickedEvent)
56 53

  
57 54
    '''
58 55
        @brief  show item's property
......
60 57
        @date   2018.07.03
61 58
        @history    euisung  2019.01.15     add icon image to line item
62 59
    '''
63
    def showItemProperty(self, item):
60
    def show_item_property(self, item):
64 61
        try:
65 62
            from PyQt5 import QtGui
63
            from SymbolAttr import SymbolAttr
64

  
65
            self._item = item
66

  
67
            self.blockSignals(True)
68

  
66 69
            if type(item) is QEngineeringLineItem:
67 70
                self.initTitleCell(item)
68 71
                self.setItem(0, 1, QTableWidgetItem(str(item.uid)))
69

  
70 72
                owner_item = QTableWidgetItem('{}'.format('None' if item.owner is None else item.owner.uid))
71 73
                icon = QtGui.QIcon()
72 74
                icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
73 75
                owner_item.setIcon(icon)
76
                attr = SymbolAttr()
77
                attr.AttributeType = "OWNER"
78
                owner_item.setData(Qt.UserRole, attr)
79

  
74 80
                self.setItem(1, 1, owner_item)
75 81

  
76 82
                pt = item.startPoint()
83
                key_item = QTableWidgetItem("시작점")
84
                key_item.setBackground(Qt.lightGray)
85
                self.setItem(3, 0, key_item)
77 86
                self.setItem(3, 1, QTableWidgetItem('({},{})'.format(pt[0], pt[1])))
78 87
                pt = item.endPoint()
88
                key_item = QTableWidgetItem("끝점")
89
                key_item.setBackground(Qt.lightGray)
90
                self.setItem(4, 0, key_item)
79 91
                self.setItem(4, 1, QTableWidgetItem('({},{})'.format(pt[0], pt[1])))
80
                connItem = QTableWidgetItem('{}'.format('None' if item.connectors[0].connectedItem is None else item.connectors[0].connectedItem.uid))
81
                icon = QtGui.QIcon()
82
                icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
83
                connItem.setIcon(icon)
84
                self.setItem(5, 1, connItem)
85
                connItem = QTableWidgetItem('{}'.format('None' if item.connectors[1].connectedItem is None else item.connectors[1].connectedItem.uid))
86
                icon = QtGui.QIcon()
87
                icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
88
                connItem.setIcon(icon)
89
                self.setItem(6, 1, connItem)
92
                self.show_item_connectors(item)
90 93
            elif issubclass(type(item), SymbolSvgItem):
91 94
                self.onSymbolClicked(item)
92 95
            elif type(item) is QEngineeringLineNoTextItem:
......
101 104

  
102 105
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
103 106
            App.mainWnd().addMessage.emit(MessageType.Error, message)
107
        finally:
108
            self.blockSignals(False)
104 109

  
105 110
    '''
106 111
        @brief      Initialize TableWidget
......
115 120
        self.setRowCount(13)
116 121
        self.verticalHeader().hide()
117 122
        self.horizontalHeader().setStretchLastSection(True)
118
        #self.setEditTriggers(QAbstractItemView.NoEditTriggers)
119 123
        
120 124
    '''
121 125
        @brief      Slot to accept item click event
......
126 130
    @pyqtSlot(SymbolSvgItem)
127 131
    def onSymbolClicked(self, symbol):
128 132
        if issubclass(type(symbol), SymbolSvgItem):
129
            self.symData = symbol
133
            self._item = symbol
130 134
            self.symbolChanged(symbol)
131 135
        elif type(symbol) is QEngineeringLineNoTextItem:
132 136
            self.lineNoChanged(symbol)
......
145 149
            name = attr[0]
146 150
            item = QTableWidgetItem(name)
147 151
            item.setFlags(Qt.ItemIsEnabled)
148
            item.setBackground(QColor(220, 220, 220))
152
            item.setBackground(Qt.lightGray)
149 153
            self.setItem(row, 0, item)
150 154

  
151 155
            value = attr[1]
......
226 230
            self.clear()
227 231
            self.setHorizontalHeaderLabels(['Name', 'Value'])
228 232
            self.horizontalHeaderItem(0).setSizeHint(QSize(25, 25))
229
            if issubclass(type(item), SymbolSvgItem):
230
                self.setRowCount(7)
233
            if type(item) is QEngineeringSpecBreakItem:
234
                self.setRowCount(8)
235

  
236
                self.setItem(0, 0, QTableWidgetItem("UID"))
237
                self.setItem(1, 0, QTableWidgetItem("심볼명"))
238
                self.setItem(2, 0, QTableWidgetItem("타입"))
239
                self.setItem(3, 0, QTableWidgetItem("각도"))
240
                self.setItem(4, 0, QTableWidgetItem("원점"))
241
                self.setItem(5, 0, QTableWidgetItem("OWNER"))
242
                self.setItem(7, 0, QTableWidgetItem("Set Specs"))
243
            elif type(item) is QEngineeringErrorItem:
244
                self.setRowCount(8)
245

  
246
                self.setItem(0, 0, QTableWidgetItem("UID"))
247
                self.setItem(1, 0, QTableWidgetItem("심볼명"))
248
                self.setItem(2, 0, QTableWidgetItem("타입"))
249
                self.setItem(3, 0, QTableWidgetItem("각도"))
250
                self.setItem(4, 0, QTableWidgetItem("원점"))
251
                self.setItem(5, 0, QTableWidgetItem("OWNER"))
252
                self.setItem(7, 0, QTableWidgetItem("Message"))
253
            elif issubclass(type(item), SymbolSvgItem):
254
                self.setRowCount(6)
231 255
                
232 256
                self.setItem(0, 0, QTableWidgetItem("UID"))
233 257
                self.setItem(1, 0, QTableWidgetItem("심볼명"))
......
235 259
                self.setItem(3, 0, QTableWidgetItem("각도"))
236 260
                self.setItem(4, 0, QTableWidgetItem("원점"))
237 261
                self.setItem(5, 0, QTableWidgetItem("OWNER"))
238
                self.setItem(6, 0, QTableWidgetItem("Supplied by"))
239
                if type(item) is QEngineeringSpecBreakItem:
240
                    self.setRowCount(8)
241
                    self.setItem(7, 0, QTableWidgetItem("Set Specs"))
242
                if type(item) is QEngineeringErrorItem:
243
                    self.setRowCount(8)
244
                    self.setItem(7, 0, QTableWidgetItem("Message"))
245 262
            elif type(item) is QEngineeringNoteItem:
246 263
                self.setRowCount(1)
247 264
                self.setItem(0, 0, QTableWidgetItem("노트번호"))
......
250 267
                self.setRowCount(1)
251 268
                self.setItem(0, 0, QTableWidgetItem("UID"))
252 269
            elif type(item) is QEngineeringLineItem:
253
                self.setRowCount(7)
270
                self.setRowCount(5)
254 271

  
255 272
                self.setItem(0, 0, QTableWidgetItem('UID'))
256 273
                self.setItem(1, 0, QTableWidgetItem('OWNER'))
......
267 284
                self._lineTypeComboBox.setCurrentText(item.lineType)
268 285
                self._lineTypeComboBox.currentIndexChanged.connect(self.onLineTypeChanged)
269 286

  
270
                self.setItem(3, 0, QTableWidgetItem("시작점"))
271
                self.setItem(4, 0, QTableWidgetItem("끝점"))
272
                self.setItem(5, 0, QTableWidgetItem("CONN1"))
273
                self.setItem(6, 0, QTableWidgetItem("CONN2"))
274

  
275 287
            for index in range(self.rowCount()):
276 288
                item = self.item(index, 0)
277 289
                if item is not None:
278 290
                    item.setFlags(Qt.ItemIsEnabled)
279
                    item.setBackground(QColor(220, 220, 220))
291
                    item.setBackground(Qt.lightGray)
280 292
        except Exception as ex:
281 293
            from App import App 
282 294

  
......
293 305
        data = self._lineTypeComboBox.tag.data(Qt.UserRole)
294 306
        if type(data) is QEngineeringLineItem:
295 307
            data.lineType = lineType
308

  
309
    def show_item_properties(self, item):
310
        """ show item properties on grid """
311
        from PyQt5 import QtGui
312

  
313
        row = self.rowCount()
314
        if hasattr(item, '_properties'):
315
            self.setRowCount(row + len(item.properties))
316

  
317
            for prop,value in item.properties.items():
318
                """ show property name """
319
                key_item = QTableWidgetItem(prop.DisplayAttribute if prop.DisplayAttribute else prop.Attribute)
320
                key_item.setFlags(Qt.ItemIsEnabled)
321
                key_item.setBackground(Qt.lightGray)
322
                key_item.setData(Qt.UserRole, prop)
323
                self.setItem(row, 0, key_item)
324

  
325
                """ show property value """
326
                if prop.is_selectable:
327
                    if prop.Expression:
328
                        item = value    # assume item is instance
329
                        value_item = QTableWidgetItem(eval(prop.Expression))
330
                    else:
331
                        value_item = QTableWidgetItem(str(value.uid) if value else '')
332
                    icon = QtGui.QIcon()
333
                    icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
334
                    value_item.setIcon(icon)
335
                    value_item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
336
                    self.setItem(row, 1, value_item)
337
                else:
338
                    value_item = QTableWidgetItem(value if value else '')
339
                    if prop.AttributeType == "String":
340
                        icon = QtGui.QIcon()
341
                        icon.addPixmap(QtGui.QPixmap(":/newPrefix/type.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
342
                        value_item.setIcon(icon)
343
                    value_item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable|Qt.ItemIsEditable)
344
                    self.setItem(row, 1, value_item)
345
                row = row + 1
346
        
347
    def show_item_attributes(self, item):
348
        """ show item's attributes on grid """
349
        from PyQt5 import QtGui
350

  
351
        row = self.rowCount()
352
        attrs = item.getAttributes()
353

  
354
        # display attributes of symbol
355
        if attrs is not None:
356
            self.setRowCount(row + len(attrs))
357

  
358
            for key,value in attrs.items():
359
                key_item = QTableWidgetItem(key.DisplayAttribute if key.DisplayAttribute else key.Attribute)
360
                key_item.setBackground(Qt.lightGray)
361
                key_item.setData(Qt.UserRole, key)
362
                self.setItem(row, 0, key_item)
363

  
364
                value_item = QTableWidgetItem(str(value))
365
                if key.is_selectable:
366
                    icon = QtGui.QIcon()
367
                    icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
368
                    value_item.setIcon(icon)
369
                else:
370
                    value_item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable|Qt.ItemIsEditable)
371

  
372
                if type(item) is QEngineeringSpecBreakItem:
373
                    '''
374
                    comboBox = QComboBox()
375
                    comboBox.addItem('')
376

  
377
                    itemList = self.mainWindow.findOverlapConnector(self._item.connectors[0])
378
                    for item in itemList:
379
                        comboBox.addItem(str(item.uid))
380

  
381
                    if key == 'Up Stream':
382
                        comboBox.currentTextChanged.connect(self.upStreamChanged)
383
                    else:
384
                        comboBox.currentTextChanged.connect(self.downStreamChanged)
385

  
386
                    tempIndex = comboBox.findText(value) if comboBox.findText(value) != -1 else 0
387
                    comboBox.setCurrentIndex(tempIndex)
388

  
389
                    self.setCellWidget(row, 1, comboBox)
390
                    '''
391
                    if key.Attribute == 'UpStream' or key.Attribute == 'DownStream':
392
                        UpDownItem = QTableWidgetItem('{}'.format('None' if value is None else value))
393
                        icon = QtGui.QIcon()
394
                        icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
395
                        UpDownItem.setIcon(icon)
396
                        self.setItem(row, 1, UpDownItem)
397
                    elif key.AttributeType == 'Spec':
398
                        self.setItem(row, 1, QTableWidgetItem(key.Attribute))
399
                else:
400
                    self.setItem(row, 1, value_item)
401

  
402
                row = row + 1
403

  
404
    def show_item_connectors(self, item):
405
        """ show items' connectors on grid """
406
        from PyQt5 import QtGui
407
        from SymbolAttr import SymbolAttr
408

  
409
        row = self.rowCount()
410
        self.setRowCount(row + len(item.connectors))
411

  
412
        count = 1
413
        for connector in item.connectors:
414
            connector_item = QTableWidgetItem('CONN{}'.format(count))
415
            connector_item.setFlags(Qt.ItemIsEnabled)
416
            connector_item.setBackground(Qt.lightGray)
417
            self.setItem(row, 0, connector_item)
418

  
419
            attr = SymbolAttr()
420
            attr.AttributeType = "CONN"
421
            attr.AttrAt = count
422
            connector_item.setData(Qt.UserRole, attr)
423

  
424
            connector_item = QTableWidgetItem('{}'.format('None' if connector.connectedItem is None else str(connector.connectedItem.uid)))
425
            icon = QtGui.QIcon()
426
            icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
427
            connector_item.setIcon(icon)
428
            self.setItem(row, 1, connector_item)
296 429
            
430
            row = row + 1
431
            count = count + 1
432

  
297 433
    '''
298 434
        @brief      Initialize Contents Cell
299 435
        @author     Jeongwoo
......
304 440
    '''
305 441
    def initContentsCell(self):
306 442
        from PyQt5 import QtGui
307
        self.attrValueList = []
308
        self.intCell = []
309
        self.stringCell = []
443
        from SymbolAttr import SymbolAttr
310 444

  
311 445
        try:
312
            if self.symData is not None:
446
            if self._item is not None:
313 447
                docData = AppDocData.instance()
314 448

  
315
                self.setItem(0, 1, QTableWidgetItem(str(self.symData.uid)))
316
                self.setItem(1, 1, QTableWidgetItem(self.symData.name))
317
                self.setItem(2, 1, QTableWidgetItem(self.symData.type))
318
                self.setItem(3, 1, QTableWidgetItem(str(round(math.degrees(self.symData.angle)))))
319
                self.setItem(4, 1, QTableWidgetItem(str(self.symData.origin)))
320
                owner_item = QTableWidgetItem('{}'.format('None' if self.symData.owner is None else self.symData.owner.uid))
449
                self.setItem(0, 1, QTableWidgetItem(str(self._item.uid)))
450
                self.setItem(1, 1, QTableWidgetItem(self._item.name))
451
                self.setItem(2, 1, QTableWidgetItem(self._item.type))
452
                self.setItem(3, 1, QTableWidgetItem(str(round(math.degrees(self._item.angle)))))
453
                self.setItem(4, 1, QTableWidgetItem(str(self._item.origin)))
454
                owner_item = QTableWidgetItem('{}'.format('None' if self._item.owner is None else self._item.owner.uid))
321 455
                icon = QtGui.QIcon()
322 456
                icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
323 457
                owner_item.setIcon(icon)
458
                attr = SymbolAttr()
459
                attr.AttributeType = "OWNER"
460
                owner_item.setData(Qt.UserRole, attr)
324 461
                self.setItem(5, 1, owner_item)
462
                
463
                row = self.rowCount() 
464
                self.show_item_properties(self._item)
325 465

  
326
                suppliedItem = QTableWidgetItem(self.symData.supplied_by)
327
                icon = QtGui.QIcon()
328
                icon.addPixmap(QtGui.QPixmap(":/newPrefix/type.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
329
                suppliedItem.setIcon(icon)
330
                self.setItem(6, 1, suppliedItem)
331

  
332
                if type(self.symData) is QEngineeringSpecBreakItem:
466
                if type(self._item) is QEngineeringSpecBreakItem:
333 467
                    setSpecsItem = QTableWidgetItem('Open')
334 468
                    icon = QtGui.QIcon()
335 469
                    icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
336 470
                    setSpecsItem.setIcon(icon)
337
                    self.setItem(7, 1, setSpecsItem)
471
                    self.setItem(row, 1, setSpecsItem)
472
                    row = row + 1
338 473

  
339
                if type(self.symData) is QEngineeringErrorItem:
474
                if type(self._item) is QEngineeringErrorItem:
340 475
                    errType = 'None'
341
                    if type(self.symData.parent) is QEngineeringLineItem:
476
                    if type(self._item.parent) is QEngineeringLineItem:
342 477
                        errType = 'line'
343
                    elif issubclass(type(self.symData.parent), SymbolSvgItem):
478
                    elif issubclass(type(self._item.parent), SymbolSvgItem):
344 479
                        errType = 'symbol'
345 480
                    self.setItem(2, 1, QTableWidgetItem(errType))
346
                    self.setItem(5, 1, QTableWidgetItem(self.symData.parent.uid))
347
                    self.setItem(7, 1, QTableWidgetItem(self.symData.msg))
348

  
349
                row = self.rowCount()
350
                attrs = self.symData.getAttributes()
351
                self.setRowCount(row + len(attrs) + len(self.symData.connectors))
352
                # display attributes of symbol
353
                if attrs is not None:
354
                    for key in attrs.keys():
355
                        value = attrs[key]
356
                        keyItem = QTableWidgetItem(key.Attribute)
357
                        keyItem.setBackground(QColor(220, 220, 220))
358
                        keyItem.tag = key
359
                        valueItem = QTableWidgetItem(str(value))
360
                        if key.is_selectable:
361
                            from PyQt5 import QtGui
362
                            icon = QtGui.QIcon()
363
                            icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
364
                            valueItem.setIcon(icon)
365
                        elif key.AttributeType == 'Int':
366
                            self.intCell.append(valueItem)
367
                        elif key.AttributeType == 'String':
368
                            self.stringCell.append(valueItem)
369

  
370
                        if key.AttributeType == 'Text Item':
371
                            textItem = self.findTextItemFromUID(value)
372
                            if textItem is not None:
373
                                valueItem.setText(textItem.text())
374
                        self.attrValueList.append((valueItem, key))
375

  
376
                        if key.DisplayAttribute is not None:
377
                            keyItem.setText(key.DisplayAttribute)
378
                        self.setItem(row, 0, keyItem)
379

  
380
                        if type(self.symData) is QEngineeringSpecBreakItem:
381
                            '''
382
                            comboBox = QComboBox()
383
                            comboBox.addItem('')
384

  
385
                            itemList = self.mainWindow.findOverlapConnector(self.symData.connectors[0])
386
                            for item in itemList:
387
                                comboBox.addItem(str(item.uid))
388

  
389
                            if key == 'Up Stream':
390
                                comboBox.currentTextChanged.connect(self.upStreamChanged)
391
                            else:
392
                                comboBox.currentTextChanged.connect(self.downStreamChanged)
393

  
394
                            tempIndex = comboBox.findText(value) if comboBox.findText(value) != -1 else 0
395
                            comboBox.setCurrentIndex(tempIndex)
396

  
397
                            self.setCellWidget(row, 1, comboBox)
398
                            '''
399
                            if key.Attribute == 'UpStream' or key.Attribute == 'DownStream':
400
                                UpDownItem = QTableWidgetItem('{}'.format('None' if value is None else value))
401
                                icon = QtGui.QIcon()
402
                                icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
403
                                UpDownItem.setIcon(icon)
404
                                self.setItem(row, 1, UpDownItem)
405

  
406
                            elif key.AttributeType == 'Spec':
407
                                self.setItem(row, 1, QTableWidgetItem(key.Attribute))
408

  
409
                        else:
410
                            self.setItem(row, 1, valueItem)
411

  
412
                        row = row + 1
413
                # up to here
414

  
415
                # display connectivity
416
                count = 1
417
                for connector in self.symData.connectors:
418
                    item = QTableWidgetItem('CONN{}'.format(count))
419
                    item.setFlags(Qt.ItemIsEnabled)
420
                    item.setBackground(QColor(220, 220, 220))
421
                    self.setItem(row, 0, item)
422

  
423
                    item = QTableWidgetItem('{}'.format('None' if connector.connectedItem is None else str(connector.connectedItem.uid)))
424
                    icon = QtGui.QIcon()
425
                    icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
426
                    item.setIcon(icon)
427
                    self.setItem(row, 1, item)
428
                    row = row + 1
429
                    count = count + 1
430
                # up to here
481
                    self.setItem(5, 1, QTableWidgetItem(self._item.parent.uid))
482
                    self.setItem(7, 1, QTableWidgetItem(self._item.msg))
431 483

  
484
                self.show_item_attributes(self._item)
485
                self.show_item_connectors(self._item)
486
                
432 487
                for index in range(self.rowCount()):
433 488
                    item = self.item(index, 1)
434
                    if item is not None:
435
                        item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
436
                        item.setToolTip(item.text())
437
                suppliedItem.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable|Qt.ItemIsEditable)
489
                    if item is not None: item.setToolTip(item.text())
490
                        #item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
438 491
            else:
439 492
                self.setRowCount(0)
440 493
        except Exception as ex:
......
449 502
        @date       2018.08.28
450 503
    '''
451 504
    def upStreamChanged(self, text):
452
        if self.symData is not None:
505
        if self._item is not None:
453 506
            find = False
454
            for index in range(len(self.symData.attrs)):
455
                if type(self.symData.attrs[index]) is tuple and self.symData.attrs[index][0] == 'Up Stream':
456
                    self.symData.attrs[index] = (self.symData.attrs[index][0], text)
507
            for index in range(len(self._item.attrs)):
508
                if type(self._item.attrs[index]) is tuple and self._item.attrs[index][0] == 'Up Stream':
509
                    self._item.attrs[index] = (self._item.attrs[index][0], text)
457 510
                    find = True
458 511
                    break
459 512
            
460 513
            if not find:
461
                self.symData.attrs.append(('Up Stream', text))
514
                self._item.attrs.append(('Up Stream', text))
462 515

  
463 516
    '''
464 517
        @brief      combobox change event
......
466 519
        @date       2018.08.28
467 520
    '''
468 521
    def downStreamChanged(self, text):
469
        if self.symData is not None:
522
        if self._item is not None:
470 523
            find = False
471
            for index in range(len(self.symData.attrs)):
472
                if type(self.symData.attrs[index]) is tuple and self.symData.attrs[index][0] == 'Down Stream':
473
                    self.symData.attrs[index] = (self.symData.attrs[index][0], text)
524
            for index in range(len(self._item.attrs)):
525
                if type(self._item.attrs[index]) is tuple and self._item.attrs[index][0] == 'Down Stream':
526
                    self._item.attrs[index] = (self._item.attrs[index][0], text)
474 527
                    find = True
475 528
                    break
476 529
            
477 530
            if not find:
478
                self.symData.attrs.append(('Down Stream', text))
531
                self._item.attrs.append(('Down Stream', text))
479 532

  
480 533
    '''
481 534
        @brief      find text item using uid
......
511 564
            item = self.item(index, 0)
512 565
            if item is not None:
513 566
                item.setFlags(Qt.ItemIsEnabled)
514
                item.setBackground(QColor(220, 220, 220))
567
                item.setBackground(Qt.lightGray)
515 568

  
516 569
    '''
517 570
        @brief      Initialize Line No Contents Cell
......
524 577
        configs = appDocData.getConfigs('Line No', 'Configuration')
525 578
        configs = configs[0].value.split('"-"')
526 579

  
527
        self.attrValueList = []
528
        self.stringCell = []
529

  
530 580
        item = QTableWidgetItem(str(lineNoItem.uid))
531 581
        item.setFlags(Qt.ItemIsEnabled)
532 582
        self.setItem(0, 1, item)
533 583

  
584
        self.show_item_properties(lineNoItem)
585
        
534 586
        row = self.rowCount()
535

  
536 587
        attrs = lineNoItem.getAttributes()
537 588
        self.setRowCount(row + len(attrs))
538 589
        if attrs is not None:
539 590
            for key in attrs.keys():
540 591
                item = QTableWidgetItem(key.DisplayAttribute if key.DisplayAttribute else key.Attribute)
541 592
                item.setFlags(Qt.ItemIsEnabled)
542
                item.setBackground(QColor(220, 220, 220))
593
                item.setBackground(Qt.lightGray)
543 594
                item.tag = key
544 595
                self.setItem(row, 0, item)
545 596

  
......
552 603
                if keyStr:
553 604
                    # editable value cell
554 605
                    if keyStr[0].AttributeType == 'String':
555
                        self.attrValueList.append((valueCell, key.Attribute))
556
                        self.stringCell.append(valueCell)
606
                        pass
607
                        #self.attrValueList.append((valueCell, key.Attribute))
608
                        #self.stringCell.append(valueCell)
557 609
                    if keyStr[0].UID in configs: valueCell.setFlags(Qt.ItemIsEnabled)
558 610
                else:
559 611
                    valueCell.setFlags(Qt.ItemIsEnabled)
......
602 654
        self.setRowCount(1)
603 655

  
604 656
        lineTypeItem = QTableWidgetItem("라인 타입")
605
        lineTypeItem.setBackground(QColor(220, 220, 220))
657
        lineTypeItem.setBackground(Qt.lightGray)
606 658
        lineTypeItem.setFlags(Qt.ItemIsEnabled)
607 659
        self.setItem(0, 0, lineTypeItem)
608 660

  
......
626 678
                    selectedUID = self.item(selectedIndexes[0].row(), 1).text()
627 679
                    connNum = int(keyCell.text().replace('CONN', ''))
628 680
                    items[0].connectors[connNum - 1].connectedItem = None
629
                    self.showItemProperty(items[0])
681
                    self.show_item_property(items[0])
630 682

  
631 683
                    for sceneItem in self.mainWindow.graphicsView.scene.items():
632 684
                        if hasattr(sceneItem, 'uid') and str(sceneItem.uid) == selectedUID and hasattr(sceneItem, 'connectors'):
......
639 691
                    for attr in items[0].attrs.keys():
640 692
                        if attr.Attribute == keyCell.text():
641 693
                            items[0].attrs[attr] = None
642
                    self.showItemProperty(items[0])
694
                    self.show_item_property(items[0])
695

  
643 696
    '''
644 697
        @brief      int cell check
645 698
        @author     kyouho
......
647 700
    '''
648 701
    def cellChangedEvent(self, row, column):
649 702
        cell = self.item(row, 0)
650
        if cell is not None and cell.text() == 'Supplied by':
651
            items = self.mainWindow.graphicsView.scene.selectedItems()
652
            if items is not None and len(items) == 1 and self.item(row, 1) is not None:
653
                items[0].supplied_by = self.item(row, 1).text()
654
        if not hasattr(cell, 'tag'): return
703
        data = cell.data(Qt.UserRole)
704
        if data is not None and not data.is_selectable:
705
            if self._item: self._item.properties[data] = self.item(row, column).text()
655 706

  
707
        """
656 708
        key = self.item(row, 0).tag
657 709
        cell = self.item(row, column)
658 710
        
......
664 716
                items[0].setAttribute(key, cell.text())
665 717
            else:
666 718
                return
719
        """
667 720

  
668 721
    '''
669 722
        @brief      Check Number
......
686 739
        @history    euisung  2019.01.15  edit specbreak
687 740
    '''
688 741
    def cellDoubleClickedEvent(self, row, column):
742
        from SymbolAttr import SymbolProp
689 743

  
690 744
        if column == 1:
691 745
            items = self.mainWindow.graphicsView.scene.selectedItems()
692 746
            keyCell = self.item(row, 0)
747
            attr = keyCell.data(Qt.UserRole)
693 748
            if hasattr(keyCell, 'tag') and type(items[0]) is not QEngineeringSpecBreakItem:
694 749
                attr = keyCell.tag
695 750
                if attr.is_selectable:
......
705 760
                cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
706 761
                cmd.onSuccess.connect(self.onSuccessSelectAttribute)
707 762
                self.mainWindow.graphicsView.command = cmd
708
            elif keyCell.text().find('CONN') is 0 and (type(items[0]) is QEngineeringLineItem or (issubclass(type(items[0]), SymbolSvgItem) and type(items[0]) is not QEngineeringSpecBreakItem)):
709
                from SymbolAttr import SymbolAttr
710
                attr = SymbolAttr()
711
                attr.AttributeType = "Conn"
712
                attr.ConnNum = int(keyCell.text().replace('CONN', ''))
713
                cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
714
                cmd.onSuccess.connect(self.onSuccessSelectAttribute)
715
                self.mainWindow.graphicsView.command = cmd
716 763
            elif keyCell.text() == 'OWNER' and ((type(items[0]) is QEngineeringLineItem) or (issubclass(type(items[0]), SymbolSvgItem))):
717
                from SymbolAttr import SymbolAttr
718
                attr = SymbolAttr()
719
                attr.AttributeType = "OWNER"
764
                attr = keyCell.data(Qt.UserRole)
720 765
                cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
721 766
                cmd.onSuccess.connect(self.onSuccessSelectAttribute)
722 767
                self.mainWindow.graphicsView.command = cmd
723 768
            elif type(items[0]) is QEngineeringSpecBreakItem:
724 769
                if keyCell.text() == 'UpStream' or keyCell.text() == 'DownStream':
725
                    attr = keyCell.tag
770
                    attr = keyCell.data(Qt.UserRole)
726 771
                    cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
727 772
                    cmd.onSuccess.connect(self.onSuccessSelectAttribute)
728 773
                    self.mainWindow.graphicsView.command = cmd
......
733 778
                    try:
734 779
                        dialog = QSpecBreakDialog(self, items[0])
735 780
                        dialog.exec_()
736
                        self.showItemProperty(items[0])
781
                        self.show_item_property(items[0])
737 782
                    except Exception as ex:
738 783
                        print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
739

  
740
            #elif Qt.ItemIsEnabled is not self.item(row, column).flags():
741
            #    self.editItem(self.item(row, column))
784
            elif issubclass(type(attr), SymbolProp):
785
                attr = keyCell.data(Qt.UserRole)
786
                cmd = SelectAttributeCommand.SelectAttributeCommand(items[0], attr, self.mainWindow.graphicsView)
787
                cmd.onSuccess.connect(self.onSuccessSelectAttribute)
788
                self.mainWindow.graphicsView.command = cmd
742 789

  
743 790
    '''
744 791
        @brief      success select attribute 
......
746 793
        @date       2018.10.23
747 794
    '''
748 795
    def onSuccessSelectAttribute(self, connItem = None):
749
        if connItem is None:
750
            self.mainWindow.refreshResultPropertyTableWidget()
751
        else:
752
            self.showItemProperty(connItem)
796
        """ update item's properties after selecting """
797
        self.show_item_property(self._item)
DTI_PID/DTI_PID/MainWindow.py
220 220
        self.graphicsView.scene.changed.connect(self.onSceneChanged)
221 221
        self.graphicsView.scene.selectionChanged.connect(self.onSelectionChanged)
222 222
        self.actionInitialize.triggered.connect(self.onInitializeScene)
223
        self.resultPropertyTableWidget.cellDoubleClicked.connect(self.resultPropertyTableWidget.cellDoubleClickedEvent)
224
        self.resultPropertyTableWidget.cellClicked.connect(self.cellClickedEvent)
225 223
        self.actionSave.triggered.connect(self.actionSaveCliked)
226 224
        self.addMessage.connect(self.onAddMessage)
227 225
        self.actionFindReplaceText.triggered.connect(self.findReplaceTextClicked)
......
682 680
    def refreshResultPropertyTableWidget(self):
683 681
        items = self.graphicsView.scene.selectedItems()
684 682
        if len(items) == 1:
685
            self.resultPropertyTableWidget.showItemProperty(items[0])
683
            self.resultPropertyTableWidget.show_item_property(items[0])
686 684
    
687 685
    '''
688
        @brief      resultPropertyTableWidget Cell Click Event
689
        @author     kyouho
690
        @date       2018.08.23
691
    '''
692
    def cellClickedEvent(self, row, column):
693
        item = self.graphicsView.scene.selectedItems()
694
        if len(item) != 1:
695
            return
696
        item = item[0]
697

  
698
        cell = self.resultPropertyTableWidget.item(row, column)
699
        for valueCell, uid in self.resultPropertyTableWidget.attrValueList:
700
            if valueCell == cell and issubclass(type(item), SymbolSvgItem):
701
                for attr in item.attrs:
702
                    if attr.Attribute == uid and (issubclass(type(attr), SymbolSvgItem) or type(attr) is QEngineeringTextItem):
703
                        prevItem = item
704
                        currentItem = attr
705

  
706
                        rect = currentItem.sceneBoundingRect()
707
                        self.graphicsView.centerOn(rect.center())
708
                        self.graphicsView.zoomImage(True, QMouseEvent(QEvent.MouseButtonPress, self.graphicsView.mapFromScene(QPointF(rect.left(), rect.top())), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier), 3)
709
                        prevItem.setSelected(True)
710

  
711
                        currentItem.setHightlight()
712
                    elif (issubclass(type(attr), SymbolSvgItem) or type(attr) is QEngineeringTextItem):
713
                        attr.unsetHightlight()
714

  
715
    '''
716 686
        @brief  add message listwidget
717 687
        @author humkyung
718 688
        @date   2018.07.31
......
838 808
        if items:
839 809
            item = items[-1]
840 810
            self.itemTreeWidget.findItem(item)
841
            self.resultPropertyTableWidget.showItemProperty(item)
811
            #self.resultPropertyTableWidget.show_item_property(item)
842 812
            if type(item) is QEngineeringErrorItem:
843 813
                for index in range(self.tableWidgetInconsistency.rowCount()):
844 814
                    if self.tableWidgetInconsistency.item(index, 1).tag is item:
845 815
                        self.tableWidgetInconsistency.selectRow(index)
846 816
                        break
847 817
        else:
848
            self.resultPropertyTableWidget.showItemProperty(None)
818
            self.resultPropertyTableWidget.show_item_property(None)
849 819
        
850 820
    '''
851 821
        @brief      Initialize scene and itemTreeWidget
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
30 30
                    humkyung 2018.07.09 add stream no
31 31
    '''
32 32
    def __init__(self, uid=None, parent=None):
33
        from SymbolAttr import SymbolProp
34

  
33 35
        QEngineeringTextItem.__init__(self, uid, parent)
36

  
37
        self._properties = {SymbolProp(None, 'From', 'Comp Item'):None, SymbolProp(None, 'To', 'Comp Item'):None}
34 38
        self._runs = []
35 39

  
40
    @property
41
    def properties(self):
42
        """ getter of properties """
43
        import uuid
44

  
45
        for prop,value in self._properties.items():
46
            if prop.is_selectable and type(value) is uuid.UUID:
47
                matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(value)]
48
                if matches: self._properties[prop] = matches[0]
49
            
50
        return self._properties
51

  
52
    @properties.setter
53
    def properties(self, value):
54
        """ setter of properties """
55
        self._properties = value
56

  
36 57
    def setVisible(self, visible):
37 58
        """ override visible value """
38 59
        super(QEngineeringTextItem, self).setVisible(visible)
......
167 188

  
168 189
    @staticmethod
169 190
    def fromXml(node):
170
        """
171
        generate EngineeringLineNoTextItem from xml node
172
        """
191
        """ generate EngineeringLineNoTextItem from xml node """
192
        import uuid
173 193
        from TextItemFactory import TextItemFactory
174 194
        from SymbolAttr import SymbolAttr
175 195

  
176 196
        item = None
177 197

  
178
        location = node.find('LOCATION').text if node.find('LOCATION') is not None else '0,0'
179
        x = float(location.split(',')[0])
180
        y = float(location.split(',')[1])
181
        width = float(node.find('WIDTH').text) if node.find('WIDTH') is not None else 0
182
        height = float(node.find('HEIGHT').text) if node.find('HEIGHT') is not None else 0
183
        angle = float(node.find('ANGLE').text) if node.find('ANGLE') is not None else 0
184
        text = node.find('TEXT').text
185
        textInfo = TextInfo(text, x, y, width, height, angle)
186

  
187
        item = TextItemFactory.instance().createTextItem(textInfo)
188
        if item is not None:
189
            for attr_node in node.iter('ATTRIBUTE'):
190
                attr = SymbolAttr.fromXml(attr_node)
191
                item.attrs[attr] = attr_node.text
192

  
193
            item.loc = (x, y)
194
            item.size = (width, height)
195
            item.angle = angle
198
        try:
199
            location = node.find('LOCATION').text if node.find('LOCATION') is not None else '0,0'
200
            x = float(location.split(',')[0])
201
            y = float(location.split(',')[1])
202
            width = float(node.find('WIDTH').text) if node.find('WIDTH') is not None else 0
203
            height = float(node.find('HEIGHT').text) if node.find('HEIGHT') is not None else 0
204
            angle = float(node.find('ANGLE').text) if node.find('ANGLE') is not None else 0
205
            text = node.find('TEXT').text
206
            textInfo = TextInfo(text, x, y, width, height, angle)
207

  
208
            item = TextItemFactory.instance().createTextItem(textInfo)
209
            if item is not None:
210
                for prop_node in node.iter('PROPERTY'):
211
                    matches = [prop for prop in item._properties.keys() if prop.Attribute == prop_node.attrib['Attribute']]
212
                    if matches:
213
                        matches[0].parse_xml(prop_node)
214
                        item._properties[matches[0]] = uuid.UUID(prop_node.text) if prop_node.text and matches[0].is_selectable else prop_node.text if prop_node.text else ''
215
                    
216
                for attr_node in node.iter('ATTRIBUTE'):
217
                    attr = SymbolAttr.fromXml(attr_node)
218
                    item.attrs[attr] = attr_node.text
219

  
220
                item.loc = (x, y)
221
                item.size = (width, height)
222
                item.angle = angle
223
        except Exception as ex:
224
            from App import App
225
            from AppDocData import MessageType
226

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

  
197 230
        return item
198 231

  
......
246 279
            for run in self.runs:
247 280
                node.append(run.toXml())
248 281

  
282
            properties_node = Element('PROPERTIES')
283
            for prop,value in self.properties.items():
284
                prop_node = prop.toXml()
285
                prop_node.text = '' if not value else str(value.uid) if prop.is_selectable else str(value)
286
                properties_node.append(prop_node)
287
            node.append(properties_node)
288

  
249 289
            _attrs = self.getAttributes()
250 290
            for key in _attrs.keys():
251 291
                if key.UID is not None:
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
30 30
    '''
31 31
    def __init__(self, path, uid=None, flip=0):
32 32
        import uuid
33
        from SymbolAttr import SymbolProp
33 34

  
34 35
        QGraphicsSvgItem.__init__(self)
35 36
        QEngineeringAbstractItem.__init__(self)
......
50 51
        self.flip = flip
51 52
        # attributeType uid
52 53
        self.attribute = ''
54
        self._properties = {SymbolProp(None, 'Supplied By', 'String'):None}
53 55
        self.supplied_by = ''
54 56
        
55 57
        self.setAcceptDrops(True)
......
104 106
            self._color = self.DEFAULT_COLOR
105 107
        self.setColor(self._color)
106 108

  
109
    @property
110
    def properties(self):
111
        """ getter of properties """
112
        return self._properties
113

  
114
    @properties.setter
115
    def properties(self, value):
116
        """ setter of properties """
117
        self._properties = value
118

  
107 119
    def validate(self):
108 120
        '''
109 121
            @brief  validation check : flow
......
801 813
            flipNode.text = str(self.flip)
802 814
            node.append(flipNode)
803 815
            
804
            suppliedNode = Element('SUPPLIED_BY')
805
            suppliedNode.text = self.supplied_by
806
            node.append(suppliedNode)
816
            properties_node = Element('PROPERTIES')
817
            for prop,value in self.properties.items():
818
                prop_node = prop.toXml()
819
                prop_node.text = '' if not value else str(value.uid) if prop.is_selectable else str(value)
820
                properties_node.append(prop_node)
821
            node.append(properties_node)
807 822

  
808 823
            attributesNode = Element('SYMBOLATTRIBUTES')
809 824
            _attrs = self.getAttributes()
......
880 895
            flipLabelNode = node.find('FLIP')
881 896
            flipLabel = int(flipLabelNode.text) if flipLabelNode is not None else 0
882 897

  
883
            suppliedNode = node.find('SUPPLIED_BY')
884
            suppliedLabel = suppliedNode.text if suppliedNode is not None else ''
885

  
886 898
            appDocData = AppDocData.instance()
887 899
            project = appDocData.getCurrentProject()
888 900
            svgFilePath = os.path.join(project.getSvgFilePath(), _type, name + '.svg')
......
890 902
                item[0] = SymbolSvgItem.createItem(_type, svgFilePath, uid, flip=flipLabel)
891 903
                item[0].setVisible(False)
892 904
                item[0].buildItem(name, _type, angle, pt, size, origin, connPts, baseSymbol, childSymbol, hasInstrumentLabel)
893
                item[0].supplied_by = suppliedLabel
905

  
906
                for prop_node in node.iter('PROPERTY'):
907
                    matches = [prop for prop in item[0]._properties.keys() if prop.Attribute == prop_node.attrib['Attribute']]
908
                    if matches:
909
                        matches[0].parse_xml(prop_node)
910
                        item[0]._properties[matches[0]] = uuid.UUID(prop_node.text) if prop_node.text and matches[0].is_selectable else prop_node.text if prop_node.text else ''
894 911

  
895 912
                ## assign area
896 913
                areaNode = node.find('AREA')
DTI_PID/DTI_PID/SymbolAttr.py
3 3
    This is Symbol Attribute module
4 4
"""
5 5

  
6
class SymbolAttr:
7
    """
8
    This is symbol attribute class
9
    """
6
class SymbolProp:
7
    """ This is symbol property class """
8

  
9
    def __init__(self, UID, Attribute, AttributType, DisplayAttribute=None, Length=None, Expression=None):
10
        import uuid
11

  
12
        self.UID = uuid.uuid4() if UID is None else UID 
13
        self.Attribute = Attribute 
14
        self.AttributeType = AttributType
15
        self.DisplayAttribute = DisplayAttribute if DisplayAttribute else Attribute
16
        self.Length = Length 
17
        self.Expression = Expression 
18

  
19
    @property
20
    def is_selectable(self):
21
        """ return if attribute is selectable """
22
        from SymbolAttrEditorDialog import QSymbolAttrEditorDialog
23

  
24
        return (self.AttributeType in [key for key,value in QSymbolAttrEditorDialog.SYMBOL_ATTR_DATA_TYPES.items() if value == -1])
25

  
26
    def match_type(self, item):
27
        """ check if given item's attribute type matches """
28

  
29
        from EngineeringAbstractItem import QEngineeringAbstractItem
30
        from SymbolSvgItem import SymbolSvgItem
31
        from EngineeringLineItem import QEngineeringLineItem
32

  
33
        if self.AttributeType == 'Comp Item':
34
            return issubclass(type(item), SymbolSvgItem) or type(item) is QEngineeringLineItem
35
        elif self.AttributeType == QEngineeringAbstractItem.assoc_type(item):
36
            return True
37

  
38
        return False
39

  
40
    def parse_xml(self, node):
41
        """ parse xml node for property """
42
        import uuid
43
        
44
        self.UID = uuid.UUID(node.attrib['UID'])
45
        self.Attribute = node.attrib['Attribute']
46
        self.AttributeType = node.attrib['AttributeType']
47
        self.DisplayAttribute = node.attrib['DisplayAttribute']
48
        self.Expression = node.attrib['Expression']
49
        self.Length = node.attrib['Length']
50

  
51
    def toXml(self):
52
        """ generate xml code for symbol property """
53
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
54

  
55
        node = Element('PROPERTY')
56
        node.attrib['UID'] = str(self.UID) if self.UID else ''
57
        node.attrib['Attribute'] = self.Attribute if self.Attribute is not None else ''
58
        node.attrib['AttributeType'] = self.AttributeType if self.AttributeType is not None else ''
59
        node.attrib['DisplayAttribute'] = self.DisplayAttribute if self.DisplayAttribute else ''
60
        node.attrib['Expression'] = self.Expression if self.Expression else ''
61
        node.attrib['Length'] = str(self.Length) if self.Length else ''
62

  
63
        return node
64

  
65
class SymbolAttr(SymbolProp):
66
    """ This is symbol attribute class """
10 67
    def __init__(self):
68
        SymbolProp.__init__(self, None, None, None)
69

  
11 70
        self.UID = None
12 71
        self.Attribute = None
13 72
        self.DisplayAttribute = None
......
16 75
        self.Expression = None
17 76
        self.Length = None
18 77

  
19
    @property
20
    def is_selectable(self):
21
        """
22
        return if attribute is selectable
23
        """
24
        from SymbolAttrEditorDialog import QSymbolAttrEditorDialog
25

  
26
        return (self.AttributeType in [key for key,value in QSymbolAttrEditorDialog.SYMBOL_ATTR_DATA_TYPES.items() if value == -1])
27

  
28 78
    @staticmethod
29 79
    def fromXml(node):
30
        """
31
        generate SymbolAttr instance from xml node
32
        """
80
        """ generate SymbolAttr instance from xml node """
81
        import uuid
33 82

  
34 83
        attr = SymbolAttr()
35
        attr.UID = node.attrib['UID']
84
        attr.UID = uuid.UUID(node.attrib['UID'])
36 85
        attr.Attribute = node.attrib['Attribute']
37 86
        attr.DisplayAttribute = node.attrib['DisplayAttribute']
38 87
        attr.AttributeType = node.attrib['AttributeType']
......
43 92
        return attr
44 93

  
45 94
    def toXml(self):
46
        """
47
        generate xml code for symbol attribute
48
        """
95
        """ generate xml code for symbol attribute """
49 96
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
50 97

  
51 98
        node = Element('ATTRIBUTE')
......
57 104
        node.attrib['Expression'] = self.Expression if self.Expression is not None else ''
58 105
        node.attrib['Length'] = str(self.Length) if self.Length is not None else ''
59 106

  
60
        return node
107
        return node

내보내기 Unified diff

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