개정판 c3a5995f
issue #000: attr freeze and connline testing
Change-Id: Ieab357a37e84b7e7fbd1de75c853fa7e8685ee1d
DTI_PID/DTI_PID/Commands/SelectAttributeCommand.py | ||
---|---|---|
93 | 93 |
# self._item.attrs[self._attr] = str(item.uid) |
94 | 94 |
# self.onSuccess.emit() |
95 | 95 |
elif item is not None and self._attr.AttributeType == QEngineeringAbstractItem.assoc_type(item): |
96 |
if self._attr.Freeze: |
|
97 |
self.onSuccess.emit() |
|
98 |
return |
|
99 |
|
|
96 | 100 |
if self._attr.AttributeType not in self._item._associations: |
97 | 101 |
self._item._associations[self._attr.AttributeType] = [] |
98 | 102 |
|
DTI_PID/DTI_PID/ItemPropertyTableWidget.py | ||
---|---|---|
27 | 27 |
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
28 | 28 |
from EngineeringErrorItem import QEngineeringErrorItem |
29 | 29 |
from EngineeringVendorItem import QEngineeringVendorItem |
30 |
from SymbolAttr import SymbolAttr |
|
30 | 31 |
from AppDocData import * |
31 | 32 |
from Drawing import Drawing |
32 | 33 |
from enum import Enum |
... | ... | |
52 | 53 |
def state_changed(self, state): |
53 | 54 |
""" check box state is changed """ |
54 | 55 |
if self.col == 0: |
56 |
''' |
|
57 |
for index in range(self.table.rowCount()): |
|
58 |
data = self.table.item(index, 1).data(Qt.UserRole) if self.table.item(index, 1) is not None else None |
|
59 |
if data and type(data) is SymbolAttr: |
|
60 |
widget = self.table.cellWidget(index, 3) |
|
61 |
if widget: |
|
62 |
widget.setEnabled(False) if state else widget.setEnabled(True) |
|
63 |
data.Freeze = self.isChecked() |
|
64 |
|
|
65 |
item = self.table.item(index, 3) |
|
66 |
if item: |
|
67 |
item.setFlags(Qt.ItemIsEnabled) if state else item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsEditable|Qt.ItemIsSelectable) |
|
68 |
item.setBackground(Qt.lightGray) if state else item.setBackground(Qt.white) |
|
69 |
''' |
|
70 |
|
|
55 | 71 |
widget = self.table.cellWidget(self.row, 3) |
56 | 72 |
if widget: |
57 | 73 |
widget.setEnabled(False) if state else widget.setEnabled(True) |
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
161 | 161 |
for lineno in self._lineNos: |
162 | 162 |
_from = lineno.prop('From') |
163 | 163 |
_to = lineno.prop('To') |
164 |
|
|
164 |
|
|
165 | 165 |
lineno.conns.clear() |
166 | 166 |
minDist = None |
167 | 167 |
startLine = None |
... | ... | |
430 | 430 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
431 | 431 |
|
432 | 432 |
""" try to connect label to valve """ |
433 |
labels = [symbol for symbol in symbols if type(symbol) is QEngineeringInstrumentItem and not symbol.is_connected] |
|
434 |
valves = [symbol for symbol in symbols if type(symbol) is not QEngineeringInstrumentItem and type(symbol) is not QEngineeringReducerItem and type(symbol) is not QEngineeringEquipmentItem \ |
|
433 |
labels = [symbol for symbol in symbols if type(symbol) is QEngineeringInstrumentItem and not symbol.has_connection] |
|
434 |
#print(labels[0]) |
|
435 |
valves = [symbol for symbol in symbols if (type(symbol) is QEngineeringInstrumentItem and symbol.has_connection) and type(symbol) is not QEngineeringReducerItem and type(symbol) is not QEngineeringEquipmentItem \ |
|
435 | 436 |
and type(symbol) is not QEngineeringOPCItem and type(symbol) is not QEngineeringSpecBreakItem] |
437 |
#print(valves[0]) |
|
436 | 438 |
for valve in valves: |
437 | 439 |
valve.connectAttribute(labels, clear=False) |
438 | 440 |
|
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py | ||
---|---|---|
77 | 77 |
self._owner = value |
78 | 78 |
|
79 | 79 |
@property |
80 |
def is_connected(self):
|
|
80 |
def has_connection(self):
|
|
81 | 81 |
""" check this is connected to other """ |
82 | 82 |
for connector in self.connectors: |
83 | 83 |
if connector.connectedItem: return True |
... | ... | |
154 | 154 |
|
155 | 155 |
return _type |
156 | 156 |
|
157 |
def clear_attr_and_assoc_item(self, force=False): |
|
158 |
if force: |
|
159 |
self.attrs.clear() |
|
160 |
self._associations.clear() |
|
161 |
else: |
|
162 |
for key in self.attrs.keys(): |
|
163 |
if key.Freeze: |
|
164 |
return |
|
165 |
|
|
166 |
|
|
167 |
self.attrs.clear() |
|
168 |
self._associations.clear() |
|
169 |
|
|
157 | 170 |
def add_assoc_item(self, item, at=None): |
158 | 171 |
""" add given item to association """ |
159 | 172 |
|
... | ... | |
162 | 175 |
from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem |
163 | 176 |
from QEngineeringSizeTextItem import QEngineeringSizeTextItem |
164 | 177 |
|
178 |
for key in self.attrs.keys(): |
|
179 |
if key.Freeze: |
|
180 |
return False |
|
181 |
|
|
165 | 182 |
_type = QEngineeringAbstractItem.assoc_type(item) |
166 | 183 |
if _type is not None: |
167 | 184 |
if not _type in self._associations: |
168 | 185 |
self._associations[_type] = [] |
169 | 186 |
|
170 |
if item in self._associations[_type]: return |
|
187 |
if item in self._associations[_type]: return True
|
|
171 | 188 |
|
172 | 189 |
if at is None: |
173 | 190 |
self._associations[_type].append(item) |
174 | 191 |
else: |
175 | 192 |
while len(self._associations[_type]) <= at: self._associations[_type].append(None) |
193 |
#if len(self._associations[_type]) > at and self._associations[_type][at] is not None: |
|
194 |
# self._associations[_type][at].owner = None |
|
176 | 195 |
self._associations[_type][at] = item |
177 | 196 |
|
197 |
return True |
|
198 |
|
|
199 |
return False |
|
200 |
|
|
178 | 201 |
def remove_assoc_item(self, item): |
179 | 202 |
""" remove given item from association """ |
180 | 203 |
_type = QEngineeringAbstractItem.assoc_type(item) |
DTI_PID/DTI_PID/Shapes/EngineeringEquipmentItem.py | ||
---|---|---|
81 | 81 |
from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem |
82 | 82 |
|
83 | 83 |
if clear: |
84 |
self.attrs.clear() |
|
85 |
self._associations.clear() |
|
84 |
self.clear_attr_and_assoc_item() |
|
86 | 85 |
|
86 |
# tag no text item will find owner itself |
|
87 |
''' |
|
87 | 88 |
try: |
88 | 89 |
rect = self.sceneBoundingRect() |
89 | 90 |
attrs = [attr for attr in attributes if type(attr) is QEngineeringTagNoTextItem] |
... | ... | |
114 | 115 |
|
115 | 116 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
116 | 117 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
118 |
''' |
|
117 | 119 |
|
118 | 120 |
def getColor(self): |
119 | 121 |
""" return equipment's color """ |
DTI_PID/DTI_PID/Shapes/EngineeringInstrumentItem.py | ||
---|---|---|
163 | 163 |
@date 2018.05.06 |
164 | 164 |
''' |
165 | 165 |
def connectAttribute(self, attributes, clear=True): |
166 |
if clear: |
|
167 |
self.attrs.clear() |
|
168 |
self._associations.clear() |
|
169 |
|
|
170 | 166 |
try: |
167 |
if clear: |
|
168 |
self.clear_attr_and_assoc_item() |
|
169 |
|
|
171 | 170 |
rect = self.sceneBoundingRect() |
172 | 171 |
for attr in attributes: |
173 | 172 |
if rect.contains(attr.center()): |
174 | 173 |
if issubclass(type(attr), QEngineeringTextItem): |
175 |
attr.owner = self # set owner of text
|
|
176 |
self.add_assoc_item(attr)
|
|
174 |
if self.add_assoc_item(attr):
|
|
175 |
attr.owner = self # set owner of text
|
|
177 | 176 |
elif issubclass(type(attr), SymbolSvgItem): |
178 |
attr.owner = self # set owner of symbol
|
|
179 |
self.add_assoc_item(attr)
|
|
177 |
if self.add_assoc_item(attr):
|
|
178 |
attr.owner = self # set owner of text
|
|
180 | 179 |
except Exception as ex: |
181 | 180 |
from App import App |
182 | 181 |
from AppDocData import MessageType |
DTI_PID/DTI_PID/Shapes/EngineeringReducerItem.py | ||
---|---|---|
74 | 74 |
from EngineeringInstrumentItem import QEngineeringInstrumentItem |
75 | 75 |
from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem |
76 | 76 |
|
77 |
if clear: |
|
78 |
self.attrs.clear() |
|
79 |
self._associations.clear() |
|
80 |
|
|
81 | 77 |
try: |
78 |
if clear: |
|
79 |
self.clear_attr_and_assoc_item() |
|
80 |
|
|
82 | 81 |
#configs = AppDocData.instance().getConfigs('Size', 'Delimiter') |
83 | 82 |
#delimiter = configs[0].value if configs else 'X' |
84 | 83 |
configs = AppDocData.instance().getConfigs('Range', 'Detection Ratio') |
... | ... | |
103 | 102 |
dx = attr.center().x() - center.x() |
104 | 103 |
dy = attr.center().y() - center.y() |
105 | 104 |
if math.sqrt(dx*dx + dy*dy) < dist: |
106 |
self.add_assoc_item(attr)
|
|
107 |
attr.owner = self
|
|
105 |
if self.add_assoc_item(attr):
|
|
106 |
attr.owner = self # set owner of text
|
|
108 | 107 |
|
109 | 108 |
if selected is not None: |
110 |
self.add_assoc_item(selected)
|
|
111 |
selected.owner = self
|
|
109 |
if self.add_assoc_item(selected):
|
|
110 |
selected.owner = self # set owner of text
|
|
112 | 111 |
|
113 | 112 |
except Exception as ex: |
114 | 113 |
from App import App |
DTI_PID/DTI_PID/Shapes/EngineeringValveOperCodeTextItem.py | ||
---|---|---|
56 | 56 |
selected = symbol |
57 | 57 |
|
58 | 58 |
if selected is not None: |
59 |
selected.add_assoc_item(self)
|
|
60 |
self.owner = selected |
|
59 |
if selected.add_assoc_item(self):
|
|
60 |
self.owner = selected
|
|
61 | 61 |
|
62 | 62 |
except Exception as ex: |
63 | 63 |
from App import App |
DTI_PID/DTI_PID/Shapes/QEngineeringOPCItem.py | ||
---|---|---|
66 | 66 |
from AppDocData import AppDocData, MessageType |
67 | 67 |
from EngineeringLineItem import QEngineeringLineItem |
68 | 68 |
|
69 |
if clear: |
|
70 |
self.attrs.clear() |
|
71 |
self._associations.clear() |
|
72 |
|
|
73 | 69 |
try: |
70 |
if clear: |
|
71 |
self.clear_attr_and_assoc_item() |
|
72 |
|
|
74 | 73 |
app_doc_data = AppDocData.instance() |
75 | 74 |
|
76 | 75 |
matches = [connector.connectedItem for connector in self.connectors if connector is not None and type(connector.connectedItem) is QEngineeringLineItem] |
DTI_PID/DTI_PID/Shapes/QEngineeringSizeTextItem.py | ||
---|---|---|
61 | 61 |
minDist = length |
62 | 62 |
selected = symbol |
63 | 63 |
|
64 |
if selected is not None: |
|
65 |
selected.add_assoc_item(self)
|
|
66 |
self.owner = selected |
|
64 |
if selected is not None:
|
|
65 |
if selected.add_assoc_item(self):
|
|
66 |
self.owner = selected
|
|
67 | 67 |
|
68 | 68 |
except Exception as ex: |
69 | 69 |
from App import App |
DTI_PID/DTI_PID/Shapes/QEngineeringTagNoTextItem.py | ||
---|---|---|
61 | 61 |
selected = symbol |
62 | 62 |
|
63 | 63 |
if selected is not None: |
64 |
self.owner = selected
|
|
65 |
#selected.owner = self.owner
|
|
64 |
if selected.add_assoc_item(self):
|
|
65 |
self.owner = selected
|
|
66 | 66 |
|
67 | 67 |
except Exception as ex: |
68 | 68 |
from App import App |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
735 | 735 |
from EngineeringInstrumentItem import QEngineeringInstrumentItem |
736 | 736 |
from EngineeringValveOperCodeTextItem import QEngineeringValveOperCodeTextItem |
737 | 737 |
|
738 |
if clear: |
|
739 |
self.attrs.clear() |
|
740 |
self._associations.clear() |
|
741 |
|
|
742 | 738 |
try: |
739 |
if clear: |
|
740 |
self.clear_attr_and_assoc_item() |
|
741 |
|
|
743 | 742 |
configs = AppDocData.instance().getConfigs('Range', 'Detection Ratio') |
744 | 743 |
ratio = float(configs[0].value) if 1 == len(configs) else 1.5 |
745 | 744 |
|
... | ... | |
762 | 761 |
dx = attr.center().x() - center.x() |
763 | 762 |
dy = attr.center().y() - center.y() |
764 | 763 |
if math.sqrt(dx*dx + dy*dy) < dist: |
765 |
self.add_assoc_item(attr)
|
|
766 |
attr.owner = self |
|
764 |
if self.add_assoc_item(attr):
|
|
765 |
attr.owner = self
|
|
767 | 766 |
|
768 | 767 |
if selected is not None: |
769 |
self.add_assoc_item(selected)
|
|
770 |
selected.owner = self |
|
768 |
if self.add_assoc_item(selected):
|
|
769 |
selected.owner = self
|
|
771 | 770 |
|
772 | 771 |
except Exception as ex: |
773 | 772 |
from App import App |
DTI_PID/DTI_PID/SymbolAttr.py | ||
---|---|---|
11 | 11 |
|
12 | 12 |
self.UID = uuid.uuid4() if UID is None else uuid.UUID(UID, version=4) |
13 | 13 |
self.Freeze = Freeze |
14 |
self.Attribute = Attribute
|
|
14 |
self.Attribute = Attribute |
|
15 | 15 |
self.AttributeType = AttributType |
16 | 16 |
self.DisplayAttribute = DisplayAttribute if DisplayAttribute else Attribute |
17 | 17 |
self.Length = Length |
내보내기 Unified diff