개정판 ac917e1b
issue #1052: 스트림 라인 생성 시 스트림 넘버 태그 배치 오류 수정
Change-Id: Ia7591b6377da4f884099dca346f973dc394e3fd9
HYTOS/HYTOS/Commands/PlaceStreamlineCommand.py | ||
---|---|---|
49 | 49 |
@date 2018.07.23 |
50 | 50 |
''' |
51 | 51 |
def execute(self, param): |
52 |
import shapely |
|
53 | 52 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
54 |
from SymbolSvgItem import SymbolSvgItem |
|
55 | 53 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
56 | 54 | |
57 | 55 |
self.isTreated = False |
... | ... | |
78 | 76 |
else: |
79 | 77 |
return |
80 | 78 | |
81 |
#QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
|
82 |
connectorItems = [] |
|
83 |
for connectorItem in self.connectorItems: |
|
84 |
connectorItems.append(connectorItem.uid) |
|
85 | ||
79 |
# QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
|
80 |
connectorItems = [conn.uid for conn in self.connectorItems] |
|
86 | 81 |
self._streamline.build_connectors(connectorItems) |
87 | 82 | |
88 |
#self._streamline.build_connectors(self.connectorItems) |
|
83 |
# self._streamline.build_connectors(self.connectorItems)
|
|
89 | 84 |
self._streamline.update() |
90 | 85 |
self.onSuccess.emit() |
91 | 86 |
self.connectorItems.clear() |
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py | ||
---|---|---|
18 | 18 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
19 | 19 |
from EngineeringAbstractItem import QEngineeringAbstractItem |
20 | 20 | |
21 | ||
21 | 22 |
class QEngineeringStreamlineItem(QGraphicsPathItem, QEngineeringAbstractItem): |
22 | 23 |
""" This is EngineeringStreamlineItem Class """ |
23 | 24 | |
... | ... | |
30 | 31 |
2018.05.15 Jeongwoo Change method to call parent's __init__ |
31 | 32 |
2018.05.25 Jeongwoo Change self.pen's default color (red → blue) |
32 | 33 |
''' |
34 | ||
33 | 35 |
def __init__(self, uid=None, parent=None): |
34 | 36 |
import uuid |
35 | 37 |
from EngineeringStreamNoTextItem import QEngineeringStreamNoTextItem |
... | ... | |
37 | 39 |
try: |
38 | 40 |
QGraphicsPathItem.__init__(self, parent) |
39 | 41 |
QEngineeringAbstractItem.__init__(self) |
40 |
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable)
|
|
42 |
self.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable)
|
|
41 | 43 |
self.setAcceptHoverEvents(True) |
42 | 44 |
self.setAcceptTouchEvents(True) |
43 | 45 | |
... | ... | |
46 | 48 |
self._vertices = [] |
47 | 49 |
self.isCreated = False |
48 | 50 |
self._pt = None |
49 |
self.setPen(QPen(Qt.blue, 1, Qt.SolidLine)) # set default pen |
|
50 |
|
|
51 |
self.setPen(QPen(Qt.blue, 1, Qt.SolidLine)) # set default pen
|
|
52 | ||
51 | 53 |
self._stream_no = 0 |
52 | 54 |
self._stream_no_text = None |
53 | 55 | |
... | ... | |
56 | 58 |
except Exception as ex: |
57 | 59 |
from App import App |
58 | 60 |
from AppDocData import MessageType |
59 |
|
|
60 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
61 | ||
62 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
63 |
sys.exc_info()[-1].tb_lineno) |
|
61 | 64 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
62 | 65 | |
63 | 66 |
def __repr__(self): |
... | ... | |
76 | 79 | |
77 | 80 |
self._stream_no = value |
78 | 81 |
self._stream_no_text = QEngineeringStreamNoTextItem('<{}>'.format(self._stream_no), self) |
79 |
|
|
82 |
self.build_path() |
|
83 | ||
80 | 84 |
@property |
81 | 85 |
def data(self): |
82 | 86 |
""" return hmb data""" |
... | ... | |
113 | 117 |
""" |
114 | 118 | |
115 | 119 |
from SymbolSvgItem import SymbolSvgItem |
116 |
from EngineeringConnectorItem import QEngineeringConnectorItem
|
|
120 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
|
117 | 121 | |
118 | 122 |
targets = [] |
119 | 123 |
index = 0 |
120 |
for vertex in [self._vertices[0],self._vertices[-1]]:
|
|
124 |
for vertex in [self._vertices[0], self._vertices[-1]]:
|
|
121 | 125 |
if pointsUids: |
122 |
connector = QEngineeringConnectorItem(pointsUids[index], parent=self, index=index+1)
|
|
123 |
else:
|
|
124 |
connector = QEngineeringConnectorItem(uid=None, parent=self, index=index+1)
|
|
126 |
connector = QEngineeringConnectorItem(pointsUids[index], parent=self, index=index + 1)
|
|
127 |
else: |
|
128 |
connector = QEngineeringConnectorItem(uid=None, parent=self, index=index + 1)
|
|
125 | 129 | |
126 | 130 |
connector.setPos(vertex) |
127 | 131 |
connector.setParentItem(self) |
... | ... | |
129 | 133 |
connector.sceneConnectPoint = vertex |
130 | 134 | |
131 | 135 |
# add connector move ables |
132 |
connector.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable)
|
|
136 |
connector.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable)
|
|
133 | 137 |
connector.setAcceptTouchEvents(True) |
134 | 138 |
connector.transfer.onPosChanged.connect(self.on_connector_pos_changed) |
135 | 139 | |
... | ... | |
164 | 168 | |
165 | 169 |
dx = end[0] - start[0] |
166 | 170 |
dy = end[1] - start[1] |
167 |
length = math.sqrt(dx*dx + dy*dy)
|
|
171 |
length = math.sqrt(dx * dx + dy * dy)
|
|
168 | 172 |
if length == 0: return |
169 | 173 | |
170 |
_dir = [(end[0] - start[0])/length, (end[1] - start[1])/length]
|
|
174 |
_dir = [(end[0] - start[0]) / length, (end[1] - start[1]) / length]
|
|
171 | 175 |
perpendicular = (-_dir[1], _dir[0]) |
172 | 176 |
polygon = QPolygonF() |
173 |
polygon.append(QPointF(end[0] - _dir[0]*QEngineeringStreamlineItem.ARROW_SIZE + perpendicular[0]*QEngineeringStreamlineItem.ARROW_SIZE*0.25, |
|
174 |
end[1] - _dir[1]*QEngineeringStreamlineItem.ARROW_SIZE + perpendicular[1]*QEngineeringStreamlineItem.ARROW_SIZE*0.25)) |
|
175 |
polygon.append(QPointF(end[0] - _dir[0]*QEngineeringStreamlineItem.ARROW_SIZE - perpendicular[0]*QEngineeringStreamlineItem.ARROW_SIZE*0.25, |
|
176 |
end[1] - _dir[1]*QEngineeringStreamlineItem.ARROW_SIZE - perpendicular[1]*QEngineeringStreamlineItem.ARROW_SIZE*0.25)) |
|
177 |
polygon.append(QPointF(end[0] - _dir[0] * QEngineeringStreamlineItem.ARROW_SIZE + perpendicular[ |
|
178 |
0] * QEngineeringStreamlineItem.ARROW_SIZE * 0.25, |
|
179 |
end[1] - _dir[1] * QEngineeringStreamlineItem.ARROW_SIZE + perpendicular[ |
|
180 |
1] * QEngineeringStreamlineItem.ARROW_SIZE * 0.25)) |
|
181 |
polygon.append(QPointF(end[0] - _dir[0] * QEngineeringStreamlineItem.ARROW_SIZE - perpendicular[ |
|
182 |
0] * QEngineeringStreamlineItem.ARROW_SIZE * 0.25, |
|
183 |
end[1] - _dir[1] * QEngineeringStreamlineItem.ARROW_SIZE - perpendicular[ |
|
184 |
1] * QEngineeringStreamlineItem.ARROW_SIZE * 0.25)) |
|
177 | 185 |
polygon.append(QPointF(end[0], end[1])) |
178 | 186 |
polygon.append(polygon[0]) # close polygon |
179 | 187 | |
... | ... | |
188 | 196 |
''' |
189 | 197 |
@brief construct a polyline |
190 | 198 |
''' |
199 | ||
191 | 200 |
def process(self, param): |
192 | 201 |
if ('mousePressEvent' == param[0]) and (param[1].button() == Qt.LeftButton): |
193 | 202 |
self._vertices.append(param[2]) |
... | ... | |
199 | 208 |
''' |
200 | 209 |
@brief clone an object |
201 | 210 |
''' |
211 | ||
202 | 212 |
def clone(self): |
203 | 213 |
clone = QEngineeringStreamlineItem() |
204 | 214 |
clone._vertices = copy.deepcopy(self._vertices) |
205 | 215 |
clone.isCreated = self.isCreated |
206 | 216 | |
207 | 217 |
return clone |
208 |
|
|
218 | ||
209 | 219 |
def init(self): |
210 | 220 |
self._vertices = [] |
211 | 221 |
self._pt = None |
212 | 222 |
self.isCreated = False |
213 | 223 | |
214 |
def buildItem(self): |
|
215 |
self.__buildItem() |
|
216 | ||
217 | 224 |
''' |
218 | 225 |
@build build path |
219 | 226 |
@author humkyung |
220 | 227 |
@date 2018.04.23 |
221 | 228 |
''' |
222 |
def __buildItem(self): |
|
223 |
import math |
|
224 | 229 | |
225 |
path = QPainterPath() |
|
226 |
path.moveTo(self._vertices[0][0], self._vertices[0][1]) |
|
227 | ||
228 |
max_length = 0 |
|
229 |
max_length_line = [None, None] |
|
230 |
for i in range(1, len(self._vertices)): |
|
231 |
path.lineTo(self._vertices[i][0], self._vertices[i][1]) |
|
232 |
dx = self._vertices[i][0] - self._vertices[i-1][0] |
|
233 |
dy = self._vertices[i][1] - self._vertices[i-1][1] |
|
234 |
if dx*dx + dy*dy > max_length: |
|
235 |
max_length = dx*dx + dy*dy |
|
236 |
max_length_line[0] = self._vertices[i-1] |
|
237 |
max_length_line[1] = self._vertices[i] |
|
238 | ||
239 |
self.setPath(path) |
|
240 |
self.isCreated = True |
|
241 | ||
242 |
if self._stream_no_text: |
|
243 |
if max_length_line[0] is not None and max_length_line[1] is not None: |
|
244 |
x = (max_length_line[0][0] + max_length_line[1][0] - self._stream_no_text.textWidth())*0.5 |
|
245 |
y = (max_length_line[0][1] + max_length_line[1][1])*0.5 |
|
246 |
self._stream_no_text.setPos(QPointF(x, y)) |
|
247 |
dx = max_length_line[0][0] - max_length_line[1][0] |
|
248 |
dy = max_length_line[0][1] - max_length_line[1][1] |
|
249 |
self._stream_no_text.setRotation(90) if abs(dy) > abs(dx) else self._stream_no_text.setRotation(0) |
|
230 |
def build_path(self): |
|
231 |
if not self._vertices or len(self._vertices) < 2: |
|
232 |
return |
|
233 | ||
234 |
try: |
|
235 |
path = QPainterPath() |
|
236 |
path.moveTo(self._vertices[0][0], self._vertices[0][1]) |
|
237 | ||
238 |
max_length = 0 |
|
239 |
max_length_line = [None, None] |
|
240 |
for i in range(1, len(self._vertices)): |
|
241 |
path.lineTo(self._vertices[i][0], self._vertices[i][1]) |
|
242 |
dx = self._vertices[i][0] - self._vertices[i - 1][0] |
|
243 |
dy = self._vertices[i][1] - self._vertices[i - 1][1] |
|
244 |
if dx * dx + dy * dy > max_length: |
|
245 |
max_length = dx * dx + dy * dy |
|
246 |
max_length_line[0] = self._vertices[i - 1] |
|
247 |
max_length_line[1] = self._vertices[i] |
|
248 | ||
249 |
self.setPath(path) |
|
250 |
self.isCreated = True |
|
251 | ||
252 |
if self._stream_no_text: |
|
253 |
if max_length_line[0] is not None and max_length_line[1] is not None: |
|
254 |
x = (max_length_line[0][0] + max_length_line[1][0] - self._stream_no_text.textWidth()) * 0.5 |
|
255 |
y = (max_length_line[0][1] + max_length_line[1][1]) * 0.5 |
|
256 |
self._stream_no_text.setPos(QPointF(x, y)) |
|
257 |
dx = max_length_line[0][0] - max_length_line[1][0] |
|
258 |
dy = max_length_line[0][1] - max_length_line[1][1] |
|
259 |
self._stream_no_text.setRotation(90) if abs(dy) > abs(dx) else self._stream_no_text.setRotation(0) |
|
260 |
except Exception as ex: |
|
261 |
from App import App |
|
262 |
from AppDocData import MessageType |
|
263 | ||
264 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
265 |
sys.exc_info()[-1].tb_lineno) |
|
266 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
250 | 267 | |
251 | 268 |
''' |
252 |
@brief return bouding rectangle of polyline |
|
269 |
@brief return bounding rectangle of polyline
|
|
253 | 270 |
@author humkyung |
254 | 271 |
@date 2018.07.23 |
255 | 272 |
''' |
273 | ||
256 | 274 |
def boundingRect(self): |
257 | 275 |
rect = QRectF() |
258 |
|
|
276 | ||
259 | 277 |
if self.isCreated: |
260 | 278 |
rect = self.path().boundingRect() |
261 | 279 |
rect = QRectF(rect.left() - 5, rect.top() - 5, rect.width() + 10, rect.height() + 10) |
... | ... | |
269 | 287 |
minX = pt[0] |
270 | 288 |
if minY is None or pt[1] < minY: |
271 | 289 |
minY = pt[1] |
272 |
|
|
290 | ||
273 | 291 |
if maxX is None or pt[0] > maxX: |
274 | 292 |
maxX = pt[0] |
275 | 293 |
if maxY is None or pt[1] > maxY: |
276 | 294 |
maxY = pt[1] |
277 |
|
|
295 | ||
278 | 296 |
if self._pt is not None: |
279 | 297 |
if minX is None or self._pt[0] < minX: |
280 | 298 |
minX = self._pt[0] |
281 | 299 |
if minY is None or self._pt[1] < minY: |
282 | 300 |
minY = self._pt[1] |
283 |
|
|
301 | ||
284 | 302 |
if maxX is None or self._pt[0] > maxX: |
285 | 303 |
maxX = self._pt[0] |
286 | 304 |
if maxY is None or self._pt[1] > maxY: |
... | ... | |
288 | 306 | |
289 | 307 |
if minX is not None and minY is not None and maxX is not None and maxY is not None: |
290 | 308 |
rect = QRectF(minX - 5, minY - 5, maxX - minX + 10, maxY - minY + 10) |
291 |
|
|
309 | ||
292 | 310 |
return rect |
293 | 311 | |
294 | 312 |
''' |
... | ... | |
296 | 314 |
@author humkyung |
297 | 315 |
@date 2018.07.26 |
298 | 316 |
''' |
317 | ||
299 | 318 |
def onMouseMoved(self, event, scenePos): |
300 | 319 |
from SymbolSvgItem import SymbolSvgItem |
301 | 320 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
... | ... | |
309 | 328 |
elif (item is not None) and (type(item) is QEngineeringConnectorItem): |
310 | 329 |
pt = item.center() |
311 | 330 |
# up to here |
312 |
|
|
331 | ||
313 | 332 |
del self._vertices[1:] |
314 | 333 |
dx = pt[0] - self._vertices[0][0] |
315 | 334 |
dy = pt[1] - self._vertices[0][1] |
316 |
self._vertices.append((self._vertices[0][0] + dx*0.5, self._vertices[0][1]))
|
|
335 |
self._vertices.append((self._vertices[0][0] + dx * 0.5, self._vertices[0][1]))
|
|
317 | 336 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
318 | 337 |
self._vertices.append(pt) |
319 | 338 | |
320 |
self.__buildItem()
|
|
339 |
self.build_path()
|
|
321 | 340 |
self.update() |
322 |
|
|
341 | ||
323 | 342 |
def hoverEnterEvent(self, event): |
324 | 343 |
""" hilight item and it's children """ |
325 | 344 |
self.highlight(True) |
... | ... | |
329 | 348 |
self.highlight(False) |
330 | 349 | |
331 | 350 |
def highlight(self, flag): |
332 |
self.hover = flag |
|
333 |
self.setZValue(QEngineeringAbstractItem.HOVER_ZVALUE) if flag else self.setZValue(QEngineeringStreamlineItem.ZVALUE) |
|
351 |
self.hover = flag |
|
352 |
self.setZValue(QEngineeringAbstractItem.HOVER_ZVALUE) if flag else self.setZValue( |
|
353 |
QEngineeringStreamlineItem.ZVALUE) |
|
334 | 354 |
self.update() |
335 | 355 | |
336 | 356 |
def paint(self, painter, option, widget): |
... | ... | |
346 | 366 |
color = self.getColor() |
347 | 367 |
self.setColor(color) |
348 | 368 |
QGraphicsPathItem.paint(self, painter, option, widget) |
349 |
|
|
369 | ||
350 | 370 |
''' |
351 | 371 |
@brief Return real item position |
352 | 372 |
@authro Jeongwoo |
353 | 373 |
@date 2018.05.29 |
354 | 374 |
''' |
375 | ||
355 | 376 |
def boundingRectOnScene(self): |
356 | 377 |
rect = self.boundingRect() |
357 | 378 |
sp = self.startPoint() |
... | ... | |
365 | 386 |
@history 2018.05.11 Jeongwoo Add self.setPen() Method |
366 | 387 |
@history humkyung 2018.05.13 call setPen method to apply changed color |
367 | 388 |
''' |
389 | ||
368 | 390 |
def setColor(self, color): |
369 | 391 |
c = QColor() |
370 | 392 |
c.setNamedColor(color) |
... | ... | |
375 | 397 | |
376 | 398 |
def on_symbol_pos_changed(self, symbol): |
377 | 399 |
""" rebuild stream line because symbol position is changed """ |
378 |
if self.connectors[0].connectedItem is not None : self.connectors[0].setPos(self.connectors[0].connectedItem.center()) |
|
379 |
if self.connectors[-1].connectedItem is not None : self.connectors[-1].setPos(self.connectors[-1].connectedItem.center()) |
|
400 |
if self.connectors[0].connectedItem is not None: self.connectors[0].setPos( |
|
401 |
self.connectors[0].connectedItem.center()) |
|
402 |
if self.connectors[-1].connectedItem is not None: self.connectors[-1].setPos( |
|
403 |
self.connectors[-1].connectedItem.center()) |
|
380 | 404 |
self.on_connector_pos_changed(None) |
381 | 405 | |
382 | 406 |
def on_connector_pos_changed(self, connector): |
... | ... | |
387 | 411 |
self._vertices.append(self.connectors[0].center()) |
388 | 412 |
dx = self.connectors[-1].center()[0] - self._vertices[0][0] |
389 | 413 |
dy = self.connectors[-1].center()[1] - self._vertices[0][1] |
390 |
self._vertices.append((self._vertices[0][0] + dx*0.5, self._vertices[0][1]))
|
|
414 |
self._vertices.append((self._vertices[0][0] + dx * 0.5, self._vertices[0][1]))
|
|
391 | 415 |
self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy)) |
392 | 416 |
self._vertices.append(self.connectors[-1].center()) |
393 |
self.__buildItem()
|
|
417 |
self.build_path()
|
|
394 | 418 |
self.update_arrow() |
395 | 419 |
self.update() |
396 | 420 | |
397 | 421 |
def mouseDoubleClickEvent(self, event): |
398 | 422 |
from StreamDataDialog import QStreamDataDialog |
399 |
|
|
423 | ||
400 | 424 |
dialog = QStreamDataDialog() |
401 | 425 |
res = dialog.showDialog(self) |
402 | 426 |
if res == True: |
403 | 427 |
self.load_HMB() |
404 | 428 | |
405 |
def load_HMB(self):
|
|
406 |
from App import App
|
|
429 |
def load_HMB(self): |
|
430 |
from App import App |
|
407 | 431 | |
408 | 432 |
App.mainWnd().load_HMB() |
409 |
|
|
433 | ||
410 | 434 |
def keyPressEvent(self, event): |
411 | 435 |
from App import App |
412 | 436 |
from AppDocData import AppDocData |
413 | 437 |
if not self.isSelected(): return |
414 | 438 | |
415 |
if event.key() == Qt.Key_Delete:
|
|
439 |
if event.key() == Qt.Key_Delete: |
|
416 | 440 |
self.transfer.onRemoved.emit(self) |
417 | 441 |
elif event.key() == Qt.Key_QuoteLeft: |
418 |
self.mouseDoubleClickEvent(event)
|
|
419 |
|
|
442 |
self.mouseDoubleClickEvent(event) |
|
443 | ||
420 | 444 |
def toSql(self): |
421 | 445 |
""" convert valve data to sql query """ |
422 | 446 |
import uuid |
... | ... | |
430 | 454 |
uid = self.uid |
431 | 455 | |
432 | 456 |
cols = ['UID', 'Symbols_UID', 'Name'] |
433 |
values = ['?','?', '?'] |
|
457 |
values = ['?', '?', '?']
|
|
434 | 458 |
param = [str(uid), str(dbUid), str(self.stream_no)] |
435 | 459 |
sql = 'insert or replace into Components({}) values({})'.format(','.join(cols), ','.join(values)) |
436 | 460 |
res.append((sql, tuple(param))) |
437 | 461 | |
438 | 462 |
# save vertices to database |
439 | 463 |
index = 1 |
440 |
for vertex in self._vertices:
|
|
464 |
for vertex in self._vertices: |
|
441 | 465 |
if index == 1 and self.connectors[0].connectedItem is not None: |
442 | 466 |
cols = ['UID', 'Components_UID', '[Index]', 'X', 'Y', 'ConnectedItem_UID'] |
443 | 467 |
values = ['?', '?', '?', '?', '?', '?'] |
444 |
param = [str(uuid.uuid4()), str(uid), index, vertex[0], vertex[1], str(self.connectors[0].connectedItem.uid)] |
|
468 |
param = [str(uuid.uuid4()), str(uid), index, vertex[0], vertex[1], |
|
469 |
str(self.connectors[0].connectedItem.uid)] |
|
445 | 470 |
elif index == 4 and self.connectors[1].connectedItem is not None: |
446 | 471 |
cols = ['UID', 'Components_UID', '[Index]', 'X', 'Y', 'ConnectedItem_UID'] |
447 | 472 |
values = ['?', '?', '?', '?', '?', '?'] |
448 |
param = [str(uuid.uuid4()), str(uid), index, vertex[0], vertex[1], str(self.connectors[1].connectedItem.uid)] |
|
473 |
param = [str(uuid.uuid4()), str(uid), index, vertex[0], vertex[1], |
|
474 |
str(self.connectors[1].connectedItem.uid)] |
|
449 | 475 |
else: |
450 | 476 |
cols = ['UID', 'Components_UID', '[Index]', 'X', 'Y'] |
451 | 477 |
values = ['?', '?', '?', '?', '?'] |
452 | 478 |
param = [str(uuid.uuid4()), str(uid), index, vertex[0], vertex[1]] |
453 |
|
|
479 | ||
454 | 480 |
sql = 'insert or replace into Points({}) values({})'.format(','.join(cols), ','.join(values)) |
455 | 481 | |
456 | 482 |
res.append((sql, tuple(param))) |
457 | 483 |
index += 1 |
458 | 484 |
# up to here |
459 | 485 | |
460 | ||
461 | ||
462 | 486 |
return res |
463 | 487 | |
464 |
@staticmethod
|
|
488 |
@staticmethod |
|
465 | 489 |
def fromDatabase(componentInfos): |
466 | 490 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
467 | 491 |
from AppDocData import AppDocData |
... | ... | |
470 | 494 |
try: |
471 | 495 |
app_doc_data = AppDocData.instance() |
472 | 496 | |
473 |
uid = componentInfos[0][0] #uid@Components
|
|
497 |
uid = componentInfos[0][0] # uid@Components
|
|
474 | 498 | |
475 | 499 |
item = QEngineeringStreamlineItem(uid) |
476 | 500 |
hmb_data = app_doc_data.activeDrawing.hmbTable.get_hmb_data(uid) |
477 |
item.stream_no = int(hmb_data.stream_no) if hmb_data else 1 # stream no |
|
501 |
item.stream_no = int(hmb_data.stream_no) if hmb_data else 1 # stream no
|
|
478 | 502 | |
479 | 503 |
pointsUids = [] |
480 |
for componentInfo in componentInfos:
|
|
481 |
pointsUid = componentInfo[11] # uid@Points
|
|
482 |
x = componentInfo[13] # X@Points
|
|
483 |
y = componentInfo[14] # Y@Points
|
|
504 |
for componentInfo in componentInfos: |
|
505 |
pointsUid = componentInfo[11] # uid@Points
|
|
506 |
x = componentInfo[13] # X@Points |
|
507 |
y = componentInfo[14] # Y@Points |
|
484 | 508 | |
485 | 509 |
pointsUids.append(pointsUid) |
486 | 510 |
item._vertices.append((x, y)) |
... | ... | |
488 | 512 |
connectorItems = [componentInfos[0][15], componentInfos[-1][15]] |
489 | 513 | |
490 | 514 |
item.setVisible(False) |
491 |
item.__buildItem()
|
|
515 |
item.build_path()
|
|
492 | 516 |
item.build_connectors(connectorItems, pointsUids) |
493 |
|
|
517 | ||
494 | 518 |
item.update() |
495 | 519 | |
496 | 520 |
except Exception as ex: |
497 |
from App import App
|
|
521 |
from App import App |
|
498 | 522 |
from AppDocData import MessageType |
499 | 523 | |
500 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
524 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
525 |
sys.exc_info()[-1].tb_lineno) |
|
501 | 526 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
502 | 527 | |
503 | 528 |
return item |
... | ... | |
508 | 533 |
@author Jeongwoo |
509 | 534 |
@date 2018.06.18 |
510 | 535 |
''' |
536 | ||
537 | ||
511 | 538 |
class Transfer(QObject): |
512 | 539 |
onRemoved = pyqtSignal(QGraphicsItem) |
513 | 540 | |
514 |
def __init__(self, parent = None): |
|
515 |
QObject.__init__(self, parent) |
|
541 |
def __init__(self, parent=None): |
|
542 |
QObject.__init__(self, parent) |
HYTOS/HYTOS/Shapes/SymbolSvgItem.py | ||
---|---|---|
18 | 18 |
from UserInputAttribute import UserInputAttribute |
19 | 19 |
from Resizer import Resizer |
20 | 20 | |
21 | ||
21 | 22 |
class SymbolSvgItem(QGraphicsSvgItem, QEngineeringAbstractItem): |
22 | 23 |
""" This is symbolsvgitem class """ |
23 | 24 | |
... | ... | |
31 | 32 |
18.05.25 Jeongwoo Call setColor() method |
32 | 33 |
18.05.30 Jeongwoo Add self variables (parentSymbol, childSymbol) |
33 | 34 |
''' |
35 | ||
34 | 36 |
def __init__(self, path, uid=None, flip=0): |
35 | 37 |
import uuid |
36 | 38 |
from SymbolAttr import SymbolProp |
... | ... | |
38 | 40 |
QGraphicsSvgItem.__init__(self) |
39 | 41 |
QEngineeringAbstractItem.__init__(self) |
40 | 42 | |
41 |
self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable|QGraphicsItem.ItemIsMovable|QGraphicsItem.ItemSendsGeometryChanges) |
|
43 |
self.setFlags( |
|
44 |
QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable | QGraphicsItem.ItemIsMovable | QGraphicsItem.ItemSendsGeometryChanges) |
|
42 | 45 | |
43 | 46 |
self.dbUid = None |
44 | 47 |
self.uid = uuid.uuid4() if uid is None else uuid.UUID(uid, version=4) |
... | ... | |
52 | 55 |
self.size = None |
53 | 56 |
self._owner = None |
54 | 57 |
self.parentSymbol = '' |
55 |
self.childSymbol = ''
|
|
58 |
self.childSymbol = '' |
|
56 | 59 |
self.hasInstrumentLabel = 0 |
57 | 60 |
self.flip = flip |
58 | 61 |
# attributeType uid |
59 | 62 |
self.attribute = '' |
60 |
self._properties = {SymbolProp(None, 'Supplied By', 'String'):None} |
|
63 |
self._properties = {SymbolProp(None, 'Supplied By', 'String'): None}
|
|
61 | 64 | |
62 | 65 |
self.setAcceptDrops(True) |
63 | 66 |
self.setAcceptHoverEvents(True) |
64 | 67 |
self.setAcceptedMouseButtons(Qt.LeftButton) |
65 | 68 |
self.setAcceptTouchEvents(True) |
66 |
|
|
69 | ||
67 | 70 |
self.currentCursor = 0 |
68 | 71 |
self.transfer = Transfer() |
69 | 72 | |
... | ... | |
80 | 83 |
except Exception as ex: |
81 | 84 |
from App import App |
82 | 85 |
from AppDocData import MessageType |
83 |
|
|
84 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
86 | ||
87 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
88 |
sys.exc_info()[-1].tb_lineno) |
|
85 | 89 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
86 | 90 |
finally: |
87 | 91 |
f.close() |
... | ... | |
97 | 101 |
@author humkyung |
98 | 102 |
@date 2018.05.10 |
99 | 103 |
''' |
104 | ||
100 | 105 |
@property |
101 | 106 |
def owner(self): |
102 | 107 |
import uuid |
... | ... | |
117 | 122 |
@date 2018.05.10 |
118 | 123 |
@history 2018.05.17 Jeongwoo Add Calling setColor if self._owner is None or not |
119 | 124 |
''' |
125 | ||
120 | 126 |
@owner.setter |
121 | 127 |
def owner(self, value): |
122 | 128 |
self._owner = value |
... | ... | |
130 | 136 |
""" getter of properties """ |
131 | 137 |
import uuid |
132 | 138 | |
133 |
for prop,value in self._properties.items(): |
|
139 |
for prop, value in self._properties.items():
|
|
134 | 140 |
try: |
135 | 141 |
if prop.is_selectable and type(value) is uuid.UUID and self.scene(): |
136 | 142 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(value)] |
137 | 143 |
if matches: self._properties[prop] = matches[0] |
138 |
|
|
144 | ||
139 | 145 |
if prop.Expression: |
140 |
item = self._properties[prop] # assign item
|
|
146 |
item = self._properties[prop] # assign item |
|
141 | 147 |
self._properties[prop] = eval(prop.Expression) |
142 | 148 |
except Exception as ex: |
143 |
from App import App
|
|
149 |
from App import App |
|
144 | 150 | |
145 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
146 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
151 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
152 |
sys.exc_info()[-1].tb_lineno) |
|
153 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
147 | 154 | |
148 | 155 |
return self._properties |
149 | 156 | |
... | ... | |
155 | 162 |
def set_property(self, property, value): |
156 | 163 |
""" set property with given value """ |
157 | 164 |
if issubclass(type(value), QEngineeringAbstractItem): self.add_assoc_item(value, 0) |
158 |
matches = [prop for prop,_ in self._properties.items() if prop.Attribute == property] |
|
165 |
matches = [prop for prop, _ in self._properties.items() if prop.Attribute == property]
|
|
159 | 166 |
if matches: self._properties[matches[0]] = value |
160 | 167 | |
161 | 168 |
def prop(self, name): |
162 | 169 |
""" return the value of given property with name """ |
163 |
matches = [(prop,value) for prop,value in self.properties.items() if prop.Attribute == name]
|
|
170 |
matches = [(prop, value) for prop, value in self.properties.items() if prop.Attribute == name]
|
|
164 | 171 |
if matches: return matches[0][1] |
165 | 172 | |
166 | 173 |
return None |
... | ... | |
175 | 182 |
return matches[0].text() |
176 | 183 |
else: |
177 | 184 |
return None |
178 |
|
|
185 | ||
179 | 186 |
def includes(self, pt, margin=0): |
180 | 187 |
""" return True if symbol contains given point else return False """ |
181 | 188 |
rect = self.sceneBoundingRect() |
... | ... | |
193 | 200 |
maxX = minX + rect.width() + margin |
194 | 201 |
maxY = minY + rect.height() + margin |
195 | 202 | |
196 |
#print([minX, minY, maxX, maxY]) |
|
203 |
# print([minX, minY, maxX, maxY])
|
|
197 | 204 | |
198 | 205 |
return True if (pt[0] >= minX and pt[0] <= maxX and pt[1] >= minY and pt[1] <= maxY) else False |
199 | 206 | |
... | ... | |
204 | 211 | |
205 | 212 |
res = [] |
206 | 213 |
appDocData = AppDocData.instance() |
207 |
|
|
214 | ||
208 | 215 |
rect = self.sceneBoundingRect() |
209 | 216 | |
210 | 217 |
cols = ['UID', 'Symbols_UID', 'X', 'Y', 'Rotation', 'Scale'] |
211 |
values = ['?','?', '?', '?', '?', '?'] |
|
218 |
values = ['?', '?', '?', '?', '?', '?']
|
|
212 | 219 |
param = [str(self.uid), str(self.dbUid), rect.left(), rect.top(), str(self.angle), self.transform().m11()] |
213 | 220 |
sql = 'insert or replace into Components({}) values({})'.format(','.join(cols), ','.join(values)) |
214 | 221 |
res.append((sql, tuple(param))) |
215 |
|
|
222 | ||
216 | 223 |
# save connectors to database |
217 | 224 |
index = 1 |
218 | 225 |
for connector in self.connectors: |
... | ... | |
229 | 236 |
@history 2018.05.09 Jeongwoo Clear self.connectors |
230 | 237 |
2018.05.30 Jeongwoo Add parameters (parentSymbol, childSymbol) |
231 | 238 |
''' |
239 | ||
232 | 240 |
def buildItem(self, name, _type, angle, scale, loc, origin, connPts, dbUid=None, pointsUids=None): |
233 | 241 |
try: |
234 | 242 |
if not hasattr(self, 'counters'): self.counters = {} |
235 | 243 |
if name in self.counters: |
236 | 244 |
self.counters[name] += 1 |
237 |
else: self.counters[name] = 1 |
|
245 |
else: |
|
246 |
self.counters[name] = 1 |
|
238 | 247 | |
239 | 248 |
self.name = name |
240 | 249 |
self.index = self.counters[name] |
241 |
self.type = _type
|
|
242 |
self.angle = angle
|
|
250 |
self.type = _type |
|
251 |
self.angle = angle |
|
243 | 252 |
self._scale = scale |
244 |
self.loc = loc
|
|
253 |
self.loc = loc |
|
245 | 254 | |
246 | 255 |
docData = AppDocData.instance() |
247 | 256 |
if dbUid is None: |
248 | 257 |
symbolInfo = docData.getSymbolByQuery('name', name) |
249 | 258 |
else: |
250 | 259 |
symbolInfo = docData.getSymbolByQuery('UID', dbUid) |
251 |
|
|
260 | ||
252 | 261 |
self.dbUid = symbolInfo.uid |
253 | 262 |
self.category = symbolInfo.sCategory |
254 | 263 |
originalPoint = symbolInfo.getOriginalPoint().split(',') |
255 | 264 |
self.symbolOrigin = [float(originalPoint[0]), float(originalPoint[1])] |
256 |
|
|
265 | ||
257 | 266 |
# setting connectors |
258 | 267 |
connectionPoints = symbolInfo.getConnectionPoint().split('/') |
259 | 268 |
for index in range(len(connectionPoints)): |
... | ... | |
261 | 270 |
break |
262 | 271 |
tokens = connectionPoints[index].split(',') |
263 | 272 | |
264 |
direction = 'AUTO'
|
|
273 |
direction = 'AUTO' |
|
265 | 274 |
symbol_idx = '0' |
266 | 275 | |
267 | 276 |
if len(tokens) == 2: |
... | ... | |
278 | 287 |
symbol_idx = tokens[3] |
279 | 288 | |
280 | 289 |
if pointsUids: |
281 |
self.setConnector(pointsUids[index], index+1)
|
|
290 |
self.setConnector(pointsUids[index], index + 1)
|
|
282 | 291 |
else: |
283 |
self.setConnector(None, index+1)
|
|
284 |
|
|
292 |
self.setConnector(None, index + 1)
|
|
293 | ||
285 | 294 |
self.connectors[index].direction = direction |
286 | 295 |
self.connectors[index].symbol_idx = symbol_idx |
287 | 296 |
self.connectors[index].setPos((x, y)) |
288 | 297 |
self.connectors[index].connectPoint = (x, y) |
289 |
|
|
290 | 298 | |
291 | 299 |
tooltip = '<b>{}</b><br>{}={}'.format(str(self.uid), self.type, self.name) |
292 | 300 |
self.setToolTip(tooltip) |
293 | 301 |
except Exception as ex: |
294 |
from App import App
|
|
302 |
from App import App |
|
295 | 303 | |
296 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
304 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
305 |
sys.exc_info()[-1].tb_lineno) |
|
297 | 306 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
298 | 307 | |
299 | 308 |
''' |
... | ... | |
301 | 310 |
@author humkyung |
302 | 311 |
@date 2018.04.08 |
303 | 312 |
''' |
313 | ||
304 | 314 |
def rect(self): |
305 | 315 |
return self.sceneBoundingRect() |
306 |
|
|
316 | ||
307 | 317 |
''' |
308 | 318 |
@brief return true if line is able to connect symbol |
309 | 319 |
@author humkyung |
310 | 320 |
@date 2018.04.13 |
311 | 321 |
''' |
322 | ||
312 | 323 |
def is_connectable(self, item, toler=10): |
313 |
#from EngineeringLineItem import QEngineeringLineItem |
|
324 |
# from EngineeringLineItem import QEngineeringLineItem
|
|
314 | 325 | |
315 | 326 |
''' |
316 | 327 |
if False:#type(item) is QEngineeringLineItem: |
... | ... | |
330 | 341 |
for iConnector in item.connectors: |
331 | 342 |
dx = connector.sceneConnectPoint[0] - iConnector.sceneConnectPoint[0] |
332 | 343 |
dy = connector.sceneConnectPoint[1] - iConnector.sceneConnectPoint[1] |
333 |
if (math.sqrt(dx*dx + dy*dy) < toler): return True
|
|
344 |
if (math.sqrt(dx * dx + dy * dy) < toler): return True
|
|
334 | 345 | |
335 | 346 |
return False |
336 |
|
|
347 | ||
337 | 348 |
''' |
338 | 349 |
@author humkyung |
339 | 350 |
@date 2018.07.03 |
340 | 351 |
''' |
352 | ||
341 | 353 |
def is_connected(self, item, at=QEngineeringAbstractItem.CONNECTED_AT_PT): |
342 | 354 |
""" check if given item is connected to self """ |
343 | 355 | |
344 |
_connectors = [connector for connector in self.connectors if (connector.connectedItem == item and (connector._connected_at == at if at else True))] |
|
356 |
_connectors = [connector for connector in self.connectors if |
|
357 |
(connector.connectedItem == item and (connector._connected_at == at if at else True))] |
|
345 | 358 |
return len(_connectors) > 0 |
346 | 359 | |
347 | 360 |
def next_connected(self, lhs, rhs): |
... | ... | |
350 | 363 |
lhs_matches = [at for at in range(len(self.connectors)) if self.connectors[at].connectedItem == lhs] |
351 | 364 |
rhs_matches = [at for at in range(len(self.connectors)) if self.connectors[at].connectedItem == rhs] |
352 | 365 |
if lhs_matches and rhs_matches: |
353 |
return (lhs_matches[0] in [0,1] and rhs_matches[0] in [0,1]) or (lhs_matches[0] in [2,3] and rhs_matches[0] in [2,3]) |
|
366 |
return (lhs_matches[0] in [0, 1] and rhs_matches[0] in [0, 1]) or ( |
|
367 |
lhs_matches[0] in [2, 3] and rhs_matches[0] in [2, 3]) |
|
354 | 368 | |
355 | 369 |
return False |
356 | 370 | |
... | ... | |
361 | 375 |
@history humkyung 2018.05.08 check if symbol is possible to be connected |
362 | 376 |
Jeongwoo 2018.05.15 Connect each symbol and line |
363 | 377 |
''' |
378 | ||
364 | 379 |
def connect_if_possible(self, obj, toler=10): |
365 | 380 |
from shapely.geometry import Point |
366 | 381 |
from EngineeringLineItem import QEngineeringLineItem |
... | ... | |
371 | 386 |
startPt = obj.startPoint() |
372 | 387 |
endPt = obj.endPoint() |
373 | 388 |
for i in range(len(self.connectors)): |
374 |
if (Point(startPt[0], startPt[1]).distance(Point(self.connectors[i].sceneConnectPoint[0], self.connectors[i].sceneConnectPoint[1])) < toler): |
|
389 |
if (Point(startPt[0], startPt[1]).distance(Point(self.connectors[i].sceneConnectPoint[0], |
|
390 |
self.connectors[i].sceneConnectPoint[1])) < toler): |
|
375 | 391 |
if self.connectors[i].connectedItem is None: |
376 | 392 |
self.connectors[i].connect(obj) |
377 | 393 |
if obj.connectors[0].connectedItem is None: |
378 | 394 |
obj.connectors[0].connect(self) |
379 |
|
|
395 | ||
380 | 396 |
res.append(obj) |
381 |
if (Point(endPt[0], endPt[1]).distance(Point(self.connectors[i].sceneConnectPoint[0], self.connectors[i].sceneConnectPoint[1])) < toler): |
|
397 |
if (Point(endPt[0], endPt[1]).distance(Point(self.connectors[i].sceneConnectPoint[0], |
|
398 |
self.connectors[i].sceneConnectPoint[1])) < toler): |
|
382 | 399 |
if self.connectors[i].connectedItem is None: |
383 | 400 |
self.connectors[i].connect(obj) |
384 | 401 |
if obj.connectors[1].connectedItem is None: |
385 | 402 |
obj.connectors[1].connect(self) |
386 |
|
|
403 | ||
387 | 404 |
res.append(obj) |
388 | 405 |
elif issubclass(type(obj), SymbolSvgItem): |
389 | 406 |
for i in range(len(self.connectors)): |
390 | 407 |
for j in range(len(obj.connectors)): |
391 | 408 |
_pt = Point(obj.connectors[j].sceneConnectPoint[0], obj.connectors[j].sceneConnectPoint[1]) |
392 |
if (_pt.distance(Point(self.connectors[i].sceneConnectPoint[0], self.connectors[i].sceneConnectPoint[1])) < toler): |
|
409 |
if (_pt.distance(Point(self.connectors[i].sceneConnectPoint[0], |
|
410 |
self.connectors[i].sceneConnectPoint[1])) < toler): |
|
393 | 411 |
if self.connectors[i].connectedItem is None: |
394 | 412 |
self.connectors[i].connect(obj) |
395 | 413 |
if obj.connectors[j].connectedItem is None: |
... | ... | |
397 | 415 | |
398 | 416 |
res.append(obj) |
399 | 417 |
except Exception as ex: |
400 |
from App import App |
|
401 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
418 |
from App import App |
|
419 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
420 |
sys.exc_info()[-1].tb_lineno) |
|
402 | 421 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
403 | 422 | |
404 | 423 |
return res |
... | ... | |
408 | 427 |
@author kyouho |
409 | 428 |
@date 2018.08.30 |
410 | 429 |
''' |
430 | ||
411 | 431 |
def disconnectedItemAtConnector(self, connector): |
412 | 432 |
for conn in self.connectors: |
413 | 433 |
if conn.isOverlapConnector(connector): |
... | ... | |
418 | 438 |
@author humkyung |
419 | 439 |
@dat |
420 | 440 |
''' |
441 | ||
421 | 442 |
def getConnectionPointCloseTo(self, pt, toler=10): |
422 | 443 |
import math |
423 | 444 | |
424 | 445 |
for connector in self.connectors: |
425 | 446 |
dx = connector.sceneConnectPoint[0] - pt[0] |
426 | 447 |
dy = connector.sceneConnectPoint[1] - pt[1] |
427 |
if math.sqrt(dx*dx + dy*dy) < toler: return connPt
|
|
428 |
|
|
448 |
if math.sqrt(dx * dx + dy * dy) < toler: return connPt
|
|
449 | ||
429 | 450 |
return None |
430 | 451 | |
431 | 452 |
''' |
... | ... | |
433 | 454 |
@author humkyung |
434 | 455 |
@date 2018.04.08 |
435 | 456 |
''' |
457 | ||
436 | 458 |
def center(self): |
437 | 459 |
return self.sceneBoundingRect().center() |
438 |
|
|
460 | ||
439 | 461 |
''' |
440 | 462 |
@brief highlight connector and attribute |
441 | 463 |
@authro humkyung |
442 | 464 |
@date 2018.05.02 |
443 | 465 |
''' |
466 | ||
444 | 467 |
def hoverEnterEvent(self, event): |
445 | 468 |
from Resizer import Resizer |
446 | 469 | |
447 | 470 |
self.highlight(True) |
448 | 471 | |
449 | ||
450 | 472 |
''' 잠시 주석 처리 |
451 | 473 |
""" create a resizer """ |
452 | 474 |
resizer = Resizer.instance() |
... | ... | |
472 | 494 |
@date 2018.05.02 |
473 | 495 |
@history kyouho 2018.07.18 edit ArrowCursor |
474 | 496 |
''' |
497 | ||
475 | 498 |
def hoverLeaveEvent(self, event): |
476 | 499 |
self.highlight(False) |
477 | 500 | |
... | ... | |
479 | 502 |
""" highlight/unhighlight the symbol """ |
480 | 503 | |
481 | 504 |
try: |
482 |
self.hover = flag
|
|
505 |
self.hover = flag |
|
483 | 506 |
self.setZValue(QEngineeringAbstractItem.HOVER_ZVALUE) if flag else self.setZValue(SymbolSvgItem.ZVALUE) |
484 | 507 |
self.update() |
485 | 508 | |
486 |
#for assoc in self.associations(): |
|
509 |
# for assoc in self.associations():
|
|
487 | 510 |
# assoc.highlight(flag) |
488 |
except Exception as ex: |
|
489 |
from App import App |
|
490 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
511 |
except Exception as ex: |
|
512 |
from App import App |
|
513 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
514 |
sys.exc_info()[-1].tb_lineno) |
|
491 | 515 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
492 | 516 | |
493 | 517 |
''' |
... | ... | |
495 | 519 |
@author kyouho |
496 | 520 |
@date 2018.08.27 |
497 | 521 |
''' |
522 | ||
498 | 523 |
def setHightlight(self): |
499 | 524 |
self.setColor('url(#hover)') |
500 | 525 |
self.update() |
... | ... | |
504 | 529 |
@author kyouho |
505 | 530 |
@date 2018.08.27 |
506 | 531 |
''' |
532 | ||
507 | 533 |
def unsetHightlight(self): |
508 | 534 |
self.setColor('url(#normal)') |
509 | 535 |
self.update() |
... | ... | |
513 | 539 |
@author humkyung |
514 | 540 |
@date 2018.04.28 |
515 | 541 |
''' |
542 | ||
516 | 543 |
def hoverMoveEvent(self, event): |
517 | 544 |
pass |
518 | 545 | |
... | ... | |
522 | 549 |
@date 18.04.11 |
523 | 550 |
@history kyouho 2018.07.18 add isClick logic |
524 | 551 |
''' |
552 | ||
525 | 553 |
def mousePressEvent(self, event): |
526 | 554 |
if event.buttons() == Qt.LeftButton: |
527 | 555 |
self.clicked.emit(self) |
... | ... | |
531 | 559 |
@author humkyung |
532 | 560 |
@date 19.07.17 |
533 | 561 |
''' |
562 | ||
534 | 563 |
def mouseReleaseEvent(self, event): |
535 | 564 |
super().mouseReleaseEvent(event) |
536 | 565 | |
... | ... | |
539 | 568 |
if change == QGraphicsItem.ItemPositionHasChanged: |
540 | 569 |
self.transfer.on_pos_changed.emit(self) |
541 | 570 |
return value |
542 |
|
|
571 | ||
543 | 572 |
return super().itemChange(change, value) |
544 | 573 | |
545 | 574 |
def removeSelfAttr(self, attributeName): |
... | ... | |
548 | 577 |
if attr.Attribute == attributeName: |
549 | 578 |
target = attr |
550 | 579 |
break |
551 |
|
|
580 | ||
552 | 581 |
if target: |
553 | 582 |
del self.attrs[attr] |
554 | 583 | |
... | ... | |
557 | 586 |
@author kyouho |
558 | 587 |
@date 18.07.17 |
559 | 588 |
''' |
589 | ||
560 | 590 |
def isOverlapItemAndPoint(self, item, point): |
561 | 591 |
x = point.x() |
562 | 592 |
y = point.y() |
... | ... | |
575 | 605 |
@history 2018.05.17 Jeongwoo Add if-statement and move 'break' |
576 | 606 |
2018.05.25 Jeongwoo Seperate delete item method |
577 | 607 |
''' |
608 | ||
578 | 609 |
def keyPressEvent(self, event): |
579 | 610 |
if not self.isSelected(): return |
580 | 611 | |
... | ... | |
582 | 613 |
self.deleteSvgItemFromScene() |
583 | 614 |
elif event.key() == Qt.Key_QuoteLeft: |
584 | 615 |
self.mouseDoubleClickEvent(event) |
585 |
|
|
586 |
|
|
616 | ||
587 | 617 |
''' |
588 | 618 |
@brief connect attribute |
589 | 619 |
@author humkyung |
590 | 620 |
@date 2018.05.02 |
591 | 621 |
@history humkyung 2018.05.09 append only nearest size attribute |
592 | 622 |
''' |
623 | ||
593 | 624 |
def connectAttribute(self, attributes, clear=True): |
594 | 625 |
import math |
595 | 626 |
from EngineeringTextItem import QEngineeringTextItem |
596 |
from QEngineeringSizeTextItem import QEngineeringSizeTextItem
|
|
627 |
from QEngineeringSizeTextItem import QEngineeringSizeTextItem |
|
597 | 628 | |
598 | 629 |
try: |
599 | 630 |
if clear: |
... | ... | |
601 | 632 | |
602 | 633 |
configs = AppDocData.instance().getConfigs('Range', 'Detection Ratio') |
603 | 634 |
ratio = float(configs[0].value) if 1 == len(configs) else 1.5 |
604 |
|
|
635 | ||
605 | 636 |
dist = max(self.sceneBoundingRect().height(), self.sceneBoundingRect().width()) * ratio |
606 | 637 |
center = self.sceneBoundingRect().center() |
607 | 638 | |
... | ... | |
609 | 640 |
selected = None |
610 | 641 |
for attr in attributes: |
611 | 642 |
# size text and operation code text will find onwer themselves in findowner method |
612 |
if False:# type(attr) is QEngineeringSizeTextItem or type(attr) is QEngineeringValveOperCodeTextItem: |
|
643 |
if False: # type(attr) is QEngineeringSizeTextItem or type(attr) is QEngineeringValveOperCodeTextItem:
|
|
613 | 644 |
dx = attr.center().x() - center.x() |
614 | 645 |
dy = attr.center().y() - center.y() |
615 |
length = math.sqrt(dx*dx + dy*dy)
|
|
646 |
length = math.sqrt(dx * dx + dy * dy)
|
|
616 | 647 |
if (length < dist) and (minDist is None or length < minDist): |
617 | 648 |
minDist = length |
618 | 649 |
selected = attr |
... | ... | |
620 | 651 |
if not attr.is_connected: |
621 | 652 |
dx = attr.center().x() - center.x() |
622 | 653 |
dy = attr.center().y() - center.y() |
623 |
if math.sqrt(dx*dx + dy*dy) < dist:
|
|
654 |
if math.sqrt(dx * dx + dy * dy) < dist:
|
|
624 | 655 |
if self.add_assoc_item(attr): |
625 | 656 |
attr.owner = self |
626 | 657 | |
... | ... | |
629 | 660 |
selected.owner = self |
630 | 661 | |
631 | 662 |
except Exception as ex: |
632 |
from App import App |
|
633 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
663 |
from App import App |
|
664 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
665 |
sys.exc_info()[-1].tb_lineno) |
|
634 | 666 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
635 | 667 | |
636 | 668 |
''' |
... | ... | |
638 | 670 |
@author euisung |
639 | 671 |
@date 2019.04.16 |
640 | 672 |
''' |
673 | ||
641 | 674 |
def mouseDoubleClickEvent(self, event): |
642 | 675 |
func_map = [ |
643 | 676 |
(('Equipment - [ Pressure Drop ]', 'Air Fin Cooler', 'AF_Cooler'), self.show_AirFinCooler), |
644 |
(('Equipment - [ Pressure Drop ]', 'Filter', ('Filter_H','Filter_V')), self.show_Filter), |
|
645 |
(('Equipment - [ Pressure Drop ]', 'Heat Exchanger', ('HEX_DP','HEX_H','HEX_K','HEX_V')), self.show_ShlTubHeatExchanger), |
|
677 |
(('Equipment - [ Pressure Drop ]', 'Filter', ('Filter_H', 'Filter_V')), self.show_Filter), |
|
678 |
(('Equipment - [ Pressure Drop ]', 'Heat Exchanger', ('HEX_DP', 'HEX_H', 'HEX_K', 'HEX_V')), |
|
679 |
self.show_ShlTubHeatExchanger), |
|
646 | 680 |
(('Equipment - [ Pressure Drop ]', 'Heat Exchanger', ('HEX_P')), self.show_PlateHeatExchanger), |
647 | 681 |
(('Equipment - [ Pressure Drop ]', 'Miscellaneous', ('M_Coil')), self.show_Coil), |
648 | 682 |
(('Equipment - [ Pressure Drop ]', 'Miscellaneous', ('M_DP_E')), self.show_DP_Equipment), |
649 | 683 |
(('Equipment - [ Pressure Drop ]', 'Miscellaneous', ('M_React')), self.show_Reactor), |
650 |
(('Equipment - [ Pressure Drop ]', 'Strainer', ('T_Strainer_H','T_Strainer_V')), self.show_Strainer_T), |
|
651 |
(('Equipment - [ Pressure Drop ]', 'Strainer', ('Y_Strainer_H','Y_Strainer_V')), self.show_Strainer_Y), |
|
684 |
(('Equipment - [ Pressure Drop ]', 'Strainer', ('T_Strainer_H', 'T_Strainer_V')), self.show_Strainer_T),
|
|
685 |
(('Equipment - [ Pressure Drop ]', 'Strainer', ('Y_Strainer_H', 'Y_Strainer_V')), self.show_Strainer_Y),
|
|
652 | 686 |
(('Equipment - [ Pressurized ]', 'Battery Limit', None), self.show_BatteryLimit), |
653 | 687 |
(('Equipment - [ Pressurized ]', 'Column', ('CwT')), self.show_Tray), |
654 | 688 |
(('Equipment - [ Pressurized ]', 'Column', ('CwP_Single')), self.show_SinglePacked), |
... | ... | |
659 | 693 |
(('Equipment - [ Pressurized ]', 'Tank', ('Ball_Tank')), self.show_Ball), |
660 | 694 |
(('Equipment - [ Pressurized ]', 'Tank', ('CRT')), self.show_ConeRoof), |
661 | 695 |
(('Equipment - [ Pressurized ]', 'Tank', ('DRT')), self.show_DomeRoof), |
662 |
(('Equipment - [ Rotating ]', 'Compressor', ('L_Comp','R_Comp')), self.show_Compressor), |
|
663 |
(('Equipment - [ Rotating ]', 'Pump', ('L_Pump','R_Pump','V_Pump')), self.show_Pump),
|
|
664 |
(('Instrument', 'Valve', ('CV_H','CV_V')), self.show_ValveControl), |
|
665 |
(('Instrument', 'Valve', ('MV_H','MV_V')), self.show_ValveManual), |
|
696 |
(('Equipment - [ Rotating ]', 'Compressor', ('L_Comp', 'R_Comp')), self.show_Compressor),
|
|
697 |
(('Equipment - [ Rotating ]', 'Pump', ('L_Pump', 'R_Pump', 'V_Pump')), self.show_Pump),
|
|
698 |
(('Instrument', 'Valve', ('CV_H', 'CV_V')), self.show_ValveControl),
|
|
699 |
(('Instrument', 'Valve', ('MV_H', 'MV_V')), self.show_ValveManual),
|
|
666 | 700 |
(('Instrument', 'Line Splitter', ('Line_Splitter')), self.show_LineSplitter), |
667 |
(('Instrument', 'Flowmeter', ('Ori_Flowmeter_H','Oth_Flowmeter_H','Ven_Flowmeter_H','Ori_Flowmeter_V','Oth_Flowmeter_V','Ven_Flowmeter_V')), self.show_Flowmeter), |
|
668 |
(('Instrument', 'Reducer', ('Re_Ex_Dw','Re_Ex_L','Re_Ex_R','Re_Ex_Up')), self.show_Reducer) |
|
669 |
] |
|
701 |
(('Instrument', 'Flowmeter', ( |
|
702 |
'Ori_Flowmeter_H', 'Oth_Flowmeter_H', 'Ven_Flowmeter_H', 'Ori_Flowmeter_V', 'Oth_Flowmeter_V', |
|
703 |
'Ven_Flowmeter_V')), self.show_Flowmeter), |
|
704 |
(('Instrument', 'Reducer', ('Re_Ex_Dw', 'Re_Ex_L', 'Re_Ex_R', 'Re_Ex_Up')), self.show_Reducer) |
|
705 |
] |
|
670 | 706 | |
671 | 707 |
connectedItems = [connector for connector in self.connectors if connector.connectedItem is not None] |
672 |
if len(connectedItems) < 1: |
|
673 | ||
708 |
if len(connectedItems) < 1: |
|
674 | 709 |
msg = QMessageBox() |
675 | 710 |
msg.setIcon(QMessageBox.Information) |
676 | 711 |
msg.setText(self.tr('Connect Line before Data input')) |
677 | 712 |
msg.setWindowTitle(self.tr("Notice")) |
678 | 713 |
msg.setStandardButtons(QMessageBox.Ok) |
679 |
msg.exec_()
|
|
714 |
msg.exec_() |
|
680 | 715 |
return |
681 | 716 | |
682 |
matches = [func for func in func_map if func[0][0] == self.category and func[0][1] == self.type and (func[0][2] is None or self.name in func[0][2])] |
|
717 |
matches = [func for func in func_map if func[0][0] == self.category and func[0][1] == self.type and ( |
|
718 |
func[0][2] is None or self.name in func[0][2])] |
|
683 | 719 |
if matches: matches[0][1]() |
684 | 720 | |
685 | 721 |
def show_AirFinCooler(self): |
... | ... | |
690 | 726 | |
691 | 727 |
def show_Filter(self): |
692 | 728 |
from Filter import QFilter |
693 |
|
|
729 | ||
694 | 730 |
dialog = QFilter() |
695 | 731 |
dialog.showDialog(self) |
696 | 732 | |
697 | 733 |
def show_Coil(self): |
698 | 734 |
from Coil import QCoil |
699 |
|
|
735 | ||
700 | 736 |
dialog = QCoil() |
701 | 737 |
dialog.showDialog(self) |
702 | 738 | |
703 | 739 |
def show_DP_Equipment(self): |
704 | 740 |
from DP_Equipment import QDP_Equipment |
705 |
|
|
741 | ||
706 | 742 |
dialog = QDP_Equipment() |
707 | 743 |
dialog.showDialog(self) |
708 | 744 | |
709 | 745 |
def show_Reactor(self): |
710 | 746 |
from Reactor import QReactor |
711 |
|
|
747 | ||
712 | 748 |
dialog = QReactor() |
713 | 749 |
dialog.showDialog(self) |
714 | 750 | |
715 | 751 |
def show_Strainer_T(self): |
716 | 752 |
from Strainer_T import QStrainer_T |
717 |
|
|
753 | ||
718 | 754 |
dialog = QStrainer_T() |
719 | 755 |
dialog.showDialog(self) |
720 | 756 | |
721 | 757 |
def show_Strainer_Y(self): |
722 | 758 |
from Strainer_Y import QStrainer_Y |
723 |
|
|
759 | ||
724 | 760 |
dialog = QStrainer_Y() |
725 | 761 |
dialog.showDialog(self) |
726 | 762 | |
727 | 763 |
def show_BatteryLimit(self): |
728 | 764 |
from BatteryLimit import QBatteryLimit |
729 |
|
|
765 | ||
730 | 766 |
dialog = QBatteryLimit() |
731 | 767 |
dialog.showDialog(self) |
732 |
|
|
768 | ||
733 | 769 |
def show_Tray(self): |
734 | 770 |
from Tray import QTray |
735 |
|
|
771 | ||
736 | 772 |
dialog = QTray() |
737 | 773 |
dialog.showDialog(self) |
738 | 774 | |
739 | 775 |
def show_SinglePacked(self): |
740 | 776 |
from SinglePacked import QSinglePacked |
741 |
|
|
777 | ||
742 | 778 |
dialog = QSinglePacked() |
743 | 779 |
dialog.showDialog(self) |
744 | 780 | |
745 | 781 |
def show_DualPacked(self): |
746 | 782 |
from DualPacked import QDualPacked |
747 |
|
|
783 | ||
748 | 784 |
dialog = QDualPacked() |
749 | 785 |
dialog.showDialog(self) |
750 | 786 | |
751 | 787 |
def show_Drum_Horizontal(self): |
752 | 788 |
from Drum_Horizontal import QDrum_Horizontal |
753 |
|
|
789 | ||
754 | 790 |
dialog = QDrum_Horizontal() |
755 | 791 |
dialog.showDialog(self) |
756 | 792 | |
757 | 793 |
def show_Drum_Vertical(self): |
758 | 794 |
from Drum_Vertical import QDrum_Vertical |
759 |
|
|
795 | ||
760 | 796 |
dialog = QDrum_Vertical() |
761 | 797 |
dialog.showDialog(self) |
762 | 798 | |
763 | 799 |
def show_PlateHeatExchanger(self): |
764 | 800 |
from PlateHeatExchanger import QPlateHeatExchanger |
765 |
|
|
801 | ||
766 | 802 |
dialog = QPlateHeatExchanger() |
767 | 803 |
dialog.showDialog(self) |
768 | 804 | |
769 | 805 |
def show_Equipment(self): |
770 | 806 |
from Equipment import QEquipment |
771 |
|
|
807 | ||
772 | 808 |
dialog = QEquipment() |
773 | 809 |
dialog.showDialog(self) |
774 | 810 | |
775 | 811 |
def show_Ball(self): |
776 | 812 |
from Ball import QBall |
777 |
|
|
813 | ||
778 | 814 |
dialog = QBall() |
779 | 815 |
dialog.showDialog(self) |
780 | 816 | |
781 | 817 |
def show_ShlTubHeatExchanger(self): |
782 | 818 |
from ShlTubHeatExchanger import QShlTubHeatExchanger |
783 |
|
|
819 | ||
784 | 820 |
dialog = QShlTubHeatExchanger() |
785 | 821 |
dialog.showDialog(self) |
786 | 822 | |
787 | 823 |
def show_ConeRoof(self): |
788 | 824 |
from ConeRoof import QConeRoof |
789 |
|
|
825 | ||
790 | 826 |
dialog = QConeRoof() |
791 | 827 |
dialog.showDialog(self) |
792 |
|
|
828 | ||
793 | 829 |
def show_DomeRoof(self): |
794 | 830 |
from DomeRoof import QDomeRoof |
795 |
|
|
831 | ||
796 | 832 |
dialog = QDomeRoof() |
797 | 833 |
dialog.showDialog(self) |
798 | 834 | |
799 | 835 |
def show_Compressor(self): |
800 | 836 |
from Compressor import QCompressor |
801 |
|
|
837 | ||
802 | 838 |
dialog = QCompressor() |
803 | 839 |
dialog.showDialog(self) |
804 | 840 | |
805 | 841 |
def show_Pump(self): |
806 | 842 |
from Pump import QPump |
807 |
|
|
843 | ||
808 | 844 |
dialog = QPump() |
809 | 845 |
dialog.showDialog(self) |
810 | 846 | |
811 | 847 |
def show_ValveControl(self): |
812 | 848 |
from Valve_Control import QValve_Control |
813 |
|
|
849 | ||
814 | 850 |
dialog = QValve_Control() |
815 | 851 |
dialog.showDialog(self) |
816 | 852 | |
817 | 853 |
def show_ValveManual(self): |
818 | 854 |
from Valve_Manual import QValve_Manual |
819 |
|
|
855 | ||
820 | 856 |
dialog = QValve_Manual() |
821 | 857 |
dialog.showDialog(self) |
822 | 858 | |
823 | 859 |
def show_LineSplitter(self): |
824 | 860 |
from LineSplitter import QLineSplitter |
825 |
|
|
861 | ||
826 | 862 |
dialog = QLineSplitter() |
827 | 863 |
dialog.showDialog(self) |
828 | 864 | |
829 | 865 |
def show_Flowmeter(self): |
830 | 866 |
from Flowmeter import QFlowmeter |
831 |
|
|
867 | ||
832 | 868 |
dialog = QFlowmeter() |
833 | 869 |
dialog.showDialog(self) |
834 | 870 | |
835 | 871 |
def show_Reducer(self): |
836 | 872 |
from Reducer import QReducer |
837 |
|
|
873 | ||
838 | 874 |
dialog = QReducer() |
839 | 875 |
dialog.showDialog(self) |
840 | 876 | |
841 |
@staticmethod
|
|
877 |
@staticmethod |
|
842 | 878 |
def fromDatabase(componentInfos): |
843 | 879 |
""" create a componenet from database """ |
844 | 880 |
item = None |
845 | 881 | |
846 | 882 |
try: |
847 |
uid = componentInfos[0][0] # uid@Components
|
|
848 |
dbUid = componentInfos[0][2] # Symbol_UID@Components
|
|
849 |
category = componentInfos[0][3] # Category@SymbolType
|
|
850 |
_type = componentInfos[0][4] # Type@SymbolType
|
|
851 |
name = componentInfos[0][5] # Name@Symbols
|
|
852 |
originalPoint = componentInfos[0][6] # OriginalPoint@Symbols
|
|
853 |
x = componentInfos[0][7] # X@Components
|
|
854 |
y = componentInfos[0][8] # Y@Components
|
|
855 |
angle = componentInfos[0][9] # Rotation@Components
|
|
856 |
scale = componentInfos[0][10] # Scale@Components
|
|
883 |
uid = componentInfos[0][0] # uid@Components |
|
884 |
dbUid = componentInfos[0][2] # Symbol_UID@Components |
|
885 |
category = componentInfos[0][3] # Category@SymbolType |
|
886 |
_type = componentInfos[0][4] # Type@SymbolType |
|
887 |
name = componentInfos[0][5] # Name@Symbols |
|
888 |
originalPoint = componentInfos[0][6] # OriginalPoint@Symbols |
|
889 |
x = componentInfos[0][7] # X@Components |
|
890 |
y = componentInfos[0][8] # Y@Components |
|
891 |
angle = componentInfos[0][9] # Rotation@Components
|
|
892 |
scale = componentInfos[0][10] # Scale@Components
|
|
857 | 893 | |
858 | 894 |
pt = [] |
859 | 895 |
pt.append(float(x)) |
... | ... | |
865 | 901 | |
866 | 902 |
pointsUids = [] |
867 | 903 |
for componentInfo in componentInfos: |
868 |
pointsUid = componentInfo[11] # uid@Points
|
|
904 |
pointsUid = componentInfo[11] # uid@Points |
|
869 | 905 |
pointsUids.append(pointsUid) |
870 | 906 | |
871 | 907 |
app_doc_data = AppDocData.instance() |
... | ... | |
876 | 912 |
item.setVisible(False) |
877 | 913 |
item.buildItem(name, _type, float(angle), float(scale), pt, origin, connPts, dbUid, pointsUids) |
878 | 914 |
except Exception as ex: |
879 |
from App import App |
|
880 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
915 |
from App import App |
|
916 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
917 |
sys.exc_info()[-1].tb_lineno) |
|
881 | 918 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
882 | 919 | |
883 | 920 |
return item |
... | ... | |
890 | 927 |
humkyung 2018.05.10 change symbol's color to blue |
891 | 928 |
humkyung 2018.07.19 create nozzle instance if type is 'Nozzles' |
892 | 929 |
''' |
930 | ||
893 | 931 |
@staticmethod |
894 |
def createItem(type, path, uid=None, owner=None, flip=0):
|
|
895 |
from EngineeringNozzleItem import QEngineeringNozzleItem
|
|
896 |
from EngineeringErrorItem import QEngineeringErrorItem
|
|
932 |
def createItem(type, path, uid=None, owner=None, flip=0): |
|
933 |
from EngineeringNozzleItem import QEngineeringNozzleItem |
|
934 |
from EngineeringErrorItem import QEngineeringErrorItem |
|
897 | 935 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
898 | 936 |
from AppDocData import AppDocData |
899 | 937 |
import uuid |
... | ... | |
912 | 950 |
@history 2018.05.11 Jeongwoo Override QEngineeringAbstractItem's |
913 | 951 |
humkyung 2018.05.13 update after change color |
914 | 952 |
''' |
953 | ||
915 | 954 |
def setColor(self, color): |
916 | 955 |
self.changeAttributes('fill', color) |
917 | 956 |
self.changeAttributes('stroke', color) |
... | ... | |
920 | 959 | |
921 | 960 |
def getColor(self): |
922 | 961 |
""" return hover color if mouse is over otherwise reutrn owner's color if owner exist else this color """ |
923 |
return SymbolSvgItem.HOVER_COLOR if self.hover else (self.owner._color if self.owner and hasattr(self.owner, '_color') else self._color) |
|
962 |
return SymbolSvgItem.HOVER_COLOR if self.hover else ( |
|
963 |
self.owner._color if self.owner and hasattr(self.owner, '_color') else self._color) |
|
924 | 964 | |
925 | 965 |
''' |
926 | 966 |
@brief get attributes from svg file |
927 | 967 |
@author humkyung |
928 | 968 |
@date 2019.03.08 |
929 | 969 |
''' |
970 | ||
930 | 971 |
def get_attribute(self, attName): |
931 | 972 |
root = self._document.documentElement() |
932 | 973 |
node = root.firstChild() |
... | ... | |
949 | 990 |
@author humkyung |
950 | 991 |
@date 2019.03.08 |
951 | 992 |
''' |
993 | ||
952 | 994 |
def recursive_get_attribute(self, node, attName): |
953 | 995 |
while not node.isNull(): |
954 | 996 |
if node.isElement(): |
... | ... | |
959 | 1001 |
if node.hasChildNodes(): |
960 | 1002 |
att_val = self.recursive_get_attribute(node.firstChild(), attName) |
961 | 1003 |
if att_val is not None: return att_val |
962 |
|
|
1004 | ||
963 | 1005 |
node = node.nextSibling() |
964 | 1006 | |
965 | 1007 |
return None |
... | ... | |
969 | 1011 |
@author humkyung |
970 | 1012 |
@date 2018.05.10 |
971 | 1013 |
''' |
1014 | ||
972 | 1015 |
def changeAttributes(self, attName, attValue): |
973 | 1016 |
root = self._document.documentElement() |
974 | 1017 |
node = root.firstChild() |
... | ... | |
988 | 1031 |
@author humkyung |
989 | 1032 |
@date 2018.05.10 |
990 | 1033 |
''' |
1034 | ||
991 | 1035 |
def recursiveChangeAttributes(self, node, attName, attValue): |
992 | 1036 |
while not node.isNull(): |
993 | 1037 |
if node.isElement(): |
... | ... | |
997 | 1041 | |
998 | 1042 |
if node.hasChildNodes(): |
999 | 1043 |
recursiveChangeAttributes(node.firstChild(), attName, attValue) |
1000 |
|
|
1044 | ||
1001 | 1045 |
node = node.nextSibling() |
1002 | 1046 | |
1003 | 1047 |
''' |
... | ... | |
1005 | 1049 |
@author humkyung |
1006 | 1050 |
@date 2018.07.07 |
1007 | 1051 |
''' |
1052 | ||
1008 | 1053 |
def drawFocusRect(self, painter): |
1009 | 1054 |
self.focuspen = QPen(Qt.DotLine) |
1010 | 1055 |
self.focuspen.setColor(Qt.black) |
... | ... | |
1019 | 1064 |
@author humkyung |
1020 | 1065 |
@date 2018.04.21 |
1021 | 1066 |
''' |
1067 | ||
1022 | 1068 |
def paint(self, painter, options=None, widget=None): |
1023 | 1069 |
from EngineeringAbstractItem import QEngineeringAbstractItem |
1024 | 1070 |
from EngineeringTextItem import QEngineeringTextItem |
... | ... | |
1029 | 1075 |
QGraphicsSvgItem.paint(self, painter, options, widget) |
1030 | 1076 |
for attr in self.attrs: |
1031 | 1077 |
if issubclass(type(attr), QEngineeringTextItem): |
1032 |
color = QEngineeringAbstractItem.HOVER_COLOR if self.hover else (self._owner._color if self._owner else QEngineeringAbstractItem.DEFAULT_COLOR) |
|
1078 |
color = QEngineeringAbstractItem.HOVER_COLOR if self.hover else ( |
|
1079 |
self._owner._color if self._owner else QEngineeringAbstractItem.DEFAULT_COLOR) |
내보내기 Unified diff