개정판 42318ecb
issue #503: add just vendor item class
Change-Id: I3f80bc70007525b993637a7a8fe889c3490ab516
DTI_PID/DTI_PID/Commands/PlacePolygonCommand.py | ||
---|---|---|
64 | 64 |
finally: |
65 | 65 |
pass |
66 | 66 |
elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.RightButton and self._polyline is not None: |
67 |
self._polyline._vertices.append(self._polyline._vertices[0]) |
|
68 |
self._polyline.update() |
|
69 | 67 |
self.onSuccess.emit() |
70 | 68 |
elif 'mouseReleaseEvent' == param[0] and event.button() == Qt.RightButton and self._polyline is None: |
71 | 69 |
self.onRejected.emit(self) |
... | ... | |
75 | 73 |
if event.key() == Qt.Key_Escape: |
76 | 74 |
self.onRejected.emit(self) |
77 | 75 |
self.isTreated = False |
78 |
elif event.key() == Qt.Key_A: # axis lock mode |
|
79 |
self._polyline.drawing_mode = QEngineeringPolylineItem.AXIS_MODE |
|
80 |
elif event.key() == Qt.Key_F: # free drawing mode |
|
81 |
self._polyline.drawing_mode = QEngineeringPolylineItem.FREE_MODE |
|
82 | 76 |
|
83 | 77 |
def undo(self): |
84 | 78 |
pass |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
47 | 47 |
from EngineeringInstrumentItem import QEngineeringInstrumentItem |
48 | 48 |
from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
49 | 49 |
from EngineeringErrorItem import QEngineeringErrorItem |
50 |
from EngineeringVendorItem import QEngineeringVendorItem |
|
50 | 51 |
from AppDocData import * |
51 | 52 |
import SymbolTreeWidget, SymbolPropertyTableWidget |
52 | 53 |
import SymbolEditorDialog |
... | ... | |
785 | 786 |
@date 2019.04.29 |
786 | 787 |
''' |
787 | 788 |
try: |
788 |
pass |
|
789 |
count = len(self.actionVendor.tag._polyline._vertices) |
|
790 |
if count > 2: |
|
791 |
points = [] |
|
792 |
for point in self.actionVendor.tag._polyline._vertices: |
|
793 |
points.append(QPoint(round(point[0]), round(point[1]))) |
|
794 |
vendorArea = QPolygonF(points) |
|
795 |
vendorItem = QEngineeringVendorItem(vendorArea) |
|
796 |
self.graphicsView.scene.addItem(vendorItem) |
|
789 | 797 |
finally: |
790 | 798 |
self.graphicsView.scene.removeItem(self.actionVendor.tag._polyline) |
791 | 799 |
self.actionVendor.tag.reset() |
DTI_PID/DTI_PID/Shapes/EngineeringVendorItem.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
import sys |
|
3 |
import cv2 |
|
4 |
import os |
|
5 |
|
|
6 |
try: |
|
7 |
from PyQt5.QtCore import * |
|
8 |
from PyQt5.QtGui import * |
|
9 |
from PyQt5.QtWidgets import * |
|
10 |
except ImportError: |
|
11 |
try: |
|
12 |
from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect |
|
13 |
from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QGraphicsLineItem |
|
14 |
except ImportError: |
|
15 |
raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.") |
|
16 |
|
|
17 |
from EngineeringAbstractItem import QEngineeringAbstractItem |
|
18 |
|
|
19 |
class QEngineeringVendorItem(QGraphicsPolygonItem, QEngineeringAbstractItem): |
|
20 |
""" |
|
21 |
This is vendor package item |
|
22 |
""" |
|
23 |
def __init__(self, polygon, parent=None): |
|
24 |
import uuid |
|
25 |
|
|
26 |
QGraphicsPolygonItem.__init__(self, polygon, parent) |
|
27 |
QEngineeringAbstractItem.__init__(self) |
|
28 |
|
|
29 |
self.uid = uuid.uuid4() |
|
30 |
self.conns = [] |
|
31 |
|
|
32 |
self.setColor(self._color) |
|
33 |
self._savedColor = None |
|
34 |
|
|
35 |
def setColor(self, color): |
|
36 |
c = QColor() |
|
37 |
c.setNamedColor(color) |
|
38 |
_pen = self.pen() |
|
39 |
_pen.setColor(c) |
|
40 |
self.setPen(_pen) |
|
41 |
self.update() |
내보내기 Unified diff