프로젝트

일반

사용자정보

개정판 7caf7034

ID7caf7034718f152cf441f281c82a5ff31bc249a4
상위 828c3d53
하위 d7582878

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

issue #481: 라인 넘버 별로 On/Off 할 수 있다

Change-Id: I81985062683cb52f8480cf88549ee6ba18876390

차이점 보기:

DTI_PID/DTI_PID/ItemTreeWidget.py
28 28
from AppDocData import AppDocData
29 29
from Drawing import Drawing
30 30

  
31
class CustomTreeWidgetItem(QTreeWidgetItem):
32
    def __init__(self, *args, **kwargs):
33
        super(CustomTreeWidgetItem, self).__init__(*args, **kwargs)
34

  
35
    def setData(self, column, role, value):
36
        if role == Qt.EditRole:
37
            pass
38
        elif role == Qt.CheckStateRole:
39
            if self.treeWidget() is not None:
40
                state = Qt.CheckState.Unchecked if value is 0 else Qt.CheckState.Checked
41
                self.treeWidget().checkBoxToggled.emit(self, state)
42

  
43
        super(CustomTreeWidgetItem, self).setData(column, role, value)
44

  
31 45
class QItemTreeWidget(QTreeWidget):
32 46
    TREE_DATA_ROLE = Qt.UserRole
33 47

  
......
36 50
    noteNoSingleClicked = pyqtSignal(str, dict)
37 51
    lineNoSingleClicked = pyqtSignal(QEngineeringAbstractItem)
38 52
    drawingClicked = pyqtSignal(Drawing)
53
    checkBoxToggled = pyqtSignal(QTreeWidgetItem, Qt.CheckState)
39 54

  
40 55
    '''
41 56
        @history    2018.05.11  Jeongwoo    Add Context Menu settings
42 57
    '''
43 58
    def __init__(self, imageViewer):
44 59
        QTreeWidget.__init__(self)
60

  
61
        self.checkBoxToggled.connect(self.itemCheckBoxToggled)
62

  
45 63
        self.itemClicked.connect(self.itemClickEvent)
46 64
        self.imageViewer = imageViewer
47 65
        self.scene = imageViewer.scene
......
265 283
                    item = QTreeWidgetItem(self.SymbolsTreeItem, [child.name])
266 284
                
267 285
                if item is not None:
268
                    #if type(child) is QEngineeringErrorItem:
269
                    #    iconPath = appDocData.getErrorItemSvgPath()
270
                    #else:
271
                        #iconPath = os.path.join(AppDocData.instance().getCurrentProject().getSvgFilePath(), child.type , child.name + ".svg")
272 286
                    iconPath = os.path.join(AppDocData.instance().getCurrentProject().getSvgFilePath(), child.type , child.name + ".svg")
273 287
                    item.setIcon(0, QIcon(iconPath))
274 288
                    item.setData(0, self.TREE_DATA_ROLE, child)
......
280 294
                    self.SymbolsTreeItem.addChild(item)
281 295
                    self.SymbolsTreeItem.sortChildren(0, Qt.AscendingOrder)  # sort childrens
282 296
            elif type(child) is QEngineeringLineNoTextItem:
283
                item = QTreeWidgetItem([child.text()])
297
                item = CustomTreeWidgetItem([child.text()])
284 298
                item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
285 299
                item.setData(0, self.TREE_DATA_ROLE, child)
286
                item.setCheckState(0, Qt.Unchecked)
300
                item.setCheckState(0, Qt.Checked if child.isVisible() else Qt.Unchecked)
287 301
                brush = QBrush()
288 302
                brush.setColor(QColor(child.getColor()))
289 303
                item.setForeground(0, brush)
......
291 305
                child.treeItem = item
292 306
                self.LineNoTreeItem.addChild(item)
293 307
            elif type(child) is QEngineeringTrimLineNoTextItem:
294
                item = QTreeWidgetItem(['Trim Line'])
308
                item = CustomTreeWidgetItem(['Trim Line'])
295 309
                item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
296 310
                item.setData(0, self.TREE_DATA_ROLE, child)
297
                item.setCheckState(0, Qt.Unchecked)
311
                item.setCheckState(0, Qt.Checked if child.isVisible() else Qt.Unchecked)
298 312
                brush = QBrush()
299 313
                brush.setColor(QColor(child.getColor()))
300 314
                item.setForeground(0, brush)
......
409 423

  
410 424
        self.expandAll()
411 425
        
