프로젝트

일반

사용자정보

개정판 d1576bff

IDd1576bffe777665dad0295c9139cd26bc77d1ac1
상위 1f45633d
하위 667d66ee, f90c018b

김정우 이(가) 6년 이상 전에 추가함

QResultTreeWidget 에서 라인넘버 색상 변경하도록 수정 / 라인넘버 색상 수정 시 하위 심볼 색상 변경

차이점 보기:

DTI_PID/DTI_PID/QResultTreeWidget.py
24 24
    noteNoSingleClicked = pyqtSignal(str, list)
25 25
    lineNoSingleClicked = pyqtSignal(QEngineeringLineNoTextItem)
26 26

  
27
    '''
28
        @history    2018.05.11  Jeongwoo    Add Context Menu settings
29
    '''
27 30
    def __init__(self, imageViewer):
28 31
        QTreeWidget.__init__(self)
29 32
        self.itemClicked.connect(self.itemClickEvent)
30 33
        self.imageViewer = imageViewer
31 34
        self.scene = imageViewer.scene
32 35
        self.root = None
36
        self.setContextMenuPolicy(Qt.CustomContextMenu)
37
        self.customContextMenuRequested.connect(self.openContextMenu)
38
            
39
    '''
40
        @brief      Show Context Menu
41
        @author     Jeongwoo
42
        @date       18.05.11
43
    '''
44
    def openContextMenu(self, position):
45
        indexes = self.selectedIndexes()
46
        itemPosition = self.mapTo(self, position)
47
        item = self.itemAt(itemPosition)
48
        data = item.data(0, self.TREE_DATA_ROLE)
49
        if len(indexes) > 0 and data is not None and type(data) is QEngineeringLineNoTextItem:
50
            index = indexes[0]
51
            menu = QMenu()
52
            pickColorAction = QAction(self.tr("Pick Color"))
53
            pickColorAction.triggered.connect(lambda : self.pickColorClickEvent(item))
54
            menu.addAction(pickColorAction)
55
            menu.exec_(self.viewport().mapToGlobal(position))
56

  
57
    '''
58
        @brief      Pick Color for Line No
59
        @author     Jeongwoo
60
        @date       18.05.11
61
    '''
62
    def pickColorClickEvent(self, lineNoTreeWidgetItem):
63
        ''''''
64
        color = QColorDialog.getColor() # Dialog returns QColor
65
        
66
        if color is not None:
67
            lineNoTreeWidgetItem.setForeground(0, QBrush(color))
68
            lineNoTreeWidgetItem.setFont(0, lineNoTreeWidgetItem.font(0))
69
            lineNoItem = lineNoTreeWidgetItem.data(0, self.TREE_DATA_ROLE)
70
            lineNoItem.setColor(color.name())
71
            connectedItems = lineNoItem.getConnectedItems()
72
            if connectedItems is not None:
73
                for connectedItem in connectedItems:
74
                    connectedItem.setColor(color.name())
75
                for index in range(lineNoTreeWidgetItem.childCount()):
76
                    child = lineNoTreeWidgetItem.child(index)
77
                    child.setForeground(0, QBrush(color))
78
                    child.setFont(0, lineNoTreeWidgetItem.font(0))
33 79

  
34 80
    '''
35 81
        @brief      Clear TreeWidget and Set Current PID
......
53 99
                    Jeongwoo 2018.04.26 QEngineeringTextItem → QEngineeringLineNoTextItem
54 100
                                        Insert if-statement for QEngineeringNoteItem
55 101
                                        Add if-statement for QEngineeringLineNoTextItem
102
                    Jeongwoo 2018.05.11 Set color when SymbolSvgItem moved into new parent(Line No)
56 103
    '''
57 104
    def addTreeItem(self, parent, child):
58 105
        item = None
......
91 138
                    data = item.data(0, self.TREE_DATA_ROLE)
92 139
                    if data is not None and (data == child) and (parent is not item.parent()):
93 140
                        item.parent().removeChild(item)
141
                        brush = parent.foreground(0)
142
                        item.setForeground(0, brush)
143
                        item.data(0, self.TREE_DATA_ROLE).setColor(brush.color().name())
144
                        item.setFont(0, item.font(0))
94 145
                        parent.addChild(item)
95 146
                        break
96 147
        elif type(child) is QEngineeringLineNoTextItem:
