[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2646] contrib/py/scripts/addons/ io_import_pdb_atomic_blender.py:

Clemens Barth barth at root-1.de
Wed Nov 23 00:02:57 CET 2011


Revision: 2646
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2646
Author:   blendphys
Date:     2011-11-22 23:02:56 +0000 (Tue, 22 Nov 2011)
Log Message:
-----------


- some minor changes
- use of vectors instead of lists
- 'def Read_atom_for_stick' deleted (now in main routine)

Cheers,

Blendphys.

Modified Paths:
--------------
    contrib/py/scripts/addons/io_import_pdb_atomic_blender.py

Modified: contrib/py/scripts/addons/io_import_pdb_atomic_blender.py
===================================================================
--- contrib/py/scripts/addons/io_import_pdb_atomic_blender.py	2011-11-22 20:31:43 UTC (rev 2645)
+++ contrib/py/scripts/addons/io_import_pdb_atomic_blender.py	2011-11-22 23:02:56 UTC (rev 2646)
@@ -7,7 +7,7 @@
 #
 #  Start of project              : 2011-08-31 by Clemens Barth
 #  First publication in Blender  : 2011-11-11
-#  Last modified                 : 2011-11-21
+#  Last modified                 : 2011-11-22
 #
 #
 # ##### BEGIN GPL LICENSE BLOCK #####
@@ -54,8 +54,8 @@
 import math
 import os
 from mathutils import Vector, Matrix
-from bpy_extras.io_utils import ExportHelper
-from bpy.props import StringProperty, BoolProperty, EnumProperty
+from bpy_extras.io_utils import ImportHelper
+from bpy.props import StringProperty, BoolProperty, EnumProperty, IntProperty, FloatProperty
 
 
 # These are variables, which contain the name of the PDB file and
@@ -185,11 +185,6 @@
 LOADED_STRUCTURES       = []
 LOADED_STRUCTURES_DUPLI = []     
     
-    
-    
-    
-    
-    
 
 # The panel, which is loaded after the file has been
 # chosen via the menu 'File -> Import'
@@ -315,29 +310,29 @@
 
 
 class CLASS_Input_Output(bpy.types.PropertyGroup):
