개정판 3e7dc880
issue #1363: grouped svg 파일을 생성할 수 있다
Change-Id: I26f00e1732d41cd13564f50ed20cd9c74e2e63ca
DTI_PID/DTI_PID/App.py | ||
---|---|---|
115 | 115 |
app = App(sys.argv) |
116 | 116 |
|
117 | 117 |
""" log for unhandled exception """ |
118 |
exceptionHandler = QExceptionHandler() |
|
119 |
sys._excepthook = sys.excepthook |
|
120 |
sys.excepthook = exceptionHandler.handler |
|
121 |
|
|
122 |
""" |
|
123 |
try: |
|
124 |
import qtmodern.styles |
|
125 |
except ImportError: |
|
126 |
pass |
|
127 |
else: |
|
128 |
qtmodern.styles.darkorange(app) |
|
129 |
""" |
|
130 |
if True == QLicenseDialog.check_license_key(): |
|
118 |
app.exception_handler = QExceptionHandler() |
|
119 |
app._excepthook = sys.excepthook |
|
120 |
sys.excepthook = app.exception_handler.handler |
|
121 |
|
|
122 |
if QLicenseDialog.check_license_key(): |
|
131 | 123 |
dlg = Ui_Dialog() |
132 | 124 |
selectedProject = dlg.showDialog() |
133 | 125 |
if selectedProject is not None: |
134 | 126 |
AppDocData.instance().setCurrentProject(selectedProject) |
135 |
AppDocData.instance().ex = exceptionHandler |
|
127 |
#AppDocData.instance().ex = exceptionHandler
|
|
136 | 128 |
app._mainWnd = MainWindow.instance() |
137 | 129 |
app._mainWnd.show() |
138 | 130 |
sys.exit(app.exec_()) |
DTI_PID/DTI_PID/Commands/ExportCommand.py | ||
---|---|---|
48 | 48 |
from xml.etree import ElementTree |
49 | 49 |
from xml.dom import minidom |
50 | 50 |
|
51 |
rough_string = ElementTree.tostring(elem, 'utf-8') |
|
52 |
reparsed = minidom.parseString(rough_string) |
|
53 |
return reparsed.toprettyxml(indent=" ") |
|
51 |
try: |
|
52 |
rough_string = ElementTree.tostring(elem, 'utf-8') |
|
53 |
reparsed = minidom.parseString(rough_string) |
|
54 |
return reparsed.toprettyxml(indent=" ") |
|
55 |
except Exception as ex: |
|
56 |
from AppDocData import MessageType |
|
57 |
|
|
58 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
59 |
sys.exc_info()[-1].tb_lineno) |
|
60 |
self.display_message.emit(MessageType.Error, message) |
|
54 | 61 |
|
55 | 62 |
def export_as_svg(self, file_path): |
56 | 63 |
"""export to svg file""" |
57 | 64 |
from xml.etree.ElementTree import Element, tostring, SubElement, dump, ElementTree, parse |
65 |
from SymbolSvgItem import SymbolSvgItem |
|
66 |
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem |
|
67 |
from EngineeringLineItem import QEngineeringLineItem |
|
58 | 68 |
|
59 | 69 |
if not file_path: |
60 | 70 |
options = QFileDialog.Options() |
... | ... | |
76 | 86 |
svg.attrib['version'] = "1.2" |
77 | 87 |
svg.attrib['baseProfile'] = "tiny" |
78 | 88 |
for item in self._scene.items(): |
79 |
if hasattr(item, 'to_svg'): |
|
80 |
node = item.to_svg() |
|
89 |
if hasattr(item, 'to_svg') and \ |
|
90 |
(not item.owner or |
|
91 |
(issubclass(type(item), SymbolSvgItem) and type(item.owner) is QEngineeringLineNoTextItem) or |
|
92 |
(type(item) is QEngineeringLineItem and type(item.owner) is QEngineeringLineNoTextItem and item is not item.owner.connected_line)): |
|
93 |
node = item.to_svg(None) |
|
81 | 94 |
if node: |
82 |
svg.append(node)
|
|
95 |
svg.extend(node)
|
|
83 | 96 |
|
84 | 97 |
with open(save_file_path, 'w', encoding='utf-8') as output_file: |
85 | 98 |
output_file.write(self.prettify(svg)) |
DTI_PID/DTI_PID/ConnectAttrDialog.py | ||
---|---|---|
21 | 21 |
''' |
22 | 22 |
|
23 | 23 |
|
24 |
class Worker(QObject): |
|
24 |
class WorkerSignals(QObject): |
|
25 |
"""Defines the signals available from a running worker thread.""" |
|
26 |
finished = pyqtSignal() |
|
27 |
intReady = pyqtSignal(int) |
|
28 |
display_message = pyqtSignal(str) |
|
29 |
updateProgress = pyqtSignal(int) |
|
30 |
|
|
31 |
def __init__(self, scene): |
|
32 |
super(WorkerSignals, self).__init__() |
|
33 |
|
|
34 |
self.scene = scene |
|
35 |
|
|
36 |
|
|
37 |
class Worker(QRunnable): |
|
25 | 38 |
""" This is Worker class """ |
26 | 39 |
from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QGridLayout, QListWidget |
27 | 40 |
from QtImageViewer import QtImageViewer |
28 | 41 |
import sys |
29 | 42 |
|
30 |
''' |
|
31 |
''' |
|
32 |
finished = pyqtSignal() |
|
33 |
intReady = pyqtSignal(int) |
|
34 |
displayMessage = pyqtSignal(str) |
|
35 |
updateProgress = pyqtSignal(int) |
|
36 |
|
|
37 |
def __init__(self, scene, update_line_type, update_flow_mark, update_spec): |
|
43 |
def __init__(self, scene, fn, *args, **kwargs): #update_line_type, update_flow_mark, update_spec): |
|
38 | 44 |
super(Worker, self).__init__() |
39 |
self.scene = scene |
|
40 |
self._update_line_type = update_line_type |
|
41 |
self._update_flow_mark = update_flow_mark |
|
42 |
self._update_spec = update_spec |
|
45 |
self.fn = fn |
|
46 |
self.args = args |
|
47 |
self.kwargs = kwargs |
|
43 | 48 |
self.need_update_texts = [] |
49 |
self.signals = WorkerSignals(scene) |
|
44 | 50 |
|
45 | 51 |
''' |
46 | 52 |
@brief execute connecting attributes |
... | ... | |
48 | 54 |
@date 2018.06.17 |
49 | 55 |
''' |
50 | 56 |
|
57 |
@pyqtSlot() |
|
51 | 58 |
def run(self): # A slot takes no params |
52 |
from LineNoTracer import connectAttrImpl |
|
53 |
|
|
54 | 59 |
try: |
55 |
connectAttrImpl(self, self._update_line_type, self._update_flow_mark, self._update_spec)
|
|
60 |
self.fn(self.signals, *self.args, **self.kwargs)
|
|
56 | 61 |
except Exception as ex: |
57 |
from App import App |
|
58 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
62 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
59 | 63 |
sys.exc_info()[-1].tb_lineno) |
60 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
64 |
self.display_message.emit(message) |
|
65 |
except: |
|
66 |
(_type, value, traceback) = sys.exc_info() |
|
67 |
sys.excepthook(_type, value, traceback) |
|
68 |
finally: |
|
69 |
self.signals.finished.emit() |
|
61 | 70 |
|
62 | 71 |
|
63 | 72 |
class QConnectAttrDialog(QDialog): |
... | ... | |
77 | 86 |
self.ui.listWidget.model().rowsInserted.connect(self.rowInserted) # connect to func rowInserted(self, item) |
78 | 87 |
self.isRunned = False |
79 | 88 |
|
80 |
self.ui.pushButtonStart.clicked.connect(self.connStart)
|
|
89 |
self.ui.pushButtonStart.clicked.connect(self.start_job)
|
|
81 | 90 |
|
82 | 91 |
@property |
83 | 92 |
def validation_checked(self): |
84 | 93 |
"""return if validation is checked""" |
85 | 94 |
return self.ui.checkBoxValidation.isChecked() |
86 | 95 |
|
87 |
def connStart(self):
|
|
96 |
def start_job(self):
|
|
88 | 97 |
"""start to connect attributes""" |
89 | 98 |
|
90 | 99 |
self.ui.buttonBox.setEnabled(False) |
91 | 100 |
self.ui.pushButtonStart.setEnabled(False) |
92 | 101 |
self.ui.progressBar.setValue(0) |
93 |
self.startThread()
|
|
102 |
self.start_thread()
|
|
94 | 103 |
self.isRunned = True |
95 | 104 |
|
96 | 105 |
''' |
... | ... | |
132 | 141 |
@date 2018.06.17 |
133 | 142 |
''' |
134 | 143 |
|
135 |
def startThread(self):
|
|
144 |
def start_thread(self):
|
|
136 | 145 |
import timeit |
146 |
from LineNoTracer import connectAttrImpl |
|
137 | 147 |
|
138 | 148 |
try: |
139 | 149 |
self.ui.buttonBox.setDisabled(True) |
140 | 150 |
|
141 | 151 |
# 1 - create Worker and Thread inside the Form |
142 |
self.obj = Worker(self.scene, self.ui.checkBoxUpdateLineType.isChecked(), |
|
152 |
self.obj = Worker(self.scene, connectAttrImpl, self.ui.checkBoxUpdateLineType.isChecked(),
|
|
143 | 153 |
self.ui.checkBoxUpdateFlowMark.isChecked(), self.ui.checkBoxUpdateSpec.isChecked()) |
144 |
self.thread = QThread() |
|
145 |
|
|
146 |
# 2 - Move the Worker object to the Thread object |
|
147 |
self.obj.moveToThread(self.thread) |
|
148 |
|
|
149 |
# 3 - Connect Worker Signals to the Thread slots |
|
150 |
self.obj.finished.connect(self.thread.quit) |
|
151 |
self.obj.displayMessage.connect(self.addListItem) |
|
152 |
self.obj.updateProgress.connect(self.updateProgress) |
|
153 |
|
|
154 |
# 4 - Connect Thread started signal to Worker operational slot method |
|
155 |
self.thread.started.connect(self.obj.run) |
|
156 | 154 |
|
157 |
# 5 - Thread finished signal will close the app if you want! |
|
158 |
self.thread.finished.connect(self.dlgExit) |
|
155 |
# 2 - Connect Worker Signals to the Thread slots |
|
156 |
self.obj.signals.display_message.connect(self.addListItem) |
|
157 |
self.obj.signals.updateProgress.connect(self.updateProgress) |
|
159 | 158 |
|
160 |
# 6 - Start the thread
|
|
161 |
self.thread.start()
|
|
159 |
# 3 - Thread finished signal will close the app if you want!
|
|
160 |
self.obj.signals.finished.connect(self.dlgExit)
|
|
162 | 161 |
|
163 |
self.tmStart = timeit.default_timer() |
|
162 |
# 4 - Start the thread |
|
163 |
self.tm_start = timeit.default_timer() |
|
164 |
#self.thread_pool.start(self.obj) |
|
165 |
self.obj.run() |
|
164 | 166 |
except Exception as ex: |
165 | 167 |
from App import App |
166 | 168 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
... | ... | |
194 | 196 |
sys.exc_info()[-1].tb_lineno) |
195 | 197 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
196 | 198 |
finally: |
197 |
self.tmStop = timeit.default_timer()
|
|
198 |
seconds = self.tmStop - self.tmStart
|
|
199 |
self.tm_stop = timeit.default_timer()
|
|
200 |
seconds = self.tm_stop - self.tm_start
|
|
199 | 201 |
self.ui.listWidget.addItem("\nRunning Time : {} min".format(str(round(seconds / 60, 1))) + "\n") |
DTI_PID/DTI_PID/ExceptionHandler.py | ||
---|---|---|
13 | 13 |
import logging |
14 | 14 |
from datetime import datetime |
15 | 15 |
|
16 |
|
|
16 | 17 |
class QExceptionHandler(QObject): |
17 | 18 |
""" This is exception handler class """ |
18 | 19 |
|
... | ... | |
23 | 24 |
|
24 | 25 |
self.log_path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID', 'id2.log') |
25 | 26 |
self.logger = logging.getLogger(__name__) |
26 |
logging.basicConfig(filename=self.log_path , filemode='a', level=logging.CRITICAL) |
|
27 |
self.logger.critical(datetime.now().strftime('%Y-%m-%d %H:%M:%S')) |
|
27 |
logging.basicConfig(filename=self.log_path, filemode='a', level=logging.CRITICAL) |
|
28 | 28 |
|
29 | 29 |
def handler(self, exctype, value, traceback): |
30 | 30 |
""" log exception, file name and line number """ |
31 | 31 |
from App import App |
32 | 32 |
from AppDocData import MessageType |
33 | 33 |
|
34 |
message = 'error occurred({}) in {}:{}'.format(value, traceback.tb_frame.f_code.co_filename, traceback.tb_lineno) |
|
34 |
message = 'error occurred({}) in {}:{}'.format(value, traceback.tb_frame.f_code.co_filename, |
|
35 |
traceback.tb_lineno) |
|
35 | 36 |
message = 'Unhandled exception: {}'.format(message) |
36 | 37 |
self.errorSignal.emit() |
37 | 38 |
self.logger.critical(message) |
38 | 39 |
message = 'CRITICAL : Unhandled exception: {}'.format(message) |
39 | 40 |
|
40 | 41 |
try: |
41 |
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
|
42 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
42 | 43 |
except Exception as ex: |
43 |
pass |
|
44 |
pass |
DTI_PID/DTI_PID/ItemTreeWidget.py | ||
---|---|---|
469 | 469 |
if foundItems is not None: |
470 | 470 |
for item in foundItems: |
471 | 471 |
data = item.data(0, self.TREE_DATA_ROLE) |
472 |
if data is not None and (data == child) and (parent is not item.parent()): |
|
472 |
if data is not None and (data == child) and (parent and parent is not item.parent()):
|
|
473 | 473 |
parentData = parent.data(0, self.TREE_DATA_ROLE) |
474 | 474 |
if parentData is not None and issubclass(type(parentData), QEngineeringLineNoTextItem): |
475 | 475 |
for index in range(len(parentData.runs)): |
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
177 | 177 |
from EngineeringEquipmentItem import QEngineeringEquipmentItem |
178 | 178 |
|
179 | 179 |
try: |
180 |
docData = AppDocData.instance()
|
|
180 |
app_doc_data = AppDocData.instance()
|
|
181 | 181 |
|
182 |
configs = docData.getConfigs('Line No', 'Delimiter')
|
|
182 |
configs = app_doc_data.getConfigs('Line No', 'Delimiter')
|
|
183 | 183 |
if 1 == len(configs): |
184 |
configs = docData.getConfigs('Line No', 'Configuration')
|
|
184 |
configs = app_doc_data.getConfigs('Line No', 'Configuration')
|
|
185 | 185 |
|
186 |
for lineno in self._lineNos: |
|
187 |
_from = lineno.prop('From') |
|
188 |
_to = lineno.prop('To') |
|
186 |
for line_no in self._lineNos:
|
|
187 |
_from = line_no.prop('From')
|
|
188 |
_to = line_no.prop('To')
|
|
189 | 189 |
|
190 |
lineno.conns.clear() |
|
190 |
line_no.conns.clear()
|
|
191 | 191 |
minDist = None |
192 | 192 |
startLine = None |
193 | 193 |
for line in [line for line in self._lines if line.owner is None and line.is_piping(strong=True)]: |
194 |
dist = line.distanceTo((lineno.center().x(), lineno.center().y()))
|
|
194 |
dist = line.distanceTo((line_no.center().x(), line_no.center().y()))
|
|
195 | 195 |
if (minDist is None) or (dist < minDist): |
196 | 196 |
minDist = dist |
197 | 197 |
startLine = line |
198 | 198 |
if (startLine is not None) and (minDist < toler): |
199 |
lineno.conns.append(startLine) |
|
199 |
line_no.conns.append(startLine)
|
|
200 | 200 |
if not _from or not _to: |
201 |
startLine.owner = lineno |
|
202 |
|
|
203 |
if _from and _to and (
|
|
204 |
type(_from) is QEngineeringLineItem or issubclass(type(_from), SymbolSvgItem)) and (
|
|
205 |
type(_to) is QEngineeringLineItem or issubclass(type(_to), SymbolSvgItem)): |
|
206 |
_from.owner = lineno |
|
207 |
_to.owner = lineno |
|
208 |
lineno._fixed = True |
|
201 |
startLine.owner = line_no
|
|
202 |
|
|
203 |
if _from and _to and \
|
|
204 |
(type(_from) is QEngineeringLineItem or issubclass(type(_from), SymbolSvgItem)) and \
|
|
205 |
(type(_to) is QEngineeringLineItem or issubclass(type(_to), SymbolSvgItem)):
|
|
206 |
_from.owner = line_no
|
|
207 |
_to.owner = line_no
|
|
208 |
line_no._fixed = True
|
|
209 | 209 |
else: |
210 |
lineno.set_property('From', None) |
|
211 |
lineno.set_property('To', None) |
|
212 |
lineno._fixed = False |
|
210 |
line_no.set_property('From', None)
|
|
211 |
line_no.set_property('To', None)
|
|
212 |
line_no._fixed = False
|
|
213 | 213 |
|
214 |
self.maxValue = len(self._lineNos) + 1 ## line no's count + secondary line
|
|
214 |
self.maxValue = len(self._lineNos) + 1 # line no's count + secondary line |
|
215 | 215 |
|
216 | 216 |
# find primary lines |
217 | 217 |
# sort line no with from,to value |
... | ... | |
274 | 274 |
orphans.remove(item) |
275 | 275 |
updateProgress.emit(self.maxValue) |
276 | 276 |
|
277 |
docData.tracerLineNos.append(trimLineNo)
|
|
277 |
app_doc_data.tracerLineNos.append(trimLineNo)
|
|
278 | 278 |
|
279 | 279 |
if updateProgress: updateProgress.emit(self.maxValue) |
280 | 280 |
except Exception as ex: |
... | ... | |
282 | 282 |
|
283 | 283 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
284 | 284 |
sys.exc_info()[-1].tb_lineno) |
285 |
AppDocData.instance().ex.logger.critical('message') |
|
286 | 285 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
287 | 286 |
|
288 | 287 |
''' |
... | ... | |
473 | 472 |
from EngineeringLineTracerRunItem import QEngineeringLineTracerRunItem |
474 | 473 |
|
475 | 474 |
try: |
476 |
worker.displayMessage.emit('Initiating...') |
|
477 | 475 |
docdata = AppDocData.instance() |
476 |
worker.display_message.emit('Initializing...') |
|
478 | 477 |
symbols = [] |
479 | 478 |
lines = docdata.lines |
480 | 479 |
lineNos = [] |
... | ... | |
497 | 496 |
else: |
498 | 497 |
end_breaks.append(end_break) |
499 | 498 |
|
499 |
QApplication.processEvents() |
|
500 |
|
|
500 | 501 |
''' |
501 | 502 |
for flow_mark in [item for item in worker.scene.items() if type(item) is QEngineeringFlowMarkItem]: |
502 | 503 |
if not flow_mark.prop('Freeze'): |
... | ... | |
533 | 534 |
elif item.type == 'Notes': |
534 | 535 |
notes.append(item) |
535 | 536 |
|
537 |
QApplication.processEvents() |
|
538 |
|
|
536 | 539 |
# remove unknown line's |
537 | 540 |
pastTrim = docdata.tracerLineNos |
538 | 541 |
treeWidget = App.mainWnd().itemTreeWidget |
... | ... | |
548 | 551 |
|
549 | 552 |
# trace line no |
550 | 553 |
tracer = LineNoTracer(symbols, lines, lineNos, spec_breaks, lineIndicator, vendor_packages, end_breaks) |
551 |
tracer.execute(worker.displayMessage, worker.updateProgress)
|
|
554 |
tracer.execute(worker.display_message, worker.updateProgress)
|
|
552 | 555 |
# up to here |
553 | 556 |
|
557 |
QApplication.processEvents() |
|
554 | 558 |
# connect attribute |
555 |
worker.displayMessage.emit('Connecting Attribute...')
|
|
559 |
worker.display_message.emit('Connecting Attribute...')
|
|
556 | 560 |
texts = [item for item in worker.scene.items() if issubclass(type(item), QEngineeringTextItem)] |
557 | 561 |
for symbol in symbols: |
558 | 562 |
try: |
559 | 563 |
symbol.connectAttribute(texts) |
560 | 564 |
except Exception as ex: |
561 |
from App import App |
|
562 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
565 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
563 | 566 |
sys.exc_info()[-1].tb_lineno) |
564 |
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
|
567 |
worker.display_message.emit(message)
|
|
565 | 568 |
|
566 | 569 |
""" try to connect label to valve """ |
567 | 570 |
labels = [symbol for symbol in symbols if symbol.iType == 19] # Labels - General Instrument => Instrument |
... | ... | |
575 | 578 |
for label in labels: |
576 | 579 |
label.connectAttribute(valves, clear=False) |
577 | 580 |
|
581 |
QApplication.processEvents() |
|
578 | 582 |
for symbol in symbols: |
579 | 583 |
for assoc in symbol.associations(): |
580 | 584 |
if assoc.owner is None: |
... | ... | |
590 | 594 |
for text in texts: |
591 | 595 |
text.findOwner(lines) |
592 | 596 |
|
597 |
QApplication.processEvents() |
|
593 | 598 |
# restore and save manual edited attr's text item |
594 | 599 |
texts = [item for item in worker.scene.items() if issubclass(type(item), QEngineeringTextItem)] |
595 | 600 |
targetText = [] |
... | ... | |
626 | 631 |
|
627 | 632 |
""" update line type """ |
628 | 633 |
if update_line_type: |
629 |
worker.displayMessage.emit('Updating Line Type...')
|
|
634 |
worker.display_message.emit('Updating Line Type...')
|
|
630 | 635 |
for line in lines: |
631 | 636 |
line.update_line_type() |
632 | 637 |
|
638 |
QApplication.processEvents() |
|
633 | 639 |
"""make end break""" |
634 | 640 |
end_break_names = docdata.getSymbolListByType('type', 'End Break') |
635 | 641 |
if len(end_break_names) is not 0: |
... | ... | |
711 | 717 |
'Connected Item').lineType == 'Primary'))): |
712 | 718 |
end_break.addSvgItemToScene(worker.scene) |
713 | 719 |
|
720 |
QApplication.processEvents() |
|
714 | 721 |
""" update spec break """ |
715 | 722 |
if update_spec: |
716 | 723 |
freezed_spec_breaks = [] |
... | ... | |
942 | 949 |
|
943 | 950 |
worker.updateProgress.emit(tracer.maxValue) |
944 | 951 |
|
952 |
QApplication.processEvents() |
|
945 | 953 |
# trace special item |
946 |
worker.displayMessage.emit('Find line for special item...')
|
|
947 |
tracer = SpecialItemTracer([item for item in worker.scene.items() if (
|
|
948 |
type(item) is SymbolSvgItem or type(item) is QEngineeringTextItem) and item.special_item_type],
|
|
949 |
lines) |
|
950 |
tracer.execute(worker.displayMessage, worker.updateProgress)
|
|
954 |
worker.display_message.emit('Find line for special item...')
|
|
955 |
tracer = SpecialItemTracer([item for item in worker.scene.items() if |
|
956 |
(type(item) is SymbolSvgItem or type(item) is QEngineeringTextItem) and
|
|
957 |
item.special_item_type], lines)
|
|
958 |
tracer.execute(worker.display_message, worker.updateProgress)
|
|
951 | 959 |
# up to here |
952 | 960 |
|
961 |
QApplication.processEvents() |
|
953 | 962 |
# sort run flow order |
954 | 963 |
fixed_run_infos = [] # QEngineeringLineTracerRunItem s |
955 | 964 |
waiting_run_infos = [] # QEngineeringLineTracerRunItem s |
... | ... | |
1032 | 1041 |
|
1033 | 1042 |
run_index += 1 |
1034 | 1043 |
|
1044 |
QApplication.processEvents() |
|
1035 | 1045 |
# second step : determine waiting run flow, connected by point |
1036 | 1046 |
remain_count_past = len(waiting_run_infos) |
1037 | 1047 |
while True: |
... | ... | |
1126 | 1136 |
else: |
1127 | 1137 |
remain_count_past = remain_count |
1128 | 1138 |
|
1139 |
QApplication.processEvents() |
|
1129 | 1140 |
# third step : body connected run sort, not split |
1130 | 1141 |
remain_count_past = len(waiting_run_infos) |
1131 | 1142 |
while True: |
... | ... | |
1168 | 1179 |
fixed_merged_run_infos = [] # [[run_info1, run_info2, ... in order], [merged run with items]] |
1169 | 1180 |
waiting_merged_run_infos = [] # [[run_info1, run_info2, ... in order], [merged run with items]] |
1170 | 1181 |
|
1182 |
QApplication.processEvents() |
|
1171 | 1183 |
# waiting run merge and sort |
1172 | 1184 |
consumed_count_past = 0 |
1173 | 1185 |
for index1 in range(len(waiting_run_infos)): |
... | ... | |
1191 | 1203 |
[[waiting_run_infos[index1], waiting_run_infos[index2]], merged_run_info]) |
1192 | 1204 |
break |
1193 | 1205 |
|
1206 |
QApplication.processEvents() |
|
1194 | 1207 |
while True: |
1195 | 1208 |
consumed_count = 0 |
1196 | 1209 |
for index in range(len(waiting_run_infos)): |
... | ... | |
1217 | 1230 |
else: |
1218 | 1231 |
consumed_count_past = consumed_count |
1219 | 1232 |
|
1233 |
QApplication.processEvents() |
|
1220 | 1234 |
while True: |
1221 | 1235 |
merged = False |
1222 | 1236 |
for index1 in range(len(waiting_merged_run_infos)): |
... | ... | |
1251 | 1265 |
if not merged: |
1252 | 1266 |
break |
1253 | 1267 |
|
1268 |
QApplication.processEvents() |
|
1254 | 1269 |
# fixed run merge |
1255 | 1270 |
consumed_count_past = 0 |
1256 | 1271 |
for index1 in range(len(fixed_run_infos)): |
... | ... | |
1274 | 1289 |
[[fixed_run_infos[index1], fixed_run_infos[index2]], merged_run_info]) |
1275 | 1290 |
break |
1276 | 1291 |
|
1292 |
QApplication.processEvents() |
|
1277 | 1293 |
while True: |
1278 | 1294 |
consumed_count = 0 |
1279 | 1295 |
for index in range(len(fixed_run_infos)): |
... | ... | |
1300 | 1316 |
else: |
1301 | 1317 |
consumed_count_past = consumed_count |
1302 | 1318 |
|
1319 |
QApplication.processEvents() |
|
1303 | 1320 |
while True: |
1304 | 1321 |
merged = False |
1305 | 1322 |
for index1 in range(len(fixed_merged_run_infos)): |
... | ... | |
1331 | 1348 |
else: |
1332 | 1349 |
fixed_merged_run_infos.append([[fixed_run_info], fixed_run_info]) |
1333 | 1350 |
|
1351 |
QApplication.processEvents() |
|
1334 | 1352 |
# sort merged waiting runs by using merged fixed runs |
1335 | 1353 |
remain_count_past = len(waiting_merged_run_infos) |
1336 | 1354 |
while True: |
... | ... | |
1375 | 1393 |
else: |
1376 | 1394 |
remain_count_past = remain_count |
1377 | 1395 |
|
1396 |
QApplication.processEvents() |
|
1378 | 1397 |
""" make flow mark """ |
1379 | 1398 |
if update_flow_mark: |
1380 | 1399 |
for line in lines: |
... | ... | |
1397 | 1416 |
lineNo.EvaluatedEQ() |
1398 | 1417 |
|
1399 | 1418 |
except Exception as ex: |
1400 |
from App import App |
|
1401 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1419 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1402 | 1420 |
sys.exc_info()[-1].tb_lineno) |
1403 |
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
|
1421 |
worker.display_message.emit(message)
|
|
1404 | 1422 |
except: |
1405 | 1423 |
(type1, value, traceback) = sys.exc_info() |
1406 | 1424 |
sys.excepthook(type1, value, traceback) |
1407 |
finally: |
|
1408 |
worker.finished.emit() |
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py | ||
---|---|---|
125 | 125 |
def toXml(self): |
126 | 126 |
pass |
127 | 127 |
|
128 |
def to_svg(self):
|
|
128 |
def to_svg(self, parent=None) -> list:
|
|
129 | 129 |
pass |
130 | 130 |
|
131 | 131 |
''' |
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
1582 | 1582 |
|
1583 | 1583 |
return node |
1584 | 1584 |
|
1585 |
def to_svg(self):
|
|
1585 |
def to_svg(self, parent) -> list:
|
|
1586 | 1586 |
"""convert line item to svg""" |
1587 | 1587 |
import uuid |
1588 | 1588 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
1589 | 1589 |
|
1590 |
res = [] |
|
1590 | 1591 |
try: |
1591 | 1592 |
node = Element('g') |
1592 | 1593 |
node.attrib['ID'] = str(self.uid) |
1593 | 1594 |
node.attrib['stroke'] = self.pen().color().name() |
1594 | 1595 |
node.attrib['stroke-width'] = str(self.pen().width()) |
1596 |
if not parent: |
|
1597 |
trans = QTransform() |
|
1598 |
else: |
|
1599 |
trans, _ = parent.sceneTransform().inverted() |
|
1600 |
|
|
1595 | 1601 |
node.attrib['transform'] = f"matrix(" \ |
1596 |
f"{1},{0}," \
|
|
1597 |
f"{0},{1}," \
|
|
1598 |
f"{0},{0}" \
|
|
1602 |
f"{trans.m11()},{trans.m12()}," \
|
|
1603 |
f"{trans.m21()},{trans.m22()}," \
|
|
1604 |
f"{trans.m31()},{trans.m32()}" \
|
|
1599 | 1605 |
f")" |
1606 |
|
|
1600 | 1607 |
polyline = Element('polyline') |
1601 | 1608 |
start_pt = self.startPoint() |
1602 | 1609 |
end_pt = self.endPoint() |
1603 | 1610 |
polyline.attrib['points'] = f"{start_pt[0]},{start_pt[1]} " \ |
1604 | 1611 |
f"{end_pt[0]},{end_pt[1]}" |
1605 | 1612 |
node.append(polyline) |
1613 |
|
|
1614 |
res.append(node) |
|
1606 | 1615 |
except Exception as ex: |
1607 | 1616 |
from App import App |
1617 |
from AppDocData import MessageType |
|
1608 | 1618 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1609 | 1619 |
sys.exc_info()[-1].tb_lineno) |
1610 | 1620 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1611 | 1621 |
|
1612 |
return None |
|
1613 |
|
|
1614 |
return node |
|
1622 |
return res |
|
1615 | 1623 |
|
1616 | 1624 |
def toSql_return_separately(self): |
1617 | 1625 |
""" generate sql phrase to save line to database """ |
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
4 | 4 |
import os.path |
5 | 5 |
import sys |
6 | 6 |
import copy |
7 |
|
|
7 | 8 |
try: |
8 | 9 |
from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
9 | 10 |
from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont |
10 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem |
|
11 |
from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, \ |
|
12 |
QGraphicsTextItem |
|
11 | 13 |
except ImportError: |
12 | 14 |
try: |
13 | 15 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
... | ... | |
23 | 25 |
from EngineeringTextItem import QEngineeringTextItem |
24 | 26 |
from TextInfo import TextInfo |
25 | 27 |
|
26 |
lineColumnList = ['UID', 'LINE_SIZE', 'LINE_SYMBOL', 'LINE_NO', 'LINE_CLASS', 'LINE_ROUTING_FROM', 'LINE_ROUTING_TO', 'SERVICE_FLUID', 'SERVICE_DENSITY', 'SERVICE_STATE', 'OPERATION_CONDITION_TEMP', 'OPERATION_CONDITION_PRESS', 'DESIGN_CONDITION_TEMP', 'DESIGN_CONDITION_PRESS', 'TEST_CONDITION_TEMP', 'TEST_CONDITION_PRESS', 'INSUL_CODE', 'PAINT_CODE', 'NDE_CODE', 'PWHT', 'PNID_NO'] |
|
28 |
lineColumnList = ['UID', 'LINE_SIZE', 'LINE_SYMBOL', 'LINE_NO', 'LINE_CLASS', 'LINE_ROUTING_FROM', 'LINE_ROUTING_TO', |
|
29 |
'SERVICE_FLUID', 'SERVICE_DENSITY', 'SERVICE_STATE', 'OPERATION_CONDITION_TEMP', |
|
30 |
'OPERATION_CONDITION_PRESS', 'DESIGN_CONDITION_TEMP', 'DESIGN_CONDITION_PRESS', 'TEST_CONDITION_TEMP', |
|
31 |
'TEST_CONDITION_PRESS', 'INSUL_CODE', 'PAINT_CODE', 'NDE_CODE', 'PWHT', 'PNID_NO'] |
|
32 |
|
|
27 | 33 |
|
28 | 34 |
class QEngineeringLineNoTextItem(QEngineeringTextItem): |
29 | 35 |
''' |
30 | 36 |
@history 18.05.14 Jeongwoo Add variable self.runs |
31 | 37 |
humkyung 2018.07.09 add stream no |
32 | 38 |
''' |
39 |
|
|
33 | 40 |
def __init__(self, uid=None, parent=None): |
34 | 41 |
from SymbolAttr import SymbolProp |
35 | 42 |
from EngineeringFreezeItem import QEngineeringFreezeItem |
36 | 43 |
|
37 | 44 |
QEngineeringTextItem.__init__(self, uid, parent) |
38 | 45 |
|
39 |
self._properties = {SymbolProp(None, 'From', 'Comp Item'):None, SymbolProp(None, 'To', 'Comp Item'):None}#, SymbolProp(None, 'Freeze', 'Boolean'):False} |
|
46 |
self._properties = {SymbolProp(None, 'From', 'Comp Item'): None, |
|
47 |
SymbolProp(None, 'To', 'Comp Item'): None} # , SymbolProp(None, 'Freeze', 'Boolean'):False} |
|
40 | 48 |
self._runs = [] |
41 | 49 |
|
42 | 50 |
""" create freeze control """ |
43 |
#self.freeze_item = QEngineeringFreezeItem(-QEngineeringFreezeItem.FREEZE_SIZE*0.5, -QEngineeringFreezeItem.FREEZE_SIZE*0.5, QEngineeringFreezeItem.FREEZE_SIZE, QEngineeringFreezeItem.FREEZE_SIZE) |
|
44 |
#self.freeze_item.setParentItem(self) |
|
45 |
#self.freeze_item.setZValue(self.zValue() + 1) |
|
46 |
#self.freeze_item.setPen(Qt.black) |
|
51 |
# self.freeze_item = QEngineeringFreezeItem(-QEngineeringFreezeItem.FREEZE_SIZE*0.5, -QEngineeringFreezeItem.FREEZE_SIZE*0.5, QEngineeringFreezeItem.FREEZE_SIZE, QEngineeringFreezeItem.FREEZE_SIZE)
|
|
52 |
# self.freeze_item.setParentItem(self)
|
|
53 |
# self.freeze_item.setZValue(self.zValue() + 1)
|
|
54 |
# self.freeze_item.setPen(Qt.black)
|
|
47 | 55 |
|
48 | 56 |
@property |
49 | 57 |
def Size(self): |
50 | 58 |
""" return line no's size """ |
51 | 59 |
attrs = self.getAttributes() |
52 |
matches = [value for attr,value in attrs.items() if attr.Attribute.upper() == 'NOMINALDIAMETER'] |
|
60 |
matches = [value for attr, value in attrs.items() if attr.Attribute.upper() == 'NOMINALDIAMETER']
|
|
53 | 61 |
return matches[0] if matches else None |
54 | 62 |
|
55 | 63 |
def empty(self): |
... | ... | |
62 | 70 |
for run in self.runs: |
63 | 71 |
run.visible = visible |
64 | 72 |
|
73 |
@property |
|
74 |
def connected_line(self): |
|
75 |
"""return connected line""" |
|
76 |
if self.conns: |
|
77 |
if type(self.conns[0]) is str: |
|
78 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(self.conns[0])] |
|
79 |
if matches: |
|
80 |
self.conns[0] = matches[0] |
|
81 |
|
|
82 |
return self.conns[0] |
|
83 |
|
|
84 |
return None |
|
85 |
|
|
65 | 86 |
''' |
66 | 87 |
@brief getter of runs |
67 | 88 |
@author humkyung |
68 | 89 |
@date 2018.05.11 |
69 | 90 |
''' |
91 |
|
|
70 | 92 |
@property |
71 | 93 |
def runs(self): |
72 | 94 |
return self._runs |
... | ... | |
76 | 98 |
@author humkyung |
77 | 99 |
@date 2018.05.11 |
78 | 100 |
''' |
101 |
|
|
79 | 102 |
@runs.setter |
80 | 103 |
def runs(self, value): |
81 | 104 |
self._runs = value |
82 |
|
|
105 |
|
|
83 | 106 |
def hoverEnterEvent(self, event): |
84 | 107 |
""" highlight line no text and run's item """ |
85 | 108 |
self.hover = True |
... | ... | |
98 | 121 |
for item in run.items: |
99 | 122 |
item.hoverLeaveEvent(event) |
100 | 123 |
|
101 |
def keyPressEvent(self, event):
|
|
124 |
def keyPressEvent(self, event): |
|
102 | 125 |
""" reverse line routine when user press 'C' key """ |
103 | 126 |
if event.key() == Qt.Key_C: |
104 | 127 |
self.reverse() |
105 |
|
|
128 |
|
|
106 | 129 |
QEngineeringTextItem.keyPressEvent(self, event) |
107 | 130 |
|
108 | 131 |
def update_flow_mark(self, position, minLength): |
... | ... | |
117 | 140 |
pre = None |
118 | 141 |
preRadian = None |
119 | 142 |
for item in run.items: |
120 |
if pre is None and type(item) is QEngineeringLineItem and (item._lineType == 'Primary' or item._lineType == 'Secondary') and item.length() > minLength: |
|
143 |
if pre is None and type(item) is QEngineeringLineItem and ( |
|
144 |
item._lineType == 'Primary' or item._lineType == 'Secondary') and item.length() > minLength: |
|
121 | 145 |
pre = item |
122 | 146 |
start = item.line().p1() |
123 | 147 |
end = item.line().p2() |
124 |
_dir = [(end.x() - start.x())/item.length(), (end.y() - start.y())/item.length()]
|
|
148 |
_dir = [(end.x() - start.x()) / item.length(), (end.y() - start.y()) / item.length()]
|
|
125 | 149 |
radian = math.atan2(_dir[1], _dir[0]) - math.pi / 2 |
126 | 150 |
preRadian = radian if radian >= 0 else radian + 2 * math.pi |
127 | 151 |
preRadian = abs(preRadian - math.pi) |
128 | 152 |
|
129 |
elif pre and type(pre) is QEngineeringLineItem and type(item) is QEngineeringLineItem and (item._lineType == 'Primary' or item._lineType == 'Secondary'): |
|
153 |
elif pre and type(pre) is QEngineeringLineItem and type(item) is QEngineeringLineItem and ( |
|
154 |
item._lineType == 'Primary' or item._lineType == 'Secondary'): |
|
130 | 155 |
start = item.line().p1() |
131 | 156 |
end = item.line().p2() |
132 |
_dir = [(end.x() - start.x())/item.length(), (end.y() - start.y())/item.length()]
|
|
157 |
_dir = [(end.x() - start.x()) / item.length(), (end.y() - start.y()) / item.length()]
|
|
133 | 158 |
radian = math.atan2(_dir[1], _dir[0]) - math.pi / 2 |
134 | 159 |
currRadian = radian if radian >= 0 else radian + 2 * math.pi |
135 | 160 |
currRadian = abs(currRadian - math.pi) |
136 | 161 |
if abs(currRadian - preRadian) > allowed_error_radian: |
137 | 162 |
# insert flow mark at pre line |
138 | 163 |
if pre.length() > minLength: |
139 |
#if str(pre.uid) == '62edfbe5-29fd-49af-840b-6dce051e04d1': |
|
140 |
#print(math.atan2(preDir[0], preDir[1]) - math.pi / 2)
|
|
141 |
#print(currRadian)
|
|
142 |
#print(preRadian)
|
|
164 |
# if str(pre.uid) == '62edfbe5-29fd-49af-840b-6dce051e04d1':
|
|
165 |
# print(math.atan2(preDir[0], preDir[1]) - math.pi / 2)
|
|
166 |
# print(currRadian)
|
|
167 |
# print(preRadian)
|
|
143 | 168 |
pre.flowMark = position |
144 | 169 |
pre.update_arrow() |
145 | 170 |
|
146 | 171 |
pre = item |
147 | 172 |
preRadian = currRadian |
148 |
|
|
149 |
if pre and type(item) is QEngineeringLineItem and (item._lineType == 'Primary' or item._lineType == 'Secondary') and item.length() > minLength: |
|
173 |
|
|
174 |
if pre and type(item) is QEngineeringLineItem and ( |
|
175 |
item._lineType == 'Primary' or item._lineType == 'Secondary') and item.length() > minLength: |
|
150 | 176 |
pre.flowMark = position |
151 | 177 |
pre.update_arrow() |
152 | 178 |
|
153 | 179 |
except Exception as ex: |
154 |
from App import App
|
|
180 |
from App import App |
|
155 | 181 |
from AppDocData import MessageType |
156 | 182 |
|
157 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
183 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
184 |
sys.exc_info()[-1].tb_lineno) |
|
158 | 185 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
159 | 186 |
|
160 | 187 |
""" |
... | ... | |
171 | 198 |
|
172 | 199 |
def reverse(self): |
173 | 200 |
""" reverse line routine """ |
174 |
|
|
201 |
|
|
175 | 202 |
if self.runs: |
176 | 203 |
self.runs[0].reverse() |
177 | 204 |
_from = self.prop('From') |
... | ... | |
185 | 212 |
|
186 | 213 |
maxDistance = None |
187 | 214 |
for i in range(len(pts)): |
188 |
for j in range(i+1, len(pts)):
|
|
215 |
for j in range(i + 1, len(pts)):
|
|
189 | 216 |
dx = pts[i][0] - pts[j][0] |
190 | 217 |
dy = pts[i][1] - pts[j][1] |
191 |
dist = math.sqrt(dx*dx + dy*dy)
|
|
218 |
dist = math.sqrt(dx * dx + dy * dy)
|
|
192 | 219 |
if (maxDistance is None) or (maxDistance < dist): |
193 | 220 |
maxDistance = dist |
194 | 221 |
res[0] = pts[i] |
195 | 222 |
res[1] = pts[j] |
196 |
|
|
223 |
|
|
197 | 224 |
return res |
198 |
|
|
225 |
|
|
199 | 226 |
''' |
200 | 227 |
@brief set attribute |
201 | 228 |
@author humkyung |
202 | 229 |
@date 2018.07.20 |
203 | 230 |
''' |
231 |
|
|
204 | 232 |
def set_attrib(self, attrib, value): |
205 | 233 |
matches = [attr for attr in self.attrs if attr.UID == attrib.UID] |
206 | 234 |
if len(matches) == 1: |
... | ... | |
216 | 244 |
@author kyouho |
217 | 245 |
@date 2018.09.06 |
218 | 246 |
''' |
247 |
|
|
219 | 248 |
def getLineNoAttributes(self, _attrs=None): |
220 | 249 |
from SymbolAttr import SymbolAttr |
221 | 250 |
from Configs import LineNoConfig |
... | ... | |
259 | 288 |
matches = [attr for attr in self.attrs if attr.UID == prop.UID] |
260 | 289 |
if len(matches) == 1: |
261 | 290 |
_attrs[matches[0]] = self.attrs[matches[0]] |
262 |
#else: |
|
291 |
# else:
|
|
263 | 292 |
# _attrs[prop] = '' |
264 | 293 |
except Exception as ex: |
265 | 294 |
from App import App |
266 | 295 |
from AppDocData import MessageType |
267 | 296 |
|
268 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
297 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
298 |
sys.exc_info()[-1].tb_lineno) |
|
269 | 299 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
270 |
|
|
300 |
|
|
271 | 301 |
return _attrs |
272 | 302 |
|
273 | 303 |
@staticmethod |
... | ... | |
321 | 351 |
item.setToolTip('<b>{}</b><br>LINE NO={}'.format(str(item.uid), text)) |
322 | 352 |
|
323 | 353 |
""" apply freeze value """ |
324 |
#item.freeze_item.update_freeze(item.prop('Freeze')) |
|
354 |
# item.freeze_item.update_freeze(item.prop('Freeze'))
|
|
325 | 355 |
|
326 | 356 |
if connline is not None: |
327 | 357 |
item.conns.append(connline) |
... | ... | |
329 | 359 |
from App import App |
330 | 360 |
from AppDocData import MessageType |
331 | 361 |
|
332 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
362 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
363 |
sys.exc_info()[-1].tb_lineno) |
|
333 | 364 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
334 | 365 |
return None |
335 | 366 |
|
... | ... | |
358 | 389 |
item = TextItemFactory.instance().createTextItem(textInfo) |
359 | 390 |
if item is not None: |
360 | 391 |
for prop_node in node.iter('PROPERTY'): |
361 |
matches = [prop for prop in item._properties.keys() if prop.Attribute == prop_node.attrib['Attribute']] |
|
392 |
matches = [prop for prop in item._properties.keys() if |
|
393 |
prop.Attribute == prop_node.attrib['Attribute']] |
|
362 | 394 |
if matches: |
363 | 395 |
item._properties[matches[0]] = matches[0].parse_value(prop_node.text) |
364 |
|
|
396 |
|
|
365 | 397 |
for attr_node in node.iter('ATTRIBUTE'): |
366 | 398 |
attr = SymbolAttr.fromXml(attr_node) |
367 | 399 |
item.attrs[attr] = attr_node.text |
... | ... | |
373 | 405 |
item.setToolTip('<b>{}</b><br>LINE NO={}'.format(str(item.uid), text)) |
374 | 406 |
|
375 | 407 |
""" apply freeze value """ |
376 |
#item.freeze_item.update_freeze(item.prop('Freeze')) |
|
408 |
# item.freeze_item.update_freeze(item.prop('Freeze'))
|
|
377 | 409 |
|
378 | 410 |
if connline is not None: |
379 | 411 |
item.conns.append(connline) |
... | ... | |
381 | 413 |
from App import App |
382 | 414 |
from AppDocData import MessageType |
383 | 415 |
|
384 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
416 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
417 |
sys.exc_info()[-1].tb_lineno) |
|
385 | 418 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
386 | 419 |
return None |
387 | 420 |
|
... | ... | |
394 | 427 |
@history humkyung 2018.05.02 write symbol's attribute |
395 | 428 |
humkyung 2018.05.16 write run information to xml |
396 | 429 |
''' |
430 |
|
|
397 | 431 |
def toXml(self): |
398 | 432 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
399 | 433 |
from EngineeringLineItem import QEngineeringLineItem |
... | ... | |
411 | 445 |
node.append(uidNode) |
412 | 446 |
|
413 | 447 |
textNode = Element('TEXT') |
414 |
textNode.text = self.text()
|
|
448 |
textNode.text = self.text() |
|
415 | 449 |
node.append(textNode) |
416 | 450 |
|
417 | 451 |
locNode = Element('LOCATION') |
... | ... | |
438 | 472 |
node.append(run.toXml()) |
439 | 473 |
|
440 | 474 |
properties_node = Element('PROPERTIES') |
441 |
for prop,value in self.properties.items(): |
|
475 |
for prop, value in self.properties.items():
|
|
442 | 476 |
prop_node = prop.toXml() |
443 | 477 |
prop_node.text = str(value) if value else '' |
444 | 478 |
properties_node.append(prop_node) |
... | ... | |
449 | 483 |
if key.UID is not None: |
450 | 484 |
attrNode = key.toXml() |
451 | 485 |
attrNode.text = str(_attrs[key]) |
452 |
node.append(attrNode)
|
|
453 |
|
|
486 |
node.append(attrNode) |
|
487 |
|
|
454 | 488 |
if self.conns: |
455 | 489 |
connNode = Element('CONNLINE') |
456 | 490 |
connNode.text = str(self.conns[0].uid) if hasattr(self.conns[0], 'uid') else str(self.conns[0]) |
457 | 491 |
node.append(connNode) |
458 | 492 |
|
459 | 493 |
sceneNode = Element('SCENE') |
460 |
sceneNode.text = str(self.sceneBoundingRect()).replace('PyQt5.QtCore.QRectF(', '').replace(' ', '').replace(')', '') |
|
494 |
sceneNode.text = str(self.sceneBoundingRect()).replace('PyQt5.QtCore.QRectF(', '').replace(' ', '').replace( |
|
495 |
')', '') |
|
461 | 496 |
node.append(sceneNode) |
462 | 497 |
|
463 | 498 |
except Exception as ex: |
464 | 499 |
from App import App |
465 | 500 |
from AppDocData import MessageType |
466 | 501 |
|
467 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
502 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
503 |
sys.exc_info()[-1].tb_lineno) |
|
468 | 504 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
469 | 505 |
|
470 | 506 |
return None |
471 | 507 |
|
472 |
return node |
|
473 |
|
|
508 |
return node |
|
509 |
|
|
510 |
def to_svg(self, parent) -> list: |
|
511 |
"""convert line no item to svg""" |
|
512 |
import re |
|
513 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
|
514 |
|
|
515 |
res = [] |
|
516 |
try: |
|
517 |
node = Element('g') |
|
518 |
node.attrib['ID'] = str(self.uid) |
|
519 |
|
|
520 |
except_pattern = re.compile('[^a-zA-Z0-9_]') |
|
521 |
for attr, value in self.getAttributes().items(): |
|
522 |
node.attrib[re.sub(except_pattern, '_', attr.Attribute)] = value if value else '' |
|
523 |
trans = self.sceneTransform() |
|
524 |
node.attrib['transform'] = f"matrix(" \ |
|
525 |
f"{trans.m11()},{trans.m12()}," \ |
|
526 |
f"{trans.m21()},{trans.m22()}," \ |
|
527 |
f"{trans.m31()},{trans.m32()}" \ |
|
528 |
f")" |
|
529 |
|
|
530 |
text = Element('text') |
|
531 |
text.text = self.toPlainText() |
|
532 |
text.attrib['alignment-baseline'] = 'hanging' # align left-top corner |
|
533 |
node.append(text) |
|
534 |
|
|
535 |
connected_line = self.connected_line |
|
536 |
if connected_line: |
|
537 |
conn_node = connected_line.to_svg(self) |
|
538 |
if conn_node: |
|
539 |
node.extend(conn_node) |
|
540 |
|
|
541 |
res.append(node) |
|
542 |
except Exception as ex: |
|
543 |
from App import App |
|
544 |
from AppDocData import MessageType |
|
545 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
546 |
sys.exc_info()[-1].tb_lineno) |
|
547 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
548 |
|
|
549 |
return res |
|
550 |
|
|
474 | 551 |
def end_break(self): |
475 | 552 |
''' |
476 | 553 |
@brief end break check |
... | ... | |
496 | 573 |
|
497 | 574 |
svgFileName = end_break_names[0].sName |
498 | 575 |
symbol = AppDocData.instance().getSymbolByQuery('name', svgFileName) |
499 |
svgFilePath = os.path.join(AppDocData.instance().getCurrentProject().getSvgFilePath(), symbol.getType(), svgFileName+'.svg') |
|
500 |
|
|
576 |
svgFilePath = os.path.join(AppDocData.instance().getCurrentProject().getSvgFilePath(), symbol.getType(), |
|
577 |
svgFileName + '.svg') |
|
578 |
|
|
501 | 579 |
for line_end in [line_from, line_to]: |
502 | 580 |
for connector in line_end.connectors: |
503 | 581 |
if connector.connectedItem is not None and connector.connectedItem.owner is not self: |
504 | 582 |
end_break = SymbolSvgItem.createItem(symbol.getType(), None, svgFilePath) |
505 |
pt = [connector.center()[0] - float(symbol.getOriginalPoint().split(',')[0]), connector.center()[1] - float(symbol.getOriginalPoint().split(',')[1])] |
|
506 |
origin = [0,0] |
|
583 |
pt = [connector.center()[0] - float(symbol.getOriginalPoint().split(',')[0]), |
|
584 |
connector.center()[1] - float(symbol.getOriginalPoint().split(',')[1])] |
|
585 |
origin = [0, 0] |
|
507 | 586 |
if 2 == len(symbol.getOriginalPoint().split(',')): |
508 | 587 |
tokens = symbol.getOriginalPoint().split(',') |
509 | 588 |
origin = [pt[0] + float(tokens[0]), pt[1] + float(tokens[1])] |
510 |
end_break.buildItem(svgFileName, symbol.getType(), 5.7, pt, [end_break.boundingRect().width(), end_break.boundingRect().height()], origin, [], symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getHasInstrumentLabel()) |
|
511 |
|
|
589 |
end_break.buildItem(svgFileName, symbol.getType(), 5.7, pt, |
|
590 |
[end_break.boundingRect().width(), end_break.boundingRect().height()], |
|
591 |
origin, [], symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), |
|
592 |
symbol.getHasInstrumentLabel()) |
|
593 |
|
|
512 | 594 |
end_break.set_property('Connected Item', connector.connectedItem) |
513 | 595 |
end_break.setToolTip('owner : ' + str(line_end)) |
514 | 596 |
end_break.area = 'Drawing' |
515 | 597 |
end_break.owner = line_end |
516 | 598 |
end_breaks.append(end_break) |
517 | 599 |
except Exception as ex: |
518 |
from App import App
|
|
600 |
from App import App |
|
519 | 601 |
from AppDocData import MessageType |
520 | 602 |
|
521 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
603 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
604 |
sys.exc_info()[-1].tb_lineno) |
|
522 | 605 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
523 |
|
|
606 |
|
|
524 | 607 |
return end_breaks |
525 | 608 |
|
526 | 609 |
''' |
... | ... | |
529 | 612 |
@author Jeongwoo |
530 | 613 |
@date 2018.05.15 |
531 | 614 |
''' |
615 |
|
|
532 | 616 |
def getConnectedItems(self): |
533 | 617 |
visited = [] |
534 | 618 |
|
... | ... | |
539 | 623 |
from App import App |
540 | 624 |
from AppDocData import MessageType |
541 | 625 |
|
542 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
626 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
627 |
sys.exc_info()[-1].tb_lineno) |
|
543 | 628 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
544 | 629 |
|
545 | 630 |
return visited |
... | ... | |
547 | 632 |
def explode(self, remainFromTo=False): |
548 | 633 |
""" explode line no """ |
549 | 634 |
|
550 |
#if False == self.prop('Freeze'): |
|
635 |
# if False == self.prop('Freeze'):
|
|
551 | 636 |
try: |
552 | 637 |
for index in reversed(range(len(self.runs))): |
553 | 638 |
self.runs[index].explode() |
... | ... | |
562 | 647 |
@author humkyung |
563 | 648 |
@date 2018.08.14 |
564 | 649 |
''' |
650 |
|
|
565 | 651 |
def toSql_return_separately(self): |
566 | 652 |
import uuid |
567 | 653 |
from EngineeringAbstractItem import QEngineeringAbstractItem |
... | ... | |
570 | 656 |
resLater = [] |
571 | 657 |
|
572 | 658 |
app_doc_data = AppDocData.instance() |
573 |
cols = ['UID', 'Drawings_UID', 'Symbol_UID', 'X', 'Y', 'Width', 'Height', 'Rotation', 'Value', 'Connected', '[From]', '[To]'] |
|
659 |
cols = ['UID', 'Drawings_UID', 'Symbol_UID', 'X', 'Y', 'Width', 'Height', 'Rotation', 'Value', 'Connected', |
|
660 |
'[From]', '[To]'] |
|
574 | 661 |
if type(self) is QEngineeringLineNoTextItem: |
575 |
values = ['?', '?', "(select UID from Symbol where Name='Line NO' and SymbolType_UID=-1)", '?', '?', '?', '?', '?', '?', '?', '?', '?'] |
|
662 |
values = ['?', '?', "(select UID from Symbol where Name='Line NO' and SymbolType_UID=-1)", '?', '?', '?', |
|
663 |
'?', '?', '?', '?', '?', '?'] |
|
576 | 664 |
else: |
577 |
values = ['?', '?', "(select UID from Symbol where Name='Trim Line NO' and SymbolType_UID=-1)", '?', '?', '?', '?', '?', '?', '?', '?', '?'] |
|
578 |
params = [(str(self.uid), str(app_doc_data.activeDrawing.UID), self.loc[0], self.loc[1], self.size[0], self.size[1], str(self.angle),\ |
|
579 |
self.text(), str(self.conns[0]) if self.conns else None, str(self.prop('From')), str(self.prop('To')))] |
|
665 |
values = ['?', '?', "(select UID from Symbol where Name='Trim Line NO' and SymbolType_UID=-1)", '?', '?', |
|
666 |
'?', '?', '?', '?', '?', '?', '?'] |
|
667 |
params = [(str(self.uid), str(app_doc_data.activeDrawing.UID), self.loc[0], self.loc[1], self.size[0], |
|
668 |
self.size[1], str(self.angle), \ |
|
669 |
self.text(), str(self.conns[0]) if self.conns else None, str(self.prop('From')), |
|
670 |
str(self.prop('To')))] |
|
580 | 671 |
sql = 'insert into Components({}) values({})'.format(','.join(cols), ','.join(values)) |
581 | 672 |
res.append((sql, tuple(params))) |
582 | 673 |
|
... | ... | |
584 | 675 |
values = ['?', '?', '?', '?'] |
585 | 676 |
params = [] |
586 | 677 |
attrs = self.getAttributes() |
587 |
for key,value in attrs.items(): |
|
588 |
if key.Attribute == 'LINE NO':# or key.IsProp != 5: |
|
678 |
for key, value in attrs.items():
|
|
679 |
if key.Attribute == 'LINE NO': # or key.IsProp != 5:
|
|
589 | 680 |
continue |
590 | 681 |
params.append((str(uuid.uuid4()), str(self.uid), str(key.UID), str(value))) |
591 | 682 |
sql = 'insert into LineNoAttributes({}) values({})'.format(','.join(cols), ','.join(values)) |
... | ... | |
618 | 709 |
_index += 1 |
619 | 710 |
|
620 | 711 |
return res, resLater |
621 |
|
|
712 |
|
|
622 | 713 |
''' |
623 | 714 |
@brief return Line Data List |
624 | 715 |
@author kyouho |
625 | 716 |
@date 2018.08.14 |
626 | 717 |
''' |
718 |
|
|
627 | 719 |
def getLineDataList(self): |
628 | 720 |
dataList = [] |
629 | 721 |
try: |
... | ... | |
641 | 733 |
if type(key) is not UserInputAttribute: |
642 | 734 |
lineProp = docData.getLinePropertiesByUID(key.UID) |
643 | 735 |
if lineProp: |
644 |
attrName = lineProp[0].Attribute.upper().replace(' ','') |
|
736 |
attrName = lineProp[0].Attribute.upper().replace(' ', '')
|
|
645 | 737 |
else: |
646 |
attrName = key.Attribute.upper().replace(' ','') |
|
738 |
attrName = key.Attribute.upper().replace(' ', '')
|
|
647 | 739 |
|
648 | 740 |
data = attrs[key] |
649 | 741 |
if attrName == 'NOMINALDIAMETER': |
... | ... | |
677 | 769 |
from App import App |
678 | 770 |
from AppDocData import MessageType |
679 | 771 |
|
680 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
772 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
773 |
sys.exc_info()[-1].tb_lineno) |
|
681 | 774 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
682 | 775 |
|
683 | 776 |
if dataList[0] == '': |
... | ... | |
699 | 792 |
if type(items[0]) is QEngineeringNozzleItem: |
700 | 793 |
for connector in items[0].connectors: |
701 | 794 |
# From |
702 |
if (type(connector.connectedItem) is QEngineeringVendorItem or type(connector.connectedItem) is QEngineeringEquipmentItem) and \ |
|
795 |
if (type(connector.connectedItem) is QEngineeringVendorItem or type( |
|
796 |
connector.connectedItem) is QEngineeringEquipmentItem) and \ |
|
703 | 797 |
connector.connectedItem not in items: |
704 | 798 |
for _attr in _attrs: |
705 |
if _attr.Attribute == 'From_eq' and self.add_assoc_item(connector.connectedItem, at=_attr.AttrAt): |
|
799 |
if _attr.Attribute == 'From_eq' and self.add_assoc_item(connector.connectedItem, |
|
800 |
at=_attr.AttrAt): |
|
706 | 801 |
_attr.AssocItem = connector.connectedItem |
707 | 802 |
break |
708 | 803 |
break |
... | ... | |
710 | 805 |
if type(items[-1]) is QEngineeringNozzleItem: |
711 | 806 |
for connector in items[-1].connectors: |
712 | 807 |
# To |
713 |
if (type(connector.connectedItem) is QEngineeringVendorItem or type(connector.connectedItem) is QEngineeringEquipmentItem) and \ |
|
808 |
if (type(connector.connectedItem) is QEngineeringVendorItem or type( |
|
809 |
connector.connectedItem) is QEngineeringEquipmentItem) and \ |
|
714 | 810 |
connector.connectedItem not in items: |
715 | 811 |
for _attr in _attrs: |
716 |
if _attr.Attribute == 'To_eq' and self.add_assoc_item(connector.connectedItem, at=_attr.AttrAt): |
|
812 |
if _attr.Attribute == 'To_eq' and self.add_assoc_item(connector.connectedItem, |
|
813 |
at=_attr.AttrAt): |
|
717 | 814 |
_attr.AssocItem = connector.connectedItem |
718 | 815 |
break |
719 | 816 |
break |
720 |
|
DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py | ||
---|---|---|
796 | 796 |
|
797 | 797 |
return node |
798 | 798 |
|
799 |
def to_svg(self):
|
|
799 |
def to_svg(self, parent) -> list:
|
|
800 | 800 |
"""convert text item to svg""" |
801 |
import uuid |
|
802 | 801 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
803 | 802 |
|
803 |
res = [] |
|
804 | 804 |
try: |
805 |
node = Element('g') |
|
806 |
node.attrib['ID'] = str(self.uid) |
|
807 |
node.attrib['font-family'] = self.font().family() |
|
808 |
node.attrib['font-size'] = str(self.font().pointSizeF()) |
|
809 |
node.attrib['font-weight'] = str(self.font().weight()) |
|
810 |
trans = self.sceneTransform() |
|
811 |
node.attrib['transform'] = f"matrix(" \ |
|
812 |
f"{trans.m11()},{trans.m12()}," \ |
|
813 |
f"{trans.m21()},{trans.m22()}," \ |
|
814 |
f"{trans.m31()},{trans.m32()}" \ |
|
815 |
f")" |
|
816 |
text = Element('text') |
|
817 |
text.text = self.toPlainText() |
|
818 |
text.attrib['alignment-baseline'] = 'hanging' # align left-top corner |
|
819 |
node.append(text) |
|
805 |
node = None |
|
806 |
if parent is None or str(self.owner) == str(parent): |
|
807 |
node = Element('g') |
|
808 |
node.attrib['ID'] = str(self.uid) |
|
809 |
node.attrib['font-family'] = self.font().family() |
|
810 |
node.attrib['font-size'] = str(self.font().pointSizeF()) |
|
811 |
node.attrib['font-weight'] = str(self.font().weight()) |
|
812 |
|
|
813 |
if not parent: |
|
814 |
trans = self.sceneTransform() |
|
815 |
else: |
|
816 |
trans = parent.sceneTransform() |
|
817 |
inverted, _ = trans.inverted() |
|
818 |
trans = self.sceneTransform()*inverted |
|
819 |
|
|
820 |
node.attrib['transform'] = f"matrix(" \ |
|
821 |
f"{trans.m11()},{trans.m12()}," \ |
|
822 |
f"{trans.m21()},{trans.m22()}," \ |
|
823 |
f"{trans.m31()},{trans.m32()}" \ |
|
824 |
f")" |
|
825 |
text = Element('text') |
|
826 |
text.text = self.toPlainText() |
|
827 |
text.attrib['alignment-baseline'] = 'hanging' # align left-top corner |
|
828 |
node.append(text) |
|
829 |
|
|
830 |
res.append(node) |
|
820 | 831 |
except Exception as ex: |
821 | 832 |
from App import App |
822 | 833 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
823 | 834 |
sys.exc_info()[-1].tb_lineno) |
824 | 835 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
825 | 836 |
|
826 |
return None |
|
827 |
|
|
828 |
return node |
|
837 |
return res |
|
829 | 838 |
|
830 | 839 |
def findOwner(self, symbols): |
831 | 840 |
import math |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
1638 | 1638 |
|
1639 | 1639 |
return item |
1640 | 1640 |
|
1641 |
def to_svg(self):
|
|
1641 |
def to_svg(self, parent) -> list:
|
|
1642 | 1642 |
"""convert symbol svg item to svg""" |
1643 |
import uuid
|
|
1643 |
import re
|
|
1644 | 1644 |
from xml.etree.ElementTree import Element, SubElement, dump, ElementTree |
1645 | 1645 |
|
1646 |
res = [] |
|
1646 | 1647 |
try: |
1647 | 1648 |
node = Element('g') |
1648 | 1649 |
node.attrib['ID'] = str(self.uid) |
1649 | 1650 |
node.attrib['class'] = self.name |
1651 |
|
|
1652 |
except_pattern = re.compile('[^a-zA-Z0-9_]') |
|
1653 |
for attr, value in self.getAttributes().items(): |
|
1654 |
node.attrib[re.sub(except_pattern, '_', attr.Attribute)] = value if value else '' |
|
1650 | 1655 |
trans = self.sceneTransform() |
1651 | 1656 |
node.attrib['transform'] = f"matrix(" \ |
1652 | 1657 |
f"{trans.m11()},{trans.m12()}," \ |
... | ... | |
1660 | 1665 |
path.attrib['d'] = node_list.item(at).attributes().namedItem('d').nodeValue() |
1661 | 1666 |
path.attrib['transform'] = self._document.elementsByTagName('g').item(0).attributes().namedItem('transform').nodeValue() |
1662 | 1667 |
node.append(path) |
1668 |
|
|
1669 |
for assoc in self.associations(): |
|
1670 |
assoc_node = assoc.to_svg(parent=self) |
|
1671 |
node.extend(assoc_node) |
|
1672 |
|
|
1673 |
res.append(node) |
|
1663 | 1674 |
except Exception as ex: |
1664 | 1675 |
from App import App |
1665 | 1676 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
1666 | 1677 |
sys.exc_info()[-1].tb_lineno) |
1667 | 1678 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1668 | 1679 |
|
1669 |
return None |
|
1670 |
|
|
1671 |
return node |
|
1680 |
return res |
|
1672 | 1681 |
|
1673 | 1682 |
''' |
1674 | 1683 |
@brief create item corresponding to given type |
... | ... | |
1741 | 1750 |
''' |
1742 | 1751 |
|
1743 | 1752 |
def setColor(self, color): |
1744 |
self.changeAttributes('fill', color) |
|
1745 |
self.changeAttributes('stroke', color) |
|
1746 |
self.renderer().load(self._document.toByteArray()) |
|
1747 |
self.update() |
|
1753 |
if self._document: |
|
1754 |
self.changeAttributes('fill', color) |
|
1755 |
self.changeAttributes('stroke', color) |
|
1756 |
self.renderer().load(self._document.toByteArray()) |
|
1757 |
self.update() |
|
1748 | 1758 |
|
1749 | 1759 |
def getColor(self): |
1750 | 1760 |
""" return hover color if mouse is over otherwise reutrn owner's color if owner exist else this color """ |
내보내기 Unified diff