[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3908] contrib/py/scripts/addons/ io_mesh_xyz:

Clemens Barth barth at root-1.de
Wed Oct 31 00:43:37 CET 2012


Revision: 3908
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3908
Author:   blendphys
Date:     2012-10-30 23:43:36 +0000 (Tue, 30 Oct 2012)
Log Message:
-----------

Major change of the Atomic Blender XYZ IO: removal of the panel and 
improvements according to http://codereview.appspot.com/6815052. I have done 
almost everything, however, 2nd review is needed for verification. 

Blendphys.

Modified Paths:
--------------
    contrib/py/scripts/addons/io_mesh_xyz/__init__.py
    contrib/py/scripts/addons/io_mesh_xyz/export_xyz.py
    contrib/py/scripts/addons/io_mesh_xyz/import_xyz.py

Modified: contrib/py/scripts/addons/io_mesh_xyz/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_mesh_xyz/__init__.py	2012-10-30 22:54:33 UTC (rev 3907)
+++ contrib/py/scripts/addons/io_mesh_xyz/__init__.py	2012-10-30 23:43:36 UTC (rev 3908)
@@ -25,7 +25,7 @@
 #
 #  Start of project              : 2011-12-01 by Clemens Barth
 #  First publication in Blender  : 2011-12-18
-#  Last modified                 : 2012-10-27
+#  Last modified                 : 2012-10-30
 #
 #  Acknowledgements: Thanks to ideasman, meta_androcto, truman, kilon,
 #  dairin0d, PKHG, Valter, etc
@@ -61,742 +61,12 @@
 from . import import_xyz
 from . import export_xyz
 
-ATOM_XYZ_ERROR = ""
-ATOM_XYZ_NOTE  = ""
-ATOM_XYZ_PANEL = ""
 
 # -----------------------------------------------------------------------------
 #                                                                           GUI
 
-# This is the panel, which can be used to prepare the scene.
-# It is loaded after the file has been chosen via the menu 'File -> Import'
-class CLASS_atom_xyz_prepare_panel(Panel):
-    bl_label       = "XYZ - Atomic Blender"
-    bl_space_type  = "VIEW_3D"
-    bl_region_type = "TOOL_PROPS"
 
-    @classmethod
-    def poll(self, context):
-        global ATOM_XYZ_PANEL
-        
-        if ATOM_XYZ_PANEL == "0" and import_xyz.ATOM_XYZ_FILEPATH == "":
-            return False
-        if ATOM_XYZ_PANEL == "0" and import_xyz.ATOM_XYZ_FILEPATH != "":
-            return True
-        if ATOM_XYZ_PANEL == "1":
-            return True
-        if ATOM_XYZ_PANEL == "2":
-            return False
-        
-        return True
 
