[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59053] trunk/blender/release/scripts/ startup/bl_operators/add_mesh_torus.py: Add better UI for "Add Torus" function

Sv. Lockal lockalsash at gmail.com
Sat Aug 10 17:37:25 CEST 2013


Revision: 59053
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59053
Author:   lockal
Date:     2013-08-10 15:37:24 +0000 (Sat, 10 Aug 2013)
Log Message:
-----------
Add better UI for "Add Torus" function

The previous one did nothing in many cases and was very unintuitive:
http://www.pasteall.org/pic/show.php?id=57219

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_operators/add_mesh_torus.py

Modified: trunk/blender/release/scripts/startup/bl_operators/add_mesh_torus.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/add_mesh_torus.py	2013-08-10 13:43:39 UTC (rev 59052)
+++ trunk/blender/release/scripts/startup/bl_operators/add_mesh_torus.py	2013-08-10 15:37:24 UTC (rev 59053)
@@ -87,6 +87,31 @@
     bl_label = "Add Torus"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
 
+    def mode_update_callback(self, context):
+        if self.mode == 'EXT_INT':
+            self.abso_major_rad = self.major_radius + self.minor_radius
+            self.abso_minor_rad = self.major_radius - self.minor_radius
+
+    major_segments = IntProperty(
+            name="Major Segments",
+            description="Number of segments for the main ring of the torus",
+            min=3, max=256,
+            default=48,
+            )
+    minor_segments = IntProperty(
+            name="Minor Segments",
+            description="Number of segments for the minor ring of the torus",
+            min=3, max=256,
+            default=12,
+            )
+    mode = bpy.props.EnumProperty(
+            name="Torus Dimentions",
+            items=(("MAJOR_MINOR", "Major/Minor", 
+                    "Use the major/minor radiuses for torus dimensions"),
+                   ("EXT_INT", "Exterior/Interior", 
+                    "Use the exterior/interior radiuses for torus dimensions")),
+            update=mode_update_callback,
+            )
     major_radius = FloatProperty(
             name="Major Radius",
             description=("Radius from the origin to the "
@@ -104,47 +129,69 @@
             subtype='DISTANCE',
             unit='LENGTH',
             )
-    major_segments = IntProperty(
-            name="Major Segments",
-            description="Number of segments for the main ring of the torus",
-            min=3, max=256,
-            default=48,
-            )
-    minor_segments = IntProperty(
-            name="Minor Segments",
-            description="Number of segments for the minor ring of the torus",
-            min=3, max=256,
-            default=12,
-            )
-    use_abso = BoolProperty(
-            name="Use Int+Ext Controls",
-            description="Use the Int / Ext controls for torus dimensions",
-            default=False,
-            )
     abso_major_rad = FloatProperty(
             name="Exterior Radius",
             description="Total Exterior Radius of the torus",
             min=0.01, max=100.0,
-            default=1.0,
+            default=1.25,
             subtype='DISTANCE',
             unit='LENGTH',
             )
     abso_minor_rad = FloatProperty(
-            name="Inside Radius",
+            name="Interior Radius",
             description="Total Interior Radius of the torus",
             min=0.01, max=100.0,
-            default=0.5,
+            default=0.75,
             subtype='DISTANCE',
             unit='LENGTH',
             )
 
+    def draw(self, context):
+        layout = self.layout
+        col = layout.column(align=True)
+        col.prop(self, 'view_align')
+        col = layout.column(align=True)
+
+        col.label(text="Location")
+        col.prop(self, 'location', text="")
+        col = layout.column(align=True)
+
+        col.label(text="Rotation")
+        col.prop(self, 'rotation', text="")
+
+        col = layout.column(align=True)
+        col.label(text="Major Segments")
+        col.prop(self, 'major_segments', text="")
+        col = layout.column(align=True)
+        col.label(text="Minor Segments")
+        col.prop(self, 'minor_segments', text="")
+
+        col = layout.column(align=True)
+        col.label(text="Torus Dimentions")
+        col.row().prop(self, 'mode', expand=True)
+
+        if self.mode == 'MAJOR_MINOR':
+            col = layout.column(align=True)
+            col.label(text="Major Radius")
+            col.prop(self, 'major_radius', text="")
+            col = layout.column(align=True)
+            col.label(text="Minor Radius")
+            col.prop(self, 'minor_radius', text="")
+        else:
+            col = layout.column(align=True)
+            col.label(text="Exterior Radius")
+            col.prop(self, 'abso_major_rad', text="")
+            col = layout.column(align=True)
+            col.label(text="Interior Radius")
+            col.prop(self, 'abso_minor_rad', text="")
+
     def invoke(self, context, event):
         object_utils.object_add_grid_scale_apply_operator(self, context)
         return self.execute(context)
 
     def execute(self, context):
 
-        if self.use_abso is True:
+        if self.mode == 'EXT_INT':
             extra_helper = (self.abso_major_rad - self.abso_minor_rad) * 0.5
             self.major_radius = self.abso_minor_rad + extra_helper
             self.minor_radius = extra_helper




More information about the Bf-blender-cvs mailing list