-    bpy.types.Scene.atom_pdb_PDB_filename        = bpy.props.StringProperty(name = "File name", default="", description = "PDB file name")
-    bpy.types.Scene.atom_pdb_PDB_file            = bpy.props.StringProperty(name = "Path to file", default="", description = "Path of the PDB file")
-    bpy.types.Scene.use_atom_pdb_dupliverts      = bpy.props.BoolProperty  (name = "Use dupliverts (Loading much faster)", default=True, description = "Use the dublication method via vertice referencing (Much faster loading!)")    
-    bpy.types.Scene.use_atom_pdb_mesh            = bpy.props.BoolProperty  (name = "Mesh balls", default=False, description = "Do you want to use mesh balls instead of NURBS?")    
-    bpy.types.Scene.atom_pdb_mesh_azimuth        = bpy.props.IntProperty   (name = "Azimuth", default=32, min=0, description = "Number of sectors (azimuth)")
-    bpy.types.Scene.atom_pdb_mesh_zenith         = bpy.props.IntProperty   (name = "Zenith", default=32, min=0, description = "Number of sectors (zenith)")
-    bpy.types.Scene.atom_pdb_scale_ballradius    = bpy.props.FloatProperty (name = "Balls", default=1.0, min=0.0, description = "Scale factor for all atom radii")
-    bpy.types.Scene.atom_pdb_scale_distances     = bpy.props.FloatProperty (name = "Distances", default=1.0, min=0.0, description = "Scale factor for all distances")
-    bpy.types.Scene.use_atom_pdb_center          = bpy.props.BoolProperty  (name = "Object to origin", default=True, description = "Shall the object first put into the global origin before applying the offsets on the left?")    
-    bpy.types.Scene.atom_pdb_offset_x            = bpy.props.FloatProperty (name = "X", default=0.0, description = "Offset in X")
-    bpy.types.Scene.atom_pdb_offset_y            = bpy.props.FloatProperty (name = "Y", default=0.0, description = "Offset in Y")
-    bpy.types.Scene.atom_pdb_offset_z            = bpy.props.FloatProperty (name = "Z", default=0.0, description = "Offset in Z")
-    bpy.types.Scene.use_atom_pdb_sticks          = bpy.props.BoolProperty  (name = "Use sticks", default=False, description = "Do you want to display also the sticks?")    
-    bpy.types.Scene.atom_pdb_sticks_sectors      = bpy.props.IntProperty   (name = "Sector", default = 20, min=0,   description = "Number of sectors of a stick")        
-    bpy.types.Scene.atom_pdb_sticks_radius       = bpy.props.FloatProperty (name = "Radius", default =  0.1, min=0.0, description = "Radius of a stick")  
-    bpy.types.Scene.use_atom_pdb_cam             = bpy.props.BoolProperty  (name = "Camera", default=False, description = "Do you need a camera?")   
-    bpy.types.Scene.use_atom_pdb_lamp            = bpy.props.BoolProperty  (name = "Lamp", default=False, description = "Do you need a lamp?")
-    bpy.types.Scene.atom_pdb_number_atoms        = bpy.props.StringProperty(name = "", default="Number", description = "This output shows the number of atoms which have been loaded")
-    bpy.types.Scene.atom_pdb_distance            = bpy.props.StringProperty(name = "", default="Distance (Angstrom)", description = "Distance of 2 objects in Angstrom")  
-    bpy.types.Scene.atom_pdb_mod_atomname        = bpy.props.StringProperty(name = "", default = "Atom name", description="Put in the name of the atom (e.g. Hydrogen)")
-    bpy.types.Scene.atom_pdb_mod_pm_radius       = bpy.props.FloatProperty (name = "", default = 100.0, min=0.0, description="Put in the radius of the atom (in pm)")
-    bpy.types.Scene.atom_pdb_mod_rel_radius      = bpy.props.FloatProperty (name = "", default = 1.05, min=1.0, description="Put in the scale factor")
-    bpy.types.Scene.atom_pdb_mod_all_radii       = bpy.props.FloatProperty (name = "Scale", default = 1.05, min=1.0, description="Put in the scale factor")
+    bpy.types.Scene.atom_pdb_PDB_filename        = StringProperty(name = "File name", default="", description = "PDB file name")
+    bpy.types.Scene.atom_pdb_PDB_file            = StringProperty(name = "Path to file", default="", description = "Path of the PDB file")
+    bpy.types.Scene.use_atom_pdb_dupliverts      = BoolProperty  (name = "Use dupliverts (much faster)", default=True, description = "Use the dublication method via vertice referencing (Much faster loading!)")    
+    bpy.types.Scene.use_atom_pdb_mesh            = BoolProperty  (name = "Mesh balls", default=False, description = "Do you want to use mesh balls instead of NURBS?")    
+    bpy.types.Scene.atom_pdb_mesh_azimuth        = IntProperty   (name = "Azimuth", default=32, min=0, description = "Number of sectors (azimuth)")
+    bpy.types.Scene.atom_pdb_mesh_zenith         = IntProperty   (name = "Zenith", default=32, min=0, description = "Number of sectors (zenith)")
+    bpy.types.Scene.atom_pdb_scale_ballradius    = FloatProperty (name = "Balls", default=1.0, min=0.0, description = "Scale factor for all atom radii")
+    bpy.types.Scene.atom_pdb_scale_distances     = FloatProperty (name = "Distances", default=1.0, min=0.0, description = "Scale factor for all distances")
+    bpy.types.Scene.use_atom_pdb_center          = BoolProperty  (name = "Object to origin", default=True, description = "Shall the object first put into the global origin before applying the offsets on the left?")    
+    bpy.types.Scene.atom_pdb_offset_x            = FloatProperty (name = "X", default=0.0, description = "Offset in X")
+    bpy.types.Scene.atom_pdb_offset_y            = FloatProperty (name = "Y", default=0.0, description = "Offset in Y")
+    bpy.types.Scene.atom_pdb_offset_z            = FloatProperty (name = "Z", default=0.0, description = "Offset in Z")
+    bpy.types.Scene.use_atom_pdb_sticks          = BoolProperty  (name = "Use sticks", default=False, description = "Do you want to display also the sticks?")    
+    bpy.types.Scene.atom_pdb_sticks_sectors      = IntProperty   (name = "Sector", default = 20, min=0,   description = "Number of sectors of a stick")        
+    bpy.types.Scene.atom_pdb_sticks_radius       = FloatProperty (name = "Radius", default =  0.1, min=0.0, description = "Radius of a stick")  
+    bpy.types.Scene.use_atom_pdb_cam             = BoolProperty  (name = "Camera", default=False, description = "Do you need a camera?")   
+    bpy.types.Scene.use_atom_pdb_lamp            = BoolProperty  (name = "Lamp", default=False, description = "Do you need a lamp?")
+    bpy.types.Scene.atom_pdb_number_atoms        = StringProperty(name = "", default="Number", description = "This output shows the number of atoms which have been loaded")
+    bpy.types.Scene.atom_pdb_distance            = StringProperty(name = "", default="Distance (Angstrom)", description = "Distance of 2 objects in Angstrom")  
+    bpy.types.Scene.atom_pdb_mod_atomname        = StringProperty(name = "", default = "Atom name", description="Put in the name of the atom (e.g. Hydrogen)")
+    bpy.types.Scene.atom_pdb_mod_pm_radius       = FloatProperty (name = "", default = 100.0, min=0.0, description="Put in the radius of the atom (in pm)")
+    bpy.types.Scene.atom_pdb_mod_rel_radius      = FloatProperty (name = "", default = 1.05, min=1.0, description="Put in the scale factor")
+    bpy.types.Scene.atom_pdb_mod_all_radii       = FloatProperty (name = "Scale", default = 1.05, min=1.0, description="Put in the scale factor")
 
 
 # Button for measuring the distance of the active objects
