[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3161] contrib/py/scripts/addons/ io_mesh_xyz: Basically, I have done same changes in the XYZ importer as in the PDB IO.

Clemens Barth barth at root-1.de
Thu Mar 22 16:58:15 CET 2012


Revision: 3161
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3161
Author:   blendphys
Date:     2012-03-22 15:58:14 +0000 (Thu, 22 Mar 2012)
Log Message:
-----------
Basically, I have done same changes in the XYZ importer as in the PDB IO.

1. Operator presets: can be used now 
2. New: The user can now decide whether the panel is always, once or never shown 
after a PDB file is loaded. Note that the panel is quite essential since it 
helps quickly modifying PDB structures.
3. Some code cleaning
4. Wiki will be updated

Blendphys 

Modified Paths:
--------------
    contrib/py/scripts/addons/io_mesh_xyz/__init__.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-03-22 15:55:26 UTC (rev 3160)
+++ contrib/py/scripts/addons/io_mesh_xyz/__init__.py	2012-03-22 15:58:14 UTC (rev 3161)
@@ -20,7 +20,7 @@
     "name": "XYZ Atomic Blender",
     "description": "Loading and manipulating atoms from XYZ files",
     "author": "Clemens Barth",
-    "version": (0,5),
+    "version": (0,6),
     "blender": (2,6),
     "location": "File -> Import -> XYZ (.xyz), Panel: View 3D - Tools",
     "warning": "",
@@ -31,7 +31,8 @@
     "category": "Import-Export"
 }
 
-
+import os
+import io
 import bpy
 from bpy.types import Operator, Panel
 from bpy_extras.io_utils import ImportHelper
@@ -41,11 +42,10 @@
                        IntProperty,
                        FloatProperty)
 
-
-
 from . import import_xyz
 ATOM_XYZ_ERROR = ""
 ATOM_XYZ_NOTE  = ""
+ATOM_XYZ_PANEL = ""
 
 # -----------------------------------------------------------------------------
 #                                                                           GUI
@@ -54,100 +54,95 @@
 # 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  = "PROPERTIES"
-    #bl_region_type = "WINDOW"
-    #bl_context     = "physics"
-    # This could be also an option ... :
     bl_space_type  = "VIEW_3D"
     bl_region_type = "TOOL_PROPS"
 
     @classmethod
     def poll(self, context):
-        if import_xyz.ATOM_XYZ_FILEPATH == "":
+        global ATOM_XYZ_PANEL
+        
+        if ATOM_XYZ_PANEL == "0" and import_xyz.ATOM_XYZ_FILEPATH == "":
             return False
-        else:
+        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
-        scn    = bpy.context.scene
+        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, "atom_xyz_datafile")
+        col.prop(scn, "datafile")
         col.operator("atom_xyz.datafile_apply")
         row = box.row()
         col = row.column(align=True)
-        col.prop(scn, "atom_xyz_XYZ_file")
+        col.prop(scn, "XYZ_file")
         row = box.row()
-        # TODO, use lanel() instead
-        row.prop(scn, "atom_xyz_number_atoms")
+        row.prop(scn, "number_atoms")
         row = box.row()
         row.operator("atom_xyz.button_distance")
-        row.prop(scn, "atom_xyz_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, "atom_xyz_radius_how")
-
+        row.prop(scn, "radius_how")
         row = box.row()
         row.label(text="1. Change type of radii")
         row = box.row()
-        row.prop(scn, "atom_xyz_radius_type")
-
+        row.prop(scn, "radius_type")
         row = box.row()
         row.label(text="2. Change atom radii in pm")
         row = box.row()
-        row.prop(scn, "atom_xyz_radius_pm_name")
+        row.prop(scn, "radius_pm_name")
         row = box.row()
-        row.prop(scn, "atom_xyz_radius_pm")
-
+        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, "atom_xyz_radius_all")
+        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, "atom_xyz_number_frames")
+        col.prop(scn, "number_frames")
         row = box.row()
         col = row.column()
         col.label(text="Skip frames")
         col = row.column()
-        col.prop(scn, "atom_xyz_skip_frames")
+        col.prop(scn, "skip_frames")
         row = box.row()
         col = row.column()
         col.label(text="Frames/key")
         col = row.column()
-        col.prop(scn, "atom_xyz_images_per_key")        
-        
+        col.prop(scn, "images_per_key")        
         row = box.row()
         row.operator("atom_xyz.load_frames")
         row = box.row()
