프로젝트

일반

사용자정보

개정판 5953ddc1

ID5953ddc1e1c670bd3ea6dd019bf65c9af7242c1f
상위 337be753
하위 357646b0

gaqhf 이(가) 6년 이상 전에 추가함

dev issue #640: symbol의 attrs type(tuple) 추가(attributeType의 경우 tuple로 attrs 추가)

차이점 보기:

DTI_PID/DTI_PID/Commands/SelectAttributeCommand.py
22 22
        super(SelectAttributeCommand, self).__init__(imageViewer)
23 23
        self.name = 'SelectAttribute'
24 24
        self.imageViewer.setCursor(QCursor(Qt.ArrowCursor))
25
        
25
        self._type = None
26 26
        self.resultItem = None
27 27
    '''
28 28
        @brief      Select Attribuew
......
34 34
        scenePos = param[2]
35 35

  
36 36
        if 'mouseReleaseEvent' == param[0] and event.button() == Qt.LeftButton:
37
            result = self.findTextItemInPoint(scenePos)
38
            if result[0]:
39
                self.resultItem = result[1]
37
            if self._type is not None:
38
                result = []
39
                if self._type == 'Text Item':
40
                    result = self.findTextItemInPoint(scenePos)
41
                elif self._type == 'Symbol Item':
42
                    result = self.findSymbolItemInPoint(scenePos)
43

  
44
                
45
                if result[0]:
46
                    self.resultItem = result[1]
40 47

  
41 48
        self.isTreated = True
42 49

  
50
    def setType(self, _type):
51
        self._type = _type
52

  
43 53
    def undo(self):
44 54
        pass
45 55

  
......
62 72
        return (False,)
63 73

  
64 74
    '''
75
        @brief      Find Symbol Item contain Point
76
        @author     kyouho
77
        @date       18.07.19
78
    '''
79
    def findSymbolItemInPoint(self, point):
80
        from SymbolSvgItem import SymbolSvgItem
81
        
82
        for item in self.imageViewer.items():
83
            if issubclass(type(item), SymbolSvgItem):
84
                if self.isOverlapItemAndPoint(item, point):
85
                    return (True, item)
86

  
87
        return (False,)
88

  
89
    '''
65 90
        @brief      Check Overlap
66 91
        @author     kyouho
67 92
        @date       18.07.17
DTI_PID/DTI_PID/ItemPropertyTableWidget.py
14 14
import os
15 15
import sys
16 16
import math
17
import re
17 18
from SymbolSvgItem import SymbolSvgItem
18 19
from QEngineeringLineNoTextItem import QEngineeringLineNoTextItem
19 20
from EngineeringLineItem import QEngineeringLineItem
20 21
from QEngineeringNoteItem import QEngineeringNoteItem
22
from EngineeringTextItem import QEngineeringTextItem
21 23
from AppDocData import *
22 24
from Drawing import Drawing
23 25
from enum import Enum
......
41 43
        self.mainWindow = mainWindow
42 44

  
43 45
        self.attrValueList = []
46
        self.intCell = []
47
        self.stringCell = []
48

  
49
        self.cellChanged.connect(self.cellChangedEvent)
44 50
    '''
45 51
        @brief  show item's property
46 52
        @author humkyung
......
254 260
        from QEngineeringInstrumentItem import QEngineeringInstrumentItem
255 261
        
256 262
        self.attrValueList = []
263
        self.intCell = []
264
        self.stringCell = []
257 265

  
258 266
        if self.symData is not None:
259 267

  
......
279 287
                    valueItem = QTableWidgetItem(value)
280 288
                    if docData.checkAttribute(key):
281 289
                        attrType = docData.getSymbolAttributeByUID(key)
282
                        if attrType[2] == 'Text Item':
290
                        if attrType[2] == 'Text Item' or attrType[2] == 'Symbol Item':
283 291
                            from PyQt5 import QtGui
284 292
                            icon = QtGui.QIcon()
285 293
                            icon.addPixmap(QtGui.QPixmap(":/newPrefix/doubleclick.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
286 294
                            valueItem.setIcon(icon)
287
                        
295
                        elif attrType[2] == 'Int':
296
                            self.intCell.append(valueItem)
297
                        elif attrType[2] == 'String':
298
                            self.stringCell.append(valueItem)
299

  
300
                        if attrType[2] == 'Text Item':
301
                            textItem = self.findTextItemFromUID(value)
302
                            if textItem is not None:
303
                                valueItem.setText(textItem.text())
288 304
                        self.attrValueList.append((valueItem, key))
289 305
                        keyText = docData.getSymbolAttributeByUID(key)
290 306
                        if keyText is not None:
291 307
                            keyItem.setText(keyText[1])
292 308
                            self.setItem(row, 0, keyItem)
309

  
310

  
293 311
                    else:
294 312
                        self.setItem(row, 0, keyItem)
295 313

  
......
314 332
        else:
315 333
            self.setRowCount(0)
316 334

  
335
    def findTextItemFromUID(self, uid):
336
        items = [item for item in self.mainWindow.graphicsView.scene.items() if issubclass(type(item), QEngineeringTextItem)]
337
        for item in items:
338
            if item.uid == uid:
339
                return item
340
        return None
341

  
317 342
    '''
