개정판 88c56bef
issue #000: add symbol move
Change-Id: I6dbfffa0720b963e8c184aece15fcf7dde4766f9
DTI_PID/DTI_PID/RotateSymbolDialog.py | ||
---|---|---|
15 | 15 |
import math |
16 | 16 |
|
17 | 17 |
class QRotateSymbolDialog(QDialog): |
18 |
def __init__(self, parent, angle): |
|
18 |
def __init__(self, parent, angle, loc):
|
|
19 | 19 |
QDialog.__init__(self, parent) |
20 | 20 |
|
21 | 21 |
self.ui = RotateSymbol_UI.Ui_RotateSymbolDialog() |
... | ... | |
24 | 24 |
self.angle = angle |
25 | 25 |
self.isAccepted = False |
26 | 26 |
self.ui.doubleSpinBox.setValue(round(180 * self.angle / math.pi)) |
27 |
self.ui.doubleSpinBoxX.setValue(loc[0]) |
|
28 |
self.ui.doubleSpinBoxY.setValue(loc[1]) |
|
27 | 29 |
|
28 | 30 |
def showDialog(self): |
29 | 31 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint & ~QtCore.Qt.WindowContextHelpButtonHint) |
30 | 32 |
self.exec_() |
31 |
return self.isAccepted, self.angle |
|
33 |
return self.isAccepted, self.angle, self.x, self.y
|
|
32 | 34 |
|
33 | 35 |
def accept(self): |
34 | 36 |
self.degree = self.ui.doubleSpinBox.value() |
35 |
allowed_error = 0.0001 |
|
37 |
self.x = self.ui.doubleSpinBoxX.value() |
|
38 |
self.y = self.ui.doubleSpinBoxY.value() |
|
39 |
|
|
40 |
allowed_error = 0.001 |
|
36 | 41 |
|
37 | 42 |
#degree 0 |
38 | 43 |
if abs(self.degree - 0) <= allowed_error: |
DTI_PID/DTI_PID/RotateSymbol_UI.py | ||
---|---|---|
11 | 11 |
class Ui_RotateSymbolDialog(object): |
12 | 12 |
def setupUi(self, RotateSymbolDialog): |
13 | 13 |
RotateSymbolDialog.setObjectName("RotateSymbolDialog") |
14 |
RotateSymbolDialog.resize(350, 79)
|
|
15 |
RotateSymbolDialog.setMinimumSize(QtCore.QSize(350, 79))
|
|
16 |
RotateSymbolDialog.setMaximumSize(QtCore.QSize(350, 79))
|
|
14 |
RotateSymbolDialog.resize(350, 141)
|
|
15 |
RotateSymbolDialog.setMinimumSize(QtCore.QSize(350, 0))
|
|
16 |
RotateSymbolDialog.setMaximumSize(QtCore.QSize(350, 350))
|
|
17 | 17 |
font = QtGui.QFont() |
18 | 18 |
font.setFamily("맑은 고딕") |
19 | 19 |
font.setBold(True) |
... | ... | |
27 | 27 |
font = QtGui.QFont() |
28 | 28 |
font.setFamily("맑은 고딕") |
29 | 29 |
font.setPointSize(10) |
30 |
font.setBold(False)
|
|
31 |
font.setWeight(50)
|
|
30 |
font.setBold(True)
|
|
31 |
font.setWeight(75)
|
|
32 | 32 |
self.label.setFont(font) |
33 | 33 |
self.label.setObjectName("label") |
34 | 34 |
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label) |
35 | 35 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
36 | 36 |
self.horizontalLayout.setObjectName("horizontalLayout") |
37 | 37 |
self.doubleSpinBox = QtWidgets.QDoubleSpinBox(RotateSymbolDialog) |
38 |
self.doubleSpinBox.setDecimals(3)
|
|
38 |
self.doubleSpinBox.setDecimals(1)
|
|
39 | 39 |
self.doubleSpinBox.setMinimum(0.0) |
40 | 40 |
self.doubleSpinBox.setMaximum(359.0) |
41 | 41 |
self.doubleSpinBox.setObjectName("doubleSpinBox") |
42 | 42 |
self.horizontalLayout.addWidget(self.doubleSpinBox) |
43 | 43 |
self.formLayout.setLayout(0, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout) |
44 |
self.Origin_X = QtWidgets.QLabel(RotateSymbolDialog) |
|
45 |
self.Origin_X.setObjectName("Origin_X") |
|
46 |
self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.Origin_X) |
|
47 |
self.label_2 = QtWidgets.QLabel(RotateSymbolDialog) |
|
48 |
self.label_2.setObjectName("label_2") |
|
49 |
self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_2) |
|
50 |
self.doubleSpinBoxX = QtWidgets.QDoubleSpinBox(RotateSymbolDialog) |
|
51 |
self.doubleSpinBoxX.setDecimals(1) |
|
52 |
self.doubleSpinBoxX.setMaximum(99999999.0) |
|
53 |
self.doubleSpinBoxX.setObjectName("doubleSpinBoxX") |
|
54 |
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.doubleSpinBoxX) |
|
55 |
self.doubleSpinBoxY = QtWidgets.QDoubleSpinBox(RotateSymbolDialog) |
|
56 |
self.doubleSpinBoxY.setDecimals(1) |
|
57 |
self.doubleSpinBoxY.setMaximum(99999999.0) |
|
58 |
self.doubleSpinBoxY.setObjectName("doubleSpinBoxY") |
|
59 |
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.doubleSpinBoxY) |
|
44 | 60 |
self.verticalLayout.addLayout(self.formLayout) |
45 | 61 |
self.errorLabel = QtWidgets.QLabel(RotateSymbolDialog) |
46 | 62 |
self.errorLabel.setMaximumSize(QtCore.QSize(16777215, 0)) |
... | ... | |
66 | 82 |
|
67 | 83 |
def retranslateUi(self, RotateSymbolDialog): |
68 | 84 |
_translate = QtCore.QCoreApplication.translate |
69 |
RotateSymbolDialog.setWindowTitle(_translate("RotateSymbolDialog", "Symbol Rotation"))
|
|
85 |
RotateSymbolDialog.setWindowTitle(_translate("RotateSymbolDialog", "Symbol Position"))
|
|
70 | 86 |
self.label.setText(_translate("RotateSymbolDialog", "Degree : ")) |
87 |
self.Origin_X.setText(_translate("RotateSymbolDialog", "Position_X")) |
|
88 |
self.label_2.setText(_translate("RotateSymbolDialog", "Position_Y")) |
|
71 | 89 |
|
72 | 90 |
|
73 | 91 |
if __name__ == "__main__": |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
813 | 813 |
''' |
814 | 814 |
def mouseDoubleClickEvent(self, event): |
815 | 815 |
from RotateSymbolDialog import QRotateSymbolDialog |
816 |
dialog = QRotateSymbolDialog(None, self.angle) |
|
817 |
(isAccept, angle) = dialog.showDialog() |
|
816 |
dialog = QRotateSymbolDialog(None, self.angle, self.loc)
|
|
817 |
(isAccept, angle, x, y) = dialog.showDialog()
|
|
818 | 818 |
|
819 | 819 |
if isAccept: |
820 |
self.rotateSymbol(angle) |
|
820 |
self.angle = angle |
|
821 |
self.loc = [x, y] |
|
822 |
self.origin = [x + self.symbolOrigin[0], y + self.symbolOrigin[1]] |
|
823 |
scene = self.scene() |
|
824 |
scene.removeItem(self) |
|
825 |
self.addSvgItemToScene(scene) |
|
826 |
|
|
827 |
self.reSettingConnetors() |
|
821 | 828 |
|
822 | 829 |
''' |
823 | 830 |
@brief get attribute |
... | ... | |
1480 | 1487 |
transform.translate(-self.size[0], 0) |
1481 | 1488 |
|
1482 | 1489 |
self.setTransform(transform) |
1490 |
self.reSettingConnetors() |
|
1491 |
|
|
1492 |
def reSettingConnetors(self): |
|
1493 |
for conn in self.connectors: |
|
1494 |
conn.sceneConnectPoint = (conn.sceneBoundingRect().center().x(), conn.sceneBoundingRect().center().y()) |
|
1483 | 1495 |
|
1484 | 1496 |
from EngineeringLineItem import QEngineeringLineItem |
1485 | 1497 |
for connector in self.connectors: |
1486 | 1498 |
if connector.connectedItem is not None and type(connector.connectedItem) == QEngineeringLineItem: |
1487 | 1499 |
line = connector.connectedItem |
1488 | 1500 |
line.reDrawLine(self, connector.center()) |
1489 |
|
|
1490 |
for conn in self.connectors: |
|
1491 |
conn.sceneConnectPoint = (conn.sceneBoundingRect().center().x(), conn.sceneBoundingRect().center().y()) |
|
1501 |
line.update_arrow() |
|
1492 | 1502 |
|
1493 | 1503 |
''' |
1494 | 1504 |
@brief change Conn point |
DTI_PID/DTI_PID/UI/RotateSymbol.ui | ||
---|---|---|
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 | 9 |
<width>350</width> |
10 |
<height>79</height>
|
|
10 |
<height>141</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="minimumSize"> |
14 | 14 |
<size> |
15 | 15 |
<width>350</width> |
16 |
<height>79</height>
|
|
16 |
<height>0</height>
|
|
17 | 17 |
</size> |
18 | 18 |
</property> |
19 | 19 |
<property name="maximumSize"> |
20 | 20 |
<size> |
21 | 21 |
<width>350</width> |
22 |
<height>79</height>
|
|
22 |
<height>350</height>
|
|
23 | 23 |
</size> |
24 | 24 |
</property> |
25 | 25 |
<property name="font"> |
... | ... | |
30 | 30 |
</font> |
31 | 31 |
</property> |
32 | 32 |
<property name="windowTitle"> |
33 |
<string>Symbol Rotation</string>
|
|
33 |
<string>Symbol Position</string>
|
|
34 | 34 |
</property> |
35 | 35 |
<layout class="QVBoxLayout" name="verticalLayout"> |
36 | 36 |
<item> |
... | ... | |
41 | 41 |
<font> |
42 | 42 |
<family>맑은 고딕</family> |
43 | 43 |
<pointsize>10</pointsize> |
44 |
<weight>50</weight>
|
|
45 |
<bold>false</bold>
|
|
44 |
<weight>75</weight>
|
|
45 |
<bold>true</bold>
|
|
46 | 46 |
</font> |
47 | 47 |
</property> |
48 | 48 |
<property name="text"> |
... | ... | |
55 | 55 |
<item> |
56 | 56 |
<widget class="QDoubleSpinBox" name="doubleSpinBox"> |
57 | 57 |
<property name="decimals"> |
58 |
<number>3</number>
|
|
58 |
<number>1</number>
|
|
59 | 59 |
</property> |
60 | 60 |
<property name="minimum"> |
61 | 61 |
<double>0.000000000000000</double> |
... | ... | |
67 | 67 |
</item> |
68 | 68 |
</layout> |
69 | 69 |
</item> |
70 |
<item row="1" column="0"> |
|
71 |
<widget class="QLabel" name="Origin_X"> |
|
72 |
<property name="text"> |
|
73 |
<string>Position_X</string> |
|
74 |
</property> |
|
75 |
</widget> |
|
76 |
</item> |
|
77 |
<item row="2" column="0"> |
|
78 |
<widget class="QLabel" name="label_2"> |
|
79 |
<property name="text"> |
|
80 |
<string>Position_Y</string> |
|
81 |
</property> |
|
82 |
</widget> |
|
83 |
</item> |
|
84 |
<item row="1" column="1"> |
|
85 |
<widget class="QDoubleSpinBox" name="doubleSpinBoxX"> |
|
86 |
<property name="decimals"> |
|
87 |
<number>1</number> |
|
88 |
</property> |
|
89 |
<property name="maximum"> |
|
90 |
<double>99999999.000000000000000</double> |
|
91 |
</property> |
|
92 |
</widget> |
|
93 |
</item> |
|
94 |
<item row="2" column="1"> |
|
95 |
<widget class="QDoubleSpinBox" name="doubleSpinBoxY"> |
|
96 |
<property name="decimals"> |
|
97 |
<number>1</number> |
|
98 |
</property> |
|
99 |
<property name="maximum"> |
|
100 |
<double>99999999.000000000000000</double> |
|
101 |
</property> |
|
102 |
</widget> |
|
103 |
</item> |
|
70 | 104 |
</layout> |
71 | 105 |
</item> |
72 | 106 |
<item> |
내보내기 Unified diff