[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3152] trunk/py/scripts/addons/ io_mesh_pdb:

Clemens Barth barth at root-1.de
Wed Mar 21 22:50:24 CET 2012


Revision: 3152
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3152
Author:   blendphys
Date:     2012-03-21 21:50:24 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------

Attention: big changes in __init__.py, almost no changes in import_pdb.py
and export_pdb.py

1. With respect to the propositions made by Campbell and Sebastian
(see http://projects.blender.org/tracker/?func=detail&group_id=153&aid=29226&atid=469)
I changed the code. The PDB IO has now the preset option in the file dialog
of the importer and exporter.

2. Furthermore, I have put all properties into one group, which is located
in bpy.contect.scene. 

3. Some code cleaning

Soon, I will put in a new option (next days): the user can decide whether the 
panel is always, once or never shown after a PDB file is loaded. Note that
the panel is essential for me and also my students. It helps quickly modifying
PDB structures.

Blendphys 

Modified Paths:
--------------
    trunk/py/scripts/addons/io_mesh_pdb/__init__.py
    trunk/py/scripts/addons/io_mesh_pdb/export_pdb.py
    trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py

Modified: trunk/py/scripts/addons/io_mesh_pdb/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_pdb/__init__.py	2012-03-21 21:44:55 UTC (rev 3151)
+++ trunk/py/scripts/addons/io_mesh_pdb/__init__.py	2012-03-21 21:50:24 UTC (rev 3152)
@@ -71,94 +71,89 @@
 
     def draw(self, context):
         layout = self.layout
-        scn    = bpy.context.scene
+        scn    = context.scene.atom_pdb[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_pdb_datafile")
+        col.prop(scn, "datafile")
         col.operator("atom_pdb.datafile_apply")
         row = box.row()
         col = row.column(align=True)
-        col.prop(scn, "atom_pdb_PDB_file")
-
+        col.prop(scn, "PDB_file")
         row = layout.row()
         row.label(text="Reload structure")
-
         box = layout.box()
         row = box.row()
         col = row.column()
-        col.prop(scn, "use_atom_pdb_mesh")
+        col.prop(scn, "use_mesh")
         col = row.column()
         col.label(text="Scaling factors")
         row = box.row()
         col = row.column(align=True)  
-        col.active = scn.use_atom_pdb_mesh   
-        col.prop(scn, "atom_pdb_mesh_azimuth")
-        col.prop(scn, "atom_pdb_mesh_zenith")
+        col.active = scn.use_mesh   
+        col.prop(scn, "mesh_azimuth")
+        col.prop(scn, "mesh_zenith")
         col = row.column(align=True)
-        col.prop(scn, "atom_pdb_scale_ballradius")
-        col.prop(scn, "atom_pdb_scale_distances")
+        col.prop(scn, "scale_ballradius")
+        col.prop(scn, "scale_distances")
         row = box.row()
         col = row.column()  
-        col.prop(scn, "use_atom_pdb_sticks")
+        col.prop(scn, "use_sticks")
         row = box.row()        
-        row.active = scn.use_atom_pdb_sticks
+        row.active = scn.use_sticks
         col = row.column(align=True)
-        col.prop(scn, "atom_pdb_sticks_sectors")
-        col.prop(scn, "atom_pdb_sticks_radius")
-        col.prop(scn, "atom_pdb_sticks_unit_length")
+        col.prop(scn, "sticks_sectors")
+        col.prop(scn, "sticks_radius")
+        col.prop(scn, "sticks_unit_length")
         col = row.column(align=True)        
-        col.prop(scn, "use_atom_pdb_sticks_color")        
-        col.prop(scn, "use_atom_pdb_sticks_smooth")
-        col.prop(scn, "use_atom_pdb_sticks_bonds")
+        col.prop(scn, "use_sticks_color")        
+        col.prop(scn, "use_sticks_smooth")
+        col.prop(scn, "use_sticks_bonds")
         row = box.row()        
-        row.active = scn.use_atom_pdb_sticks
+        row.active = scn.use_sticks
         col = row.column(align=True)
         col = row.column(align=True)
-        col.active = scn.use_atom_pdb_sticks and scn.use_atom_pdb_sticks_bonds 
-        col.prop(scn, "atom_pdb_sticks_dist")        
+        col.active = scn.use_sticks and scn.use_sticks_bonds 
+        col.prop(scn, "sticks_dist")        
         row = box.row()
-        row.prop(scn, "use_atom_pdb_center")
+        row.prop(scn, "use_center")
         row = box.row()
         col = row.column()
-        col.prop(scn, "use_atom_pdb_cam")
-        col.prop(scn, "use_atom_pdb_lamp")
+        col.prop(scn, "use_camera")
+        col.prop(scn, "use_lamp")
         col = row.column()
         col.operator("atom_pdb.button_reload")
-        col.prop(scn, "atom_pdb_number_atoms")
+        col.prop(scn, "number_atoms")
         row = box.row()
         row.operator("atom_pdb.button_distance")
-        row.prop(scn, "atom_pdb_distance")
-
+        row.prop(scn, "distance")
         row = layout.row()
         row.label(text="Modify atom radii")
-        
         box = layout.box()
         row = box.row()
         row.label(text="All changes concern:")
         row = box.row()
-        row.prop(scn, "atom_pdb_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_pdb_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_pdb_radius_pm_name")
+        row.prop(scn, "radius_pm_name")
         row = box.row()
-        row.prop(scn, "atom_pdb_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_pdb_radius_all")
+        col.prop(scn, "radius_all")
         col = row.column(align=True)
         col.operator( "atom_pdb.radius_all_bigger" )
         col.operator( "atom_pdb.radius_all_smaller" )
@@ -177,124 +172,114 @@
             row.operator( "atom_pdb.separate_atom" )
 
 
-class CLASS_atom_pdb_IO(bpy.types.PropertyGroup):
+# The properties (gadgets) in the panel. They all go to scene
+# during initialization (see end) 
+class CLASS_atom_pdb_Properties(bpy.types.PropertyGroup):
 
     def Callback_radius_type(self, context):
-        scnn = bpy.context.scene
+        scn = bpy.context.scene.atom_pdb[0]
         import_pdb.DEF_atom_pdb_radius_type(
-                scnn.atom_pdb_radius_type,
-                scnn.atom_pdb_radius_how,
-                )
+                scn.radius_type,
+                scn.radius_how,)
 
     def Callback_radius_pm(self, context):
-        scnn = bpy.context.scene
+        scn = bpy.context.scene.atom_pdb[0]
         import_pdb.DEF_atom_pdb_radius_pm(
-                scnn.atom_pdb_radius_pm_name,
-                scnn.atom_pdb_radius_pm,
-                scnn.atom_pdb_radius_how,
-                )
+                scn.radius_pm_name,
+                scn.radius_pm,
+                scn.radius_how,)
 
     # In the file dialog window - Import
