개정판 89a2fbe0
issue #000: offset cal test
Change-Id: I7e3c52d4c489096c33be080df6535b4aec37012b
DTI_PID/DTI_PID/ImportTextFromCADDialog.py | ||
---|---|---|
218 | 218 |
self.ui.pushButtonSave.clicked.connect(self.on_save_mappings) |
219 | 219 |
self.ui.pushButtonImport.clicked.connect(self.on_import_autocad) |
220 | 220 |
self.ui.pushButtonClose.clicked.connect(self.close) |
221 |
self.ui.pushButtonAuto.clicked.connect(self.autoCalOffset) |
|
222 |
|
|
223 |
def autoCalOffset(self): |
|
224 |
""" auto calculate offset """ |
|
225 |
from App import App |
|
226 |
from EngineeringTextItem import QEngineeringTextItem |
|
227 |
|
|
228 |
if not self._dwgs: |
|
229 |
QMessageBox.information(self, self.tr('Information'), self.tr('There is no selected file(s)')) |
|
230 |
return |
|
231 |
|
|
232 |
find_text = self.ui.lineEdit.text() |
|
233 |
|
|
234 |
matches = [item for item in App.mainWnd().graphicsView.items() if issubclass(type(item), QEngineeringTextItem) and item.text() == find_text] |
|
235 |
if not matches: |
|
236 |
return |
|
237 |
|
|
238 |
text_item = matches[0] |
|
239 |
text_loc = text_item.loc |
|
240 |
|
|
241 |
app_doc_data = AppDocData.instance() |
|
242 |
project = app_doc_data.getCurrentProject() |
|
243 |
|
|
244 |
temp_path = project.getTempPath() |
|
245 |
id2_xml_files = [f for f in os.listdir(temp_path) if os.path.isfile(os.path.join(temp_path, f)) and |
|
246 |
(os.path.splitext(f)[1].upper() == '.XML')] |
|
247 |
|
|
248 |
size_area = app_doc_data.getArea('Size') |
|
249 |
if size_area: |
|
250 |
id2_bbox = [size_area.x, size_area.y, size_area.width, size_area.height] |
|
251 |
else: |
|
252 |
id2_bbox = [0, 0, |
|
253 |
int(id2_xml_root.find('SIZE').text.split(',')[0]), |
|
254 |
int(id2_xml_root.find('SIZE').text.split(',')[1])] |
|
255 |
|
|
256 |
_file = self._dwgs[0] |
|
257 |
file_name = os.path.splitext(os.path.basename(_file))[0] |
|
258 |
autocad_xml_path = os.path.join(os.path.dirname(_file), os.path.splitext(os.path.basename(_file))[0] + '.xml') |
|
259 |
matches = [id2_xml_file for id2_xml_file in id2_xml_files if id2_xml_file.replace(file_name, '').upper() == '.XML'] |
|
260 |
if matches: |
|
261 |
try: |
|
262 |
autocad_xml = parse(autocad_xml_path) |
|
263 |
|
|
264 |
autocad_xml_root = autocad_xml.getroot() |
|
265 |
|
|
266 |
find = False |
|
267 |
x_offset = None |
|
268 |
y_offset = None |
|
269 |
for blk_tbl_record in autocad_xml_root.iter('AcDbBlockTableRecord'): |
|
270 |
if blk_tbl_record.attrib['Name'].upper() != '*Model_Space'.upper(): |
|
271 |
continue |
|
272 |
|
|
273 |
min_values = [float(token) for token in |
|
274 |
blk_tbl_record.attrib['MinExtents'].strip('(').strip(')').split(',')] |
|
275 |
max_values = [float(token) for token in |
|
276 |
blk_tbl_record.attrib['MaxExtents'].strip('(').strip(')').split(',')] |
|
277 |
autocad_bbox = [min_values[0], min_values[1], |
|
278 |
max_values[0] - min_values[0], max_values[1] - min_values[1]] |
|
279 |
for record in blk_tbl_record.iter('AcDbText'): |
|
280 |
if find_text != text_node.text: |
|
281 |
continue |
|
282 |
|
|
283 |
scale = max([id2_bbox[2] / autocad_bbox[2], id2_bbox[3] / autocad_bbox[3]]) |
|
284 |
offsets = [id2_bbox[0] - autocad_bbox[0] * scale, (id2_bbox[1] + id2_bbox[3]) - autocad_bbox[1] * scale] |
|
285 |
|
|
286 |
loc = [float(text_node.attrib['X']) * scale + offsets[0], -float(text_node.attrib['Y']) * scale + offsets[1]] |
|
287 |
x_offset = text_loc[0] - loc[0] |
|
288 |
y_offset = text_loc[1] - loc[1] |
|
289 |
find = True |
|
290 |
break |
|
291 |
|
|
292 |
if not find: |
|
293 |
for blk_ref in blk_tbl_record.iter('AcDbBlockReference'): |
|
294 |
if find: |
|
295 |
break |
|
296 |
for record in blk_ref.iter('AcDbAttribute'): |
|
297 |
if find_text != text_node.text: |
|
298 |
continue |
|
299 |
|
|
300 |
scale = max([id2_bbox[2] / autocad_bbox[2], id2_bbox[3] / autocad_bbox[3]]) |
|
301 |
offsets = [id2_bbox[0] - autocad_bbox[0] * scale, (id2_bbox[1] + id2_bbox[3]) - autocad_bbox[1] * scale] |
|
302 |
|
|
303 |
loc = [float(text_node.attrib['X']) * scale + offsets[0], -float(text_node.attrib['Y']) * scale + offsets[1]] |
|
304 |
x_offset = text_loc[0] - loc[0] |
|
305 |
y_offset = text_loc[1] - loc[1] |
|
306 |
find = True |
|
307 |
break |
|
308 |
|
|
309 |
if find: |
|
310 |
self.ui.spinBoxTextX.setValue(x_offset) |
|
311 |
self.ui.spinBoxX.setValue(x_offset) |
|
312 |
self.ui.spinBoxTextY.setValue(y_offset) |
|
313 |
self.ui.spinBoxY.setValue(y_offset) |
|
314 |
|
|
315 |
except Exception as ex: |
|
316 |
from App import App |
|
317 |
from AppDocData import MessageType |
|
318 |
|
|
319 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
320 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
321 |
QMessageBox.warning(self, self._tr('Warning'), message) |
|
221 | 322 |
|
222 | 323 |
def on_load_line_type_mapping(self): |
223 | 324 |
"""load ID2-AutoCAD """ |
... | ... | |
414 | 515 |
f"{sys.exc_info()[-1].tb_lineno}" |
415 | 516 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
416 | 517 |
|
518 |
return self._symbol_types |
|
519 |
|
|
417 | 520 |
def on_save_mappings(self): |
418 | 521 |
"""save line type and symbol mappings""" |
419 | 522 |
from AppDocData import Config |
... | ... | |
513 | 616 |
|
514 | 617 |
id2_xml_path = os.path.join(temp_path, matches[0]) |
515 | 618 |
id2_xml = parse(id2_xml_path) |
516 |
autocad_xml_root = autocad_xml.getroot() |
|
517 | 619 |
id2_xml_root = id2_xml.getroot() |
518 | 620 |
|
519 |
size_area = AppDocData.instance().getArea('Size')
|
|
621 |
size_area = app_doc_data.getArea('Size')
|
|
520 | 622 |
if size_area: |
521 | 623 |
id2_bbox = [size_area.x + self.ui.spinBoxX.value(), size_area.y + self.ui.spinBoxY.value(), size_area.width, size_area.height] |
522 | 624 |
id2_bbox_text = [size_area.x + self.ui.spinBoxTextX.value(), size_area.y + self.ui.spinBoxTextY.value(), size_area.width, size_area.height] |
... | ... | |
555 | 657 |
unknowns.clear() |
556 | 658 |
"""up to here""" |
557 | 659 |
|
558 |
"""add text and line from autocad file to id xml file"""
|
|
660 |
"""add text, line and symbol from autocad file to id xml file"""
|
|
559 | 661 |
for blk_tbl_record in autocad_xml_root.iter('AcDbBlockTableRecord'): |
560 | 662 |
if blk_tbl_record.attrib['Name'].upper() != '*Model_Space'.upper(): |
561 | 663 |
continue |
DTI_PID/DTI_PID/ImportTextFromCAD_UI.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
# Form implementation generated from reading ui file '.\UI\ImportTextFromCAD.ui'
|
|
3 |
# Form implementation generated from reading ui file './UI/ImportTextFromCAD.ui'
|
|
4 | 4 |
# |
5 |
# Created by: PyQt5 UI code generator 5.15.2
|
|
5 |
# Created by: PyQt5 UI code generator 5.11.3
|
|
6 | 6 |
# |
7 |
# WARNING: Any manual changes made to this file will be lost when pyuic5 is |
|
8 |
# run again. Do not edit this file unless you know what you are doing. |
|
9 |
|
|
7 |
# WARNING! All changes made in this file will be lost! |
|
10 | 8 |
|
11 | 9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
12 | 10 |
|
13 |
|
|
14 | 11 |
class Ui_ImportTextFromCADDialog(object): |
15 | 12 |
def setupUi(self, ImportTextFromCADDialog): |
16 | 13 |
ImportTextFromCADDialog.setObjectName("ImportTextFromCADDialog") |
... | ... | |
26 | 23 |
self.verticalLayout.setObjectName("verticalLayout") |
27 | 24 |
self.gridLayout = QtWidgets.QGridLayout() |
28 | 25 |
self.gridLayout.setObjectName("gridLayout") |
29 |
self.spinBoxY = QtWidgets.QSpinBox(ImportTextFromCADDialog) |
|
30 |
self.spinBoxY.setMinimum(-50000) |
|
31 |
self.spinBoxY.setMaximum(50000) |
|
32 |
self.spinBoxY.setObjectName("spinBoxY") |
|
33 |
self.gridLayout.addWidget(self.spinBoxY, 3, 2, 1, 1) |
|
34 |
self.spinBoxX = QtWidgets.QSpinBox(ImportTextFromCADDialog) |
|
35 |
self.spinBoxX.setMinimumSize(QtCore.QSize(0, 0)) |
|
36 |
self.spinBoxX.setMinimum(-50000) |
|
37 |
self.spinBoxX.setMaximum(50000) |
|
38 |
self.spinBoxX.setObjectName("spinBoxX") |
|
39 |
self.gridLayout.addWidget(self.spinBoxX, 3, 1, 1, 1) |
|
40 |
self.label = QtWidgets.QLabel(ImportTextFromCADDialog) |
|
41 |
self.label.setObjectName("label") |
|
42 |
self.gridLayout.addWidget(self.label, 3, 0, 1, 1) |
|
26 |
self.tabWidgetEntities = QtWidgets.QTabWidget(ImportTextFromCADDialog) |
|
27 |
self.tabWidgetEntities.setObjectName("tabWidgetEntities") |
|
28 |
self.tabLineTypes = QtWidgets.QWidget() |
|
29 |
self.tabLineTypes.setObjectName("tabLineTypes") |
|
30 |
self.gridLayout_2 = QtWidgets.QGridLayout(self.tabLineTypes) |
|
31 |
self.gridLayout_2.setObjectName("gridLayout_2") |
|
32 |
self.treeViewLineType = QtWidgets.QTreeView(self.tabLineTypes) |
|
33 |
self.treeViewLineType.setObjectName("treeViewLineType") |
|
34 |
self.gridLayout_2.addWidget(self.treeViewLineType, 0, 0, 1, 1) |
|
35 |
self.tabWidgetEntities.addTab(self.tabLineTypes, "") |
|
36 |
self.tabSymbols = QtWidgets.QWidget() |
|
37 |
self.tabSymbols.setObjectName("tabSymbols") |
|
38 |
self.gridLayout_3 = QtWidgets.QGridLayout(self.tabSymbols) |
|
39 |
self.gridLayout_3.setObjectName("gridLayout_3") |
|
40 |
self.treeViewSymbolMapping = QtWidgets.QTreeView(self.tabSymbols) |
|
41 |
self.treeViewSymbolMapping.setObjectName("treeViewSymbolMapping") |
|
42 |
self.gridLayout_3.addWidget(self.treeViewSymbolMapping, 0, 0, 1, 1) |
|
43 |
self.tabWidgetEntities.addTab(self.tabSymbols, "") |
|
44 |
self.gridLayout.addWidget(self.tabWidgetEntities, 2, 1, 1, 3) |
|
43 | 45 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
44 | 46 |
self.horizontalLayout.setObjectName("horizontalLayout") |
45 | 47 |
self.spinBoxTextX = QtWidgets.QSpinBox(ImportTextFromCADDialog) |
... | ... | |
57 | 59 |
self.doubleSpinBoxScale.setObjectName("doubleSpinBoxScale") |
58 | 60 |
self.horizontalLayout.addWidget(self.doubleSpinBoxScale) |
59 | 61 |
self.gridLayout.addLayout(self.horizontalLayout, 4, 1, 1, 3) |
60 |
self.lineEditCAD = QtWidgets.QLineEdit(ImportTextFromCADDialog) |
|
61 |
self.lineEditCAD.setObjectName("lineEditCAD") |
|
62 |
self.gridLayout.addWidget(self.lineEditCAD, 0, 1, 1, 3) |
|
63 |
self.label_2 = QtWidgets.QLabel(ImportTextFromCADDialog) |
|
64 |
self.label_2.setMinimumSize(QtCore.QSize(50, 0)) |
|
65 |
self.label_2.setObjectName("label_2") |
|
66 |
self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1) |
|
67 | 62 |
self.toolButtonCAD = QtWidgets.QToolButton(ImportTextFromCADDialog) |
68 | 63 |
self.toolButtonCAD.setText("") |
69 | 64 |
icon = QtGui.QIcon() |
... | ... | |
71 | 66 |
self.toolButtonCAD.setIcon(icon) |
72 | 67 |
self.toolButtonCAD.setObjectName("toolButtonCAD") |
73 | 68 |
self.gridLayout.addWidget(self.toolButtonCAD, 0, 4, 1, 1) |
74 |
self.pushButtonClose = QtWidgets.QPushButton(ImportTextFromCADDialog)
|
|
69 |
self.pushButtonImport = QtWidgets.QPushButton(ImportTextFromCADDialog)
|
|
75 | 70 |
icon1 = QtGui.QIcon() |
76 |
icon1.addPixmap(QtGui.QPixmap(":/newPrefix/Remove.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
77 |
self.pushButtonClose.setIcon(icon1) |
|
78 |
self.pushButtonClose.setObjectName("pushButtonClose") |
|
79 |
self.gridLayout.addWidget(self.pushButtonClose, 6, 3, 1, 1) |
|
71 |
icon1.addPixmap(QtGui.QPixmap(":/newPrefix/OK.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
|
72 |
self.pushButtonImport.setIcon(icon1) |
|
73 |
self.pushButtonImport.setObjectName("pushButtonImport") |
|
74 |
self.gridLayout.addWidget(self.pushButtonImport, 7, 2, 1, 1) |
|
75 |
self.spinBoxY = QtWidgets.QSpinBox(ImportTextFromCADDialog) |
|
76 |
self.spinBoxY.setMinimum(-50000) |
|
77 |
self.spinBoxY.setMaximum(50000) |
|
78 |
self.spinBoxY.setObjectName("spinBoxY") |
|
79 |
self.gridLayout.addWidget(self.spinBoxY, 3, 2, 1, 1) |
|
80 |
self.lineEditCAD = QtWidgets.QLineEdit(ImportTextFromCADDialog) |
|
81 |
self.lineEditCAD.setObjectName("lineEditCAD") |
|
82 |
self.gridLayout.addWidget(self.lineEditCAD, 0, 1, 1, 3) |
|
83 |
self.label_2 = QtWidgets.QLabel(ImportTextFromCADDialog) |
|
84 |
self.label_2.setMinimumSize(QtCore.QSize(50, 0)) |
|
85 |
self.label_2.setObjectName("label_2") |
|
86 |
self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1) |
|
80 | 87 |
self.pushButtonSave = QtWidgets.QPushButton(ImportTextFromCADDialog) |
81 | 88 |
icon2 = QtGui.QIcon() |
82 | 89 |
icon2.addPixmap(QtGui.QPixmap(":/newPrefix/Save.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) |
83 | 90 |
self.pushButtonSave.setIcon(icon2) |
84 | 91 |
self.pushButtonSave.setObjectName("pushButtonSave") |
85 |
self.gridLayout.addWidget(self.pushButtonSave, 5, 1, 1, 3) |
|
86 |
self.pushButtonImport = QtWidgets.QPushButton(ImportTextFromCADDialog) |
|
92 |
self.gridLayout.addWidget(self.pushButtonSave, 6, 1, 1, 3) |
|
93 |
self.spinBoxX = QtWidgets.QSpinBox(ImportTextFromCADDialog) |
|
94 |
self.spinBoxX.setMinimumSize(QtCore.QSize(0, 0)) |
|
95 |
self.spinBoxX.setMinimum(-50000) |
|
96 |
self.spinBoxX.setMaximum(50000) |
|
97 |
self.spinBoxX.setObjectName("spinBoxX") |
|
98 |
self.gridLayout.addWidget(self.spinBoxX, 3, 1, 1, 1) |
|
99 |
self.label = QtWidgets.QLabel(ImportTextFromCADDialog) |
|
100 |
self.label.setObjectName("label") |
|
101 |
self.gridLayout.addWidget(self.label, 3, 0, 1, 1) |
|
102 |
self.pushButtonClose = QtWidgets.QPushButton(ImportTextFromCADDialog) |
|
87 | 103 |
icon3 = QtGui.QIcon() |
88 |
icon3.addPixmap(QtGui.QPixmap(":/newPrefix/OK.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
|
89 |
self.pushButtonImport.setIcon(icon3)
|
|
90 |
self.pushButtonImport.setObjectName("pushButtonImport")
|
|
91 |
self.gridLayout.addWidget(self.pushButtonImport, 6, 2, 1, 1)
|
|
104 |
icon3.addPixmap(QtGui.QPixmap(":/newPrefix/Remove.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
|
105 |
self.pushButtonClose.setIcon(icon3)
|
|
106 |
self.pushButtonClose.setObjectName("pushButtonClose")
|
|
107 |
self.gridLayout.addWidget(self.pushButtonClose, 7, 3, 1, 1)
|
|
92 | 108 |
self.label_3 = QtWidgets.QLabel(ImportTextFromCADDialog) |
93 | 109 |
self.label_3.setObjectName("label_3") |
94 | 110 |
self.gridLayout.addWidget(self.label_3, 4, 0, 1, 1) |
95 |
self.tabWidgetEntities = QtWidgets.QTabWidget(ImportTextFromCADDialog) |
|
96 |
self.tabWidgetEntities.setObjectName("tabWidgetEntities") |
|
97 |
self.tabLineTypes = QtWidgets.QWidget() |
|
98 |
self.tabLineTypes.setObjectName("tabLineTypes") |
|
99 |
self.gridLayout_2 = QtWidgets.QGridLayout(self.tabLineTypes) |
|
100 |
self.gridLayout_2.setObjectName("gridLayout_2") |
|
101 |
self.treeViewLineType = QtWidgets.QTreeView(self.tabLineTypes) |
|
102 |
self.treeViewLineType.setObjectName("treeViewLineType") |
|
103 |
self.gridLayout_2.addWidget(self.treeViewLineType, 0, 0, 1, 1) |
|
104 |
self.tabWidgetEntities.addTab(self.tabLineTypes, "") |
|
105 |
self.tabSymbols = QtWidgets.QWidget() |
|
106 |
self.tabSymbols.setObjectName("tabSymbols") |
|
107 |
self.gridLayout_3 = QtWidgets.QGridLayout(self.tabSymbols) |
|
108 |
self.gridLayout_3.setObjectName("gridLayout_3") |
|
109 |
self.treeViewSymbolMapping = QtWidgets.QTreeView(self.tabSymbols) |
|
110 |
self.treeViewSymbolMapping.setObjectName("treeViewSymbolMapping") |
|
111 |
self.gridLayout_3.addWidget(self.treeViewSymbolMapping, 0, 0, 1, 1) |
|
112 |
self.tabWidgetEntities.addTab(self.tabSymbols, "") |
|
113 |
self.gridLayout.addWidget(self.tabWidgetEntities, 2, 1, 1, 3) |
|
111 |
self.label_4 = QtWidgets.QLabel(ImportTextFromCADDialog) |
|
112 |
self.label_4.setObjectName("label_4") |
|
113 |
self.gridLayout.addWidget(self.label_4, 5, 0, 1, 1) |
|
114 |
self.pushButtonAuto = QtWidgets.QPushButton(ImportTextFromCADDialog) |
|
115 |
self.pushButtonAuto.setObjectName("pushButtonAuto") |
|
116 |
self.gridLayout.addWidget(self.pushButtonAuto, 5, 3, 1, 1) |
|
117 |
self.lineEdit = QtWidgets.QLineEdit(ImportTextFromCADDialog) |
|
118 |
self.lineEdit.setObjectName("lineEdit") |
|
119 |
self.gridLayout.addWidget(self.lineEdit, 5, 1, 1, 2) |
|
114 | 120 |
self.verticalLayout.addLayout(self.gridLayout) |
115 | 121 |
self.errorLabel = QtWidgets.QLabel(ImportTextFromCADDialog) |
116 | 122 |
self.errorLabel.setMaximumSize(QtCore.QSize(16777215, 0)) |
... | ... | |
127 | 133 |
def retranslateUi(self, ImportTextFromCADDialog): |
128 | 134 |
_translate = QtCore.QCoreApplication.translate |
129 | 135 |
ImportTextFromCADDialog.setWindowTitle(_translate("ImportTextFromCADDialog", "Import AutoCAD")) |
130 |
self.label.setText(_translate("ImportTextFromCADDialog", "Line Offset(x, y) : ")) |
|
136 |
self.tabWidgetEntities.setTabText(self.tabWidgetEntities.indexOf(self.tabLineTypes), _translate("ImportTextFromCADDialog", "Line Types")) |
|
137 |
self.tabWidgetEntities.setTabText(self.tabWidgetEntities.indexOf(self.tabSymbols), _translate("ImportTextFromCADDialog", "Symbols")) |
|
138 |
self.pushButtonImport.setText(_translate("ImportTextFromCADDialog", "Import")) |
|
131 | 139 |
self.lineEditCAD.setPlaceholderText(_translate("ImportTextFromCADDialog", "Select AutoCAD File(s)")) |
132 | 140 |
self.label_2.setText(_translate("ImportTextFromCADDialog", "AutoCAD Files : ")) |
133 |
self.pushButtonClose.setText(_translate("ImportTextFromCADDialog", "Close")) |
|
134 | 141 |
self.pushButtonSave.setText(_translate("ImportTextFromCADDialog", "Save Mapping")) |
135 |
self.pushButtonImport.setText(_translate("ImportTextFromCADDialog", "Import")) |
|
142 |
self.label.setText(_translate("ImportTextFromCADDialog", "Line Offset(x, y) : ")) |
|
143 |
self.pushButtonClose.setText(_translate("ImportTextFromCADDialog", "Close")) |
|
136 | 144 |
self.label_3.setText(_translate("ImportTextFromCADDialog", "Text Offset(x, y, scale) : ")) |
137 |
self.tabWidgetEntities.setTabText(self.tabWidgetEntities.indexOf(self.tabLineTypes), _translate("ImportTextFromCADDialog", "Line Types")) |
|
138 |
self.tabWidgetEntities.setTabText(self.tabWidgetEntities.indexOf(self.tabSymbols), _translate("ImportTextFromCADDialog", "Symbols")) |
|
145 |
self.label_4.setText(_translate("ImportTextFromCADDialog", "Search Text(Line No.)")) |
|
146 |
self.pushButtonAuto.setText(_translate("ImportTextFromCADDialog", "Auto Cal.")) |
|
147 |
|
|
139 | 148 |
import MainWindow_rc |
149 |
|
|
150 |
if __name__ == "__main__": |
|
151 |
import sys |
|
152 |
app = QtWidgets.QApplication(sys.argv) |
|
153 |
ImportTextFromCADDialog = QtWidgets.QDialog() |
|
154 |
ui = Ui_ImportTextFromCADDialog() |
|
155 |
ui.setupUi(ImportTextFromCADDialog) |
|
156 |
ImportTextFromCADDialog.show() |
|
157 |
sys.exit(app.exec_()) |
|
158 |
|
DTI_PID/DTI_PID/SymbolBase.py | ||
---|---|---|
138 | 138 |
|
139 | 139 |
def parse_connection_pts(self, origin: list) -> list: |
140 | 140 |
"""parse connection points and add origin point""" |
141 |
res = [] |
|
142 |
|
|
143 |
for param in self.connectionPoint.split('/'): |
|
144 |
tokens = param.split(',') |
|
145 |
res.append( |
|
146 |
('AUTO', origin[0] + float(tokens[0]), origin[1] + float(tokens[1]), '0') if len(tokens) == 2 else |
|
147 |
(tokens[0], origin[0] + float(tokens[1]), origin[1] + float(tokens[2]), '0') if len(tokens) == 3 else |
|
148 |
(tokens[0], origin[0] + float(tokens[1]), origin[1] + float(tokens[2]), tokens[3])) |
|
149 |
|
|
150 |
return res |
|
141 |
try: |
|
142 |
res = None |
|
143 |
|
|
144 |
if self.connectionPoint is not None and self.connectionPoint != '': |
|
145 |
res = [] |
|
146 |
for param in self.connectionPoint.split('/'): |
|
147 |
tokens = param.split(',') |
|
148 |
res.append( |
|
149 |
('AUTO', origin[0] + float(tokens[0]), origin[1] + float(tokens[1]), '0') if len(tokens) == 2 else |
|
150 |
(tokens[0], origin[0] + float(tokens[1]), origin[1] + float(tokens[2]), '0') if len(tokens) == 3 else |
|
151 |
(tokens[0], origin[0] + float(tokens[1]), origin[1] + float(tokens[2]), tokens[3])) |
|
152 |
|
|
153 |
return res |
|
154 |
except Exception as ex: |
|
155 |
import sys |
|
156 |
from App import App |
|
157 |
from AppDocData import MessageType |
|
158 |
|
|
159 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
160 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
161 |
|
|
162 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
151 | 163 |
|
152 | 164 |
def setConnectionPoint(self, connectionPoint): |
153 | 165 |
self.connectionPoint = connectionPoint |
DTI_PID/DTI_PID/UI/ImportTextFromCAD.ui | ||
---|---|---|
35 | 35 |
<layout class="QVBoxLayout" name="verticalLayout"> |
36 | 36 |
<item> |
37 | 37 |
<layout class="QGridLayout" name="gridLayout"> |
38 |
<item row="3" column="2"> |
|
39 |
<widget class="QSpinBox" name="spinBoxY"> |
|
40 |
<property name="minimum"> |
|
41 |
<number>-50000</number> |
|
42 |
</property> |
|
43 |
<property name="maximum"> |
|
44 |
<number>50000</number> |
|
45 |
</property> |
|
46 |
</widget> |
|
47 |
</item> |
|
48 |
<item row="3" column="1"> |
|
49 |
<widget class="QSpinBox" name="spinBoxX"> |
|
50 |
<property name="minimumSize"> |
|
51 |
<size> |
|
52 |
<width>0</width> |
|
53 |
<height>0</height> |
|
54 |
</size> |
|
55 |
</property> |
|
56 |
<property name="minimum"> |
|
57 |
<number>-50000</number> |
|
58 |
</property> |
|
59 |
<property name="maximum"> |
|
60 |
<number>50000</number> |
|
61 |
</property> |
|
62 |
</widget> |
|
63 |
</item> |
|
64 |
<item row="3" column="0"> |
|
65 |
<widget class="QLabel" name="label"> |
|
66 |
<property name="text"> |
|
67 |
<string>Line Offset(x, y) : </string> |
|
38 |
<item row="2" column="1" colspan="3"> |
|
39 |
<widget class="QTabWidget" name="tabWidgetEntities"> |
|
40 |
<property name="currentIndex"> |
|
41 |
<number>0</number> |
|
68 | 42 |
</property> |
43 |
<widget class="QWidget" name="tabLineTypes"> |
|
44 |
<attribute name="title"> |
|
45 |
<string>Line Types</string> |
|
46 |
</attribute> |
|
47 |
<layout class="QGridLayout" name="gridLayout_2"> |
|
48 |
<item row="0" column="0"> |
|
49 |
<widget class="QTreeView" name="treeViewLineType"/> |
|
50 |
</item> |
|
51 |
</layout> |
|
52 |
</widget> |
|
53 |
<widget class="QWidget" name="tabSymbols"> |
|
54 |
<attribute name="title"> |
|
55 |
<string>Symbols</string> |
|
56 |
</attribute> |
|
57 |
<layout class="QGridLayout" name="gridLayout_3"> |
|
58 |
<item row="0" column="0"> |
|
59 |
<widget class="QTreeView" name="treeViewSymbolMapping"/> |
|
60 |
</item> |
|
61 |
</layout> |
|
62 |
</widget> |
|
69 | 63 |
</widget> |
70 | 64 |
</item> |
71 | 65 |
<item row="4" column="1" colspan="3"> |
... | ... | |
99 | 93 |
</item> |
100 | 94 |
</layout> |
101 | 95 |
</item> |
96 |
<item row="0" column="4"> |
|
97 |
<widget class="QToolButton" name="toolButtonCAD"> |
|
98 |
<property name="text"> |
|
99 |
<string/> |
|
100 |
</property> |
|
101 |
<property name="icon"> |
|
102 |
<iconset resource="../res/MainWindow.qrc"> |
|
103 |
<normaloff>:/newPrefix/File.svg</normaloff>:/newPrefix/File.svg</iconset> |
|
104 |
</property> |
|
105 |
</widget> |
|
106 |
</item> |
|
107 |
<item row="7" column="2"> |
|
108 |
<widget class="QPushButton" name="pushButtonImport"> |
|
109 |
<property name="text"> |
|
110 |
<string>Import</string> |
|
111 |
</property> |
|
112 |
<property name="icon"> |
|
113 |
<iconset resource="../res/MainWindow.qrc"> |
|
114 |
<normaloff>:/newPrefix/OK.svg</normaloff>:/newPrefix/OK.svg</iconset> |
|
115 |
</property> |
|
116 |
</widget> |
|
117 |
</item> |
|
118 |
<item row="3" column="2"> |
|
119 |
<widget class="QSpinBox" name="spinBoxY"> |
|
120 |
<property name="minimum"> |
|
121 |
<number>-50000</number> |
|
122 |
</property> |
|
123 |
<property name="maximum"> |
|
124 |
<number>50000</number> |
|
125 |
</property> |
|
126 |
</widget> |
|
127 |
</item> |
|
102 | 128 |
<item row="0" column="1" colspan="3"> |
103 | 129 |
<widget class="QLineEdit" name="lineEditCAD"> |
104 | 130 |
<property name="placeholderText"> |
... | ... | |
119 | 145 |
</property> |
120 | 146 |
</widget> |
121 | 147 |
</item> |
122 |
<item row="0" column="4">
|
|
123 |
<widget class="QToolButton" name="toolButtonCAD">
|
|
148 |
<item row="6" column="1" colspan="3">
|
|
149 |
<widget class="QPushButton" name="pushButtonSave">
|
|
124 | 150 |
<property name="text"> |
125 |
<string/>
|
|
151 |
<string>Save Mapping</string>
|
|
126 | 152 |
</property> |
127 | 153 |
<property name="icon"> |
128 | 154 |
<iconset resource="../res/MainWindow.qrc"> |
129 |
<normaloff>:/newPrefix/File.svg</normaloff>:/newPrefix/File.svg</iconset>
|
|
155 |
<normaloff>:/newPrefix/Save.svg</normaloff>:/newPrefix/Save.svg</iconset>
|
|
130 | 156 |
</property> |
131 | 157 |
</widget> |
132 | 158 |
</item> |
133 |
<item row="6" column="3"> |
|
134 |
<widget class="QPushButton" name="pushButtonClose"> |
|
135 |
<property name="text"> |
|
136 |
<string>Close</string> |
|
159 |
<item row="3" column="1"> |
|
160 |
<widget class="QSpinBox" name="spinBoxX"> |
|
161 |
<property name="minimumSize"> |
|
162 |
<size> |
|
163 |
<width>0</width> |
|
164 |
<height>0</height> |
|
165 |
</size> |
|
137 | 166 |
</property> |
138 |
<property name="icon"> |
|
139 |
<iconset resource="../res/MainWindow.qrc"> |
|
140 |
<normaloff>:/newPrefix/Remove.svg</normaloff>:/newPrefix/Remove.svg</iconset> |
|
167 |
<property name="minimum"> |
|
168 |
<number>-50000</number> |
|
169 |
</property> |
|
170 |
<property name="maximum"> |
|
171 |
<number>50000</number> |
|
141 | 172 |
</property> |
142 | 173 |
</widget> |
143 | 174 |
</item> |
144 |
<item row="5" column="1" colspan="3">
|
|
145 |
<widget class="QPushButton" name="pushButtonSave">
|
|
175 |
<item row="3" column="0">
|
|
176 |
<widget class="QLabel" name="label">
|
|
146 | 177 |
<property name="text"> |
147 |
<string>Save Mapping</string> |
|
148 |
</property> |
|
149 |
<property name="icon"> |
|
150 |
<iconset resource="../res/MainWindow.qrc"> |
|
151 |
<normaloff>:/newPrefix/Save.svg</normaloff>:/newPrefix/Save.svg</iconset> |
|
178 |
<string>Line Offset(x, y) : </string> |
|
152 | 179 |
</property> |
153 | 180 |
</widget> |
154 | 181 |
</item> |
155 |
<item row="6" column="2">
|
|
156 |
<widget class="QPushButton" name="pushButtonImport">
|
|
182 |
<item row="7" column="3">
|
|
183 |
<widget class="QPushButton" name="pushButtonClose">
|
|
157 | 184 |
<property name="text"> |
158 |
<string>Import</string>
|
|
185 |
<string>Close</string>
|
|
159 | 186 |
</property> |
160 | 187 |
<property name="icon"> |
161 | 188 |
<iconset resource="../res/MainWindow.qrc"> |
162 |
<normaloff>:/newPrefix/OK.svg</normaloff>:/newPrefix/OK.svg</iconset>
|
|
189 |
<normaloff>:/newPrefix/Remove.svg</normaloff>:/newPrefix/Remove.svg</iconset>
|
|
163 | 190 |
</property> |
164 | 191 |
</widget> |
165 | 192 |
</item> |
... | ... | |
170 | 197 |
</property> |
171 | 198 |
</widget> |
172 | 199 |
</item> |
173 |
<item row="2" column="1" colspan="3">
|
|
174 |
<widget class="QTabWidget" name="tabWidgetEntities">
|
|
175 |
<property name="currentIndex">
|
|
176 |
<number>0</number>
|
|
200 |
<item row="5" column="0">
|
|
201 |
<widget class="QLabel" name="label_4">
|
|
202 |
<property name="text">
|
|
203 |
<string>Search Text(Line No.)</string>
|
|
177 | 204 |
</property> |
178 |
<widget class="QWidget" name="tabLineTypes"> |
|
179 |
<attribute name="title"> |
|
180 |
<string>Line Types</string> |
|
181 |
</attribute> |
|
182 |
<layout class="QGridLayout" name="gridLayout_2"> |
|
183 |
<item row="0" column="0"> |
|
184 |
<widget class="QTreeView" name="treeViewLineType"/> |
|
185 |
</item> |
|
186 |
</layout> |
|
187 |
</widget> |
|
188 |
<widget class="QWidget" name="tabSymbols"> |
|
189 |
<attribute name="title"> |
|
190 |
<string>Symbols</string> |
|
191 |
</attribute> |
|
192 |
<layout class="QGridLayout" name="gridLayout_3"> |
|
193 |
<item row="0" column="0"> |
|
194 |
<widget class="QTreeView" name="treeViewSymbolMapping"/> |
|
195 |
</item> |
|
196 |
</layout> |
|
197 |
</widget> |
|
198 | 205 |
</widget> |
199 | 206 |
</item> |
207 |
<item row="5" column="3"> |
|
208 |
<widget class="QPushButton" name="pushButtonAuto"> |
|
209 |
<property name="text"> |
|
210 |
<string>Auto Cal.</string> |
|
211 |
</property> |
|
212 |
</widget> |
|
213 |
</item> |
|
214 |
<item row="5" column="1" colspan="2"> |
|
215 |
<widget class="QLineEdit" name="lineEdit"/> |
|
216 |
</item> |
|
200 | 217 |
</layout> |
201 | 218 |
</item> |
202 | 219 |
<item> |
내보내기 Unified diff