DTI_PID/DTI_PID/Shapes/QEngineeringAbstractItem.py
1
from PyQt5.QtCore import pyqtSignal, QObject
2

  
3
class QEngineeringAbstractItem(QObject):
4
    def __init__():
5
        super(QEngineeringAbstractItem, self).__init__()
6

  
7
    '''
8
        @brief      Abstract method. Variable [color] is RGB hex code
9
        @author     Jeongwoo
10
        @date       2018.05.11
11
    '''
12
    def setColor(self, color):
13
        raise NotImplementedError
14

  
15
    def getColor(self):
16
        raise NotImplementedError
DTI_PID/DTI_PID/Shapes/QEngineeringConnectorItem.py
72 72
        rect = self.sceneBoundingRect()
73 73
        self.setRect(rect.center().x() - round(self.SMALL_SIZE*0.5), rect.center().y() - round(self.SMALL_SIZE*0.5), self.SMALL_SIZE, self.SMALL_SIZE)
74 74
        self.setBrush(Qt.blue)
75
        self.update()
75
        self.update()
DTI_PID/DTI_PID/Shapes/QEngineeringFlowArrowItem.py
2 2
import copy
3 3
try:
4 4
    from PyQt5.QtCore import Qt, QRectF, pyqtSignal, QPointF, QT_VERSION_STR
5
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QPolygonF
5
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QPolygonF, QColor
6 6
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsPathItem
7 7
except ImportError:
8 8
    try:
9 9
        from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR
10
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog
10
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QColor
11 11
    except ImportError:
12 12
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
13
import QEngineeringAbstractItem
13 14

  
14
class QEngineeringFlowArrowItem(QGraphicsPathItem):
15
class QEngineeringFlowArrowItem(QGraphicsPathItem, QEngineeringAbstractItem.QEngineeringAbstractItem):
15 16
    SIZE = 40
16 17

  
17 18
    def __init__(self, pt, dir, parent=None):
......
67 68
        poly.append(poly[0])
68 69
        self._path.addPolygon(poly)
69 70
        self.setPath(self._path)
70
        self.isCreated = True
71
        self.isCreated = True
72
        
73
    '''
74
        @brief      Set Color. Override QEngineeringAbstractItem's
75
        @author     Jeongwoo
76
        @date       2018.05.11
77
    '''
78
    def setColor(self, color):
79
        brush = self.brush()
80
        brush.setColor(QColor(color))
81
        self.setBrush(brush)
82
        self.update(self.boundingRect())
83
        pass
84

  
85
    def getColor(self):
86
        return self.brush().color().name()
DTI_PID/DTI_PID/Shapes/QEngineeringInstrumentItem.py
223 223

  
224 224
            owner.append(attrNode) 
225 225
        except Exception as ex:
226
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
226
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
DTI_PID/DTI_PID/Shapes/QEngineeringLineItem.py
407 407
        except Exception as ex:
408 408
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
409 409

  
410
        return node
410
        return node
DTI_PID/DTI_PID/Shapes/QEngineeringTextItem.py
4 4
import sys
5 5
try:
6 6
    from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect
7
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont
7
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont, QColor
8 8
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem
9 9
except ImportError:
10 10
    try:
11 11
        from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect
12
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QFont
12
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QFont, QColor
13 13
    except ImportError:
14 14
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
15 15

  
......
17 17
from QGraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
18 18
import QOcrResultDialog
19 19
from AppDocData import AppDocData
20
import QEngineeringAbstractItem
20 21

  
21
class QEngineeringTextItem(QGraphicsTextItem):
22
class QEngineeringTextItem(QGraphicsTextItem, QEngineeringAbstractItem.QEngineeringAbstractItem):
22 23
    removed = pyqtSignal(QGraphicsItem)
23 24

  
24 25
    def __init__(self, parent=None):
......
288 289
        except Exception as ex:
289 290
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
290 291

  
291
        return node 
292
        return node 
293
    
294
    '''
295
        @brief      Set Color. Override QEngineeringAbstractItem's
296
        @author     Jeongwoo
297
        @date       2018.05.11
298
    '''
299
    def setColor(self, color):
300
        c = QColor()
301
        c.setNamedColor(color)
302
        self.setDefaultTextColor(c)
303
        pass
304

  
305
    def getColor(self):