-    scn = bpy.types.Scene
-    scn.use_atom_pdb_cam = BoolProperty(
+    use_camera = BoolProperty(
         name="Camera", default=False,
         description="Do you need a camera?")
-    scn.use_atom_pdb_lamp = BoolProperty(
+    use_lamp = BoolProperty(
         name="Lamp", default=False,
         description = "Do you need a lamp?")
-    scn.use_atom_pdb_mesh = BoolProperty(
+    use_mesh = BoolProperty(
         name = "Mesh balls", default=False,
         description = "Use mesh balls instead of NURBS")
-    scn.atom_pdb_mesh_azimuth = IntProperty(
-        name = "Azimuth", default=32, min=0,
+    mesh_azimuth = IntProperty(
+        name = "Azimuth", default=32, min=1,
         description = "Number of sectors (azimuth)")
-    scn.atom_pdb_mesh_zenith = IntProperty(
-        name = "Zenith", default=32, min=0,
+    mesh_zenith = IntProperty(
+        name = "Zenith", default=32, min=1,
         description = "Number of sectors (zenith)")
-    scn.atom_pdb_scale_ballradius = FloatProperty(
-        name = "Balls", default=1.0, min=0.0,
+    scale_ballradius = FloatProperty(
+        name = "Balls", default=1.0, min=0.0001,
         description = "Scale factor for all atom radii")
-    scn.atom_pdb_scale_distances = FloatProperty (
-        name = "Distances", default=1.0, min=0.0,
+    scale_distances = FloatProperty (
+        name = "Distances", default=1.0, min=0.0001,
         description = "Scale factor for all distances")
-    scn.use_atom_pdb_center = BoolProperty(
+    use_center = BoolProperty(
         name = "Object to origin", default=True,
         description = "Put the object into the global origin")
-    scn.use_atom_pdb_sticks = BoolProperty(
+    use_sticks = BoolProperty(
         name="Use sticks", default=True,
         description="Do you want to display the sticks?")
-    scn.atom_pdb_sticks_sectors = IntProperty(
-        name = "Sector", default=20, min=0,
+    sticks_sectors = IntProperty(
+        name = "Sector", default=20, min=1,
         description="Number of sectors of a stick")
-    scn.atom_pdb_sticks_radius = FloatProperty(
-        name = "Radius", default=0.1, min=0.0,
+    sticks_radius = FloatProperty(
+        name = "Radius", default=0.1, min=0.0001,
         description ="Radius of a stick")
-    scn.atom_pdb_sticks_unit_length = FloatProperty(
-        name = "Unit", default=0.2, min=0,
+    sticks_unit_length = FloatProperty(
+        name = "Unit", default=0.2, min=0.0001,
         description = "Length of the unit of a stick in Angstrom")        
-    scn.use_atom_pdb_sticks_color = BoolProperty(
+    use_sticks_color = BoolProperty(
         name="Color", default=True,
         description="The sticks appear in the color of the atoms")
-    scn.use_atom_pdb_sticks_smooth = BoolProperty(
+    use_sticks_smooth = BoolProperty(
         name="Smooth", default=False,
         description="The sticks are round (sectors are not visible)")     
-    scn.use_atom_pdb_sticks_bonds = BoolProperty(
+    use_sticks_bonds = BoolProperty(
         name="Bonds", default=False,
         description="Show double and tripple bonds.")
-    scn.atom_pdb_sticks_dist = FloatProperty(
+    sticks_dist = FloatProperty(
         name="Distance", default = 1.1, min=1.0, max=3.0,
         description="Distance between sticks measured in stick diameter")        
-    scn.atom_pdb_atomradius = EnumProperty(
+    atomradius = EnumProperty(
         name="Type of radius",
         description="Choose type of atom radius",
         items=(('0', "Pre-defined", "Use pre-defined radius"),
                ('1', "Atomic", "Use atomic radius"),
                ('2', "van der Waals", "Use van der Waals radius")),
-               default='0',)
-
-    # In the file dialog window - Export
-    scn.atom_pdb_export_type = EnumProperty(
-        name="Type of Objects",
-        description="Choose type of objects",
-        items=(('0', "All", "Export all active objects"),
-               ('1', "Elements", "Export only those active objects which have a proper element name")),
-               default='1',)    
-    
+               default='0',)  
     # In the panel
-    scn.atom_pdb_datafile = StringProperty(
+    datafile = StringProperty(
         name = "", description="Path to your custom data file",
         maxlen = 256, default = "", subtype='FILE_PATH')
-    scn.atom_pdb_PDB_file = StringProperty(

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list