개정판 fb19d5c3
issue #622:
- add EngineeringReducerItem
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py | ||
---|---|---|
15 | 15 |
self._area = None |
16 | 16 |
self.connectors = [] |
17 | 17 |
self.attrs = {} # attributes |
18 |
self._associations = {} # associated items |
|
18 |
self._associations = {'Text Item':[], 'Symbol Item':[]} # associated items
|
|
19 | 19 |
|
20 | 20 |
''' |
21 | 21 |
@brief Abstract method. Variable [color] is RGB hex code |
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
879 | 879 |
""" |
880 | 880 |
restore original color |
881 | 881 |
""" |
882 |
self.setColor(self._savedColor) |
|
882 |
try: |
|
883 |
self.setColor(self._savedColor) |
|
883 | 884 |
|
884 |
rect = self.sceneBoundingRect() |
|
885 |
rect.setRect(rect.left() - QEngineeringLineItem.ARROW_SIZE, rect.top() - QEngineeringLineItem.ARROW_SIZE, |
|
886 |
rect.width() + QEngineeringLineItem.ARROW_SIZE*2, rect.height() + QEngineeringLineItem.ARROW_SIZE*2) |
|
887 |
self.scene().invalidate(rect) |
|
885 |
rect = self.sceneBoundingRect()
|
|
886 |
rect.setRect(rect.left() - QEngineeringLineItem.ARROW_SIZE, rect.top() - QEngineeringLineItem.ARROW_SIZE,
|
|
887 |
rect.width() + QEngineeringLineItem.ARROW_SIZE*2, rect.height() + QEngineeringLineItem.ARROW_SIZE*2)
|
|
888 |
self.scene().invalidate(rect)
|
|
888 | 889 |
|
889 |
for child in self.childItems(): |
|
890 |
child.setBrush(Qt.blue) |
|
890 |
for child in self.childItems(): |
|
891 |
child.setBrush(Qt.blue) |
|
892 |
except Exception as ex: |
|
893 |
from App import App |
|
894 |
from AppDocData import MessageType |
|
895 |
|
|
896 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
897 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
891 | 898 |
|
892 | 899 |
def hoverMoveEvent(self, event): |
893 | 900 |
pass |
DTI_PID/DTI_PID/Shapes/EngineeringReducerItem.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
|
|
3 |
import sys |
|
4 |
import os |
|
5 |
import math |
|
6 |
from PyQt5.QtGui import * |
|
7 |
from PyQt5.QtCore import * |
|
8 |
from PyQt5.QtSvg import * |
|
9 |
from PyQt5.QtWidgets import (QApplication, QGraphicsItem) |
|
10 |
|
|
11 |
from SymbolSvgItem import SymbolSvgItem |
|
12 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
|
13 |
|
|
14 |
class QEngineeringReducerItem(SymbolSvgItem): |
|
15 |
""" |
|
16 |
This is reducer class |
|
17 |
""" |
|
18 |
|
|
19 |
ZVALUE = 20 |
|
20 |
clicked = pyqtSignal(QGraphicsSvgItem) |
|
21 |
|
|
22 |
''' |
|
23 |
''' |
|
24 |
def __init__(self, path, uid=None): |
|
25 |
SymbolSvgItem.__init__(self, path, uid) |
|
26 |
|
|
27 |
self.setZValue(QEngineeringReducerItem.ZVALUE) |
|
28 |
|
|
29 |
def connectAttribute(self, attributes): |
|
30 |
""" |
|
31 |
connect attribute of reducer |
|
32 |
""" |
|
33 |
|
|
34 |
super(QEngineeringReducerItem, self).connectAttribute(attributes) |
|
35 |
|
|
36 |
def getAttributes(self): |
|
37 |
""" |
|
38 |
get attributes of reducer |
|
39 |
""" |
|
40 |
|
|
41 |
_attrs = {} |
|
42 |
try: |
|
43 |
from AppDocData import AppDocData |
|
44 |
from EngineeringTextItem import QEngineeringTextItem |
|
45 |
|
|
46 |
# 해당 Type의 attribute setting |
|
47 |
docData = AppDocData.instance() |
|
48 |
symbolAttrs = docData.getSymbolAttribute(self.type) |
|
49 |
_texts = self.texts() |
|
50 |
_symbols = self.symbols() |
|
51 |
for attr in symbolAttrs: |
|
52 |
if attr.AttributeType == 'Text Item': |
|
53 |
at = int(attr.AttrAt) |
|
54 |
if len(_texts) > at: |
|
55 |
item = _texts[at] |
|
56 |
_attrs[attr] = eval(attr.Expression) if attr.Expression else '' |
|
57 |
else: |
|
58 |
_attrs[attr] = '' |
|
59 |
else: |
|
60 |
matches = [prop for prop in self.attrs if prop.UID == attr.UID] |
|
61 |
if len(matches) == 1: |
|
62 |
_attrs[matches[0]] = self.attrs[matches[0]] |
|
63 |
else: |
|
64 |
_attrs[attr] = '' |
|
65 |
except Exception as ex: |
|
66 |
from App import App |
|
67 |
from AppDocData import MessageType |
|
68 |
|
|
69 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
70 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
71 |
|
|
72 |
return _attrs |
내보내기 Unified diff