426
    def itemCheckBoxToggled(self, item, checkState):
427
        """
428
        set visible of invisible of item
429
        """
430
        try:
431
            itemData = item.data(0, self.TREE_DATA_ROLE)   
432
            if (type(itemData) is QEngineeringLineNoTextItem) or (type(itemData) is QEngineeringTrimLineNoTextItem):
433
                itemData.setVisible(checkState == Qt.CheckState.Checked)
434
        except Exception as ex:
435
            from App import App
436
            from AppDocData import MessageType
437

  
438
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
439
            App.mainWnd().addMessage.emit(MessageType.Error, message)
440
        finally:
441
            pass
442

  
412 443
    '''
413 444
        @brief      TreeWidget Item click listener
414 445
        @author     Jeongwoo
......
445 476
                self.singleClicked.emit(itemData)
446 477
            elif (type(itemData) is QEngineeringLineNoTextItem) or (type(itemData) is QEngineeringRunItem):
447 478
                HighlightCommand(self.imageViewer).execute(itemData)
448
                '''
449
                if type(itemData) is QEngineeringLineNoTextItem:
450
                    rect = itemData.sceneBoundingRect()
451
                    if isSvgClick == False:
452
                        self.imageViewer.centerOn(rect.center())
453
                    ## Send new event to imageViewer's zoomImage Method
454
                    self.imageViewer.zoomImage(True, QMouseEvent(QEvent.MouseButtonPress, self.imageViewer.mapFromScene(QPointF(rect.left(), rect.top())), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier), 3)
455
                else:
456
                    pass
457
                '''
458

  
459 479
                self.lineNoSingleClicked.emit(itemData)
460 480
                item.setSelected(True)
461 481
            elif type(itemData) is list and type(itemData[0]) is QEngineeringNoteItem:
......
472 492
                self.noteNoSingleClicked.emit(itemData[0].text(), noteContentsList)
473 493
            elif type(itemData) is QEngineeringUnknownItem:
474 494
                HighlightCommand(self.imageViewer).execute(itemData)
475
                '''
476
                rect = itemData.sceneBoundingRect()
477
                self.imageViewer.centerOn(rect.center())
478
                self.imageViewer.zoomImage(True, QMouseEvent(QEvent.MouseButtonPress, self.imageViewer.mapFromScene(QPointF(rect.left(), rect.top())), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier), 3)
479
                '''
480 495
            elif type(itemData) is Drawing:
481 496
                self.drawingClicked.emit(itemData)
482 497
                
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
33 33
        QEngineeringTextItem.__init__(self, uid, parent)
34 34
        self._runs = []
35 35

  
36
    def setVisible(self, visible):
37
        """
38
        override visible value
39
        """
40
        super(QEngineeringTextItem, self).setVisible(visible)
41
        for run in self.runs:
42
            run.visible = visible
43

  
36 44
    '''
37 45
        @brief  getter of runs
38 46
        @author humkyung
DTI_PID/DTI_PID/Shapes/EngineeringRunItem.py
21 21

  
22 22
        self.uid = uuid.uuid4() # generate UUID
23 23
        self._items = []
24
        self._visible = False
25

  
26
    @property
27
    def visible(self):
28
        """
29
        return visible
30
        """
31
        return self._visible
32

  
33
    @visible.setter
34
    def visible(self, value):
35
        """
36
        set visible value
37
        """
38
        self._visible = value
39
        for item in self.items:
40
            if issubclass(type(item), QGraphicsItem):
41
                item.setVisible(value)
24 42

  
25 43
    '''
26 44
        @brief  getter of items
DTI_PID/DTI_PID/Shapes/QEngineeringTrimLineNoTextItem.py
1 1
# coding: utf-8
2
"""
3
This is engineering trim line no text item module
4
"""
5

  
2 6
import os.path
3 7
import sys
4 8
import copy
......
20 24
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
21 25

  
22 26
class QEngineeringTrimLineNoTextItem(QEngineeringLineNoTextItem):
27
    """
28
    This is engineering trim line no text item class
29
    """
23 30

  
24 31
    '''
25 32
    '''
......
30 37
        self.loc = (0, 0)
31 38
        self.size = (1, 1)
32 39
        self.angle = 0
33
        self.setPlainText('Trim Line')
34
        self.setVisible(False)
40
        self.setPlainText('')
41
        self.setVisible(True)
35 42

  
36 43
    '''
37 44
        @brief      generate xml code

내보내기 Unified diff

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