306
        return self.defaultTextColor().name()
DTI_PID/DTI_PID/Shapes/QGraphicsPolylineItem.py
2 2
import copy
3 3
try:
4 4
    from PyQt5.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR
5
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QPolygonF
5
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QPolygonF, QColor
6 6
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsPathItem
7 7
except ImportError:
8 8
    try:
9 9
        from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR
10
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog
10
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QColor
11 11
    except ImportError:
12 12
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
13
import QEngineeringAbstractItem
13 14

  
14
class QGraphicsPolylineItem(QGraphicsPathItem):
15
class QGraphicsPolylineItem(QGraphicsPathItem, QEngineeringAbstractItem.QEngineeringAbstractItem):
16
    '''
17
        @history    2018.05.11  Jeongwoo    Declare variable self.pen
18
    '''
15 19
    def __init__(self, parent=None):
16 20
        import uuid
17 21

  
......
24 28
        self._pt = None
25 29
        self._pol = QPolygonF()
26 30
        self._path = None
31
        self.pen = QPen(Qt.blue, 5, Qt.SolidLine)
27 32

  
28 33
    '''
29 34
        @brief  construct a polyline
......
83 88

  
84 89
    '''
85 90
        @brief  paint
91
        @history    2018.05.11  Jeongwoo Change variable pen → self.pen
86 92
    '''
87 93
    def paint(self, painter, options=None, widget=None):
88 94
        if self.isCreated:
89 95
            QGraphicsPathItem.paint(self, painter, options, widget)
90 96
        elif len(self._vertices) > 0:
91
            pen = QPen(Qt.blue, 5, Qt.SolidLine)
92
            painter.setPen(pen)
97
            painter.setPen(self.pen)
93 98
            for i in range(len(self._vertices)-1):
94 99
                painter.drawLine(self._vertices[i][0], self._vertices[i][1], self._vertices[i+1][0], self._vertices[i+1][1])
95 100
            if self._pt is not None:
......
99 104
        if self.isSelected:
100 105
            rect = self.boundingRect()
101 106
            painter.drawRect(rect.left(), rect.top(), rect.width(), rect.height())
102
        '''
107
        '''
108

  
109
    '''
110
        @brief      Set Color. Override QEngineeringAbstractItem's
111
        @author     Jeongwoo
112
        @date       2018.05.11
113
    '''
114
    def setColor(self, color):
115
        c = QColor()
116
        c.setNamedColor(color)
117
        self.pen.setColor(c)
118
        self.update(self.boundingRect())
119
        pass
120

  
121
    def getColor(self):
122
        return self.pen.color().name()
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
11 11
from PyQt5.QtXml import *
12 12

  
13 13
from QEngineeringConnectorItem import QEngineeringConnectorItem
14
import QEngineeringAbstractItem
14 15

  
15
class SymbolSvgItem(QGraphicsSvgItem):
16
class SymbolSvgItem(QGraphicsSvgItem, QEngineeringAbstractItem.QEngineeringAbstractItem):
16 17
    clicked = pyqtSignal(QGraphicsSvgItem)
17 18
    removed = pyqtSignal(QGraphicsItem)
18 19

  
19 20
    '''
20 21
        @history    18.04.11    Jeongwoo    Add Variable (Name, Type)
22
                    18.05.11    Jeongwoo    Declare variable self.color
21 23
    '''
22 24
    def __init__(self, path):
23 25
        import uuid
......
30 32
        self.uid = uuid.uuid4() # generate UUID
31 33
        self.name = ''
32 34
        self.type = ''
35
        self.color = '#0000FF'
33 36
        self.angle = 0
34 37
        self.origin = None
35 38
        self.loc = None
......
359 362
        @brief  change svg's color
360 363
        @author humkyung
361 364
        @date   2018.05.10
365
        @history    2018.05.11  Jeongwoo    Override QEngineeringAbstractItem's
362 366
    '''
363 367
    def setColor(self, color):
368
        self.color = color
364 369
        self.changeAttributes('fill', color)
365 370
        self.changeAttributes('stroke', color)
366 371
        self.renderer().load(self._document.toByteArray())
367 372

  
373
    def getColor(self):
374
        return self.color
375

  
368 376
    '''
369 377
        @brief  change attributes
370 378
        @author humkyung

내보내기 Unified diff

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