-
Notifications
You must be signed in to change notification settings - Fork 6
/
GUIPrimitiveDialog.py
411 lines (390 loc) · 21.4 KB
/
GUIPrimitiveDialog.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
#!/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 add primitive dialog
'''
''' standard libs '''
import math
import warnings
import numpy as np
''' VTK and PyQt4 '''
from PyQt4 import QtCore, QtGui, uic
''' custom libs '''
import Primitives
class PrimitiveDialog(QtGui.QDialog):
''' a dialog box for adding primitive actors '''
def __init__(self):
QtGui.QDialog.__init__(self)
self.setWindowTitle('Add Primitive')
self.tabWidget = QtGui.QTabWidget()
self.uiSetup()
self.addGridWidget()
self.addAxesWidget()
self.addArrowWidget()
self.addBoxWidget()
self.addSphereWidget()
self.addCylinderWidget()
self.addEllipsoidWidget()
self.addConeWidget()
self.addTorusWidget()
self.return_dict = {'type': None}
def uiSetup(self):
self.tabWidget.setTabPosition(2)
self.setFixedWidth(350)
self.setFixedHeight(600)
layout = QtGui.QVBoxLayout()
buttonLayout = QtGui.QHBoxLayout()
layout.addWidget(self.tabWidget)
layout.addLayout(buttonLayout)
cancelButton = QtGui.QPushButton("Cancel")
cancelButton.setFixedWidth(100)
addButton = QtGui.QPushButton("Add")
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.add)
addButton.setDefault(True)
self.setLayout(layout)
def add(self):
if self.tabWidget.currentWidget() == self.grid_widget:
self.return_dict['type'] = Primitives.PRIMITIVE_GRID
self.return_dict['name'] = str(self.grid_widget.nameLineEdit.text())
self.return_dict['width'] = self.grid_widget.widthSpinBox.value()
self.return_dict['cell'] = self.grid_widget.cellWidthSpinBox.value()
elif self.tabWidget.currentWidget() == self.axes_widget:
self.return_dict['type'] = Primitives.PRIMITIVE_AXES
self.return_dict['name'] = str(self.axes_widget.nameLineEdit.text())
elif self.tabWidget.currentWidget() == self.arrow_widget:
self.return_dict['type'] = Primitives.PRIMITIVE_ARROW
self.return_dict['name'] = str(self.arrow_widget.nameLineEdit.text())
self.return_dict['res'] = self.arrow_widget.resolutionSpinBox.value()
elif self.tabWidget.currentWidget() == self.box_widget:
self.return_dict['type'] = Primitives.PRIMITIVE_BOX
self.return_dict['name'] = str(self.box_widget.nameLineEdit.text())
self.return_dict['x'] = self.box_widget.xLengthSpinBox.value()
self.return_dict['y'] = self.box_widget.yLengthSpinBox.value()
self.return_dict['z'] = self.box_widget.zLengthSpinBox.value()
elif self.tabWidget.currentWidget() == self.sphere_widget:
self.return_dict['type'] = Primitives.PRIMITIVE_SPHERE
self.return_dict['name'] = str(self.sphere_widget.nameLineEdit.text())
self.return_dict['radius'] = self.sphere_widget.radiusSpinBox.value()
self.return_dict['tres'] = self.sphere_widget.tResolutionSpinBox.value()
self.return_dict['pres'] = self.sphere_widget.pResolutionSpinBox.value()
elif self.tabWidget.currentWidget() == self.cylinder_widget:
self.return_dict['type'] = Primitives.PRIMITIVE_CYLINDER
self.return_dict['name'] = str(self.cylinder_widget.nameLineEdit.text())
self.return_dict['radius'] = self.cylinder_widget.radiusSpinBox.value()
self.return_dict['height'] = self.cylinder_widget.heightSpinBox.value()
self.return_dict['res'] = self.cylinder_widget.resolutionSpinBox.value()
elif self.tabWidget.currentWidget() == self.ellipsoid_widget:
self.return_dict['type'] = Primitives.PRIMITIVE_ELLIPSOID
self.return_dict['name'] = str(self.ellipsoid_widget.nameLineEdit.text())
self.return_dict['xradius'] = self.ellipsoid_widget.xRadiusSpinBox.value()
self.return_dict['yradius'] = self.ellipsoid_widget.yRadiusSpinBox.value()
self.return_dict['zradius'] = self.ellipsoid_widget.zRadiusSpinBox.value()
elif self.tabWidget.currentWidget() == self.cone_widget:
self.return_dict['type'] = Primitives.PRIMITIVE_CONE
self.return_dict['name'] = str(self.cone_widget.nameLineEdit.text())
self.return_dict['radius'] = self.cone_widget.radiusSpinBox.value()
self.return_dict['height'] = self.cone_widget.heightSpinBox.value()
self.return_dict['res'] = self.cone_widget.resolutionSpinBox.value()
elif self.tabWidget.currentWidget() == self.torus_widget:
self.return_dict['type'] = Primitives.PRIMITIVE_TORUS
self.return_dict['name'] = str(self.torus_widget.nameLineEdit.text())
self.return_dict['ringradius'] = self.torus_widget.ringRadiusSpinBox.value()
self.return_dict['csradius'] = self.torus_widget.crossSectionRadiusSpinBox.value()
self.close()
def cancel(self):
self.close()
def addGridWidget(self):
self.grid_widget = QtGui.QTabWidget()
layout = QtGui.QFormLayout()
nameLabel = QtGui.QLabel('Name: ')
self.grid_widget.nameLineEdit = QtGui.QLineEdit()
self.grid_widget.nameLineEdit.setText('new grid')
widthLabel = QtGui.QLabel('Width: ')
self.grid_widget.widthSpinBox = QtGui.QDoubleSpinBox()
self.grid_widget.widthSpinBox.setRange(-1e6, 1e6)
self.grid_widget.widthSpinBox.setSingleStep(100)
self.grid_widget.widthSpinBox.setValue(1000)
cellWidthLabel = QtGui.QLabel('Cell Width: ')
self.grid_widget.cellWidthSpinBox = QtGui.QDoubleSpinBox()
self.grid_widget.cellWidthSpinBox.setRange(-1e6, 1e6)
self.grid_widget.cellWidthSpinBox.setSingleStep(1)
self.grid_widget.cellWidthSpinBox.setValue(10)
layout.setAlignment(QtCore.Qt.AlignTop)
layout.addRow(nameLabel, self.grid_widget.nameLineEdit)
layout.addRow(widthLabel, self.grid_widget.widthSpinBox)
layout.addRow(cellWidthLabel, self.grid_widget.cellWidthSpinBox)
self.grid_widget.setLayout(layout)
self.tabWidget.addTab(self.grid_widget, 'Grid')
def addAxesWidget(self):
self.axes_widget = QtGui.QTabWidget()
layout = QtGui.QFormLayout()
nameLabel = QtGui.QLabel('Name: ')
self.axes_widget.nameLineEdit = QtGui.QLineEdit()
self.axes_widget.nameLineEdit.setText('new axes')
layout.addRow(nameLabel, self.axes_widget.nameLineEdit)
self.axes_widget.setLayout(layout)
self.tabWidget.addTab(self.axes_widget, 'Axes')
def addArrowWidget(self):
self.arrow_widget = QtGui.QTabWidget()
layout = QtGui.QFormLayout()
nameLabel = QtGui.QLabel('Name: ')
self.arrow_widget.nameLineEdit = QtGui.QLineEdit()
self.arrow_widget.nameLineEdit.setText('new arrow')
resolutionLabel = QtGui.QLabel('Resolution: ')
self.arrow_widget.resolutionSpinBox = QtGui.QDoubleSpinBox()
self.arrow_widget.resolutionSpinBox.setRange(-1e6, 1e6)
self.arrow_widget.resolutionSpinBox.setSingleStep(0.1)
self.arrow_widget.resolutionSpinBox.setValue(10)
layout.addRow(nameLabel, self.arrow_widget.nameLineEdit)
layout.addRow(resolutionLabel, self.arrow_widget.resolutionSpinBox)
self.arrow_widget.setLayout(layout)
self.tabWidget.addTab(self.arrow_widget, 'Arrow')
def addBoxWidget(self):
self.box_widget = QtGui.QTabWidget()
layout = QtGui.QFormLayout()
nameLabel = QtGui.QLabel('Name: ')
self.box_widget.nameLineEdit = QtGui.QLineEdit()
self.box_widget.nameLineEdit.setText('new box')
xLengthLabel = QtGui.QLabel('X-length: ')
self.box_widget.xLengthSpinBox = QtGui.QDoubleSpinBox()
self.box_widget.xLengthSpinBox.setRange(-1e6, 1e6)
self.box_widget.xLengthSpinBox.setSingleStep(0.1)
self.box_widget.xLengthSpinBox.setValue(1)
yLengthLabel = QtGui.QLabel('Y-length: ')
self.box_widget.yLengthSpinBox = QtGui.QDoubleSpinBox()
self.box_widget.yLengthSpinBox.setRange(-1e6, 1e6)
self.box_widget.yLengthSpinBox.setSingleStep(0.1)
self.box_widget.yLengthSpinBox.setValue(1)
zLengthLabel = QtGui.QLabel('Z-length: ')
self.box_widget.zLengthSpinBox = QtGui.QDoubleSpinBox()
self.box_widget.zLengthSpinBox.setRange(-1e6, 1e6)
self.box_widget.zLengthSpinBox.setSingleStep(0.1)
self.box_widget.zLengthSpinBox.setValue(1)
layout.addRow(nameLabel, self.box_widget.nameLineEdit)
layout.addRow(xLengthLabel, self.box_widget.xLengthSpinBox)
layout.addRow(yLengthLabel, self.box_widget.yLengthSpinBox)
layout.addRow(zLengthLabel, self.box_widget.zLengthSpinBox)
self.box_widget.setLayout(layout)
self.tabWidget.addTab(self.box_widget, 'Box')
def addSphereWidget(self):
self.sphere_widget = QtGui.QTabWidget()
layout = QtGui.QFormLayout()
nameLabel = QtGui.QLabel('Name: ')
self.sphere_widget.nameLineEdit = QtGui.QLineEdit()
self.sphere_widget.nameLineEdit.setText('new sphere')
radiusLabel = QtGui.QLabel('Radius: ')
self.sphere_widget.radiusSpinBox = QtGui.QDoubleSpinBox()
self.sphere_widget.radiusSpinBox.setRange(-1e6, 1e6)
self.sphere_widget.radiusSpinBox.setSingleStep(0.1)
self.sphere_widget.radiusSpinBox.setValue(1)
tResolutionLabel = QtGui.QLabel('Theta Resolution: ')
self.sphere_widget.tResolutionSpinBox = QtGui.QDoubleSpinBox()
self.sphere_widget.tResolutionSpinBox.setRange(-1e6, 1e6)
self.sphere_widget.tResolutionSpinBox.setSingleStep(0.1)
self.sphere_widget.tResolutionSpinBox.setValue(10)
pResolutionLabel = QtGui.QLabel('Phi Resolution: ')
self.sphere_widget.pResolutionSpinBox = QtGui.QDoubleSpinBox()
self.sphere_widget.pResolutionSpinBox.setRange(-1e6, 1e6)
self.sphere_widget.pResolutionSpinBox.setSingleStep(0.1)
self.sphere_widget.pResolutionSpinBox.setValue(10)
layout.addRow(nameLabel, self.sphere_widget.nameLineEdit)
layout.addRow(radiusLabel, self.sphere_widget.radiusSpinBox)
layout.addRow(tResolutionLabel, self.sphere_widget.tResolutionSpinBox)
layout.addRow(pResolutionLabel, self.sphere_widget.pResolutionSpinBox)
self.sphere_widget.setLayout(layout)
self.tabWidget.addTab(self.sphere_widget, 'Sphere')
def addCylinderWidget(self):
self.cylinder_widget = QtGui.QTabWidget()
layout = QtGui.QFormLayout()
nameLabel = QtGui.QLabel('Name: ')
self.cylinder_widget.nameLineEdit = QtGui.QLineEdit()
self.cylinder_widget.nameLineEdit.setText('new cylinder')
radiusLabel = QtGui.QLabel('Radius: ')
self.cylinder_widget.radiusSpinBox = QtGui.QDoubleSpinBox()
self.cylinder_widget.radiusSpinBox.setRange(-1e6, 1e6)
self.cylinder_widget.radiusSpinBox.setSingleStep(0.1)
self.cylinder_widget.radiusSpinBox.setValue(1)
heightLabel = QtGui.QLabel('Height: ')
self.cylinder_widget.heightSpinBox = QtGui.QDoubleSpinBox()
self.cylinder_widget.heightSpinBox.setRange(-1e6, 1e6)
self.cylinder_widget.heightSpinBox.setSingleStep(0.1)
self.cylinder_widget.heightSpinBox.setValue(1)
resolutionLabel = QtGui.QLabel('Radial Resolution: ')
self.cylinder_widget.resolutionSpinBox = QtGui.QDoubleSpinBox()
self.cylinder_widget.resolutionSpinBox.setRange(-1e6, 1e6)
self.cylinder_widget.resolutionSpinBox.setSingleStep(0.1)
self.cylinder_widget.resolutionSpinBox.setValue(40)
layout.addRow(nameLabel, self.cylinder_widget.nameLineEdit)
layout.addRow(radiusLabel, self.cylinder_widget.radiusSpinBox)
layout.addRow(heightLabel, self.cylinder_widget.heightSpinBox)
layout.addRow(resolutionLabel, self.cylinder_widget.resolutionSpinBox)
self.cylinder_widget.setLayout(layout)
self.tabWidget.addTab(self.cylinder_widget, 'Cylinder')
def addEllipsoidWidget(self):
self.ellipsoid_widget = QtGui.QTabWidget()
layout = QtGui.QFormLayout()
nameLabel = QtGui.QLabel('Name: ')
self.ellipsoid_widget.nameLineEdit = QtGui.QLineEdit()
self.ellipsoid_widget.nameLineEdit.setText('new ellipsoid')
xRadiusLabel = QtGui.QLabel('X-radius: ')
self.ellipsoid_widget.xRadiusSpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.xRadiusSpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.xRadiusSpinBox.setSingleStep(0.1)
self.ellipsoid_widget.xRadiusSpinBox.setValue(1)
yRadiusLabel = QtGui.QLabel('Y-radius: ')
self.ellipsoid_widget.yRadiusSpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.yRadiusSpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.yRadiusSpinBox.setSingleStep(0.1)
self.ellipsoid_widget.yRadiusSpinBox.setValue(1)
zRadiusLabel = QtGui.QLabel('Z-radius: ')
self.ellipsoid_widget.zRadiusSpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.zRadiusSpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.zRadiusSpinBox.setSingleStep(0.1)
self.ellipsoid_widget.zRadiusSpinBox.setValue(1)
layout.addRow(nameLabel, self.ellipsoid_widget.nameLineEdit)
layout.addRow(xRadiusLabel, self.ellipsoid_widget.xRadiusSpinBox)
layout.addRow(yRadiusLabel, self.ellipsoid_widget.yRadiusSpinBox)
layout.addRow(zRadiusLabel, self.ellipsoid_widget.zRadiusSpinBox)
self.ellipsoid_widget.setLayout(layout)
self.tabWidget.addTab(self.ellipsoid_widget, 'Ellipsoid')
def addEllipsoidWidget_deprecated(self):
self.ellipsoid_widget = QtGui.QTabWidget()
layout = QtGui.QFormLayout()
nameLabel = QtGui.QLabel('Name: ')
self.ellipsoid_widget.nameLineEdit = QtGui.QLineEdit()
self.ellipsoid_widget.nameLineEdit.setText('new ellipsoid')
a0Label = QtGui.QLabel('Coefficient a0: ')
self.ellipsoid_widget.a0SpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.a0SpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.a0SpinBox.setSingleStep(0.1)
self.ellipsoid_widget.a0SpinBox.setValue(1)
a1Label = QtGui.QLabel('Coefficient a1: ')
self.ellipsoid_widget.a1SpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.a1SpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.a1SpinBox.setSingleStep(0.1)
self.ellipsoid_widget.a1SpinBox.setValue(1)
a2Label = QtGui.QLabel('Coefficient a2: ')
self.ellipsoid_widget.a2SpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.a2SpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.a2SpinBox.setSingleStep(0.1)
self.ellipsoid_widget.a2SpinBox.setValue(1)
a3Label = QtGui.QLabel('Coefficient a3: ')
self.ellipsoid_widget.a3SpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.a3SpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.a3SpinBox.setSingleStep(0.1)
self.ellipsoid_widget.a3SpinBox.setValue(0)
a4Label = QtGui.QLabel('Coefficient a4: ')
self.ellipsoid_widget.a4SpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.a4SpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.a4SpinBox.setSingleStep(0.1)
self.ellipsoid_widget.a4SpinBox.setValue(0)
a5Label = QtGui.QLabel('Coefficient a5: ')
self.ellipsoid_widget.a5SpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.a5SpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.a5SpinBox.setSingleStep(0.1)
self.ellipsoid_widget.a5SpinBox.setValue(0)
a6Label = QtGui.QLabel('Coefficient a6: ')
self.ellipsoid_widget.a6SpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.a6SpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.a6SpinBox.setSingleStep(0.1)
self.ellipsoid_widget.a6SpinBox.setValue(0)
a7Label = QtGui.QLabel('Coefficient a7: ')
self.ellipsoid_widget.a7SpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.a7SpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.a7SpinBox.setSingleStep(0.1)
self.ellipsoid_widget.a7SpinBox.setValue(0)
a8Label = QtGui.QLabel('Coefficient a8: ')
self.ellipsoid_widget.a8SpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.a8SpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.a8SpinBox.setSingleStep(0.1)
self.ellipsoid_widget.a8SpinBox.setValue(0)
a9Label = QtGui.QLabel('Coefficient a9: ')
self.ellipsoid_widget.a9SpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.a9SpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.a9SpinBox.setSingleStep(0.1)
self.ellipsoid_widget.a9SpinBox.setValue(-1)
boundsLabel = QtGui.QLabel('Bounds: ')
self.ellipsoid_widget.boundsSpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.boundsSpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.boundsSpinBox.setSingleStep(0.1)
self.ellipsoid_widget.boundsSpinBox.setValue(2)
dimsLabel = QtGui.QLabel('Sample Dims: ')
self.ellipsoid_widget.dimsSpinBox = QtGui.QDoubleSpinBox()
self.ellipsoid_widget.dimsSpinBox.setRange(-1e6, 1e6)
self.ellipsoid_widget.dimsSpinBox.setSingleStep(0.1)
self.ellipsoid_widget.dimsSpinBox.setValue(10)
layout.addRow(nameLabel, self.ellipsoid_widget.nameLineEdit)
layout.addRow(a0Label, self.ellipsoid_widget.a0SpinBox)
layout.addRow(a1Label, self.ellipsoid_widget.a1SpinBox)
layout.addRow(a2Label, self.ellipsoid_widget.a2SpinBox)
layout.addRow(a3Label, self.ellipsoid_widget.a3SpinBox)
layout.addRow(a4Label, self.ellipsoid_widget.a4SpinBox)
layout.addRow(a5Label, self.ellipsoid_widget.a5SpinBox)
layout.addRow(a6Label, self.ellipsoid_widget.a6SpinBox)
layout.addRow(a7Label, self.ellipsoid_widget.a7SpinBox)
layout.addRow(a8Label, self.ellipsoid_widget.a8SpinBox)
layout.addRow(a9Label, self.ellipsoid_widget.a9SpinBox)
layout.addRow(boundsLabel, self.ellipsoid_widget.boundsSpinBox)
layout.addRow(dimsLabel, self.ellipsoid_widget.dimsSpinBox)
self.ellipsoid_widget.setLayout(layout)
self.tabWidget.addTab(self.ellipsoid_widget, 'Ellipsoid')
def addConeWidget(self):
self.cone_widget = QtGui.QTabWidget()
layout = QtGui.QFormLayout()
nameLabel = QtGui.QLabel('Name: ')
self.cone_widget.nameLineEdit = QtGui.QLineEdit()
self.cone_widget.nameLineEdit.setText('new cone')
radiusLabel = QtGui.QLabel('Radius: ')
self.cone_widget.radiusSpinBox = QtGui.QDoubleSpinBox()
self.cone_widget.radiusSpinBox.setRange(-1e6, 1e6)
self.cone_widget.radiusSpinBox.setSingleStep(0.1)
self.cone_widget.radiusSpinBox.setValue(1)
heightLabel = QtGui.QLabel('Height: ')
self.cone_widget.heightSpinBox = QtGui.QDoubleSpinBox()
self.cone_widget.heightSpinBox.setRange(-1e6, 1e6)
self.cone_widget.heightSpinBox.setSingleStep(0.1)
self.cone_widget.heightSpinBox.setValue(1)
resolutionLabel = QtGui.QLabel('Radial Resolution: ')
self.cone_widget.resolutionSpinBox = QtGui.QDoubleSpinBox()
self.cone_widget.resolutionSpinBox.setRange(-1e6, 1e6)
self.cone_widget.resolutionSpinBox.setSingleStep(0.1)
self.cone_widget.resolutionSpinBox.setValue(40)
layout.addRow(nameLabel, self.cone_widget.nameLineEdit)
layout.addRow(radiusLabel, self.cone_widget.radiusSpinBox)
layout.addRow(heightLabel, self.cone_widget.heightSpinBox)
layout.addRow(resolutionLabel, self.cone_widget.resolutionSpinBox)
self.cone_widget.setLayout(layout)
self.tabWidget.addTab(self.cone_widget, 'Cone')
def addTorusWidget(self):
self.torus_widget = QtGui.QTabWidget()
layout = QtGui.QFormLayout()
nameLabel = QtGui.QLabel('Name: ')
self.torus_widget.nameLineEdit = QtGui.QLineEdit()
self.torus_widget.nameLineEdit.setText('new torus')
ringRadiusLabel = QtGui.QLabel('Ring Radius: ')
self.torus_widget.ringRadiusSpinBox = QtGui.QDoubleSpinBox()
self.torus_widget.ringRadiusSpinBox.setRange(-1e6, 1e6)
self.torus_widget.ringRadiusSpinBox.setSingleStep(0.1)
self.torus_widget.ringRadiusSpinBox.setValue(1)
crossSectionRadiusLabel = QtGui.QLabel('Cross-Section Radius: ')
self.torus_widget.crossSectionRadiusSpinBox = QtGui.QDoubleSpinBox()
self.torus_widget.crossSectionRadiusSpinBox.setRange(-1e6, 1e6)
self.torus_widget.crossSectionRadiusSpinBox.setSingleStep(0.1)
self.torus_widget.crossSectionRadiusSpinBox.setValue(0.1)
layout.addRow(nameLabel, self.torus_widget.nameLineEdit)
layout.addRow(ringRadiusLabel, self.torus_widget.ringRadiusSpinBox)
layout.addRow(crossSectionRadiusLabel, self.torus_widget.crossSectionRadiusSpinBox)
self.torus_widget.setLayout(layout)
self.tabWidget.addTab(self.torus_widget, 'Torus')