-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGUITransformDialog.py
149 lines (134 loc) · 6.18 KB
/
GUITransformDialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env python
# Author: Nick R. Rypkema (rypkema@mit.edu)
# License: MIT
'''
The LightField Visualizer - a VTK/PyQt4-based lightweight field robotics viewer
-------------------------------------------------------------------------------
additional gui elements - the apply transformation dialog
'''
''' standard libs '''
import math
import warnings
import numpy as np
''' VTK and PyQt4 '''
from PyQt4 import QtCore, QtGui, uic
''' custom libs '''
import TransformUtils
class TransformDialog(QtGui.QDialog):
''' a dialog box for adding primitive actors '''
def __init__(self):
QtGui.QDialog.__init__(self)
self.setWindowTitle('Apply Transform')
self.uiSetup()
self.return_dict = {}
def uiSetup(self):
self.setFixedWidth(350)
self.setFixedHeight(350)
self.layout = QtGui.QVBoxLayout()
buttonLayout = QtGui.QHBoxLayout()
self.translateWidget()
self.rotateWidget()
self.orderWidget()
self.stackWidget()
self.layout.addLayout(buttonLayout)
cancelButton = QtGui.QPushButton("Cancel")
cancelButton.setFixedWidth(100)
addButton = QtGui.QPushButton("Apply")
addButton.setFixedWidth(100)
buttonLayout.setAlignment(QtCore.Qt.AlignBottom)
buttonLayout.addStretch()
buttonLayout.addWidget(cancelButton)
buttonLayout.addStretch()
buttonLayout.addWidget(addButton)
buttonLayout.addStretch()
# add triggers
cancelButton.clicked.connect(self.cancel)
addButton.clicked.connect(self.apply)
addButton.setDefault(True)
self.setLayout(self.layout)
def apply(self):
if self.order_widget.order0RadioButton.isChecked():
self.return_dict['order'] = 0
else:
self.return_dict['order'] = 1
self.return_dict['xtranslate'] = self.translate_widget.xSpinBox.value()
self.return_dict['ytranslate'] = self.translate_widget.ySpinBox.value()
self.return_dict['ztranslate'] = self.translate_widget.zSpinBox.value()
self.return_dict['rollrotate'] = self.rotate_widget.rollSpinBox.value()
self.return_dict['pitchrotate'] = self.rotate_widget.pitchSpinBox.value()
self.return_dict['yawrotate'] = self.rotate_widget.yawSpinBox.value()
if self.stack_widget.stackRadioButton.isChecked():
self.return_dict['stack'] = 1
else:
self.return_dict['stack'] = 0
self.close()
def cancel(self):
self.close()
def translateWidget(self):
self.translate_widget = QtGui.QGroupBox('Translation')
layout = QtGui.QGridLayout()
layout.addWidget(QtGui.QLabel('x:'),1,1)
layout.addWidget(QtGui.QLabel('y:'),1,2)
layout.addWidget(QtGui.QLabel('z:'),1,3)
self.translate_widget.xSpinBox = QtGui.QDoubleSpinBox()
self.translate_widget.xSpinBox.setRange(-1e6, 1e6)
self.translate_widget.xSpinBox.setSingleStep(1.0)
self.translate_widget.xSpinBox.setValue(0)
self.translate_widget.ySpinBox = QtGui.QDoubleSpinBox()
self.translate_widget.ySpinBox.setRange(-1e6, 1e6)
self.translate_widget.ySpinBox.setSingleStep(1.0)
self.translate_widget.ySpinBox.setValue(0)
self.translate_widget.zSpinBox = QtGui.QDoubleSpinBox()
self.translate_widget.zSpinBox.setRange(-1e6, 1e6)
self.translate_widget.zSpinBox.setSingleStep(1.0)
self.translate_widget.zSpinBox.setValue(0)
layout.addWidget(self.translate_widget.xSpinBox,2,1)
layout.addWidget(self.translate_widget.ySpinBox,2,2)
layout.addWidget(self.translate_widget.zSpinBox,2,3)
self.translate_widget.setLayout(layout)
self.layout.addWidget(self.translate_widget)
def rotateWidget(self):
self.rotate_widget = QtGui.QGroupBox('Rotation')
layout = QtGui.QGridLayout()
layout.addWidget(QtGui.QLabel('roll:'),1,1)
layout.addWidget(QtGui.QLabel('pitch:'),1,2)
layout.addWidget(QtGui.QLabel('yaw:'),1,3)
self.rotate_widget.rollSpinBox = QtGui.QDoubleSpinBox()
self.rotate_widget.rollSpinBox.setRange(-180, 180)
self.rotate_widget.rollSpinBox.setSingleStep(1)
self.rotate_widget.rollSpinBox.setValue(0)
self.rotate_widget.pitchSpinBox = QtGui.QDoubleSpinBox()
self.rotate_widget.pitchSpinBox.setRange(-90, 90)
self.rotate_widget.pitchSpinBox.setSingleStep(1)
self.rotate_widget.pitchSpinBox.setValue(0)
self.rotate_widget.yawSpinBox = QtGui.QDoubleSpinBox()
self.rotate_widget.yawSpinBox.setRange(-180, 180)
self.rotate_widget.yawSpinBox.setSingleStep(1)
self.rotate_widget.yawSpinBox.setValue(0)
layout.addWidget(self.rotate_widget.rollSpinBox,2,1)
layout.addWidget(self.rotate_widget.pitchSpinBox,2,2)
layout.addWidget(self.rotate_widget.yawSpinBox,2,3)
self.rotate_widget.setLayout(layout)
self.layout.addWidget(self.rotate_widget)
def orderWidget(self):
self.order_widget = QtGui.QGroupBox('Order')
layout = QtGui.QHBoxLayout()
self.order_widget.order0RadioButton = QtGui.QRadioButton("Rotate->Translate")
self.order_widget.order0RadioButton.setChecked(False)
self.order_widget.order1RadioButton = QtGui.QRadioButton("Translate->Rotate")
self.order_widget.order1RadioButton.setChecked(True)
layout.addWidget(self.order_widget.order0RadioButton)
layout.addWidget(self.order_widget.order1RadioButton)
self.order_widget.setLayout(layout)
self.layout.addWidget(self.order_widget)
def stackWidget(self):
self.stack_widget = QtGui.QGroupBox('Stack/Set Transform')
layout = QtGui.QHBoxLayout()
self.stack_widget.stackRadioButton = QtGui.QRadioButton("Stack Transform")
self.stack_widget.stackRadioButton.setChecked(True)
self.stack_widget.setRadioButton = QtGui.QRadioButton("Set Transform")
self.stack_widget.setRadioButton.setChecked(False)
layout.addWidget(self.stack_widget.stackRadioButton)
layout.addWidget(self.stack_widget.setRadioButton)
self.stack_widget.setLayout(layout)
self.layout.addWidget(self.stack_widget)