@@ -158,106 +153,99 @@
         row.operator( "atom_xyz.render")
 
 
-class CLASS_atom_xyz_IO(bpy.types.PropertyGroup):
+class CLASS_atom_xyz_Properties(bpy.types.PropertyGroup):
 
     def Callback_radius_type(self, context):
-        scnn = bpy.context.scene
+        scn = bpy.context.scene.atom_xyz[0]
         import_xyz.DEF_atom_xyz_radius_type(
-                scnn.atom_xyz_radius_type,
-                scnn.atom_xyz_radius_how,
-                )
+                scn.radius_type,
+                scn.radius_how,)
 
     def Callback_radius_pm(self, context):
-        scnn = bpy.context.scene
+        scn = bpy.context.scene.atom_xyz[0]
         import_xyz.DEF_atom_xyz_radius_pm(
-                scnn.atom_xyz_radius_pm_name,
-                scnn.atom_xyz_radius_pm,
-                scnn.atom_xyz_radius_how,
-                )
+                scn.radius_pm_name,
+                scn.radius_pm,
+                scn.radius_how,)
 
     # In the file dialog window
-    scn = bpy.types.Scene
-    scn.use_atom_xyz_cam = BoolProperty(
+    use_camera = BoolProperty(
         name="Camera", default=False,
         description="Do you need a camera?")
-    scn.use_atom_xyz_lamp = BoolProperty(
+    use_lamp = BoolProperty(
         name="Lamp", default=False,
         description = "Do you need a lamp?")
-    scn.use_atom_xyz_mesh = BoolProperty(
+    use_mesh = BoolProperty(
         name = "Mesh balls", default=False,
         description = "Do you want to use mesh balls instead of NURBS?")
-    scn.atom_xyz_mesh_azimuth = IntProperty(
+    mesh_azimuth = IntProperty(
         name = "Azimuth", default=32, min=0,
         description = "Number of sectors (azimuth)")
-    scn.atom_xyz_mesh_zenith = IntProperty(
+    mesh_zenith = IntProperty(
         name = "Zenith", default=32, min=0,
         description = "Number of sectors (zenith)")
-    scn.atom_xyz_scale_ballradius = FloatProperty(
+    scale_ballradius = FloatProperty(
         name = "Balls", default=1.0, min=0.0,
         description = "Scale factor for all atom radii")
-    scn.atom_xyz_scale_distances = FloatProperty (
+    scale_distances = FloatProperty (
         name = "Distances", default=1.0, min=0.0,
         description = "Scale factor for all distances")
-    scn.use_atom_xyz_center = BoolProperty(
+    use_center = BoolProperty(
         name = "Object to origin", default=False,
         description = "Shall the object first put into the global origin "
         "before applying the offsets on the left?")
-    scn.atom_xyz_atomradius = EnumProperty(
+    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
-    scn.atom_xyz_datafile = StringProperty(
+    datafile = StringProperty(
         name = "", description="Path to your custom data file",
         maxlen = 256, default = "", subtype='FILE_PATH')
-    scn.atom_xyz_XYZ_file = StringProperty(
+    XYZ_file = StringProperty(
         name = "Path to file", default="",
         description = "Path of the XYZ file")
-    # TODO, remove this property, its used for display only!
-    scn.atom_xyz_number_atoms = StringProperty(name="",
+    number_atoms = StringProperty(name="",
         default="Number", description = "This output shows "
         "the number of atoms which have been loaded")
-    scn.atom_xyz_distance = StringProperty(
+    distance = StringProperty(
         name="", default="Distance (A)",
         description="Distance of 2 objects in Angstrom")
-    scn.atom_xyz_radius_how = EnumProperty(
+    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',)
-    scn.atom_xyz_radius_type = EnumProperty(
+    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)
-    scn.atom_xyz_radius_pm_name = StringProperty(
+    radius_pm_name = StringProperty(
         name="", default="Atom name",
         description="Put in the name of the atom (e.g. Hydrogen)")
-    scn.atom_xyz_radius_pm = FloatProperty(
+    radius_pm = FloatProperty(
         name="", default=100.0, min=0.0,
         description="Put in the radius of the atom (in pm)",
         update=Callback_radius_pm)
-    scn.atom_xyz_radius_all = FloatProperty(
-        name="Scale", default = 1.05, min=1.0,
+    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
-    scn.atom_xyz_number_frames = StringProperty(
+    number_frames = StringProperty(
         name="", default="0",
         description="This is the total number of frames stored in the xyz file")

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list