summaryrefslogtreecommitdiff
path: root/cad/src/commands/Extrude/Ui_ExtrudePropertyManager.py
blob: 16dd5b7be72ca626a40ae7a4f47b36ffb73dc91f (plain)
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
# Copyright 2004-2008 Nanorex, Inc.  See LICENSE file for details.
"""
Ui_ExtrudePropertyManager.py - UI elements for the B{Extrude Mode} Property
Manager.

@version: $Id$
@copyight: 2004-2008 Nanorex, Inc.  See LICENSE file for details.

History:

ninad 2007-01-10: Split the ui code out of extrudeMode while converting
extrude dashboard to extrude property manager.
ninad 2007-09-10: Code clean up to use PM module classes
"""

from PyQt4.Qt import Qt

from PM.PM_GroupBox      import PM_GroupBox
from PM.PM_CheckBox      import PM_CheckBox
from PM.PM_Slider        import PM_Slider
from PM.PM_ComboBox      import PM_ComboBox
from PM.PM_DoubleSpinBox import PM_DoubleSpinBox
from PM.PM_SpinBox       import PM_SpinBox

from PM.PM_Constants     import PM_DONE_BUTTON
from PM.PM_Constants     import PM_WHATS_THIS_BUTTON
from PM.PM_Constants     import PM_CANCEL_BUTTON
from PM.PM_Constants     import PM_PREVIEW_BUTTON

from command_support.Command_PropertyManager import Command_PropertyManager

