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
|
# Copyright 2004-2007 Nanorex, Inc. See LICENSE file for details.
"""
RotaryMotorPropertyManager.py
@author: Mark
@version: $Id$
@copyright: 2004-2007 Nanorex, Inc. See LICENSE file for details.
History:
Mark 2007-05-28: Created as RotaryMotorGeneratorDialog.py
Ninad 2007-10-09:
- Deprecated RotaryMotorGeneratorDialog class
- Created RotaryMotorPropertyManager class to match the
EditCommand API. (and related changes)
"""
from PyQt4.Qt import SIGNAL
from PM.PM_DoubleSpinBox import PM_DoubleSpinBox
from PM.PM_CheckBox import PM_CheckBox
from PM.PM_PushButton import PM_PushButton
from PM.PM_ColorComboBox import PM_ColorComboBox
from utilities.constants import gray
from command_support.MotorPropertyManager import MotorPropertyManager
class RotaryMotorPropertyManager(MotorPropertyManager):
"""
The RotaryMotorProperty manager class provides UI and propMgr object for the
RotaryMotor_EditCommand.
"""
# The title that appears in the Property Manager header.
title = "Rotary Motor"
# The name of this Property Manager. This will be set to
# the name of the PM_Dialog object via setObjectName().
pmName = title
# The relative path to the PNG file that appears in the header
iconPath = "ui/actions/Simulation/RotaryMotor.png"
def connect_or_disconnect_signals(self, isConnect):
"""
Connect or disconnect widget signals sent to their slot methods.
This can be overridden in subclasses. By default it does nothing.
@param isConnect: If True the widget will send the signals to the slot
method.
@type isConnect: boolean
"""
if isConnect:
change_connect = self.win.connect
else:
change_connect = self.win.disconnect
MotorPropertyManager.connect_or_disconnect_signals(self, isConnect)
change_connect(self.directionPushButton,
SIGNAL("clicked()"),
self.reverse_direction)
change_connect(self.motorLengthDblSpinBox,
SIGNAL("valueChanged(double)"),
self.change_motor_size)
change_connect(self.motorRadiusDblSpinBox,
SIGNAL("valueChanged(double)"),
self.change_motor_size)
change_connect(self.spokeRadiusDblSpinBox,
SIGNAL("valueChanged(double)"),
self.change_motor_size)
change_connect(self.motorColorComboBox,
SIGNAL("editingFinished()"),
self.change_jig_color)
return
def _update_widgets_in_PM_before_show(self):
"""
Update various widgets in this Property manager.
Overrides MotorPropertyManager._update_widgets_in_PM_before_show.
The various widgets , (e.g. spinboxes) will get values from the
structure for which this propMgr is constructed for
(self.editcCntroller.struct)
@see: MotorPropertyManager._update_widgets_in_PM_before_show
@see: self.show where it is called.
"""
if self.command and self.command.struct:
torque = self.command.struct.torque
initial_speed = self.command.struct.initial_speed
final_speed = self.command.struct.speed
dampers_enabled = self.command.struct.dampers_enabled
enable_minimize = self.command.struct.enable_minimize
length = self.command.struct.length
radius = self.command.struct.radius
spoke_radius = self.command.struct.sradius
normcolor = self.command.struct.normcolor
else:
torque = 0.0
initial_speed = 0.0
final_speed = 0.0
dampers_enabled = False
enable_minimize = False
length = 10.0
radius = 1.0
spoke_radius = 0.2
normcolor = gray
self.torqueDblSpinBox.setValue(torque)
self.initialSpeedDblSpinBox.setValue(initial_speed)
self.finalSpeedDblSpinBox.setValue(final_speed)
self.dampersCheckBox.setChecked(dampers_enabled)
self.enableMinimizeCheckBox.setChecked(enable_minimize)
self.motorLengthDblSpinBox.setValue(length)
self.motorRadiusDblSpinBox.setValue(radius)
self.spokeRadiusDblSpinBox.setValue(spoke_radius)
return
def change_motor_size(self, gl_update = True):
"""
Slot method to change the jig's length, radius and/or spoke radius.
"""
if self.command and self.command.struct:
self.command.struct.length = \
self.motorLengthDblSpinBox.value()# motor length
self.command.struct.radius = \
self.motorRadiusDblSpinBox.value() # motor radius
self.command.struct.sradius = \
self.spokeRadiusDblSpinBox.value() # spoke radius
if gl_update:
self.glpane.gl_update()
return
def _loadGroupBox1(self, pmGroupBox):
"""
Load widgets in MotorParamsGroupBox.
"""
if self.command and self.command.struct:
torque = self.command.struct.torque
initial_speed = self.command.struct.initial_speed
final_speed = self.command.struct.speed
dampers_enabled = self.command.struct.dampers_enabled
enable_minimize = self.command.struct.enable_minimize
else:
torque = 0.0
initial_speed = 0.0
final_speed = 0.0
dampers_enabled = False
enable_minimize = False
self.torqueDblSpinBox = \
PM_DoubleSpinBox(pmGroupBox,
label = "Torque :",
value = torque,
setAsDefault = True,
minimum = 0.0,
maximum = 1000.0,
singleStep = 1.0,
decimals = 1,
suffix =' nN-nm')
self.initialSpeedDblSpinBox = \
PM_DoubleSpinBox(pmGroupBox,
label = "Initial speed :",
value = initial_speed,
setAsDefault = True,
minimum = 0.0,
maximum = 100.0,
singleStep = 1.0,
decimals = 1,
suffix = ' GHz')
self.finalSpeedDblSpinBox = \
PM_DoubleSpinBox(pmGroupBox,
label = "Final speed :",
value = final_speed,
setAsDefault = True,
minimum = 0.0,
maximum = 100.0,
singleStep = 1.0,
decimals = 1,
suffix = ' GHz')
self.dampersCheckBox = \
PM_CheckBox(pmGroupBox,
text = "Dampers",
widgetColumn = 0
)
self.dampersCheckBox.setChecked(dampers_enabled)
self.enableMinimizeCheckBox = \
PM_CheckBox(pmGroupBox,
text = "Enable in minimize",
widgetColumn = 0
)
self.enableMinimizeCheckBox.setChecked(enable_minimize)
self.directionPushButton = \
PM_PushButton(pmGroupBox,
label = "Direction :",
text = "Reverse",
spanWidth = False)
return
def _loadGroupBox2(self, pmGroupBox):
"""
Load widgets in groubox 2.
"""
if self.command and self.command.struct:
length = self.command.struct.length
radius = self.command.struct.radius
spoke_radius = self.command.struct.sradius
normcolor = self.command.struct.normcolor
else:
length = 10
radius = 1
spoke_radius = 0.2
normcolor = gray
self.motorLengthDblSpinBox = \
PM_DoubleSpinBox(pmGroupBox,
label = "Motor length :",
value = length,
setAsDefault = True,
minimum = 0.5,
maximum = 500.0,
singleStep = 0.5,
decimals = 1,
suffix = ' Angstroms')
self.motorRadiusDblSpinBox = \
PM_DoubleSpinBox(pmGroupBox,
label="Motor radius :",
value = radius,
setAsDefault = True,
minimum = 0.1,
maximum = 50.0,
singleStep = 0.1,
decimals = 1,
suffix = ' Angstroms')
self.spokeRadiusDblSpinBox = \
PM_DoubleSpinBox(pmGroupBox,
label = "Spoke radius :",
value = spoke_radius,
setAsDefault = True,
minimum = 0.1,
maximum = 50.0,
singleStep = 0.1,
decimals = 1,
suffix = ' Angstroms')
self.motorColorComboBox = \
PM_ColorComboBox(pmGroupBox,
color = normcolor)
return
def _addWhatsThisText(self):
"""
What's This text for widgets in this Property Manager.
"""
from ne1_ui.WhatsThisText_for_PropertyManagers import whatsThis_RotaryMotorPropertyManager
whatsThis_RotaryMotorPropertyManager(self)
return
def _addToolTipText(self):
"""
What's Tool Tip text for widgets in this Property Manager.
"""
from ne1_ui.ToolTipText_for_PropertyManagers import ToolTip_RotaryMotorPropertyManager
ToolTip_RotaryMotorPropertyManager(self)
return
|