개정판 5b782afc
QResultTreeWidget의 아이템 색상이 각 아이템의 데이터 색상으로 구성되도록 수정 / LineNoTextItem 설정 시 연결된 데이터들의 색상을 수정하도록 적용
DTI_PID/DTI_PID/QResultTreeWidget.py | ||
---|---|---|
105 | 105 |
@brief create tree item for pipe run if need |
106 | 106 |
@author humkyung |
107 | 107 |
@date 2018.05.15 |
108 |
@history 2018.05.17 Jeongwoo Change run item color with parent(LineNo Item) color |
|
108 | 109 |
''' |
109 | 110 |
def addPipeRunTreeItemIfNeed(self, lineNoTreeItem, pipeRun): |
110 | 111 |
for index in range(lineNoTreeItem.childCount()): |
... | ... | |
115 | 116 | |
116 | 117 |
runItem = QTreeWidgetItem(['RUNS {}'.format(lineNoTreeItem.childCount()+1)]) |
117 | 118 |
runItem.setData(0, self.TREE_DATA_ROLE, pipeRun.uid) |
119 | ||
120 |
brush = lineNoTreeItem.foreground(0) |
|
121 |
runItem.setForeground(0, brush) |
|
122 |
runItem.setFont(0, runItem.font(0)) |
|
123 | ||
118 | 124 |
lineNoTreeItem.addChild(runItem) |
119 | 125 | |
120 | 126 |
return runItem |
... | ... | |
129 | 135 |
Add if-statement for QEngineeringLineNoTextItem |
130 | 136 |
Jeongwoo 2018.05.11 Set color when SymbolSvgItem moved into new parent(Line No) |
131 | 137 |
Jeongwoo 2018.05.15 Add break keyword on if-statement |
138 |
Jeongwoo 2018.05.17 Set TreeWidgetItem's color with data's color And Set Data's color on LineNoTextItem Setting |
|
132 | 139 |
''' |
133 | 140 |
def addTreeItem(self, parent, child): |
134 | 141 |
item = None |
... | ... | |
145 | 152 |
iconPath = os.path.join(AppDocData.instance().getCurrentProject().getSvgFilePath(), child.type , child.name + ".svg") |
146 | 153 |
item.setIcon(0, QIcon(iconPath)) |
147 | 154 |
item.setData(0, self.TREE_DATA_ROLE, child) |
155 |
brush = QBrush() |
|
156 |
brush.setColor(QColor(child.getColor())) |
|
157 |
item.setForeground(0, brush) |
|
158 |
item.setFont(0, item.font(0)) |
|
148 | 159 |
child.treeItem = item |
149 | 160 |
symbolsRootItem.addChild(item) |
150 | 161 |
elif type(child) is QEngineeringLineNoTextItem: |
... | ... | |
152 | 163 |
item.setFlags(item.flags() | Qt.ItemIsUserCheckable) |
153 | 164 |
item.setData(0, self.TREE_DATA_ROLE, child) |
154 | 165 |
item.setCheckState(0, Qt.Unchecked) |
166 |
brush = QBrush() |
|
167 |
brush.setColor(QColor(child.getColor())) |
|
168 |
item.setForeground(0, brush) |
|
169 |
item.setFont(0, item.font(0)) |
|
155 | 170 |
child.treeItem = item |
156 | 171 |
self.root.insertChild(0, item) |
157 | 172 |
elif (type(child) is QEngineeringNoteItem): |
... | ... | |
173 | 188 |
if data in runGroup.items: |
174 | 189 |
item.parent().removeChild(item) # remove item from original parent |
175 | 190 |
runItem = self.addPipeRunTreeItemIfNeed(parent, runGroup) #parent.child(index) |
176 |
brush = parent.foreground(0) |
|
191 |
brush = QBrush() |
|
192 |
brush.setColor(QColor(item.data(0, self.TREE_DATA_ROLE).getColor())) |
|
177 | 193 |
item.setForeground(0, brush) |
178 |
item.data(0, self.TREE_DATA_ROLE).setColor(brush.color().name()) |
|
194 |
#item.data(0, self.TREE_DATA_ROLE).setColor(brush.color().name())
|
|
179 | 195 |
item.setFont(0, item.font(0)) |
180 | 196 |
runItem.addChild(item) |
181 | 197 |
break |
... | ... | |
188 | 204 |
for item in foundItems: |
189 | 205 |
data = item.data(0, self.TREE_DATA_ROLE) |
190 | 206 |
if data is not None and (data == child): |
191 |
#for index in range(len(data.runs)): |
|
192 |
# item.addChild(QTreeWidgetItem(['RUNS' + str(index+1)])) |
|
207 |
connectedItems = data.getConnectedItems() |
|
208 |
color = data.getColor() |
|
209 |
for connectedItem in connectedItems: |
|
210 |
connectedItem.setColor(color) |
|
193 | 211 |
return item |
194 | 212 | |
195 | 213 |
return item |
DTI_PID/DTI_PID/Shapes/QEngineeringAbstractItem.py | ||
---|---|---|
6 | 6 |
class QEngineeringAbstractItem: |
7 | 7 |
''' |
8 | 8 |
@history 2018.05.15 Jeongwoo Remove call super |
9 |
2018.05.17 Jeongwoo Add DEFAULT_COLOR Variable |
|
9 | 10 |
''' |
11 |
DEFAULT_COLOR = '#0000FF' |
|
10 | 12 |
def __init__(self): |
11 |
self._color = '#0000FF' # default color
|
|
13 |
self._color = self.DEFAULT_COLOR # default color
|
|
12 | 14 |
self._owner = None |
13 | 15 | |
14 | 16 |
''' |
DTI_PID/DTI_PID/Shapes/QEngineeringLineItem.py | ||
---|---|---|
49 | 49 |
@brief setter owner |
50 | 50 |
@author humkyung |
51 | 51 |
@date 2018.05.10 |
52 |
@history 2018.05.17 Jeongwoo Add Calling setColor |
|
52 | 53 |
''' |
53 | 54 |
@owner.setter |
54 | 55 |
def owner(self, value): |
55 | 56 |
self._owner = value |
56 | 57 | |
58 |
if self._owner is None: |
|
59 |
self._color = self.DEFAULT_COLOR |
|
60 |
self.setColor(self._color) |
|
61 | ||
57 | 62 |
''' |
58 | 63 |
@brief construct a ProcessLineItem |
59 | 64 |
@author humkyung |
DTI_PID/DTI_PID/Shapes/QEngineeringTextItem.py | ||
---|---|---|
22 | 22 |
class QEngineeringTextItem(QGraphicsTextItem, QEngineeringAbstractItem): |
23 | 23 |
removed = pyqtSignal(QGraphicsItem) |
24 | 24 | |
25 |
''' |
|
26 |
@history 2018.05.17 Jeongwoo Add self._owner variable |
|
27 |
''' |
|
25 | 28 |
def __init__(self, parent=None): |
26 | 29 |
import uuid |
27 | 30 | |
... | ... | |
33 | 36 |
self.size = None |
34 | 37 |
self.angle = 0 # angle in radian |
35 | 38 |
self.conns = [] |
39 |
self._owner = None |
|
36 | 40 |
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable) |
37 | 41 |
self.setAcceptHoverEvents(True) |
38 | 42 |
self.setAcceptTouchEvents(True) |
39 | 43 | |
40 | 44 |
self.setColor(self._color) |
45 |
|
|
46 |
''' |
|
47 |
@brief Get owner |
|
48 |
@author Jeongwoo |
|
49 |
@date 2018.05.17 |
|
50 |
''' |
|
51 |
@property |
|
52 |
def owner(self): |
|
53 |
return self._owner |
|
54 | ||
55 |
''' |
|
56 |
@brief Set owner |
|
57 |
@author Jeongwoo |
|
58 |
@date 2018.05.17 |
|
59 |
@history 2018.05.17 Jeongwoo Add Calling setColor if self._owner is None or not |
|
60 |
''' |
|
61 |
@owner.setter |
|
62 |
def owner(self, value): |
|
63 |
self._owner = value |
|
64 | ||
65 |
if self._owner is None: |
|
66 |
self._color = self.DEFAULT_COLOR |
|
67 |
self.setColor(self._color) |
|
41 | 68 | |
42 | 69 |
''' |
43 | 70 |
@brief return text string |
... | ... | |
307 | 334 |
c = QColor() |
308 | 335 |
c.setNamedColor(color) |
309 | 336 |
self.setDefaultTextColor(c) |
310 |
self.update() |
|
337 |
self.update() |
|
338 | ||
339 |
def getColor(self): |
|
340 |
return self._color |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
71 | 71 |
@brief setter owner |
72 | 72 |
@author humkyung |
73 | 73 |
@date 2018.05.10 |
74 |
@history 2018.05.17 Jeongwoo Add Calling setColor if self._owner is None or not |
|
74 | 75 |
''' |
75 | 76 |
@owner.setter |
76 | 77 |
def owner(self, value): |
77 | 78 |
self._owner = value |
78 | 79 | |
80 |
if self._owner is None: |
|
81 |
self._color = self.DEFAULT_COLOR |
|
79 | 82 |
self.setColor(self._color) |
80 | 83 | |
81 | 84 |
''' |
... | ... | |
263 | 266 |
@brief remove item when user press delete key |
264 | 267 |
@author humkyung |
265 | 268 |
@date 2018.04.23 |
269 |
@history 2018.05.17 Jeongwoo Add if-statement and move 'break' |
|
266 | 270 |
''' |
267 | 271 |
def keyPressEvent(self, event): |
268 | 272 |
if event.key() == Qt.Key_Delete: |
269 | 273 |
for conn in self.conns: |
270 |
conn.removeSymbol(self) |
|
271 |
break |
|
274 |
if conn is not None: |
|
275 |
conn.removeSymbol(self) |
|
276 |
break |
|
272 | 277 | |
273 | 278 |
self.removed.emit(self) |
274 | 279 |
self.scene().removeItem(self) |
... | ... | |
396 | 401 |
self.update() |
397 | 402 | |
398 | 403 |
''' |
404 |
@brief Get Color code |
|
405 |
@author Jeongwoo |
|
406 |
@date 2018.05.17 |
|
407 |
''' |
|
408 |
def getColor(self): |
|
409 |
return self._color |
|
410 | ||
411 |
''' |
|
399 | 412 |
@brief change attributes |
400 | 413 |
@author humkyung |
401 | 414 |
@date 2018.05.10 |
내보내기 Unified diff