Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClemens Barth <barth@root-1.de>2011-12-26 21:20:44 +0400
committerClemens Barth <barth@root-1.de>2011-12-26 21:20:44 +0400
commit910a5a70960aabded7145bff67b276a8b8ae9b27 (patch)
treeac4b80c85a82ab5108fcb1ed7bb7b1fdc1068715 /io_mesh_pdb
parentda8002f8aca1071a73fe1e4e6c98f7c5e24b5884 (diff)
... only small changes, that's it ...
Cheers, Blendphys
Diffstat (limited to 'io_mesh_pdb')
-rw-r--r--io_mesh_pdb/__init__.py42
-rw-r--r--io_mesh_pdb/import_pdb.py40
2 files changed, 73 insertions, 9 deletions
diff --git a/io_mesh_pdb/__init__.py b/io_mesh_pdb/__init__.py
index 0a99e7eb..1fc4ffe6 100644
--- a/io_mesh_pdb/__init__.py
+++ b/io_mesh_pdb/__init__.py
@@ -45,6 +45,8 @@ from bpy.props import (StringProperty,
# TODO, allow reload
from . import import_pdb
+ATOM_PDB_ERROR = ""
+
# -----------------------------------------------------------------------------
# GUI
@@ -201,7 +203,7 @@ class CLASS_atom_pdb_IO(bpy.types.PropertyGroup):
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?")
+ description = "Use mesh balls instead of NURBS")
scn.atom_pdb_mesh_azimuth = IntProperty(
name = "Azimuth", default=32, min=0,
description = "Number of sectors (azimuth)")
@@ -216,11 +218,10 @@ class CLASS_atom_pdb_IO(bpy.types.PropertyGroup):
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?")
+ description = "Put the object into the global origin")
scn.use_atom_pdb_sticks = BoolProperty(
name="Use sticks", default=False,
- description="Do you want to display also the sticks?")
+ description="Do you want to display the sticks?")
scn.atom_pdb_sticks_sectors = IntProperty(
name = "Sector", default=20, min=0,
description="Number of sectors of a stick")
@@ -228,8 +229,8 @@ class CLASS_atom_pdb_IO(bpy.types.PropertyGroup):
name = "Radius", default=0.1, min=0.0,
description ="Radius of a stick")
scn.use_atom_pdb_sticks_color = BoolProperty(
- name="Color of atoms", default=False,
- description="Shall the sticks appear in the color of the atoms?")
+ name="Color", default=False,
+ description="The sticks appear in the color of the atoms")
scn.atom_pdb_atomradius = EnumProperty(
name="Type of radius",
description="Choose type of atom radius",
@@ -281,7 +282,7 @@ class CLASS_atom_pdb_IO(bpy.types.PropertyGroup):
class CLASS_atom_pdb_datafile_apply(Operator):
bl_idname = "atom_pdb.datafile_apply"
bl_label = "Apply"
- bl_description = "Use color and radii values stored in a custom file"
+ bl_description = "Use color and radii values stored in the custom file"
def execute(self, context):
scn = bpy.context.scene
@@ -386,7 +387,7 @@ class CLASS_atom_pdb_separate_atom(Operator):
class CLASS_atom_pdb_distance_button(Operator):
bl_idname = "atom_pdb.button_distance"
bl_label = "Measure ..."
- bl_description = "Measure the distance between two objects"
+ bl_description = "Measure the distance between two objects (only in Object Mode)"
def execute(self, context):
scn = bpy.context.scene
@@ -443,11 +444,19 @@ class CLASS_atom_pdb_radius_sticks_button(Operator):
bl_description = "Show only the sticks (atom radii = stick radii)"
def execute(self, context):
+ global ATOM_PDB_ERROR
+
scn = bpy.context.scene
- import_pdb.DEF_atom_pdb_radius_sticks(
+
+ result = import_pdb.DEF_atom_pdb_radius_sticks(
scn.atom_pdb_sticks_radius,
scn.atom_pdb_radius_how,
)
+
+ if result == False:
+ ATOM_PDB_ERROR = "No sticks => no changes"
+ bpy.ops.atom_pdb.error_dialog('INVOKE_DEFAULT')
+
return {'FINISHED'}
@@ -562,6 +571,21 @@ class ImportPDB(Operator, ImportHelper):
return {'FINISHED'}
+class CLASS_atom_pdb_error_dialog(bpy.types.Operator):
+ bl_idname = "atom_pdb.error_dialog"
+ bl_label = "Attention !"
+
+ def draw(self, context):
+ layout = self.layout
+ row = layout.row()
+ row.label(text=" "+ATOM_PDB_ERROR)
+ def execute(self, context):
+ print("Atomic Blender - Error: "+ATOM_PDB_ERROR+"\n")
+ return {'FINISHED'}
+ def invoke(self, context, event):
+ return context.window_manager.invoke_props_dialog(self)
+
+
# The entry into the menu 'file -> import'
def menu_func(self, context):
self.layout.operator(ImportPDB.bl_idname, text="Protein Data Bank (.pdb)")
diff --git a/io_mesh_pdb/import_pdb.py b/io_mesh_pdb/import_pdb.py
index 78ec2f74..d007603f 100644
--- a/io_mesh_pdb/import_pdb.py
+++ b/io_mesh_pdb/import_pdb.py
@@ -415,6 +415,45 @@ def DEF_atom_pdb_radius_all(scale, how):
# for showing the sticks.
def DEF_atom_pdb_radius_sticks(radius, how):
+ # Are there any sticks?
+ Found = False
+ if how == "ALL_IN_LAYER":
+
+ layers = []
+ for i in range(20):
+ if bpy.context.scene.layers[i] == True:
+ layers.append(i)
+
+ change_objects = []
+ for obj in bpy.context.scene.objects:
+ for layer in layers:
+ if obj.layers[layer] == True:
+ change_objects.append(obj)
+
+ for obj in change_objects:
+ if len(obj.children) != 0:
+ if obj.children[0].type == "SURFACE" or obj.children[0].type == "MESH":
+ if "Stick" in obj.name:
+ Found = True
+ else:
+ if obj.type == "SURFACE" or obj.type == "MESH":
+ if "Stick" in obj.name:
+ Found = True
+
+ if how == "ALL_ACTIVE":
+ for obj in bpy.context.selected_objects:
+ if len(obj.children) != 0:
+ if obj.children[0].type == "SURFACE" or obj.children[0].type == "MESH":
+ if "Stick" in obj.name:
+ Found = True
+ else:
+ if obj.type == "SURFACE" or obj.type == "MESH":
+ if "Stick" in obj.name:
+ Found = True
+
+ if Found == False:
+ return False
+
if how == "ALL_IN_LAYER":
layers = []
@@ -450,6 +489,7 @@ def DEF_atom_pdb_radius_sticks(radius, how):
if "Stick" not in obj.name:
obj.scale = (radius,) * 3
+ return True
# This reads a custom data file.