[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4447] trunk/py/scripts/addons/ io_mesh_pdb: 1. After importing a structure, the sticks were not selected: fixed

Clemens Barth barth at root-1.de
Thu Apr 4 19:21:55 CEST 2013


Revision: 4447
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4447
Author:   blendphys
Date:     2013-04-04 17:21:55 +0000 (Thu, 04 Apr 2013)
Log Message:
-----------
1. After importing a structure, the sticks were not selected: fixed
 
2. Small cleanups of the code

3. New feature: The sticks can be represented as entire cylinders. One can 
choose either single cylinders, which are parented to an empty, or one single
mesh object including all sticks. 
This feature is quite suitable for structures, which count more than 1000 
sticks. When the sticks are represented by one single mesh object the
handling in the 3D scene is much faster.
Note that the layout of the preferences in the file dialog had to be also 
changed since there are more options for sticks now.
 
Blendphys.

Modified Paths:
--------------
    trunk/py/scripts/addons/io_mesh_pdb/__init__.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	2013-04-04 07:01:01 UTC (rev 4446)
+++ trunk/py/scripts/addons/io_mesh_pdb/__init__.py	2013-04-04 17:21:55 UTC (rev 4447)
@@ -24,21 +24,23 @@
 #
 #  Start of project              : 2011-08-31 by Clemens Barth
 #  First publication in Blender  : 2011-11-11
-#  Last modified                 : 2013-03-22
+#  Last modified                 : 2013-04-04
 #
 #  Acknowledgements 
 #  ================
-#
 #  Blender: ideasman, meta_androcto, truman, kilon, CoDEmanX, dairin0d, PKHG, 
 #           Valter, ...
-#  Other: Frank Palmino
+#  Other  : Frank Palmino
 #
+#
+#  To do: 1. Sticks in normal representation: options bonds and colors
+#
 
 bl_info = {
     "name": "Atomic Blender - PDB",
     "description": "Loading and manipulating atoms from PDB files",
     "author": "Clemens Barth",
-    "version": (1, 6),
+    "version": (1, 7),
     "blender": (2, 60, 0),
     "location": "File -> Import -> PDB (.pdb)",
     "warning": "",
@@ -73,6 +75,9 @@
     filename_ext = ".pdb"
     filter_glob  = StringProperty(default="*.pdb", options={'HIDDEN'},)
 
+    use_center = BoolProperty(
+        name = "Object to origin", default=True,
+        description = "Put the object into the global origin")  
     use_camera = BoolProperty(
         name="Camera", default=False,
         description="Do you need a camera?")
@@ -99,7 +104,7 @@
         name = "Distances", default=1.0, min=0.0001,
         description = "Scale factor for all distances")
     atomradius = EnumProperty(
-        name="Type of radius",
+        name="Type",
         description="Choose type of atom radius",
         items=(('0', "Pre-defined", "Use pre-defined radius"),
                ('1', "Atomic", "Use atomic radius"),
@@ -107,10 +112,14 @@
                default='0',)        
     use_sticks = BoolProperty(
         name="Use sticks", default=True,
-        description="Do you want to display the sticks?")       
-    use_sticks_skin = BoolProperty(
-        name="Use skin modifier", default=False,
-        description="Do you want to display the sticks with the skin modifier?")    
+        description="Do you want to display the sticks?")     
+    use_sticks_type = EnumProperty(
+        name="Type",
+        description="Choose type of stick",
+        items=(('0', "Dupliverts", "Use dupliverts structures"),
+               ('1', "Skin", "Use skin and subdivision modifier"),
+               ('2', "Normal", "Use simple cylinders")),
+               default='0',)   
     sticks_subdiv_view  = IntProperty(
         name = "SubDivV", default=2, min=1,
         description="Number of subdivisions (view)")        
@@ -136,11 +145,14 @@
         name="Bonds", default=False,
         description="Show double and tripple bonds.")
     sticks_dist = FloatProperty(
-        name="Distance", default = 1.1, min=1.0, max=3.0,
-        description="Distance between sticks measured in stick diameter")        
-    use_center = BoolProperty(
-        name = "Object to origin", default=True,
-        description = "Put the object into the global origin")           
+        name="", default = 1.1, min=1.0, max=3.0,
+        description="Distance between sticks measured in stick diameter")         
+    use_sticks_one_object = BoolProperty(
+        name="One object", default=True,
+        description="All sticks are one object.")     
+    use_sticks_one_object_nr = IntProperty(
+        name = "No.", default=200, min=10,
+        description="Number of sticks to be grouped at once")                 
     datafile = StringProperty(
         name = "", description="Path to your custom data file",
         maxlen = 256, default = "", subtype='FILE_PATH')
@@ -151,58 +163,71 @@
         row.prop(self, "use_camera")
         row.prop(self, "use_lamp")
         row = layout.row()
-        row.prop(self, "use_center")        
-        row = layout.row()
+        row.prop(self, "use_center")     
+        # Balls
+        box = layout.box()   
+        row = box.row() 
+        row.label(text="Balls / atoms")        
+        row = box.row()
         col = row.column()
         col.prop(self, "ball")
-        row = layout.row()
+        row = box.row()
         row.active = (self.ball == "1")
         col = row.column(align=True)             
         col.prop(self, "mesh_azimuth")
         col.prop(self, "mesh_zenith")
-        row = layout.row()
+        row = box.row()
         col = row.column()
         col.label(text="Scaling factors")
         col = row.column(align=True)
         col.prop(self, "scale_ballradius")
         col.prop(self, "scale_distances")
