[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2702] contrib/py/scripts/addons/ io_mesh_pdb: split into 2 files, correct details next
Campbell Barton
ideasman42 at gmail.com
Thu Dec 1 20:55:33 CET 2011
Revision: 2702
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2702
Author: campbellbarton
Date: 2011-12-01 19:55:32 +0000 (Thu, 01 Dec 2011)
Log Message:
-----------
split into 2 files, correct details next
Modified Paths:
--------------
contrib/py/scripts/addons/io_mesh_pdb/import_pdb.py
Added Paths:
-----------
contrib/py/scripts/addons/io_mesh_pdb/__init__.py
Added: contrib/py/scripts/addons/io_mesh_pdb/__init__.py
===================================================================
--- contrib/py/scripts/addons/io_mesh_pdb/__init__.py (rev 0)
+++ contrib/py/scripts/addons/io_mesh_pdb/__init__.py 2011-12-01 19:55:32 UTC (rev 2702)
@@ -0,0 +1,589 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+bl_info = {
+ "name": "PDB Atomic Blender",
+ "description": "Loading and manipulating atoms from PDB files",
+ "author": "Clemens Barth",
+ "version": (0,9),
+ "blender": (2,6),
+ "api": 31236,
+ "location": "File -> Import -> PDB (.pdb), Panel: View 3D - Tools",
+ "warning": "",
+ "wiki_url": "http://development.root-1.de/Atomic_Blender.php",
+ "tracker_url": "http://projects.blender.org/tracker/"
+ "index.php?func=detail&aid=29226&group_id=153&atid=468",
+ "category": "Import-Export"
+}
+
+
+import bpy
+from bpy_extras.io_utils import ImportHelper
+from bpy.props import (StringProperty,
+ BoolProperty,
+ EnumProperty,
+ IntProperty,
+ FloatProperty)
+
+
+# -----------------------------------------------------------------------------
+# GUI
+
+# The panel, which is loaded after the file has been
+# chosen via the menu 'File -> Import'
+class CLASS_atom_pdb_panel(bpy.types.Panel):
+ bl_label = ATOM_PDB_PANELNAME
+ #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"
+
+ # This 'poll thing' has taken 3 hours of a hard search and understanding.
+ # I explain it in the following from my point of view:
+ #
+ # Before this class is entirely treaten (here: drawing the panel) the
+ # poll method is called first. Basically, some conditions are
+ # checked before other things in the class are done afterwards. If a
+ # condition is not valid, one returns 'False' such that nothing further
+ # is done. 'True' means: 'Go on'
+ #
+ # In the case here, it is verified if the ATOM_PDB_FILEPATH variable contains
+ # a name. If not - and this is the case directly after having started the
+ # script - the panel does not appear because 'False' is returned. However,
+ # as soon as a file has been chosen, the panel appears because
+ # ATOM_PDB_FILEPATH contains a name.
+ #
+ # Please, correct me if I'm wrong.
+ @classmethod
+ def poll(self, context):
+ if ATOM_PDB_FILEPATH == "":
+ return False
+ else:
+ return True
+
+ def draw(self, context):
+ layout = self.layout
+ scn = bpy.context.scene
+
+ row = layout.row()
+ row.label(text="Custom data file")
+ row = layout.row()
+ col = row.column()
+ col.prop(scn, "atom_pdb_datafile")
+ col.operator("atom_pdb.datafile_apply")
+ row = layout.row()
+ col = row.column(align=True)
+ col.prop(scn, "atom_pdb_PDB_filename")
+ col.prop(scn, "atom_pdb_PDB_file")
+
+ layout.separator()
+
+ row = layout.row()
+ col = row.column(align=True)
+ col.prop(scn, "use_atom_pdb_mesh")
+ col.prop(scn, "atom_pdb_mesh_azimuth")
+ col.prop(scn, "atom_pdb_mesh_zenith")
+
+
+ col = row.column(align=True)
+ col.label(text="Scaling factors")
+ col.prop(scn, "atom_pdb_scale_ballradius")
+ col.prop(scn, "atom_pdb_scale_distances")
+ row = layout.row()
+ col = row.column()
+ col.prop(scn, "use_atom_pdb_sticks")
+ col = row.column(align=True)
+ col.prop(scn, "atom_pdb_sticks_sectors")
+ col.prop(scn, "atom_pdb_sticks_radius")
+
+ row = layout.row()
+ row.prop(scn, "use_atom_pdb_center")
+
+ row = layout.row()
+ col = row.column()
+ col.prop(scn, "use_atom_pdb_cam")
+ col.prop(scn, "use_atom_pdb_lamp")
+ col = row.column()
+ col.operator("atom_pdb.button_reload")
+ col.prop(scn, "atom_pdb_number_atoms")
+ layout.separator()
+
+ row = layout.row()
+ row.operator("atom_pdb.button_distance")
+ row.prop(scn, "atom_pdb_distance")
+ layout.separator()
+
+ row = layout.row()
+ row.label(text="All changes concern:")
+ row = layout.row()
+ row.prop(scn, "atom_pdb_radius_how")
+
+ row = layout.row()
+ row.label(text="1. Change type of radii")
+ row = layout.row()
+ row.prop(scn, "atom_pdb_radius_type")
+
+ row = layout.row()
+ row.label(text="2. Change atom radii in pm")
+ row = layout.row()
+ row.prop(scn, "atom_pdb_radius_pm_name")
+ row = layout.row()
+ row.prop(scn, "atom_pdb_radius_pm")
+
+ row = layout.row()
+ row.label(text="3. Change atom radii by scale")
+ row = layout.row()
+ col = row.column()
+ col.prop(scn, "atom_pdb_radius_all")
+ col = row.column(align=True)
+ col.operator( "atom_pdb.radius_all_bigger" )
+ col.operator( "atom_pdb.radius_all_smaller" )
+
+ if bpy.context.mode == 'EDIT_MESH':
+
+ layout.separator()
+ row = layout.row()
+ row.operator( "atom_pdb.separate_atom" )
+
+
+class CLASS_atom_pdb_IO(bpy.types.PropertyGroup):
+
+ def Callback_radius_type(self, context):
+ scnn = bpy.context.scene
+ DEF_atom_pdb_radius_type(scnn.atom_pdb_radius_type,
+ scnn.atom_pdb_radius_how)
+
+ def Callback_radius_pm(self, context):
+ scnn = bpy.context.scene
+ DEF_atom_pdb_radius_pm(scnn.atom_pdb_radius_pm_name,
+ scnn.atom_pdb_radius_pm,
+ scnn.atom_pdb_radius_how)
+
+ # In the file dialog window
+ scn = bpy.types.Scene
+ scn.use_atom_pdb_cam = BoolProperty(
+ name="Camera", default=False,
+ description="Do you need a camera?")
+ scn.use_atom_pdb_lamp = BoolProperty(
+ name="Lamp", default=False,
+ description = "Do you need a lamp?")
+ scn.use_atom_pdb_mesh = BoolProperty(
+ name = "Mesh balls", default=False,
+ description = "Do you want to use mesh balls instead of NURBS?")
+ scn.atom_pdb_mesh_azimuth = IntProperty(
+ name = "Azimuth", default=32, min=0,
+ description = "Number of sectors (azimuth)")
+ scn.atom_pdb_mesh_zenith = IntProperty(
+ name = "Zenith", default=32, min=0,
+ description = "Number of sectors (zenith)")
+ scn.atom_pdb_scale_ballradius = FloatProperty(
+ name = "Balls", default=1.0, min=0.0,
+ description = "Scale factor for all atom radii")
+ scn.atom_pdb_scale_distances = FloatProperty (
+ name = "Distances", default=1.0, min=0.0,
+ description = "Scale factor for all distances")
+ scn.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?")
+ scn.use_atom_pdb_sticks = BoolProperty(
+ name="Use sticks", default=False,
+ description="Do you want to display also the sticks?")
+ scn.atom_pdb_sticks_sectors = IntProperty(
+ name = "Sector", default=20, min=0,
+ description="Number of sectors of a stick")
+ scn.atom_pdb_sticks_radius = FloatProperty(
+ name = "Radius", default=0.1, min=0.0,
+ description ="Radius of a stick")
+ scn.atom_pdb_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 panel
+ scn.atom_pdb_datafile = StringProperty(
+ name = "", description="Path to your custom data file",
+ maxlen = 256, default = "", subtype='FILE_PATH')
+ scn.atom_pdb_PDB_filename = StringProperty(
+ name = "File name", default="",
+ description = "PDB file name")
+ scn.atom_pdb_PDB_file = StringProperty(
+ name = "Path to file", default="",
+ description = "Path of the PDB file")
+ scn.atom_pdb_number_atoms = StringProperty(name="",
+ default="Number", description = "This output shows "
+ "the number of atoms which have been loaded")
+ scn.atom_pdb_distance = StringProperty(
+ name="", default="Distance (A)",
+ description="Distance of 2 objects in Angstrom")
+ scn.atom_pdb_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_pdb_radius_type = EnumProperty(
+ name="Type",
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list