@@ -350,7 +345,7 @@
         scn    = bpy.context.scene
         dist   = Measure_distance_in_scene()
 
-        if dist != "-1.0":
+        if dist != "N.A.":
            # The string length is cut, 3 digits after the first 3 digits 
            # after the '.'. Append also "Angstrom". 
            # Remember: 1 Angstrom = 10^(-10) m 
@@ -437,25 +432,23 @@
         bradius    = scn.atom_pdb_scale_ballradius
         bdistance  = scn.atom_pdb_scale_distances
         center     = scn.use_atom_pdb_center 
-        x          = scn.atom_pdb_offset_x
-        y          = scn.atom_pdb_offset_y
-        z          = scn.atom_pdb_offset_z
-        yn         = scn.use_atom_pdb_sticks 
+        offset_vec = Vector((scn.atom_pdb_offset_x,scn.atom_pdb_offset_y,scn.atom_pdb_offset_z))
+        sticks     = scn.use_atom_pdb_sticks 
         ssector    = scn.atom_pdb_sticks_sectors
         sradius    = scn.atom_pdb_sticks_radius
         cam        = scn.use_atom_pdb_cam 
         lamp       = scn.use_atom_pdb_lamp
         mesh       = scn.use_atom_pdb_mesh 
         dupliverts = scn.use_atom_pdb_dupliverts
-        
-        atom_number               = Draw_scene(dupliverts,mesh,azimuth,zenith,bradius,bdistance,x,y,z,yn,ssector,sradius,center,cam,lamp)
+              
+        atom_number               = Draw_scene(dupliverts,mesh,azimuth,zenith,bradius,bdistance,offset_vec,sticks,ssector,sradius,center,cam,lamp)
         scn.atom_pdb_number_atoms = str(atom_number)
 
         return {'FINISHED'}
 
 
 # This is the class for the file dialog.
-class CLASS_LoadPDB(bpy.types.Operator, ExportHelper):
+class CLASS_LoadPDB(bpy.types.Operator, ImportHelper):

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list