개정판 9a8ac251
cad symbol auto mapping on going
Change-Id: Ibb8a82a23254342e9d9c12fc008839de8ae8c7af
DTI_PID/DTI_PID/ImportTextFromCADDialog.py | ||
---|---|---|
298 | 298 |
self.ui.pushButtonAuto.clicked.connect(self.autoCalOffset) |
299 | 299 |
self.ui.checkBoxAuto.stateChanged.connect(self.autoStateChanged) |
300 | 300 |
self.ui.checkBoxLegend.stateChanged.connect(self.legendStateChanged) |
301 |
self.ui.checkBoxAuto.stateChanged.connect(self.autoStateChanged) |
|
302 |
self.ui.pushButtonAutoMapping.clicked.connect(self.autoMapping) |
|
301 | 303 |
|
302 | 304 |
configs = app_doc_data.getConfigs('Cad State', 'Auto') |
303 | 305 |
self.ui.checkBoxAuto.setChecked(bool(int((configs[0].value)))) if 1 == len(configs) else \ |
... | ... | |
345 | 347 |
self.ui.lineEdit.setEnabled(True) |
346 | 348 |
self.ui.lineEdit_2.setEnabled(True) |
347 | 349 |
|
350 |
def autoMapping(self): |
|
351 |
if not self._dwgs: |
|
352 |
QMessageBox.information(self, self.tr('Information'), self.tr('There is no selected file(s)')) |
|
353 |
return |
|
354 |
|
|
355 |
model = self.ui.treeViewSymbolMapping.model() |
|
356 |
for row in range(model.rowCount()): |
|
357 |
category_index = model.index(row, 0) |
|
358 |
|
|
359 |
child_count = model.rowCount(category_index) |
|
360 |
for child_row in range(child_count): |
|
361 |
child_index = model.index(child_row, 0, category_index) |
|
362 |
id2_symbol_item = model.itemFromIndex(child_index) |
|
363 |
id2_symbol_uid = id2_symbol_item.data(Qt.UserRole) |
|
364 |
cad_symbol_list = [(symbol if '+' not in symbol else symbol.split('+')[0], symbol) for symbol in self._symbol_types] |
|
365 |
matches = [cad_symbol for cad_symbol in cad_symbol_list if cad_symbol[0] == id2_symbol_item.text()] |
|
366 |
if matches: |
|
367 |
symbol = matches[0][1] |
|
368 |
if symbol not in model._autocad_symbols: |
|
369 |
model._autocad_symbols.append(symbol) |
|
370 |
|
|
371 |
childs = [QStandardItem(''), QStandardItem(symbol), QStandardItem('')] |
|
372 |
childs[0].setData(id2_symbol_uid, Qt.UserRole) |
|
373 |
for child in childs: |
|
374 |
child.setEditable(False) |
|
375 |
id2_symbol_item.appendRow(childs) |
|
376 |
|
|
348 | 377 |
def autoCalOffset(self): |
349 | 378 |
""" auto calculate offset """ |
350 | 379 |
from App import App |
... | ... | |
559 | 588 |
"""remove selected items""" |
560 | 589 |
indices = self.ui.treeViewSymbolMapping.selectionModel().selectedRows() |
561 | 590 |
for index in sorted(indices): |
591 |
_index = self.ui.treeViewSymbolMapping.model().index(index.row(), 1, index.parent()) |
|
592 |
id2_symbol_item = self.ui.treeViewSymbolMapping.model().itemFromIndex(_index) |
|
593 |
self.ui.treeViewSymbolMapping.model()._autocad_symbols.remove(id2_symbol_item.text()) |
|
594 |
|
|
562 | 595 |
self.ui.treeViewSymbolMapping.model().removeRow(index.row(), index.parent()) |
563 | 596 |
|
564 | 597 |
def on_add_symbol_type_item(index: QModelIndex): |
... | ... | |
576 | 609 |
item.setEditable(False) |
577 | 610 |
id2_symbol_item.appendRow(items) |
578 | 611 |
|
612 |
self.ui.treeViewSymbolMapping.model()._autocad_symbols.append(id2_symbol_item.text()) |
|
613 |
|
|
579 | 614 |
## add remove button |
580 | 615 |
child_count = self.ui.treeViewSymbolMapping.model().rowCount(id2_symbol_item.index()) |
581 | 616 |
button = QPushButton(icon=QIcon(":/newPrefix/Remove.svg")) |
... | ... | |
622 | 657 |
self.ui.treeViewSymbolMapping.resizeColumnToContents(2) |
623 | 658 |
self.ui.treeViewSymbolMapping.expandAll() |
624 | 659 |
|
625 |
self._symbol_types = model.autocad_symbols[:] |
|
660 |
self._symbol_types = self._symbol_types + model.autocad_symbols[:]
|
|
626 | 661 |
self.ui.treeViewSymbolMapping.setItemDelegate(SymbolMappingDelegate(self._symbol_types, |
627 | 662 |
self.ui.treeViewSymbolMapping)) |
628 | 663 |
|
DTI_PID/DTI_PID/ImportTextFromCAD_UI.py | ||
---|---|---|
175 | 175 |
self.checkBoxAuto = QtWidgets.QCheckBox(ImportTextFromCADDialog) |
176 | 176 |
self.checkBoxAuto.setObjectName("checkBoxAuto") |
177 | 177 |
self.gridLayout.addWidget(self.checkBoxAuto, 9, 3, 1, 1) |
178 |
self.pushButtonAutoMapping = QtWidgets.QPushButton(ImportTextFromCADDialog) |
|
179 |
self.pushButtonAutoMapping.setObjectName("pushButtonAutoMapping") |
|
180 |
self.gridLayout.addWidget(self.pushButtonAutoMapping, 8, 3, 1, 1) |
|
178 | 181 |
self.verticalLayout.addLayout(self.gridLayout) |
179 | 182 |
self.errorLabel = QtWidgets.QLabel(ImportTextFromCADDialog) |
180 | 183 |
self.errorLabel.setMaximumSize(QtCore.QSize(16777215, 0)) |
... | ... | |
236 | 239 |
self.tabWidgetEntities.setTabText(self.tabWidgetEntities.indexOf(self.tabLineTypes), _translate("ImportTextFromCADDialog", "Line Types")) |
237 | 240 |
self.tabWidgetEntities.setTabText(self.tabWidgetEntities.indexOf(self.tabSymbols), _translate("ImportTextFromCADDialog", "Symbols")) |
238 | 241 |
self.checkBoxAuto.setText(_translate("ImportTextFromCADDialog", "Auto Offset, Scale")) |
242 |
self.pushButtonAutoMapping.setText(_translate("ImportTextFromCADDialog", "Auto Mapping")) |
|
239 | 243 |
|
240 | 244 |
import MainWindow_rc |
241 | 245 |
|
DTI_PID/DTI_PID/UI/ImportTextFromCAD.ui | ||
---|---|---|
336 | 336 |
</property> |
337 | 337 |
</widget> |
338 | 338 |
</item> |
339 |
<item row="8" column="3"> |
|
340 |
<widget class="QPushButton" name="pushButtonAutoMapping"> |
|
341 |
<property name="text"> |
|
342 |
<string>Auto Mapping</string> |
|
343 |
</property> |
|
344 |
</widget> |
|
345 |
</item> |
|
339 | 346 |
</layout> |
340 | 347 |
</item> |
341 | 348 |
<item> |
내보내기 Unified diff