318 343
        @brief      Initialize Note Contents Cell
319 344
        @author     Jeongwoo
......
410 435
                    self.mainWindow.refreshResultPropertyTableWidget()
411 436

  
412 437
    '''
413

  
438
        @brief      int cell check
439
        @author     kyouho
440
        @date       2018.08.20
414 441
    '''
415 442
    def cellChangedEvent(self, row, column):
416
        docData = AppDocData.instance()
443
        cell = self.item(row, column)
444
        for valueCell in self.attrValueList:
445
            if valueCell[0] == cell and (self.intCell.count(cell) or self.stringCell.count(cell)):
446
                typeUID = valueCell[1]
447
                str = ''
448
                if self.intCell.count(cell):
449
                    str = cell.text()
450
                    if not self.isNumber(str):
451
                        str = ''
452
                        cell.setText(str)
453
                elif self.stringCell.count(cell):
454
                    str = cell.text()
455
                
456
                items = self.mainWindow.graphicsView.scene.selectedItems()
457
                if items is not None and len(items) == 1:
458
                    find = False
459
                    for index in range(len(items[0].attrs)):
460
                        if type(items[0].attrs[index]) is tuple and items[0].attrs[index][0] == typeUID:
461
                            items[0].attrs[index] = (typeUID, str)
462
                            find = True
463
                            break
464

  
465
                    if not find:
466
                        items[0].attrs.append((typeUID, str))
467

  
468
                    #attrs = items[0].getAttributes()
469
                    #if list(attrs.keys()).count(typeUID):
470
                    #    items[0].attrs
471
                    #else:
472
                    #    items[0].attrs.append((typeUID, str))
473
                    #for attr in items[0].getAttributes():
474
                    #    if type(attr) is tuple:
475
                    #        print(attr)
476
            
477

  
478
    '''
479
        @brief      Check Number
480
        @author     kyouho
481
        @date       2018.08.20
482
    '''
483
    def isNumber(self, num):
484
        p = re.compile('(^[0-9]+$)')
485
        result = p.match(num)
417 486

  
418
        pass
487
        if result:
488
            return True
489
        else:
490
            return False
DTI_PID/DTI_PID/MainWindow.py
246 246
            if uid is not None:
247 247
                docData = AppDocData.instance()
248 248
                attrType = docData.getSymbolAttributeByUID(uid)
249
                if attrType[2] == 'Text Item':
249
                if attrType[2] == 'Text Item' or attrType[2] == 'Symbol Item':
250 250
                    items = self.graphicsView.scene.selectedItems()
251 251
                    if items is not None and len(items) == 1:
252 252
                        self.graphicsView.command = SelectAttributeCommand.SelectAttributeCommand(self.graphicsView)
253
                        self.graphicsView.command.setType(attrType[2])
253 254
                        cursor = QCursor(Qt.PointingHandCursor)
254 255
                        QApplication.instance().setOverrideCursor(cursor)
255 256
                        self.graphicsView.currentAttribute = uid
DTI_PID/DTI_PID/Shapes/QEngineeringInstrumentItem.py
170 170
                attrs[attr[0]] = ''
171 171

  
172 172
            for attr in self.attrs:
173
                if type(attr) is QEngineeringTextItem:
173
                if type(attr) is QEngineeringTextItem or issubclass(type(attr), SymbolSvgItem):
174 174
                    attrs[attr.attribute] = attr.text()
175
                elif type(attr) is tuple:
176
                    attrs[attr[0]] = attr[1]
175 177
        except Exception as ex:
