From 3c8e1027172ef9a9323b3f9bdb865d1525c2794f Mon Sep 17 00:00:00 2001
From: Clemens Barth <barth@root-1.de>
Date: Thu, 1 Mar 2012 18:47:55 +0000
Subject: [PATCH] Importer ======== The length of the 'unit stick' of the
 dupliface structure that is used for representing the sticks can now be
 explicitly chosen before loading a PDB structure.

It was always on 0.05 Angstrom, which is a quite small value. Loading
structures with lots of sticks was therefore very slow. The value can now be
changed [from 0 to infinity]. I have set the default value onto 0.2 Angstrom,
which should be sufficient.

Note: The smaller the value, the better is the length precision. However, the
more single units need to be drawn (more vertices).

By time, I will change the wiki ... in some days.

Blendphys
---
 io_mesh_pdb/__init__.py   | 13 ++++++++++---
 io_mesh_pdb/import_pdb.py |  4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/io_mesh_pdb/__init__.py b/io_mesh_pdb/__init__.py
index bed41f996..54df08273 100644
--- a/io_mesh_pdb/__init__.py
+++ b/io_mesh_pdb/__init__.py
@@ -113,6 +113,7 @@ class CLASS_atom_pdb_panel(Panel):
         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 = row.column(align=True)        
         col.prop(scn, "use_atom_pdb_sticks_color")        
         col.prop(scn, "use_atom_pdb_sticks_smooth")
@@ -229,6 +230,9 @@ class CLASS_atom_pdb_IO(bpy.types.PropertyGroup):
     scn.atom_pdb_sticks_radius = FloatProperty(
         name = "Radius", default=0.1, min=0.0,
         description ="Radius of a stick")
+    scn.atom_pdb_sticks_unit_length = FloatProperty(
+        name = "Unit", default=0.2, min=0,
+        description = "Length of the unit of a stick in Angstrom")        
     scn.use_atom_pdb_sticks_color = BoolProperty(
         name="Color", default=True,
         description="The sticks appear in the color of the atoms")
@@ -499,6 +503,7 @@ class CLASS_atom_pdb_load_button(Operator):
         sradius    = scn.atom_pdb_sticks_radius
         stick_bond = scn.use_atom_pdb_sticks_bonds
         stick_dist = scn.atom_pdb_sticks_dist
+        stick_unit = scn.atom_pdb_sticks_unit_length
         
         cam        = scn.use_atom_pdb_cam
         lamp       = scn.use_atom_pdb_lamp
@@ -508,7 +513,7 @@ class CLASS_atom_pdb_load_button(Operator):
         # Execute main routine an other time ... from the panel
         atom_number = import_pdb.DEF_atom_pdb_main(
                 mesh, azimuth, zenith, bradius, radiustype, bdistance, 
-                sticks, sticks_col, sticks_sm, stick_bond,
+                sticks, sticks_col, sticks_sm, stick_bond, stick_unit,
                 stick_dist, ssector, sradius, center, cam, lamp, datafile)
         scn.atom_pdb_number_atoms = str(atom_number) + " atoms"
 
@@ -549,9 +554,10 @@ class ImportPDB(Operator, ImportHelper):
         col.prop(scn, "use_atom_pdb_sticks")
         row = layout.row()        
         row.active = scn.use_atom_pdb_sticks
-        col = row.column(align=True)
+        col = row.column()
         col.prop(scn, "atom_pdb_sticks_sectors")
         col.prop(scn, "atom_pdb_sticks_radius")
+        col.prop(scn, "atom_pdb_sticks_unit_length")
         col = row.column(align=True)        
         col.prop(scn, "use_atom_pdb_sticks_color")        
         col.prop(scn, "use_atom_pdb_sticks_smooth")
@@ -590,6 +596,7 @@ class ImportPDB(Operator, ImportHelper):
         sradius    = scn.atom_pdb_sticks_radius
         stick_bond = scn.use_atom_pdb_sticks_bonds
         stick_dist = scn.atom_pdb_sticks_dist
+        stick_unit = scn.atom_pdb_sticks_unit_length
                 
         cam        = scn.use_atom_pdb_cam
         lamp       = scn.use_atom_pdb_lamp
@@ -599,7 +606,7 @@ class ImportPDB(Operator, ImportHelper):
         # Execute main routine
         atom_number = import_pdb.DEF_atom_pdb_main(
                 mesh, azimuth, zenith, bradius, radiustype, bdistance, 
-                sticks, sticks_col, sticks_sm, stick_bond,
+                sticks, sticks_col, sticks_sm, stick_bond, stick_unit,
                 stick_dist, ssector, sradius, center, cam, lamp, datafile)
 
         scn.atom_pdb_number_atoms = str(atom_number) + " atoms"
diff --git a/io_mesh_pdb/import_pdb.py b/io_mesh_pdb/import_pdb.py
index 1c2abe050..9b90d78b0 100644
--- a/io_mesh_pdb/import_pdb.py
+++ b/io_mesh_pdb/import_pdb.py
@@ -567,7 +567,7 @@ def DEF_atom_pdb_custom_datafile(path_datafile):
 def DEF_atom_pdb_main(use_mesh,Ball_azimuth,Ball_zenith,
                Ball_radius_factor,radiustype,Ball_distance_factor,
                use_sticks,use_sticks_color,use_sticks_smooth,
-               use_sticks_bonds,Stick_dist,
+               use_sticks_bonds, Stick_unit, Stick_dist,
                Stick_sectors,Stick_diameter,put_to_center,
                use_camera,use_lamp,path_datafile):
 
@@ -1186,7 +1186,7 @@ def DEF_atom_pdb_main(use_mesh,Ball_azimuth,Ball_zenith,
 
     if use_sticks == True and all_sticks != []:
             
-        dl = 0.05
+        dl = Stick_unit
          
         if use_sticks_color == False:   
             bpy.ops.object.material_slot_add()
-- 
GitLab