_superclass = Command_PropertyManager
class Ui_ExtrudePropertyManager(Command_PropertyManager):
    """
    The Ui_ExtrudePropertyManager class defines UI elements for the Property
    Manager of the B{Extrude mode}.

    @ivar title: The title that appears in the property manager header.
    @type title: str

    @ivar pmName: The name of this property manager. This is used to set
                  the name of the PM_Dialog object via setObjectName().
    @type name: str

    @ivar iconPath: The relative path to the PNG file that contains a
                    22 x 22 icon image that appears in the PM header.
    @type iconPath: str
    """

    # The title that appears in the Property Manager header
    title = "Extrude"
    # 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/Properties Manager/Extrude.png"

    def __init__(self, command):
        """
        Constructor for the B{Extrude} property manager class that defines
        its UI.

        @param command: The parent mode where this Property Manager is used
        @type  command: L{extrudeMode}
        """

        _superclass.__init__(self, command)

        self.showTopRowButtons( PM_DONE_BUTTON | \
                                PM_CANCEL_BUTTON | \
                                PM_PREVIEW_BUTTON|\
                                PM_WHATS_THIS_BUTTON)


        msg = ''
        self.MessageGroupBox.insertHtmlMessage(msg, setAsDefault=False)

    def _addGroupBoxes(self):
        """
        Add various group boxes to the Extrude Property manager.
        """

        self._addProductSpecsGroupBox()
        self._addAdvancedOptionsGroupBox()

        #Define extrude preference toggles. This needs to be defined before
        #the superclass calls connect_or_disconnect_signals! Defining it in
        #_addGroupBoxes is not intuitive. But the problem is the superclass method
        #also makes connections in its __init__ method. This can be cleaned up
        #during major reafctoring of extrude Mode --  Ninad 2008-10-02
        self.extrude_pref_toggles = ( self.showEntireModelCheckBox,
                                      self.showBondOffsetCheckBox,
                                      self.makeBondsCheckBox,
                                      self.mergeCopiesCheckBox,
                                      self.extrudePrefMergeSelection)

    def _addProductSpecsGroupBox(self):
        """
        """
        self.productSpecsGroupBox = \
            PM_GroupBox( self, title = "Product Specifications" )
        self._loadProductSpecsGroupBox(self.productSpecsGroupBox)

    def _addAdvancedOptionsGroupBox(self):
        """
        Add 'Advanced Options' groupbox
        """
        self.advancedOptionsGroupBox = \
            PM_GroupBox( self, title = "Advanced Options" )
        self._loadAdvancedOptionsGroupBox(self.advancedOptionsGroupBox)

    def _loadProductSpecsGroupBox(self, inPmGroupBox):
        """
        Load widgets in the Product specifications group box.
        @param inPmGroupBox: The roduct specifications box in the PM
        @type  inPmGroupBox: L{PM_GroupBox}
        """

        productChoices = ['Rod', 'Ring']

        self.extrude_productTypeComboBox = \
            PM_ComboBox( inPmGroupBox,
                         label        = 'Final product:',
                         labelColumn  = 0,
                         choices      = productChoices,
                         index        = 0,
                         setAsDefault = True,
                         spanWidth    = False )

        # names used in the code, same order
        #if you comment out items from combobox, you also have to remove them
        # from this list unless they are at the end!!!
        self.extrude_productTypeComboBox_ptypes = ["straight rod", \
                                                   "closed ring", \
                                                   "corkscrew"]

        self.extrudeSpinBox_n = \
            PM_SpinBox( inPmGroupBox,
                        label         =  "Number of copies:",
                        labelColumn   =  0,
                        value         =  3,
                        minimum       =  1,
                        maximum       =  99
                    )
        #@WARNING: This method initializes some instance varaiables for various
        #checkboxes. (Example: self.mergeCopiesCheckBox.default = False).
        #These values are needed in extrudemode.py. This
        #won't be needed once extrudeMode.py is cleaned up. -- ninad 2007-09-10

        self.extrudeBondCriterionSlider =  \
            PM_Slider( inPmGroupBox,
                       currentValue = 100,
                       minimum      = 0,
                       maximum      = 300,
                       label        = 'Tolerence'
                   )
        self.extrudeBondCriterionLabel = \
            self.extrudeBondCriterionSlider.labelWidget

        self.extrudeBondCriterionSlider_dflt = 100
        self.extrudeBondCriterionSlider.setPageStep(5)

        self.makeBondsCheckBox = \
            PM_CheckBox(inPmGroupBox,
                        text         = 'Make bonds' ,
                        widgetColumn = 0,
                        state        = Qt.Checked
                    )
        self.makeBondsCheckBox.default = True
        self.makeBondsCheckBox.attr = 'whendone_make_bonds'
        self.makeBondsCheckBox.repaintQ = False


    def _loadAdvancedOptionsGroupBox(self, inPmGroupBox):
        """
        Load widgets in the Advanced Options group box.
        @param inPmGroupBox: The Advanced Options box in the PM
        @type  inPmGroupBox: L{PM_GroupBox}

        """
        self.offsetSpecsGroupBox = PM_GroupBox(inPmGroupBox,
                                               title = 'Offset Between Copies:'
                                           )
        self._loadOffsetSpecsGroupBox(self.offsetSpecsGroupBox)

        self.mergeOptionsGroupBox = PM_GroupBox(inPmGroupBox,
                                                title = 'Merge Options:' )
        self._loadMergeOptionsGroupBox(self.mergeOptionsGroupBox)

        self.displayOptionsGroupBox = PM_GroupBox(inPmGroupBox,
                                                  title = 'Display Options:')
        self._loadDisplayOptionsGroupBox(self.displayOptionsGroupBox)
        return

    def _loadDisplayOptionsGroupBox(self, inPmGroupBox):
        """
        Load widgets in the Display Options groupbox (which is a groupbox within
        the B{Advanced Options group box} ) .
        @param inPmGroupBox: The Display Options groupbox
        @type  inPmGroupBox: L{PM_GroupBox}
        @WARNING: This method initializes some instance varaiables for various
        checkboxes. (Example: self.mergeCopiesCheckBox.default = False). This
        won't be needed once extrudeMode.py is cleaned up.
        """
        self.showEntireModelCheckBox = \
            PM_CheckBox(inPmGroupBox,
                        text         = 'Show entire model' ,
                        widgetColumn = 1,
                        state        = Qt.Unchecked
                    )
        self.showEntireModelCheckBox.default = False
        self.showEntireModelCheckBox.attr = 'show_entire_model'
        self.showEntireModelCheckBox.repaintQ = True

        self.showBondOffsetCheckBox = \
            PM_CheckBox(inPmGroupBox,
                        text         = 'Show bond-offset spheres' ,
                        widgetColumn = 1,
                        state        = Qt.Unchecked
                    )
        self.showBondOffsetCheckBox.default = False
        self.showBondOffsetCheckBox.attr = 'show_bond_offsets'
        self.showBondOffsetCheckBox.repaintQ = True

    def _loadMergeOptionsGroupBox(self, inPmGroupBox):
        """
        Load widgets in the Merge Options groupbox (which is a groupbox within
        the B{Advanced Options group box}).
        @param inPmGroupBox: The Merge Options groupbox
        @type  inPmGroupBox: L{PM_GroupBox}
        @WARNING: This method initializes some instance varaiables for various
        checkboxes. (Example: self.mergeCopiesCheckBox.default = False). This
        won't be needed once extrudeMode.py is cleaned up.
        """
        self.mergeCopiesCheckBox = \
            PM_CheckBox(inPmGroupBox,
                        text         = 'Merge copies' ,
                        widgetColumn = 1,
                        state        = Qt.Unchecked
                    )
        self.mergeCopiesCheckBox.default = False
        self.mergeCopiesCheckBox.attr = 'whendone_all_one_part'
        self.mergeCopiesCheckBox.repaintQ = False


        self.extrudePrefMergeSelection = \
            PM_CheckBox(inPmGroupBox,
                        text         = 'Merge selection' ,
                        widgetColumn = 1,
                        state        = Qt.Unchecked
                    )
        self.extrudePrefMergeSelection.default = False
        self.extrudePrefMergeSelection.attr = 'whendone_merge_selection'
        self.extrudePrefMergeSelection.repaintQ = False

    def _loadOffsetSpecsGroupBox(self, inPmGroupBox):
        """
        Load widgets in the Offset specs groupbox (which is a groupbox within
        the B{Advanced Options group box}).
        @param inPmGroupBox: The Offset Specs gropbox box
        @type  inPmGroupBox: L{PM_GroupBox}
        """
        self.extrudeSpinBox_length = \
            PM_DoubleSpinBox( inPmGroupBox,
                              label         =  "Total offset",
                              value         =  7.0,
                              setAsDefault  =  True,
                              minimum       =  0.1,
                              maximum       =  2000.0,
                              singleStep    =  1,
                              decimals      =  3,
                              suffix        =  ' Angstroms'
                          )

        self.extrudeSpinBox_x = \
            PM_DoubleSpinBox( inPmGroupBox,
                              label         =  "X offset",
                              value         =  0,
                              minimum       =  -1000.0,
                              maximum       =  1000.0,
                              singleStep    =  1,
                              decimals      =  3,
                              suffix        =  ' Angstroms'
                          )

        self.extrudeSpinBox_y = \
            PM_DoubleSpinBox( inPmGroupBox,
                              label         =  "Y offset",
                              value         =  0,
                              minimum       =  -1000.0,
                              maximum       =  1000.0,
                              singleStep    =  1,
                              decimals      =  3,
                              suffix        =  ' Angstroms'
                          )
        self.extrudeSpinBox_z = \
            PM_DoubleSpinBox( inPmGroupBox,
                              label         =  "Z offset",
                              value         =  0,
                              minimum       =  -1000.0,
                              maximum       =  1000.0,
                              singleStep    =  1,
                              decimals      =  3,
                              suffix        =  ' Angstroms'
                          )

    def _addWhatsThisText(self):
        """
        What's This text for widgets in this Property Manager.

        @note: Many PM widgets are still missing their "What's This" text.
        """
        from ne1_ui.WhatsThisText_for_PropertyManagers import whatsThis_ExtrudePropertyManager
        whatsThis_ExtrudePropertyManager(self)

        return