176 178
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
177 179
        
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
13 13
from AppDocData import *
14 14
from EngineeringConnectorItem import QEngineeringConnectorItem
15 15
from QEngineeringAbstractItem import QEngineeringAbstractItem
16

  
17 16
import SelectAttributeDialog
18 17

  
19 18
class SymbolSvgItem(QGraphicsSvgItem, QEngineeringAbstractItem):
......
49 48
        self.parentSymbol = ''
50 49
        self.childSymbol = ''
51 50
        self.hasInstrumentLabel = 0
51
        # attributeType uid
52
        self.attribute = ''
52 53

  
53 54
        self.setAcceptHoverEvents(True)
54 55
        self.setAcceptedMouseButtons(Qt.LeftButton)
......
268 269
    '''
269 270
    def hoverEnterEvent(self, event):
270 271
        try:
272
            from EngineeringTextItem import QEngineeringTextItem
271 273
            self._savedColor = self.getColor()
272 274
            self.setColor(SymbolSvgItem.HIGHLIGHT)
273 275
            self.currentCursor = int(Qt.OpenHandCursor)
......
276 278
            self.update()
277 279

  
278 280
            for attr in self.attrs:
279
                attr.setDefaultTextColor(Qt.red)
280
                attr.update()
281
                if issubclass(type(attr), QEngineeringTextItem):
282
                    attr.setDefaultTextColor(Qt.red)
283
                    attr.update()
284
                elif issubclass(type(attr), SymbolSvgItem):
285
                    attr._savedColor = attr.getColor()
286
                    attr.setColor(SymbolSvgItem.HIGHLIGHT)
287
                    attr.update()
281 288
        except Exception as ex:
282
            from App import App
283

  
284
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
285
            App.mainWin().addMessage(MessageType.Error, message)
289
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
286 290

  
287 291
    '''
288 292
        @brief      unhighlight connector and attribute
......
291 295
        @history    kyouho 2018.07.18 edit ArrowCursor
292 296
    '''
293 297
    def hoverLeaveEvent(self, event):
298
        from EngineeringTextItem import QEngineeringTextItem
299

  
294 300
        self.setColor(self._savedColor)
295 301
        self.currentCursor = int(Qt.ArrowCursor)
296 302
        cursor = QCursor(Qt.ArrowCursor)
......
298 304
        self.update()
299 305

  
300 306
        for attr in self.attrs:
301
            attr.setDefaultTextColor(Qt.blue)
302
            attr.update()
303

  
307
            if issubclass(type(attr), QEngineeringTextItem):
308
                attr.setDefaultTextColor(Qt.blue)
309
                attr.update()
310
            elif issubclass(type(attr), SymbolSvgItem):
311
                attr.setColor(attr._savedColor)
312
                attr.update()
304 313
    '''
305 314
        @brief  change cursor to CrossCursor if mouse point is close to connection point
306 315
        @author humkyung
......
523 532
            attrs[attr[0]] = ''
524 533

  
525 534
        for attr in self.attrs:
526
            if type(attr) is QEngineeringTextItem:
527
                attrs[attr.attribute] = attr.text()
535
            if type(attr) is QEngineeringTextItem or issubclass(type(attr), SymbolSvgItem):
536
                attrs[attr.attribute] = attr.uid
528 537
            elif type(attr) is QEngineeringInstrumentItem:
529 538
                attrs['Label'] = '{}'.format(attr)
539
            elif type(attr) is tuple:
540
                attrs[attr[0]] = attr[1]
530 541
        
531 542
        return attrs
532 543
    
......
556 567
            nameNode.text = self.name
557 568
            node.append(nameNode)
558 569

  
570
            attributeValueNode = Element('ATTRIBUTEVALUE')
571
            attributeValueNode.text = self.attribute
572
            node.append(attributeValueNode)
573

  
559 574
            typeNode = Element('TYPE')
560 575
            typeNode.text = self.type
561 576
            node.append(typeNode)
......
707 722

  
708 723
                        iterIndex += 1
709 724
                
725
                attributeValue = node.find('ATTRIBUTEVALUE')
726
                if attributeValue is not None:
727
                    item[0].attribute = attributeValue.text
728

  
710 729
                attributes = node.find('SYMBOLATTRIBUTES')
711 730
                if attributes is not None:
712 731
                    for attr in attributes.iter('SYMBOLATTRIBUTE'):

내보내기 Unified diff

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