개정판 03a684dd
issue #000: fix line conns
Change-Id: I30073cfb83cb94e62f37fcb941decc5dc57ad27a
DTI_PID/DTI_PID/Commands/SaveWorkCommand.py | ||
---|---|---|
61 | 61 |
from AppDocData import MessageType |
62 | 62 |
|
63 | 63 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
64 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
64 | 65 |
self.display_message.emit(MessageType.Error, message) |
65 | 66 |
|
66 | 67 |
@staticmethod |
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
145 | 145 |
Modify find secondary lines with 'while' used sublist for unconnected line |
146 | 146 |
humkyung 2018.05.18 set start line's owner before tracing |
147 | 147 |
''' |
148 |
def execute(self, displayMessage, updateProgress, toler=50):
|
|
148 |
def execute(self, displayMessage, updateProgress, toler=300):
|
|
149 | 149 |
from EngineeringLineItem import QEngineeringLineItem |
150 | 150 |
from SymbolSvgItem import SymbolSvgItem |
151 | 151 |
from EngineeringRunItem import QEngineeringRunItem |
... | ... | |
161 | 161 |
for lineno in self._lineNos: |
162 | 162 |
_from = lineno.prop('From') |
163 | 163 |
_to = lineno.prop('To') |
164 |
#if type(_from) is str or type(_to) is str: |
|
165 |
# print(str(lineno.uid)) |
|
166 |
if _from and _to and (type(_from) is QEngineeringLineItem or issubclass(type(_from), SymbolSvgItem)) and (type(_to) is QEngineeringLineItem or issubclass(type(_to), SymbolSvgItem)): |
|
167 |
_from.owner = lineno |
|
168 |
_to.owner = lineno |
|
169 |
continue |
|
170 |
else: |
|
171 |
lineno.set_property('From', None) |
|
172 |
lineno.set_property('To', None) |
|
173 |
|
|
164 |
|
|
174 | 165 |
lineno.conns.clear() |
175 | 166 |
minDist = None |
176 | 167 |
startLine = None |
... | ... | |
182 | 173 |
if (startLine is not None) and (minDist < toler): |
183 | 174 |
lineno.conns.append(startLine) |
184 | 175 |
startLine.owner = lineno |
185 |
|
|
186 |
""" |
|
187 |
## lineIndicator |
|
188 |
extendPixel = 30 |
|
189 |
for lineIndicator in self._lineIndicator: |
|
190 |
maxOverLap = 0 |
|
191 |
matchLineNo = None |
|
192 |
liInRect = [round(lineIndicator.boundingRect().x()), round(lineIndicator.boundingRect().y()), round(lineIndicator.boundingRect().x() + lineIndicator.boundingRect().width()), round(lineIndicator.boundingRect().y() + lineIndicator.boundingRect().height())] |
|
193 |
for remainLineNo in remainLineNos: |
|
194 |
xOverlap = False |
|
195 |
yOverlap = False |
|
196 |
extendDx = remainLineNo.size[0] if lineIndicator.isVH == 'V' else remainLineNo.size[1] |
|
197 |
reNoRect = [round(remainLineNo.loc[0] - extendDx), round(remainLineNo.loc[1] - extendDx), round(remainLineNo.loc[0] + remainLineNo.size[0] + extendDx), round(remainLineNo.loc[1] + remainLineNo.size[1] + extendDx)] |
|
198 |
w, h = 0, 0 |
|
199 |
for x1 in range(reNoRect[0], reNoRect[2] + 1): |
|
200 |
for x2 in range(liInRect[0], liInRect[2] + 1): |
|
201 |
if x1 - x2 is 0: |
|
202 |
xOverlap = True |
|
203 |
w += 1 |
|
204 |
if not xOverlap: |
|
205 |
continue |
|
206 |
for y1 in range(reNoRect[1], reNoRect[3] + 1): |
|
207 |
for y2 in range(liInRect[1], liInRect[3] + 1): |
|
208 |
if y1 - y2 is 0: |
|
209 |
yOverlap = True |
|
210 |
h += 1 |
|
211 |
|
|
212 |
if not xOverlap or not yOverlap: |
|
213 |
continue |
|
214 |
overLapRate = (w / lineIndicator.boundingRect().width() * 100) if lineIndicator.boundingRect().width() > lineIndicator.boundingRect().height() else (h / lineIndicator.boundingRect().height() * 100) |
|
215 |
#print(overLapRate) |
|
216 |
if maxOverLap < overLapRate: |
|
217 |
maxOverLap = overLapRate |
|
218 |
matchLineNo = remainLineNo |
|
219 |
#lineIndicator.setBrush(QBrush(QColor(255, 0, 0, 127))) |
|
220 |
|
|
221 |
if matchLineNo is not None: |
|
222 |
#print(matchLineNo.text() + ' indicator : ' + str(lineIndicator.boundingRect().x()) + ', ' + str(lineIndicator.boundingRect().y())) |
|
223 |
matchLine = None |
|
224 |
x1, y1, x2, y2 = int(lineIndicator.boundingRect().x() + lineIndicator.otherLine[0]), int(lineIndicator.boundingRect().y() + lineIndicator.otherLine[1]), int(lineIndicator.boundingRect().x() + lineIndicator.otherLine[2]), int(lineIndicator.boundingRect().y() + lineIndicator.otherLine[3]) |
|
225 |
#print([type(x1), type(y1), type(x2), type(y2)]) |
|
226 |
startXorY = (min(liInRect[0], liInRect[2]) - extendPixel) if lineIndicator.isVH == 'V' else (min(liInRect[1], liInRect[3]) - extendPixel) |
|
227 |
endXorY = (max(liInRect[0], liInRect[2]) + extendPixel) if lineIndicator.isVH == 'V' else (max(liInRect[1], liInRect[3]) + extendPixel) |
|
228 |
fXorY = [] |
|
229 |
for dXOrdY in range(startXorY, endXorY + 1): # if horizontal -> Y, if vertical -> X |
|
230 |
if lineIndicator.isVH == 'V': |
|
231 |
fXorY.append(round(((y2-y1)/(x2-x1))*dXOrdY + y1 - ((y2-y1)/(x2-x1))*x1)) # f(x) |
|
232 |
else: |
|
233 |
fXorY.append(round(((x2-x1)/(y2-y1))*dXOrdY + x1 - ((x2-x1)/(y2-y1))*y1)) # f(y) |
|
234 |
|
|
235 |
#print(self._lines) |
|
236 |
for line in self._lines: |
|
237 |
axis1Overlap = False |
|
238 |
axis2Overlap = False |
|
239 |
lX1, lY1, lX2, lY2 = int(line.startPoint()[0]), int(line.startPoint()[1]), int(line.endPoint()[0]), int(line.endPoint()[1]) |
|
240 |
#print([lX1, lY1, lX2, lY2]) |
|
241 |
|
|
242 |
if lineIndicator.isVH == 'V': |
|
243 |
range11 = range(startXorY, endXorY + 1) |
|
244 |
range12 = range(min(lX1, lX2), max(lX1, lX2)+ 1) |
|
245 |
range21 = fXorY |
|
246 |
range22 = range(min(lY1, lY2), max(lY1, lY2) + 1) |
|
247 |
else: |
|
248 |
range11 = range(startXorY, endXorY + 1) |
|
249 |
range12 = range(min(lY1, lY2), max(lY1, lY2) + 1) |
|
250 |
range21 = fXorY |
|
251 |
range22 = range(min(lX1, lX2), max(lX1, lX2) + 1) |
|
252 |
#print(fXorY) |
|
253 |
#print(type(fXorY[0])) |
|
254 |
#print([range11[0],range11[-1], range12[0],range12[-1], range21[0],range21[-1], range22[0],range22[-1]]) |
|
255 |
|
|
256 |
for axis11 in range11: |
|
257 |
for axis12 in range12: |
|
258 |
if axis11 - axis12 is 0: |
|
259 |
axis1Overlap = True |
|
260 |
break |
|
261 |
if axis1Overlap: break |
|
262 |
if not axis1Overlap: |
|
263 |
continue |
|
264 |
for axis21 in range21: |
|
265 |
for axis22 in range22: |
|
266 |
if axis21 - axis22 is 0: |
|
267 |
axis2Overlap = True |
|
268 |
break |
|
269 |
if axis2Overlap: break |
|
270 |
|
|
271 |
if axis1Overlap and axis2Overlap: |
|
272 |
matchLine = line |
|
273 |
break |
|
274 |
if matchLine is not None: |
|
275 |
matchLineNo.conns.append(matchLine) |
|
276 |
lineIndicator.lineIndicator = 'Match' |
|
277 |
lineIndicator.setBrush(QBrush(QColor(0, 0, 255, 127))) |
|
278 |
#print('connected ' + matchLineNo.text() + ' and ' + matchLine.uid) |
|
279 |
## up to here |
|
280 |
""" |
|
176 |
|
|
177 |
if _from and _to and (type(_from) is QEngineeringLineItem or issubclass(type(_from), SymbolSvgItem)) and (type(_to) is QEngineeringLineItem or issubclass(type(_to), SymbolSvgItem)): |
|
178 |
_from.owner = lineno |
|
179 |
_to.owner = lineno |
|
180 |
continue |
|
181 |
else: |
|
182 |
lineno.set_property('From', None) |
|
183 |
lineno.set_property('To', None) |
|
281 | 184 |
|
282 | 185 |
maxValue = len(self._lineNos) + 1 ## line no's count + secondary line |
283 | 186 |
|
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
803 | 803 |
|
804 | 804 |
return |
805 | 805 |
|
806 |
msg = QMessageBox() |
|
807 |
msg.setIcon(QMessageBox.Critical) |
|
808 |
msg.setText(self.tr('Do you want to remove all items?\nThis work cannot be recovered.')) |
|
809 |
msg.setWindowTitle(self.tr("Initialize")) |
|
810 |
msg.setStandardButtons(QMessageBox.Ok|QMessageBox.Cancel) |
|
811 |
if QMessageBox.Ok == msg.exec_(): |
|
812 |
|
|
813 |
appDocData = AppDocData.instance() |
|
814 |
appDocData.clearItemList(True) |
|
806 |
try: |
|
807 |
msg = QMessageBox() |
|
808 |
msg.setIcon(QMessageBox.Critical) |
|
809 |
msg.setText(self.tr('Do you want to remove all items?\nThis work cannot be recovered.')) |
|
810 |
msg.setWindowTitle(self.tr("Initialize")) |
|
811 |
msg.setStandardButtons(QMessageBox.Ok|QMessageBox.Cancel) |
|
812 |
if QMessageBox.Ok == msg.exec_(): |
|
813 |
|
|
814 |
appDocData = AppDocData.instance() |
|
815 |
appDocData.clearItemList(True) |
|
815 | 816 |
|
816 |
items = self.graphicsView.scene.items() |
|
817 |
for item in items: |
|
818 |
if type(item) is not QGraphicsPixmapItem and item.scene() is not None: |
|
819 |
#if hasattr(item, 'tranfer'): |
|
820 |
# item.tranfer.onRemoved.emit(item) |
|
821 |
#else: |
|
822 |
# self.graphicsView.scene.removeItem(item) |
|
823 |
self.graphicsView.scene.removeItem(item) |
|
824 |
|
|
825 |
''' |
|
826 |
if type(item) is QEngineeringLineNoTextItem: |
|
827 |
self.removedItems['LINE'].append(str(item.uid)) |
|
828 |
elif type(item) is QEngineeringInstrumentItem: |
|
829 |
self.removedItems['INST'].append(str(item.uid)) |
|
830 |
elif type(item) is QEngineeringEquipmentItem: |
|
831 |
self.removedItems['EQUIP'].append(str(item.uid)) |
|
832 |
elif type(item) is QEngineeringNoteItem: |
|
833 |
self.removedItems['NOTE'].append(str(item.uid)) |
|
834 |
''' |
|
817 |
items = self.graphicsView.scene.items()
|
|
818 |
for item in items:
|
|
819 |
if type(item) is not QGraphicsPixmapItem and item.scene() is not None:
|
|
820 |
#if hasattr(item, 'tranfer'):
|
|
821 |
# item.tranfer.onRemoved.emit(item)
|
|
822 |
#else:
|
|
823 |
# self.graphicsView.scene.removeItem(item)
|
|
824 |
self.graphicsView.scene.removeItem(item)
|
|
825 |
|
|
826 |
'''
|
|
827 |
if type(item) is QEngineeringLineNoTextItem:
|
|
828 |
self.removedItems['LINE'].append(str(item.uid))
|
|
829 |
elif type(item) is QEngineeringInstrumentItem:
|
|
830 |
self.removedItems['INST'].append(str(item.uid))
|
|
831 |
elif type(item) is QEngineeringEquipmentItem:
|
|
832 |
self.removedItems['EQUIP'].append(str(item.uid))
|
|
833 |
elif type(item) is QEngineeringNoteItem:
|
|
834 |
self.removedItems['NOTE'].append(str(item.uid))
|
|
835 |
'''
|
|
835 | 836 |
|
836 |
if self.path is not None: |
|
837 |
baseName = os.path.basename(self.path) |
|
838 |
self.itemTreeWidget.setCurrentPID(baseName) |
|
837 |
if self.path is not None: |
|
838 |
baseName = os.path.basename(self.path) |
|
839 |
self.itemTreeWidget.setCurrentPID(baseName) |
|
840 |
|
|
841 |
except Exception as ex: |
|
842 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
843 |
self.addMessage.emit(MessageType.Error, message) |
|
839 | 844 |
|
840 | 845 |
''' |
841 | 846 |
@brief Manage Checkable Action statement |
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
261 | 261 |
angle = float(node.find('ANGLE').text) if node.find('ANGLE') is not None else 0 |
262 | 262 |
text = node.find('TEXT').text |
263 | 263 |
textInfo = TextInfo(text, x, y, width, height, angle) |
264 |
connline = node.find('CONNLINE').text if node.find('CONNLINE') is not None else None |
|
264 | 265 |
|
265 | 266 |
item = TextItemFactory.instance().createTextItem(textInfo) |
266 | 267 |
if item is not None: |
... | ... | |
281 | 282 |
|
282 | 283 |
""" apply freeze value """ |
283 | 284 |
item.freeze_item.update_freeze(item.prop('Freeze')) |
285 |
|
|
286 |
if connline is not None: |
|
287 |
item.conns.append(connline) |
|
284 | 288 |
except Exception as ex: |
285 | 289 |
from App import App |
286 | 290 |
from AppDocData import MessageType |
... | ... | |
357 | 361 |
|
358 | 362 |
if self.conns: |
359 | 363 |
connNode = Element('CONNLINE') |
360 |
connNode.text = str(self.conns[0].uid) |
|
364 |
connNode.text = str(self.conns[0].uid) if hasattr(self.conns[0], 'uid') else str(self.conns[0])
|
|
361 | 365 |
node.append(connNode) |
362 | 366 |
|
363 | 367 |
except Exception as ex: |
DTI_PID/DTI_PID/Shapes/QEngineeringTagNoTextItem.py | ||
---|---|---|
62 | 62 |
|
63 | 63 |
if selected is not None: |
64 | 64 |
self.owner = selected |
65 |
selected.owner = self.owner |
|
65 |
#selected.owner = self.owner
|
|
66 | 66 |
|
67 | 67 |
except Exception as ex: |
68 | 68 |
from App import App |
내보내기 Unified diff