-
-    def draw(self, context):
-        layout = self.layout
-
-        if len(context.scene.atom_xyz) == 0:
-            bpy.context.scene.atom_xyz.add()
-
-        scn    = context.scene.atom_xyz[0]
-
-        row = layout.row()
-        row.label(text="Outputs and custom data file")
-        box = layout.box()
-        row = box.row()
-        row.label(text="Custom data file")
-        row = box.row()
-        col = row.column()
-        col.prop(scn, "datafile")
-        col.operator("atom_xyz.datafile_apply")
-        row = box.row()
-        col = row.column(align=True)
-        col.prop(scn, "XYZ_file")
-        row = box.row()
-        row.prop(scn, "number_atoms")
-        row = box.row()
-        row.operator("atom_xyz.button_distance")
-        row.prop(scn, "distance")
-        row = layout.row()
-        row.label(text="Choice of atom radii")
-        box = layout.box()
-        row = box.row()
-        row.label(text="All changes concern:")
-        row = box.row()
-        row.prop(scn, "radius_how")
-        row = box.row()
-        row.label(text="1. Change type of radii")
-        row = box.row()
-        row.prop(scn, "radius_type")
-        row = box.row()
-        row.label(text="2. Change atom radii in pm")
-        row = box.row()
-        row.prop(scn, "radius_pm_name")
-        row = box.row()
-        row.prop(scn, "radius_pm")
-        row = box.row()
-        row.label(text="3. Change atom radii by scale")
-        row = box.row()
-        col = row.column()
-        col.prop(scn, "radius_all")
-        col = row.column(align=True)
-        col.operator( "atom_xyz.radius_all_bigger" )
-        col.operator( "atom_xyz.radius_all_smaller" )
-
-        if bpy.context.mode == 'EDIT_MESH':
-            layout.separator()
-            row = box.row()
-            row.operator( "atom_xyz.separate_atom" )
-
-        row = layout.row()
-        row.label(text="Loading frames")
-        box = layout.box()
-        row = box.row()
-        col = row.column()
-        col.label(text="Frames")
-        col = row.column()
-        col.prop(scn, "number_frames")
-        row = box.row()
-        col = row.column()
-        col.label(text="Skip frames")
-        col = row.column()
-        col.prop(scn, "skip_frames")
-        row = box.row()
-        col = row.column()
-        col.label(text="Frames/key")
-        col = row.column()
-        col.prop(scn, "images_per_key")        
-        row = box.row()
-        row.operator("atom_xyz.load_frames")
-        row = box.row()
-        row.operator("atom_xyz.delete_keys")
-        row = box.row()
-        row.operator( "atom_xyz.create_command")
-        row = box.row()
-        row.operator( "atom_xyz.render")
-
-
-class CLASS_atom_xyz_Properties(bpy.types.PropertyGroup):
-
-    def Callback_radius_type(self, context):
-        scn = bpy.context.scene.atom_xyz[0]
-        import_xyz.DEF_atom_xyz_radius_type(
-                scn.radius_type,
-                scn.radius_how,)
-
-    def Callback_radius_pm(self, context):
-        scn = bpy.context.scene.atom_xyz[0]
-        import_xyz.DEF_atom_xyz_radius_pm(
-                scn.radius_pm_name,
-                scn.radius_pm,
-                scn.radius_how,)
-
-    # In the file dialog window
-    use_camera = BoolProperty(
-        name="Camera", default=False,
-        description="Do you need a camera?")
-    use_lamp = BoolProperty(
-        name="Lamp", default=False,
-        description = "Do you need a lamp?")
-    use_mesh = BoolProperty(
-        name = "Mesh balls", default=False,
-        description = "Do you want to use mesh balls instead of NURBS?")
-    mesh_azimuth = IntProperty(
-        name = "Azimuth", default=32, min=0,
-        description = "Number of sectors (azimuth)")
-    mesh_zenith = IntProperty(
-        name = "Zenith", default=32, min=0,
-        description = "Number of sectors (zenith)")
-    scale_ballradius = FloatProperty(
-        name = "Balls", default=1.0, min=0.0,
-        description = "Scale factor for all atom radii")
-    scale_distances = FloatProperty (
-        name = "Distances", default=1.0, min=0.0,
-        description = "Scale factor for all distances")
-    use_center = BoolProperty(
-        name = "Object to origin (first frames)", default=False,
-        description = "Put the object into the global origin, the first frame only")           
-    use_center_all = BoolProperty(
-        name = "Object to origin (all frames)", default=True,
-        description = "Put the object into the global origin, all frames") 
-    atomradius = EnumProperty(
-        name="Type of radius",
-        description="Choose type of atom radius",
-        items=(('0', "Pre-defined", "Use pre-defined radii"),
-               ('1', "Atomic", "Use atomic radii"),
-               ('2', "van der Waals", "Use van der Waals radii")),
-               default='0',)
-    # In the panel, first part
-    datafile = StringProperty(
-        name = "", description="Path to your custom data file",
-        maxlen = 256, default = "", subtype='FILE_PATH')
-    XYZ_file = StringProperty(
-        name = "Path to file", default="",
-        description = "Path of the XYZ file")
-    number_atoms = StringProperty(name="",
-        default="Number", description = "This output shows "
-        "the number of atoms which have been loaded")
-    distance = StringProperty(
-        name="", default="Distance (A)",
-        description="Distance of 2 objects in Angstrom")
-    radius_how = EnumProperty(
-        name="",
-        description="Which objects shall be modified?",
-        items=(('ALL_ACTIVE',"all active objects", "in the current layer"),
-               ('ALL_IN_LAYER',"all"," in active layer(s)")),
-               default='ALL_ACTIVE',)
-    radius_type = EnumProperty(
-        name="Type",
-        description="Which type of atom radii?",
-        items=(('0',"predefined", "Use pre-defined radii"),
-               ('1',"atomic", "Use atomic radii"),
-               ('2',"van der Waals","Use van der Waals radii")),
-               default='0',update=Callback_radius_type)
-    radius_pm_name = StringProperty(
-        name="", default="Atom name",
-        description="Put in the name of the atom (e.g. Hydrogen)")
-    radius_pm = FloatProperty(
-        name="", default=100.0, min=0.0,
-        description="Put in the radius of the atom (in pm)",
-        update=Callback_radius_pm)
-    radius_all = FloatProperty(
-        name="Scale", default = 1.05, min=1.0, max=5.0,
-        description="Put in the scale factor")
-    # In the panel, second part
-    number_frames = StringProperty(
-        name="", default="0",
-        description="This is the total number of frames stored in the xyz file")
-    skip_frames = IntProperty(
-        name="", default=0, min=0,
-        description="Number of frames you want to skip.")
-    images_per_key = IntProperty(
-        name="", default=1, min=1,
-        description="Choose the number of images between 2 keys.")
-
-
-
-# Button for creating a file that contains the command for rendering
-class CLASS_atom_xyz_create_command(Operator):
-    bl_idname = "atom_xyz.create_command"
-    bl_label = "Create command"
-    bl_description = "Create a shell command for rendering the scene"
-
-    # If no object is in the scene, do nothing (return False).
-    @classmethod
-    def poll(self, context):
-
-        if bpy.context.object == None:
-            return False
-        if len(import_xyz.STRUCTURE) == 0:
-            return False
-        if len(import_xyz.ALL_FRAMES) < 2:
-            return False
-
-        EMPTY = True
-        for element in import_xyz.STRUCTURE:
-            if element.name != '':
-                EMPTY = False
-
-        if EMPTY == True:
-            return False
-
-        return True
-
-    def execute(self, context):
-        global ATOM_XYZ_ERROR
-        global ATOM_XYZ_NOTE
- 
-        scn = bpy.context.scene
-
-        fstart = scn.frame_start
-        fend = scn.frame_end
-        file_blend = bpy.context.blend_data.filepath
-        
-        if file_blend == "":
-            ATOM_XYZ_ERROR = "Save your scene first !"
-            bpy.ops.atom_xyz.error_dialog('INVOKE_DEFAULT')
-            return {'FINISHED'}
-            
-        cameras = []    
-        FOUND = False    
-        for obj in bpy.context.scene.objects:  
-            if obj.type == "CAMERA":
-                cameras.append(obj)
-                FOUND = True   
-        if FOUND == False:
-            ATOM_XYZ_ERROR = "No camera => no images !"
-            bpy.ops.atom_xyz.error_dialog('INVOKE_DEFAULT')
-            return {'FINISHED'}      
-        if bpy.context.scene.camera == None:
-            bpy.context.scene.camera = cameras[0]
-            
-        KEYS_PRESENT = True

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list