개정판 98db97f5
revised issue #567: user can freeze line no in graphics view
Change-Id: Ide7e0ee869f13cd2ea01da662afefe30bb0db1a8
DTI_PID/DTI_PID/ItemPropertyTableWidget.py | ||
---|---|---|
333 | 333 |
self.setItem(row, 1, value_item) |
334 | 334 |
else: |
335 | 335 |
if prop.AttributeType == 'Boolean': |
336 |
self.freeze_state_cell = QCheckBox() |
|
337 |
self.freeze_state_cell.setChecked(True if value and str(value) == 'True' else False) |
|
338 |
self.freeze_state_cell.stateChanged.connect(self.freeze_state_changed) |
|
339 |
self.setCellWidget(row, 1, self.freeze_state_cell) |
|
336 |
self.checkbox_cell = QCheckBox() |
|
337 |
self.checkbox_cell.setChecked(True if value and str(value) == 'True' else False) |
|
338 |
self.checkbox_cell.stateChanged.connect(self.bool_state_changed) |
|
339 |
if prop.Attribute == 'Freeze': self.checkbox_cell.stateChanged.connect(item.freeze_item.update_freeze) |
|
340 |
self.setCellWidget(row, 1, self.checkbox_cell) |
|
340 | 341 |
else: |
341 | 342 |
value_item = QTableWidgetItem(value if value else '') |
342 | 343 |
if prop.AttributeType == "String": |
... | ... | |
701 | 702 |
text = self.item(rows[-1], columns[-1]).text() |
702 | 703 |
QApplication.clipboard().setText(text) |
703 | 704 |
|
704 |
def freeze_state_changed(self, state):
|
|
705 |
def bool_state_changed(self, state):
|
|
705 | 706 |
""" update freeze value of line """ |
706 | 707 |
for row in range(self.rowCount()): |
707 | 708 |
widget = self.cellWidget(row, 1) |
708 |
if widget is None and widget != self.freeze_state_cell: continue
|
|
709 |
if widget is None and widget != self.checkbox_cell: continue
|
|
709 | 710 |
cell = self.item(row, 0) |
710 | 711 |
if cell: |
711 | 712 |
data = cell.data(Qt.UserRole) |
712 | 713 |
if data is not None: |
713 |
if self._item: self._item.set_property(data.Attribute, self.freeze_state_cell.isChecked())
|
|
714 |
if self._item: self._item.set_property(data.Attribute, self.checkbox_cell.isChecked())
|
|
714 | 715 |
|
715 | 716 |
''' |
716 | 717 |
@brief int cell check |
... | ... | |
719 | 720 |
''' |
720 | 721 |
def cellChangedEvent(self, row, column): |
721 | 722 |
try: |
722 |
cell = self.item(row, 0) |
|
723 |
if cell is not None: |
|
724 |
data = cell.data(Qt.UserRole) |
|
723 |
if column == 1: |
|
724 |
data = self.item(row, 0).data(Qt.UserRole) |
|
725 | 725 |
if data is not None and not data.is_selectable: |
726 |
if self._item: self._item.set_property(data.Attribute, self.item(row, column).text()) |
|
726 |
if self._item: |
|
727 |
if data.AttributeType != 'Boolean': |
|
728 |
self._item.set_property(data.Attribute, self.item(row, column).text()) |
|
729 |
else: |
|
730 |
self._item.set_property(data.Attribute, self.cellWidget(row, column).isChecked()) |
|
727 | 731 |
except Exception as ex: |
728 | 732 |
from App import App |
729 | 733 |
from AppDocData import MessageType |
... | ... | |
731 | 735 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
732 | 736 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
733 | 737 |
|
734 |
""" |
|
735 |
key = self.item(row, 0).tag |
|
736 |
cell = self.item(row, column) |
|
737 |
|
|
738 |
items = self.mainWindow.graphicsView.scene.selectedItems() |
|
739 |
if items is not None and len(items) == 1: |
|
740 |
if type(items[0]) is QEngineeringLineNoTextItem: |
|
741 |
items[0].setAttribute(key, cell.text()) |
|
742 |
elif issubclass(type(items[0]), SymbolSvgItem) and type(items[0]) is not QEngineeringSpecBreakItem: |
|
743 |
items[0].setAttribute(key, cell.text()) |
|
744 |
else: |
|
745 |
return |
|
746 |
""" |
|
747 |
|
|
748 | 738 |
''' |
749 | 739 |
@brief resultPropertyTableWidget Cell Double Click Event |
750 | 740 |
@author kyouho |
DTI_PID/DTI_PID/ItemTreeWidget.py | ||
---|---|---|
148 | 148 |
menu.addAction(pickColorAction) |
149 | 149 |
explode_action = QAction(self.tr("Explode")) |
150 | 150 |
freeze = data.prop('Freeze') |
151 |
print(freeze) |
|
151 | 152 |
explode_action.setEnabled(not freeze) |
152 | 153 |
explode_action.triggered.connect(lambda : self.explode_line_no(item)) |
153 | 154 |
menu.addAction(explode_action) |
DTI_PID/DTI_PID/Shapes/EngineeringFreezeItem.py | ||
---|---|---|
32 | 32 |
line_no = self.parentItem() |
33 | 33 |
freeze = not line_no.prop('Freeze') |
34 | 34 |
line_no.set_property('Freeze', freeze) |
35 |
self.update_freeze(freeze) |
|
35 | 36 |
|
37 |
def update_freeze(self, freeze): |
|
38 |
""" update graphics with given freeze value """ |
|
36 | 39 |
self.setBrush(Qt.gray) if freeze else self.setBrush(Qt.white) |
37 | 40 |
self.update() |
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
41 | 41 |
self._runs = [] |
42 | 42 |
|
43 | 43 |
""" create freeze control """ |
44 |
self.freeze_item = QEngineeringFreezeItem(0, 0, QEngineeringFreezeItem.FREEZE_SIZE, QEngineeringFreezeItem.FREEZE_SIZE)
|
|
44 |
self.freeze_item = QEngineeringFreezeItem(-QEngineeringFreezeItem.FREEZE_SIZE*0.5, -QEngineeringFreezeItem.FREEZE_SIZE*0.5, QEngineeringFreezeItem.FREEZE_SIZE, QEngineeringFreezeItem.FREEZE_SIZE)
|
|
45 | 45 |
self.freeze_item.setParentItem(self) |
46 | 46 |
self.freeze_item.setZValue(self.zValue() + 1) |
47 | 47 |
self.freeze_item.setPen(Qt.black) |
... | ... | |
52 | 52 |
import uuid |
53 | 53 |
|
54 | 54 |
for prop,value in self._properties.items(): |
55 |
if prop.is_selectable and type(value) is uuid.UUID: |
|
55 |
if prop.is_selectable and type(value) is uuid.UUID and self.scene():
|
|
56 | 56 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(value)] |
57 | 57 |
if matches: self._properties[prop] = matches[0] |
58 | 58 |
|
... | ... | |
271 | 271 |
item.loc = (x, y) |
272 | 272 |
item.size = (width, height) |
273 | 273 |
item.angle = angle |
274 |
|
|
275 |
""" apply freeze value """ |
|
276 |
item.freeze_item.update_freeze(item.prop('Freeze')) |
|
274 | 277 |
except Exception as ex: |
275 | 278 |
from App import App |
276 | 279 |
from AppDocData import MessageType |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
123 | 123 |
import uuid |
124 | 124 |
|
125 | 125 |
for prop,value in self._properties.items(): |
126 |
if prop.is_selectable and type(value) is uuid.UUID: |
|
126 |
if prop.is_selectable and type(value) is uuid.UUID and self.scene():
|
|
127 | 127 |
matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(value)] |
128 | 128 |
if matches: self._properties[prop] = matches[0] |
129 | 129 |
|
내보내기 Unified diff