-        row = layout.row()
+        row = box.row()
         row.prop(self, "atomradius")
-        row = layout.row()
-        # Sticks        
+        # Sticks     
+        box = layout.box()    
+        row = box.row() 
+        row.label(text="Sticks / bonds")
+        row = box.row()  
         row.prop(self, "use_sticks")
-        row = layout.row()
+        row = box.row()
         row.active = self.use_sticks                
-        row.prop(self, "use_sticks_skin")
-        row = layout.row()        
+        row.prop(self, "use_sticks_type")
+        row = box.row()        
         row.active = self.use_sticks
         col = row.column()
-        if not self.use_sticks_skin: 
+        if self.use_sticks_type == '0' or self.use_sticks_type == '2': 
             col.prop(self, "sticks_sectors")
         col.prop(self, "sticks_radius")
-        if self.use_sticks_skin: 
-            row = layout.row()        
+        if self.use_sticks_type == '1': 
+            row = box.row()        
             row.active = self.use_sticks
             row.prop(self, "sticks_subdiv_view")
             row.prop(self, "sticks_subdiv_render")
-            row = layout.row()        
+            row = box.row()        
             row.active = self.use_sticks            
-        if not self.use_sticks_skin: 
+        if self.use_sticks_type == '0': 
             col.prop(self, "sticks_unit_length")
         col = row.column(align=True)    
-        if not self.use_sticks_skin: 
+        if self.use_sticks_type == '0': 
             col.prop(self, "use_sticks_color")        
         col.prop(self, "use_sticks_smooth")
-        if not self.use_sticks_skin:
+        if self.use_sticks_type == '0' or self.use_sticks_type == '2':
             col.prop(self, "use_sticks_bonds")
-        row = layout.row()        
-        row.active = self.use_sticks
-        col = row.column(align=True)
-        col = row.column(align=True)
-        col.active = self.use_sticks
-        if not self.use_sticks_skin: 
-            col.prop(self, "sticks_dist")
-
+        row = box.row()        
+        if self.use_sticks_type == '0': 
+            row.active = self.use_sticks and self.use_sticks_bonds
+            row.label(text="Distance")
+            row.prop(self, "sticks_dist")
+        if self.use_sticks_type == '2':
+            row.active = self.use_sticks      
+            col = row.column()    
+            col.prop(self, "use_sticks_one_object")
+            col = row.column()
+            col.active = self.use_sticks_one_object
+            col.prop(self, "use_sticks_one_object_nr")
+            
+            
     def execute(self, context):
         # This is in order to solve this strange 'relative path' thing.
         filepath_pdb = bpy.path.abspath(self.filepath)
@@ -216,12 +241,14 @@
                       self.atomradius,
                       self.scale_distances,
                       self.use_sticks,
-                      self.use_sticks_skin,
+                      self.use_sticks_type,
                       self.sticks_subdiv_view,
                       self.sticks_subdiv_render,
                       self.use_sticks_color,
                       self.use_sticks_smooth,
                       self.use_sticks_bonds,
+                      self.use_sticks_one_object,
+                      self.use_sticks_one_object_nr,
                       self.sticks_unit_length,
                       self.sticks_dist,
                       self.sticks_sectors,

Modified: trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py	2013-04-04 07:01:01 UTC (rev 4446)
+++ trunk/py/scripts/addons/io_mesh_pdb/import_pdb.py	2013-04-04 17:21:55 UTC (rev 4447)
@@ -690,154 +690,11 @@
     return new_atom_mesh
 
 
-# Function, which draws the sticks with help of the skin and subdivision
-# modifiers.
-def draw_sticks_skin(all_atoms, 
-                     all_sticks,
-                     Stick_diameter,
-                     use_sticks_smooth,
-                     sticks_subdiv_view,
-                     sticks_subdiv_render):
-
-    # These counters are for the edges, in the shape [i,i+1]. 
-    i = 0
-    
-    # This is the list of vertices, containing the atom position 
-    # (vectors)).
-    stick_vertices = []
-    # This is the 'same' list, which contains not vector position of
-    # the atoms but their numbers. It is used to handle the edges.
-    stick_vertices_nr = []
-    # This is the list of edges.
-    stick_edges = []
-    
-    # Go through the list of all sticks. For each stick do:
-    for stick in all_sticks:
-                
-        # Each stick has two atoms = two vertices.        
-                
-        """
-        [ 0,1 ,  3,4 ,  0,8 ,  7,3]
-        [[0,1], [2,3], [4,5], [6,7]]
-        
-        [ 0,1 ,  3,4 ,  x,8 ,   7,x]    x:deleted
-        [[0,1], [2,3], [0,5], [6,2]]
-        """
-    
-        # Check, if the vertex (atom) is already in the vertex list.
-        # edge: [s1,s2]
-        FLAG_s1 = False                           
-        s1 = 0
-        for stick2 in stick_vertices_nr: 
-            if stick2 == stick.atom1-1: 
-                FLAG_s1 = True
-                break
-            s1 += 1
-        FLAG_s2 = False
-        s2 = 0
-        for stick2 in stick_vertices_nr: 
-            if stick2 == stick.atom2-1:
-                FLAG_s2 = True 
-                break
-            s2 += 1
-
-        # If the vertex (atom) is not yet in the vertex list:
-        # append the number of atom and the vertex to the two lists.
-        # For the first atom:
-        if FLAG_s1 == False:

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list