개정판 f9068b2a
issue #641: fix scene
Change-Id: I96bbb4df843dad5bed89cdc70b7cd36e65b484cf
DTI_PID/DTI_PID/Commands/AreaEraserCommand.py | ||
---|---|---|
35 | 35 |
try: |
36 | 36 |
if self.imageViewer.canZoom and event.button() == Qt.LeftButton: |
37 | 37 |
viewBBox = self.imageViewer.zoomStack[-1] if len(self.imageViewer.zoomStack) else self.imageViewer.sceneRect() |
38 |
selectionBBox = self.imageViewer.scene.selectionArea().boundingRect().intersected(viewBBox) |
|
39 |
self.imageViewer.scene.setSelectionArea(QPainterPath()) # Clear current selection area. |
|
38 |
selectionBBox = self.imageViewer.scene().selectionArea().boundingRect().intersected(viewBBox)
|
|
39 |
self.imageViewer.scene().setSelectionArea(QPainterPath()) # Clear current selection area.
|
|
40 | 40 |
if selectionBBox.isValid() and (selectionBBox != viewBBox): |
41 | 41 |
pixmap = self.imageViewer.pixmap() |
42 | 42 |
painter = QPainter() |
DTI_PID/DTI_PID/Commands/CreateCommand.py | ||
---|---|---|
15 | 15 |
@brief create a shape by using template |
16 | 16 |
''' |
17 | 17 |
def execute(self, param): |
18 |
if self.template in self.imageViewer.scene.items(): |
|
18 |
if self.template in self.imageViewer.scene().items():
|
|
19 | 19 |
pass |
20 | 20 |
else: |
21 |
self.imageViewer.scene.addItem(self.template) |
|
21 |
self.imageViewer.scene().addItem(self.template)
|
|
22 | 22 |
|
23 | 23 |
self.template.process(param) |
24 | 24 |
|
25 | 25 |
if self.template.isCreated == True: |
26 | 26 |
instance = self.template.clone() |
27 |
self.imageViewer.scene.removeItem(self.template) |
|
27 |
self.imageViewer.scene().removeItem(self.template)
|
|
28 | 28 |
self.template.init() |
29 |
self.imageViewer.scene.update() |
|
29 |
self.imageViewer.scene().update()
|
|
30 | 30 |
|
31 | 31 |
self.templateCreated.emit(instance) |
32 | 32 |
|
33 | 33 |
return instance |
34 | 34 |
else: |
35 |
self.imageViewer.scene.update() |
|
35 |
self.imageViewer.scene().update()
|
|
36 | 36 |
|
37 | 37 |
self.isTreated = False |
38 | 38 |
|
DTI_PID/DTI_PID/Commands/CreateSymbolCommand.py | ||
---|---|---|
54 | 54 |
QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
55 | 55 |
viewBBox = self.imageViewer.zoomStack[-1] if len( |
56 | 56 |
self.imageViewer.zoomStack) else self.imageViewer.sceneRect() |
57 |
selectionBBox = self.imageViewer.scene.selectionArea().boundingRect().intersected(viewBBox) |
|
57 |
selectionBBox = self.imageViewer.scene().selectionArea().boundingRect().intersected(viewBBox)
|
|
58 | 58 |
if selectionBBox.isValid(): |
59 | 59 |
croppedImage = self.imageViewer.image().copy(selectionBBox.toAlignedRect()) |
60 | 60 |
symbolEditorDialog = SymbolEditorDialog.QSymbolEditorDialog(self.imageViewer, croppedImage, |
... | ... | |
82 | 82 |
svg.transfer.onRemoved.connect(self.resultTreeWidget.itemRemoved) |
83 | 83 |
svg.addSvgItemToScene(self.imageViewer.scene) |
84 | 84 |
for connector in svg.connectors: |
85 |
self.imageViewer.scene.addItem(connector) |
|
85 |
self.imageViewer.scene().addItem(connector)
|
|
86 | 86 |
|
87 | 87 |
finally: |
88 | 88 |
self.imageViewer.setDragMode(QGraphicsView.NoDrag) |
DTI_PID/DTI_PID/Commands/CropCommand.py | ||
---|---|---|
35 | 35 |
try: |
36 | 36 |
QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
37 | 37 |
viewBBox = self.imageViewer.zoomStack[-1] if len(self.imageViewer.zoomStack) else self.imageViewer.sceneRect() |
38 |
selectionBBox = self.imageViewer.scene.selectionArea().boundingRect().intersected(viewBBox) |
|
38 |
selectionBBox = self.imageViewer.scene().selectionArea().boundingRect().intersected(viewBBox)
|
|
39 | 39 |
if selectionBBox.isValid(): |
40 | 40 |
croppedImage = self.imageViewer.image().copy(selectionBBox.toAlignedRect()) |
41 | 41 |
self.offsetX = selectionBBox.x() |
DTI_PID/DTI_PID/Commands/DefaultCommand.py | ||
---|---|---|
95 | 95 |
else: |
96 | 96 |
self.imageViewer.setRubberBandSelectionMode(Qt.IntersectsItemShape) |
97 | 97 |
elif 'keyPressEvent' == param[0] and (event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_C): |
98 |
selectedItems = self.imageViewer.scene.selectedItems() |
|
98 |
selectedItems = self.imageViewer.scene().selectedItems()
|
|
99 | 99 |
if len(selectedItems) == 1 and issubclass(type(selectedItems[0]), SymbolSvgItem): |
100 | 100 |
from xml.etree.ElementTree import tostring |
101 | 101 |
xmlStr = str(tostring(selectedItems[0].toXml())) |
... | ... | |
160 | 160 |
transform.translate(-currentPt[0], -currentPt[1]) |
161 | 161 |
self.symbol.setTransform(transform) |
162 | 162 |
elif 'keyPressEvent' == param[0] and event.key() == Qt.Key_Escape: |
163 |
self.imageViewer.scene.removeItem(self.symbol) |
|
163 |
self.imageViewer.scene().removeItem(self.symbol)
|
|
164 | 164 |
self.symbol = None |
165 | 165 |
self.isCopy = False |
166 | 166 |
self.isSpecBreak = False |
... | ... | |
169 | 169 |
if 'mouseReleaseEvent' == param[0] and event.button() == Qt.LeftButton: |
170 | 170 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
171 | 171 |
|
172 |
item = self.imageViewer.scene.itemAt(scenePos, QTransform()) |
|
172 |
item = self.imageViewer.scene().itemAt(scenePos, QTransform())
|
|
173 | 173 |
if item is not None and type(item) is QEngineeringConnectorItem: |
174 | 174 |
scenePos = QPointF(item.center()[0], item.center()[1]) |
175 | 175 |
|
... | ... | |
178 | 178 |
transform.translate(scenePos.x() - currentPt[0], scenePos.y() - currentPt[1]) |
179 | 179 |
self.symbol.setTransform(transform) |
180 | 180 |
|
181 |
self.imageViewer.scene.removeItem(self.symbol) |
|
181 |
self.imageViewer.scene().removeItem(self.symbol)
|
|
182 | 182 |
self.imageViewer.matchSymbolToLine(self.symbol, scenePos) |
183 | 183 |
self.symbol = None |
184 | 184 |
self.isCopy = False |
... | ... | |
187 | 187 |
elif 'mouseMoveEvent' == param[0]: |
188 | 188 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
189 | 189 |
|
190 |
item = self.imageViewer.scene.itemAt(scenePos, QTransform()) |
|
190 |
item = self.imageViewer.scene().itemAt(scenePos, QTransform())
|
|
191 | 191 |
if item is not None and type(item) is QEngineeringConnectorItem: |
192 | 192 |
scenePos = QPointF(item.center()[0], item.center()[1]) |
193 | 193 |
|
... | ... | |
196 | 196 |
transform.translate(scenePos.x() - currentPt[0], scenePos.y() - currentPt[1]) |
197 | 197 |
self.symbol.setTransform(transform) |
198 | 198 |
elif 'keyPressEvent' == param[0] and event.key() == Qt.Key_Escape: |
199 |
self.imageViewer.scene.removeItem(self.symbol) |
|
199 |
self.imageViewer.scene().removeItem(self.symbol)
|
|
200 | 200 |
self.symbol = None |
201 | 201 |
self.isCopy = False |
202 | 202 |
except Exception as ex: |
... | ... | |
232 | 232 |
connector.connectedItem = None |
233 | 233 |
# uid 새로 할당 |
234 | 234 |
self.symbol.uid = uuid.uuid4() |
235 |
self.imageViewer.scene.addItem(self.symbol) |
|
236 |
self.imageViewer.scene.clearFocus() |
|
237 |
self.imageViewer.scene.setFocusItem(self.symbol) |
|
235 |
self.imageViewer.scene().addItem(self.symbol)
|
|
236 |
self.imageViewer.scene().clearFocus()
|
|
237 |
self.imageViewer.scene().setFocusItem(self.symbol)
|
|
238 | 238 |
self.symbol.setSelected(True) |
239 | 239 |
self.isCopy = True |
240 | 240 |
|
DTI_PID/DTI_PID/Commands/PlaceLineCommand.py | ||
---|---|---|
61 | 61 |
if 'mousePressEvent' == param[0] and event.button() == Qt.LeftButton: |
62 | 62 |
if self._polyline is None: |
63 | 63 |
selected = \ |
64 |
[conn for conn in self.imageViewer.scene.items(param[2]) if type(conn) is not QGraphicsTextItem][0] |
|
64 |
[conn for conn in self.imageViewer.scene().items(param[2]) if type(conn) is not QGraphicsTextItem][0]
|
|
65 | 65 |
if selected is not None and type(selected) is QEngineeringConnectorItem: |
66 | 66 |
self._polyline = QEngineeringPolylineItem() |
67 | 67 |
self._polyline._vertices.append(selected.center()) |
68 |
self.imageViewer.scene.addItem(self._polyline) |
|
69 |
self.imageViewer.scene.setFocusItem(self._polyline) |
|
68 |
self.imageViewer.scene().addItem(self._polyline)
|
|
69 |
self.imageViewer.scene().setFocusItem(self._polyline)
|
|
70 | 70 |
elif selected is not None and type(selected) is QEngineeringLineItem: |
71 | 71 |
length = selected.length() * 0.5 |
72 | 72 |
dir = selected.perpendicular() |
... | ... | |
76 | 76 |
if (pt is not None) and (type(pt) == shapely.geometry.point.Point): |
77 | 77 |
self._polyline = QEngineeringPolylineItem() |
78 | 78 |
self._polyline._vertices.append([pt.x, pt.y]) |
79 |
self.imageViewer.scene.addItem(self._polyline) |
|
80 |
self.imageViewer.scene.setFocusItem(self._polyline) |
|
79 |
self.imageViewer.scene().addItem(self._polyline)
|
|
80 |
self.imageViewer.scene().setFocusItem(self._polyline)
|
|
81 | 81 |
else: |
82 | 82 |
try: |
83 | 83 |
QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
84 | 84 |
|
85 | 85 |
selected = \ |
86 |
[conn for conn in self.imageViewer.scene.items(param[2]) if |
|
86 |
[conn for conn in self.imageViewer.scene().items(param[2]) if
|
|
87 | 87 |
type(conn) is not QGraphicsTextItem][0] |
88 | 88 |
if selected is not None and type(selected) is QEngineeringConnectorItem: |
89 | 89 |
self._polyline._vertices.append(selected.center()) |
DTI_PID/DTI_PID/Commands/PlacePolygonCommand.py | ||
---|---|---|
59 | 59 |
self._polyline = QEngineeringPolylineItem() |
60 | 60 |
self._polyline.drawing_mode = QEngineeringPolylineItem.FREE_MODE |
61 | 61 |
self._polyline._vertices.append((param[2].x(), param[2].y())) |
62 |
self.imageViewer.scene.addItem(self._polyline) |
|
63 |
self.imageViewer.scene.setFocusItem(self._polyline) |
|
62 |
self.imageViewer.scene().addItem(self._polyline)
|
|
63 |
self.imageViewer.scene().setFocusItem(self._polyline)
|
|
64 | 64 |
else: |
65 | 65 |
QGraphicsView.mouseReleaseEvent(self.imageViewer, event) |
66 | 66 |
|
DTI_PID/DTI_PID/Commands/ZoomCommand.py | ||
---|---|---|
58 | 58 |
zoomArea = QRectF(QPointF(scenePos1.x(), scenePos1.y()), QPointF(scenePos2.x(), scenePos2.y())) |
59 | 59 |
viewBBox = self.imageViewer.zoomStack[-1] if len(self.imageViewer.zoomStack) else self.imageViewer.sceneRect() |
60 | 60 |
selectionBBox = zoomArea.intersected(viewBBox) |
61 |
self.imageViewer.scene.setSelectionArea(QPainterPath()) # Clear current selection area. |
|
61 |
self.imageViewer.scene().setSelectionArea(QPainterPath()) # Clear current selection area.
|
|
62 | 62 |
if selectionBBox.isValid() and (selectionBBox != viewBBox): |
63 | 63 |
self.imageViewer.zoomStack.append(selectionBBox) |
64 | 64 |
self.imageViewer.updateViewer() |
65 | 65 |
else: |
66 | 66 |
#print("zoom out") |
67 |
self.imageViewer.scene.setSelectionArea(QPainterPath()) # Clear current selection area. |
|
67 |
self.imageViewer.scene().setSelectionArea(QPainterPath()) # Clear current selection area.
|
|
68 | 68 |
if len(self.imageViewer.zoomStack): |
69 | 69 |
self.imageViewer.zoomStack.pop() |
70 | 70 |
self.imageViewer.updateViewer() |
DTI_PID/DTI_PID/DevelopmentToolkitDialog.py | ||
---|---|---|
33 | 33 |
color = QColorDialog.getColor(self.ui.pushButtonContourColor.palette().button().color()) |
34 | 34 |
if color.isValid(): |
35 | 35 |
item = self.ui.pushButtonContourColor.setStyleSheet(f"background-color:{color.name()}") |
36 |
self.graphics_view.scene.contour_color = color |
|
36 |
self.graphics_view.scene().contour_color = color
|
|
37 | 37 |
|
38 | 38 |
def on_show_contour(self): |
39 | 39 |
"""show contour""" |
40 | 40 |
try: |
41 |
self.graphics_view.scene.contours = [] |
|
41 |
self.graphics_view.scene().contours = []
|
|
42 | 42 |
|
43 | 43 |
bitwise_not = self.ui.checkBoxBitwiseNot.isChecked() |
44 | 44 |
min_area = self.ui.spinBoxContourMinArea.value() |
... | ... | |
64 | 64 |
epsilon = cv2.arcLength(contour, True) * 0.001 |
65 | 65 |
approx = cv2.approxPolyDP(contour, epsilon, True) |
66 | 66 |
approx = [pt[0] for pt in approx] |
67 |
self.graphics_view.scene.contours.append(approx) |
|
67 |
self.graphics_view.scene().contours.append(approx)
|
|
68 | 68 |
|
69 | 69 |
del image |
70 |
self.graphics_view.scene.invalidate() |
|
70 |
self.graphics_view.scene().invalidate()
|
|
71 | 71 |
except Exception as ex: |
72 | 72 |
from App import App |
73 | 73 |
|
... | ... | |
78 | 78 |
def on_detect_circle(self): |
79 | 79 |
"""detect circle""" |
80 | 80 |
try: |
81 |
self.graphics_view.scene.circles = None |
|
81 |
self.graphics_view.scene().circles = None
|
|
82 | 82 |
|
83 | 83 |
image = self.graphics_view.convertQImageToMat(self.graphics_view.image()) |
84 | 84 |
image = cv2.threshold(cv2.cvtColor(image, cv2.COLOR_BGR2GRAY), |
... | ... | |
86 | 86 |
|
87 | 87 |
dp = self.ui.spinBoxdp.value() |
88 | 88 |
min_dist = self.ui.spinBoxMinDist.value() |
89 |
self.graphics_view.scene.circles = cv2.HoughCircles(image, cv2.HOUGH_GRADIENT, dp, min_dist) |
|
90 |
self.graphics_view.scene.invalidate() |
|
89 |
self.graphics_view.scene().circles = cv2.HoughCircles(image, cv2.HOUGH_GRADIENT, dp, min_dist)
|
|
90 |
self.graphics_view.scene().invalidate()
|
|
91 | 91 |
except Exception as ex: |
92 | 92 |
from App import App |
93 | 93 |
|
... | ... | |
96 | 96 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
97 | 97 |
|
98 | 98 |
def accept(self): |
99 |
self.graphics_view.scene.contours = [] |
|
100 |
self.graphics_view.scene.invalidate() |
|
99 |
self.graphics_view.scene().contours = []
|
|
100 |
self.graphics_view.scene().invalidate()
|
|
101 | 101 |
QDialog.accept(self) |
102 | 102 |
|
103 | 103 |
def reject(self) -> None: |
104 |
self.graphics_view.scene.contours = [] |
|
105 |
self.graphics_view.scene.invalidate() |
|
104 |
self.graphics_view.scene().contours = []
|
|
105 |
self.graphics_view.scene().invalidate()
|
|
106 | 106 |
QDialog.reject(self) |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
3035 | 3035 |
# up to here |
3036 | 3036 |
|
3037 | 3037 |
""" update scene """ |
3038 |
self.graphicsView.scene.update(self.graphicsView.sceneRect()) |
|
3039 |
for item in self.graphicsView.scene.items(): |
|
3038 |
self.graphicsView.scene().update(self.graphicsView.sceneRect())
|
|
3039 |
for item in self.graphicsView.scene().items():
|
|
3040 | 3040 |
up_progress = False |
3041 | 3041 |
# binding items |
3042 | 3042 |
if hasattr(item, 'owner'): |
... | ... | |
3050 | 3050 |
if up_progress: |
3051 | 3051 |
self.progress.setValue(self.progress.value() + 1) |
3052 | 3052 |
|
3053 |
for item in self.graphicsView.scene.items(): |
|
3053 |
for item in self.graphicsView.scene().items():
|
|
3054 | 3054 |
item.setVisible(True) |
3055 | 3055 |
|
3056 | 3056 |
except Exception as ex: |
... | ... | |
3061 | 3061 |
app_doc_data.clearTempDBData() |
3062 | 3062 |
self.itemTreeWidget.update_item_count() |
3063 | 3063 |
self.itemTreeWidget.expandAll() |
3064 |
# self.graphicsView.scene.blockSignals(False) |
|
3064 |
# self.graphicsView.scene().blockSignals(False)
|
|
3065 | 3065 |
|
3066 | 3066 |
''' |
3067 | 3067 |
@brief load recognition result |
... | ... | |
3160 | 3160 |
item.isSymbol = True |
3161 | 3161 |
item.angle = angle |
3162 | 3162 |
item.setPen(QPen(Qt.red, 5, Qt.SolidLine)) |
3163 |
self.graphicsView.scene.addItem(item) |
|
3163 |
self.graphicsView.scene().addItem(item)
|
|
3164 | 3164 |
item.transfer.onRemoved.connect(self.itemRemoved) |
3165 | 3165 |
except Exception as ex: |
3166 | 3166 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
... | ... | |
3470 | 3470 |
return |
3471 | 3471 |
|
3472 | 3472 |
# symbol 경우 |
3473 |
items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringSpecBreakItem and type(item) is not QEngineeringEndBreakItem] |
|
3473 |
items = [item for item in self.graphicsView.scene().items() if issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringSpecBreakItem and type(item) is not QEngineeringEndBreakItem]
|
|
3474 | 3474 |
for item in items: |
3475 | 3475 |
attrs = item.attrs |
3476 | 3476 |
|
... | ... | |
3507 | 3507 |
del attrs[attr] |
3508 | 3508 |
|
3509 | 3509 |
# Line No Text Item의 경우 |
3510 |
items = [item for item in self.graphicsView.scene.items() if issubclass(type(item), QEngineeringLineNoTextItem)] |
|
3510 |
items = [item for item in self.graphicsView.scene().items() if issubclass(type(item), QEngineeringLineNoTextItem)]
|
|
3511 | 3511 |
for item in items: |
3512 | 3512 |
attrs = item.attrs |
3513 | 3513 |
|
... | ... | |
3554 | 3554 |
x = connectorItem.center()[0] |
3555 | 3555 |
y = connectorItem.center()[1] |
3556 | 3556 |
|
3557 |
connectors = [item for item in self.graphicsView.scene.items() if |
|
3557 |
connectors = [item for item in self.graphicsView.scene().items() if
|
|
3558 | 3558 |
type(item) is QEngineeringConnectorItem and item != connectorItem] |
3559 | 3559 |
for connector in connectors: |
3560 | 3560 |
if Point(x, y).distance(Point(connector.center()[0], connector.center()[1])) < 5: |
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
695 | 695 |
svg.origin = [x, y] |
696 | 696 |
svg.addSvgItemToScene(self.scene()) |
697 | 697 |
|
698 |
items = [item for item in self.scene.items(scenePos) if |
|
698 |
items = [item for item in self.scene().items(scenePos) if
|
|
699 | 699 |
type(item) is not QGraphicsPixmapItem and type(item) is not QGraphicsTextItem] |
700 | 700 |
items = [item for item in items if item.parentItem() is svg] |
701 | 701 |
if items and connectors[0].connectedItem and type(connectors[0].connectedItem) is QEngineeringLineItem: |
... | ... | |
757 | 757 |
|
758 | 758 |
self.setFocus() |
759 | 759 |
svg.setSelected(True) |
760 |
self.scene()()()()()()()()().setFocusItem(svg)
|
|
760 |
self.scene().setFocusItem(svg) |
|
761 | 761 |
|
762 | 762 |
''' |
763 | 763 |
@brief find item by uid (SymbolSvgItem 기반, QEngineeringConnectorItem 제외, QEngineeringLineItem 포함) |
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
242 | 242 |
# remove already existing symbol and text |
243 | 243 |
if not batch: |
244 | 244 |
listWidget.addItem('Deleting existing items...') |
245 |
items = [item for item in worker.graphicsView.scene.items() if |
|
245 |
items = [item for item in worker.graphicsView.scene().items() if
|
|
246 | 246 |
type(item) is QEngineeringUnknownItem or type(item) is QEngineeringEndBreakItem or |
247 | 247 |
type(item) is QEngineeringErrorItem or type(item) is QGraphicsBoundingBoxItem] |
248 | 248 |
|
249 | 249 |
if worker.isSymbolChecked: |
250 | 250 |
items.extend( |
251 |
[item for item in worker.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem)]) |
|
251 |
[item for item in worker.graphicsView.scene().items() if issubclass(type(item), SymbolSvgItem)])
|
|
252 | 252 |
if worker.isTextChecked: |
253 |
items.extend([item for item in worker.graphicsView.scene.items() if |
|
253 |
items.extend([item for item in worker.graphicsView.scene().items() if
|
|
254 | 254 |
issubclass(type(item), QEngineeringTextItem)]) |
255 | 255 |
for item in items: |
256 | 256 |
item.transfer.onRemoved.emit(item) |
... | ... | |
376 | 376 |
''' |
377 | 377 |
import math |
378 | 378 |
|
379 |
symbolItems = [item for item in worker.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem)] |
|
379 |
symbolItems = [item for item in worker.graphicsView.scene().items() if issubclass(type(item), SymbolSvgItem)]
|
|
380 | 380 |
|
381 | 381 |
for symbolItem in symbolItems: |
382 | 382 |
symbolName = symbolItem.name |
... | ... | |
423 | 423 |
[], |
424 | 424 |
baseSymbol, additionalSymbol, isExceptDetect, detectFlip)) |
425 | 425 |
|
426 |
worker.graphicsView.scene.removeItem(symbolItem) |
|
426 |
worker.graphicsView.scene().removeItem(symbolItem)
|
|
427 | 427 |
|
428 | 428 |
pool = futures.ThreadPoolExecutor(max_workers = THREAD_MAX_WORKER) |
429 | 429 |
''' |
430 |
# symbolItems = [item for item in worker.graphicsView.scene.items() if issubclass(type(item), SymbolSvgItem)] |
|
430 |
# symbolItems = [item for item in worker.graphicsView.scene().items() if issubclass(type(item), SymbolSvgItem)]
|
|
431 | 431 |
# appDocData.symbols.extend(symbolItems) |
432 | 432 |
# appDocData.allItems.extend(symbolItems) |
433 | 433 |
|
... | ... | |
505 | 505 |
import math |
506 | 506 |
from TextInfo import TextInfo |
507 | 507 |
|
508 |
textItems = [item for item in worker.graphicsView.scene.items() if |
|
508 |
textItems = [item for item in worker.graphicsView.scene().items() if
|
|
509 | 509 |
issubclass(type(item), QEngineeringTextItem)] |
510 | 510 |
app_doc_data.texts.extend(textItems) |
511 | 511 |
app_doc_data.allItems.extend(textItems) |
... | ... | |
523 | 523 |
round(math.degrees(textItem.angle)))) |
524 | 524 |
|
525 | 525 |
textItem.owner = None |
526 |
worker.graphicsView.scene.removeItem(textItem) |
|
526 |
worker.graphicsView.scene().removeItem(textItem)
|
|
527 | 527 |
|
528 | 528 |
worker.updateBatchProgress.emit(len(srcList), 2) |
529 | 529 |
|
... | ... | |
587 | 587 |
if isLineChecked: |
588 | 588 |
Worker.recognizeLine(mainRes, listWidget, worker.graphicsView, worker, batch) |
589 | 589 |
else: |
590 |
lineItems = [item for item in worker.graphicsView.scene.items() |
|
590 |
lineItems = [item for item in worker.graphicsView.scene().items()
|
|
591 | 591 |
if issubclass(type(item), QEngineeringLineItem)] |
592 | 592 |
app_doc_data.lines.extend(lineItems) |
593 | 593 |
app_doc_data.allItems.extend(lineItems) |
... | ... | |
596 | 596 |
lineItem.owner = None |
597 | 597 |
for conn in lineItem.connectors: |
598 | 598 |
conn.connectedItem = None |
599 |
worker.graphicsView.scene.removeItem(lineItem) |
|
599 |
worker.graphicsView.scene().removeItem(lineItem)
|
|
600 | 600 |
|
601 | 601 |
# connect symbol to symbol |
602 | 602 |
try: |
... | ... | |
727 | 727 |
project = app_doc_data.getCurrentProject() |
728 | 728 |
# remove already existing line and flow arrow item |
729 | 729 |
if not batch: |
730 |
items = [item for item in worker.graphicsView.scene.items() if (type(item) is QEngineeringLineItem)] |
|
730 |
items = [item for item in worker.graphicsView.scene().items() if (type(item) is QEngineeringLineItem)]
|
|
731 | 731 |
for item in items: |
732 | 732 |
item.transfer.onRemoved.emit(item) |
733 | 733 |
# up to here |
DTI_PID/DTI_PID/TrainingEditorDialog.py | ||
---|---|---|
127 | 127 |
|
128 | 128 |
def pushButtonSplitClicked(self): |
129 | 129 |
self.isChanged = True |
130 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
130 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
131 | 131 |
if len(items) is not 1: |
132 | 132 |
return |
133 | 133 |
rect = items[0].rect() |
... | ... | |
146 | 146 |
|
147 | 147 |
def pushButtonAddClicked(self): |
148 | 148 |
self.isChanged = True |
149 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
150 |
allItems = self.graphicsViewTrainingDrawing.scene.items() |
|
149 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
150 |
allItems = self.graphicsViewTrainingDrawing.scene().items()
|
|
151 | 151 |
totalWidth = 0 |
152 | 152 |
totalHeight = 0 |
153 | 153 |
count = 0 |
... | ... | |
183 | 183 |
|
184 | 184 |
def pushButtonDeleteClicked(self): |
185 | 185 |
self.isChanged = True |
186 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
186 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
187 | 187 |
for item in items: |
188 | 188 |
item.transfer.onRemoved.emit(item) |
189 | 189 |
|
... | ... | |
203 | 203 |
|
204 | 204 |
def pushButtonChangeClicked(self): |
205 | 205 |
self.isChanged = True |
206 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
206 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
207 | 207 |
if len(items) is not 1: |
208 | 208 |
return |
209 | 209 |
items[0].char = self.ui.lineEditChar.text() |
... | ... | |
231 | 231 |
''' |
232 | 232 |
|
233 | 233 |
def pushButtonSaveClicked(self): |
234 |
items = self.graphicsViewTrainingDrawing.scene.items() |
|
234 |
items = self.graphicsViewTrainingDrawing.scene().items()
|
|
235 | 235 |
outBox = "" |
236 | 236 |
for item in items: |
237 | 237 |
if type(item) is QGraphicsPixmapItem: |
... | ... | |
274 | 274 |
|
275 | 275 |
def spinBoxChangedEvent(self, event): |
276 | 276 |
self.isChanged = True |
277 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
277 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
278 | 278 |
if (len(items) is not 1) or self.spinBoxFlag: |
279 | 279 |
return |
280 | 280 |
spinBoxName = self.sender().objectName() |
... | ... | |
302 | 302 |
bound.setRect(rect) |
303 | 303 |
rectSide = QRectF(rect.x() - 3, rect.y() - 3, rect.width() + 6, rect.height() + 6) |
304 | 304 |
self.graphicsViewZoomDrawing.fitInView(rectSide) |
305 |
self.graphicsViewTrainingDrawing.scene.update() |
|
305 |
self.graphicsViewTrainingDrawing.scene().update()
|
|
306 | 306 |
|
307 | 307 |
def onAreaZoom(self, action): |
308 | 308 |
if self.ui.pushButtonZoom.isChecked(): |
... | ... | |
322 | 322 |
if type(item) is QTrainingBoxItem: |
323 | 323 |
self.removedItems.append(str(item.uid)) |
324 | 324 |
|
325 |
if item.scene is not None: item.scene.removeItem(item) |
|
325 |
if item.scene is not None: item.scene().removeItem(item)
|
|
326 | 326 |
except Exception as ex: |
327 | 327 |
print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
328 | 328 |
sys.exc_info()[-1].tb_lineno)) |
... | ... | |
335 | 335 |
|
336 | 336 |
def keyPressEvent(self, event): |
337 | 337 |
try: |
338 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
338 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
339 | 339 |
if len(items) is not 1 or type(items[0]) is not QTrainingBoxItem: |
340 | 340 |
return |
341 | 341 |
selectedItem = items[0] |
... | ... | |
344 | 344 |
|
345 | 345 |
if event.key() == Qt.Key_Left: |
346 | 346 |
dx = sys.maxsize |
347 |
for item in self.graphicsViewTrainingDrawing.scene.items(): |
|
347 |
for item in self.graphicsViewTrainingDrawing.scene().items():
|
|
348 | 348 |
if type(item) is QTrainingBoxItem: |
349 | 349 |
if x - item.rect().x() > 0 and x - item.rect().x() < dx: |
350 | 350 |
closestItem = item |
... | ... | |
355 | 355 |
closestItem.mousePressEvent('arrow key') |
356 | 356 |
elif event.key() == Qt.Key_Right: |
357 | 357 |
dx = -sys.maxsize |
358 |
for item in self.graphicsViewTrainingDrawing.scene.items(): |
|
358 |
for item in self.graphicsViewTrainingDrawing.scene().items():
|
|
359 | 359 |
if type(item) is QTrainingBoxItem: |
360 | 360 |
if x - item.rect().x() < 0 and x - item.rect().x() > dx: |
361 | 361 |
closestItem = item |
DTI_PID/DTI_PID/TrainingSymbolEditorDialog.py | ||
---|---|---|
149 | 149 |
|
150 | 150 |
def listCellClicked(self, row, col): |
151 | 151 |
self.isChanged = True |
152 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
152 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
153 | 153 |
label = self.ui.tableWidget.item(row, col).text() |
154 | 154 |
self.onCharChanged(label) |
155 | 155 |
|
... | ... | |
160 | 160 |
''' |
161 | 161 |
def pushButtonSplitClicked(self): |
162 | 162 |
self.isChanged = True |
163 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
163 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
164 | 164 |
if len(items) is not 1: |
165 | 165 |
return |
166 | 166 |
rect = items[0].rect() |
... | ... | |
176 | 176 |
''' |
177 | 177 |
def pushButtonAddClicked(self): |
178 | 178 |
self.isChanged = True |
179 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
180 |
allItems = self.graphicsViewTrainingDrawing.scene.items() |
|
179 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
180 |
allItems = self.graphicsViewTrainingDrawing.scene().items()
|
|
181 | 181 |
totalWidth = 0 |
182 | 182 |
totalHeight = 0 |
183 | 183 |
count = 0 |
... | ... | |
211 | 211 |
''' |
212 | 212 |
def pushButtonDeleteClicked(self): |
213 | 213 |
self.isChanged = True |
214 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
214 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
215 | 215 |
for item in items: |
216 | 216 |
item.transfer.onRemoved.emit(item) |
217 | 217 |
|
... | ... | |
230 | 230 |
''' |
231 | 231 |
def pushButtonChangeClicked(self): |
232 | 232 |
self.isChanged = True |
233 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
233 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
234 | 234 |
|
235 | 235 |
label = self.ui.lineEditChar.text() |
236 | 236 |
if label == '' or label == 'None': |
... | ... | |
282 | 282 |
sourceNode.append(databaseNode) |
283 | 283 |
xml.append(sourceNode) |
284 | 284 |
|
285 |
items = self.graphicsViewTrainingDrawing.scene.items() |
|
285 |
items = self.graphicsViewTrainingDrawing.scene().items()
|
|
286 | 286 |
for item in items: |
287 | 287 |
if type(item) is QGraphicsPixmapItem: |
288 | 288 |
back = item |
... | ... | |
371 | 371 |
''' |
372 | 372 |
def spinBoxChangedEvent(self, event): |
373 | 373 |
self.isChanged = True |
374 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
374 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
375 | 375 |
if (len(items) is not 1) or self.spinBoxFlag: |
376 | 376 |
return |
377 | 377 |
spinBoxName = self.sender().objectName() |
... | ... | |
399 | 399 |
bound.setRect(rect) |
400 | 400 |
rectSide = QRectF(rect.x() - 3, rect.y() - 3, rect.width() + 6, rect.height() + 6) |
401 | 401 |
self.graphicsViewZoomDrawing.fitInView(rectSide) |
402 |
self.graphicsViewTrainingDrawing.scene.update() |
|
402 |
self.graphicsViewTrainingDrawing.scene().update()
|
|
403 | 403 |
|
404 | 404 |
def onAreaZoom(self, action): |
405 | 405 |
if self.ui.pushButtonZoom.isChecked(): |
... | ... | |
419 | 419 |
if type(item) is QTrainingBoxItem: |
420 | 420 |
self.removedItems.append(str(item.uid)) |
421 | 421 |
|
422 |
if item.scene is not None: item.scene.removeItem(item) |
|
422 |
if item.scene is not None: item.scene().removeItem(item)
|
|
423 | 423 |
except Exception as ex: |
424 | 424 |
print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
425 | 425 |
|
... | ... | |
430 | 430 |
''' |
431 | 431 |
def keyPressEvent(self, event): |
432 | 432 |
try: |
433 |
items = self.graphicsViewTrainingDrawing.scene.selectedItems() |
|
433 |
items = self.graphicsViewTrainingDrawing.scene().selectedItems()
|
|
434 | 434 |
if items and type(items[0]) is not QTrainingBoxItem: |
435 | 435 |
return |
436 | 436 |
|
... | ... | |
440 | 440 |
|
441 | 441 |
if event.key() == Qt.Key_Left: |
442 | 442 |
dx = sys.maxsize |
443 |
for item in self.graphicsViewTrainingDrawing.scene.items(): |
|
443 |
for item in self.graphicsViewTrainingDrawing.scene().items():
|
|
444 | 444 |
if type(item) is QTrainingBoxItem: |
445 | 445 |
if x - item.rect().x() > 0 and x - item.rect().x() < dx: |
446 | 446 |
closestItem = item |
... | ... | |
451 | 451 |
closestItem.mousePressEvent('arrow key') |
452 | 452 |
elif event.key() == Qt.Key_Right: |
453 | 453 |
dx = -sys.maxsize |
454 |
for item in self.graphicsViewTrainingDrawing.scene.items(): |
|
454 |
for item in self.graphicsViewTrainingDrawing.scene().items():
|
|
455 | 455 |
if type(item) is QTrainingBoxItem: |
456 | 456 |
if x - item.rect().x() < 0 and x - item.rect().x() > dx: |
457 | 457 |
closestItem = item |
내보내기 Unified diff