개정판 42075d18
symbol mapping on going
Change-Id: I856c7df6e6da3e8243310d5b5e8628e0fb10ce8d
DTI_PID/DTI_PID/ImportTextFromCADDialog.py | ||
---|---|---|
353 | 353 |
return |
354 | 354 |
|
355 | 355 |
model = self.ui.treeViewSymbolMapping.model() |
356 |
row_index = [] |
|
356 | 357 |
for row in range(model.rowCount()): |
357 | 358 |
category_index = model.index(row, 0) |
358 | 359 |
|
... | ... | |
364 | 365 |
cad_symbol_list = [(symbol if '+' not in symbol else symbol.split('+')[0], symbol) for symbol in self._symbol_types] |
365 | 366 |
matches = [cad_symbol for cad_symbol in cad_symbol_list if cad_symbol[0] == id2_symbol_item.text()] |
366 | 367 |
if matches: |
367 |
symbol = matches[0][1] |
|
368 |
if symbol not in model._autocad_symbols: |
|
369 |
model._autocad_symbols.append(symbol) |
|
368 |
row_index.insert(0, [row, child_row, matches[0][1], id2_symbol_uid, id2_symbol_item]) |
|
369 |
|
|
370 |
for categoty, child, symbol, uid, item in row_index: |
|
371 |
category_index = model.index(categoty, 0) |
|
372 |
child_index = model.index(child, 0, category_index) |
|
373 |
if symbol not in model._autocad_symbols: |
|
374 |
model._autocad_symbols.append(symbol) |
|
375 |
childs = [QStandardItem(''), QStandardItem(symbol), QStandardItem('')] |
|
376 |
childs[0].setData(uid, Qt.UserRole) |
|
377 |
for _child in childs: |
|
378 |
_child.setEditable(False) |
|
379 |
item.appendRow(childs) |
|
370 | 380 |
|
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)
|
|
381 |
button = QPushButton(icon=QIcon(":/newPrefix/Remove.svg"))
|
|
382 |
button.setMaximumWidth(20)
|
|
383 |
_index = model.index(model.rowCount(category_index) - 1, 2, child_index)
|
|
384 |
button.clicked.connect(self.on_remove_symbol_mapping_item)
|
|
385 |
self.ui.treeViewSymbolMapping.setIndexWidget(_index, button)
|
|
376 | 386 |
|
377 | 387 |
def autoCalOffset(self): |
378 | 388 |
""" auto calculate offset """ |
... | ... | |
579 | 589 |
self.ui.spinBoxSymbolY.setHidden(True) |
580 | 590 |
self.ui.label_3.setText('Offset(x, y, text scale) : ') |
581 | 591 |
|
582 |
def on_load_symbol_mapping(self): |
|
583 |
""" |
|
584 |
load symbol mapping setting |
|
585 |
""" |
|
592 |
def on_remove_symbol_mapping_item(self): |
|
593 |
"""remove selected items""" |
|
594 |
indices = self.ui.treeViewSymbolMapping.selectionModel().selectedRows() |
|
595 |
for index in sorted(indices): |
|
596 |
_index = self.ui.treeViewSymbolMapping.model().index(index.row(), 1, index.parent()) |
|
597 |
id2_symbol_item = self.ui.treeViewSymbolMapping.model().itemFromIndex(_index) |
|
598 |
self.ui.treeViewSymbolMapping.model()._autocad_symbols.remove(id2_symbol_item.text()) |
|
586 | 599 |
|
587 |
def on_remove_symbol_mapping_item(): |
|
588 |
"""remove selected items""" |
|
589 |
indices = self.ui.treeViewSymbolMapping.selectionModel().selectedRows() |
|
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()) |
|
600 |
self.ui.treeViewSymbolMapping.model().removeRow(index.row(), index.parent()) |
|
594 | 601 |
|
595 |
self.ui.treeViewSymbolMapping.model().removeRow(index.row(), index.parent()) |
|
602 |
def on_add_symbol_type_item(self, index: QModelIndex): |
|
603 |
"""map AutoCAD symbol and ID2 symbol""" |
|
596 | 604 |
|
597 |
def on_add_symbol_type_item(index: QModelIndex): |
|
598 |
"""map AutoCAD symbol and ID2 symbol""" |
|
605 |
try: |
|
606 |
_index = self.ui.treeViewSymbolMapping.model().index(index.row(), 1, index.parent()) |
|
607 |
autocad_symbol_item = self.ui.treeViewSymbolMapping.model().itemFromIndex(_index) |
|
608 |
if autocad_symbol_item and autocad_symbol_item.text(): |
|
609 |
_index = self.ui.treeViewSymbolMapping.model().index(index.row(), 0, index.parent()) |
|
610 |
id2_symbol_item = self.ui.treeViewSymbolMapping.model().itemFromIndex(_index) |
|
611 |
items = [QStandardItem(''), QStandardItem(autocad_symbol_item.text()), QStandardItem('')] |
|
612 |
items[0].setData(id2_symbol_item.data(Qt.UserRole), Qt.UserRole) |
|
613 |
for item in items: |
|
614 |
item.setEditable(False) |
|
615 |
id2_symbol_item.appendRow(items) |
|
599 | 616 |
|
600 |
try: |
|
601 |
_index = self.ui.treeViewSymbolMapping.model().index(index.row(), 1, index.parent()) |
|
602 |
autocad_symbol_item = self.ui.treeViewSymbolMapping.model().itemFromIndex(_index) |
|
603 |
if autocad_symbol_item and autocad_symbol_item.text(): |
|
604 |
_index = self.ui.treeViewSymbolMapping.model().index(index.row(), 0, index.parent()) |
|
605 |
id2_symbol_item = self.ui.treeViewSymbolMapping.model().itemFromIndex(_index) |
|
606 |
items = [QStandardItem(''), QStandardItem(autocad_symbol_item.text()), QStandardItem('')] |
|
607 |
items[0].setData(id2_symbol_item.data(Qt.UserRole), Qt.UserRole) |
|
608 |
for item in items: |
|
609 |
item.setEditable(False) |
|
610 |
id2_symbol_item.appendRow(items) |
|
617 |
self.ui.treeViewSymbolMapping.model()._autocad_symbols.append(id2_symbol_item.text()) |
|
611 | 618 |
|
612 |
self.ui.treeViewSymbolMapping.model()._autocad_symbols.append(id2_symbol_item.text()) |
|
619 |
## add remove button |
|
620 |
child_count = self.ui.treeViewSymbolMapping.model().rowCount(id2_symbol_item.index()) |
|
621 |
button = QPushButton(icon=QIcon(":/newPrefix/Remove.svg")) |
|
622 |
button.setMaximumWidth(20) |
|
623 |
button.clicked.connect(on_remove_symbol_mapping_item) |
|
624 |
_index = self.ui.treeViewSymbolMapping.model().index(child_count - 1, 2, id2_symbol_item.index()) |
|
625 |
self.ui.treeViewSymbolMapping.setIndexWidget(_index, button) |
|
613 | 626 |
|
614 |
## add remove button |
|
615 |
child_count = self.ui.treeViewSymbolMapping.model().rowCount(id2_symbol_item.index()) |
|
616 |
button = QPushButton(icon=QIcon(":/newPrefix/Remove.svg")) |
|
617 |
button.setMaximumWidth(20) |
|
618 |
button.clicked.connect(on_remove_symbol_mapping_item) |
|
619 |
_index = self.ui.treeViewSymbolMapping.model().index(child_count - 1, 2, id2_symbol_item.index()) |
|
620 |
self.ui.treeViewSymbolMapping.setIndexWidget(_index, button) |
|
627 |
self.ui.treeViewSymbolMapping.expandAll() |
|
628 |
except Exception as ex: |
|
629 |
from App import App |
|
630 |
from AppDocData import MessageType |
|
621 | 631 |
|
622 |
self.ui.treeViewSymbolMapping.expandAll() |
|
623 |
except Exception as ex: |
|
624 |
from App import App |
|
625 |
from AppDocData import MessageType |
|
632 |
message = f'error occurred({ex}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:' \ |
|
633 |
f'{sys.exc_info()[-1].tb_lineno}' |
|
634 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
626 | 635 |
|
627 |
message = f'error occurred({ex}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:' \ |
|
628 |
f'{sys.exc_info()[-1].tb_lineno}' |
|
629 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
636 |
def on_load_symbol_mapping(self): |
|
637 |
""" |
|
638 |
load symbol mapping setting |
|
639 |
""" |
|
630 | 640 |
|
631 | 641 |
model = SymbolMappingModel() |
632 | 642 |
model.invisibleRootItem() |
... | ... | |
639 | 649 |
button = QPushButton(icon=QIcon(":/newPrefix/Add.svg")) |
640 | 650 |
button.setMaximumWidth(20) |
641 | 651 |
index = model.index(child_row, 2, parent_index) |
642 |
button.clicked.connect(partial(on_add_symbol_type_item, index)) |
|
652 |
button.clicked.connect(partial(self.on_add_symbol_type_item, index))
|
|
643 | 653 |
self.ui.treeViewSymbolMapping.setIndexWidget(index, button) |
644 | 654 |
|
645 | 655 |
"""add autocad symbol item""" |
... | ... | |
649 | 659 |
button = QPushButton(icon=QIcon(":/newPrefix/Remove.svg")) |
650 | 660 |
button.setMaximumWidth(20) |
651 | 661 |
_index = model.index(acad_symbol, 2, id2_symbol_index) |
652 |
button.clicked.connect(on_remove_symbol_mapping_item) |
|
662 |
button.clicked.connect(self.on_remove_symbol_mapping_item)
|
|
653 | 663 |
self.ui.treeViewSymbolMapping.setIndexWidget(_index, button) |
654 | 664 |
|
655 | 665 |
self.ui.treeViewSymbolMapping.resizeColumnToContents(0) |
내보내기 Unified diff