Cleanup: trailing space
[blender-addons.git] / io_mesh_atomic / __init__.py
blob9fed6c99d2d8ad61e31c648c36d34aa8e7f91ed8
1 # SPDX-License-Identifier: GPL-2.0-or-later
4 # Author : Clemens Barth (Blendphys@root-1.de)
5 # Homepage(Wiki) : http://development.root-1.de/Atomic_Blender.php
7 # Start of project : 2011-08-31 by CB
8 # First publication in Blender : 2011-11-11 by CB
9 # Fusion of the PDB, XYZ and Panel : 2019-03-22 by CB
10 # Last modified : 2019-05-17
12 # Contributing authors
13 # ====================
15 # So far ... none ... .
18 # Acknowledgements
19 # ================
21 # A big thank you to all those people who I met in particular in the IRC and
22 # who helped me a lot.
24 # Blender developers
25 # ------------------
26 # Campbell Barton (ideasman)
27 # Brendon Murphy (meta_androcto)
28 # Truman Melton (?) (truman)
29 # Kilon Alios (kilon)
30 # ?? (CoDEmanX)
31 # Dima Glib (dairin0d)
32 # Peter K.H. Gragert (PKHG)
33 # Valter Battioli (?) (valter)
34 # ? (atmind)
35 # Ray Molenkamp (bzztploink)
37 # Other
38 # -----
39 # Frank Palmino (Femto-St institute, Belfort-Montbéliard, France)
40 # ... for testing the addons and for feedback
42 bl_info = {
43 "name": "Atomic Blender PDB/XYZ",
44 "description": "Importing atoms listed in PDB or XYZ files as balls into Blender",
45 "author": "Clemens Barth",
46 "version": (1, 8),
47 "blender": (2, 80, 0),
48 "location": "File -> Import -> PDB (.pdb) and File -> Import -> XYZ (.xyz)",
49 "warning": "",
50 "doc_url": "{BLENDER_MANUAL_URL}/addons/import_export/mesh_atomic.html",
51 "category": "Import-Export",
54 import bpy
55 from bpy.types import Operator, AddonPreferences
56 from bpy_extras.io_utils import ImportHelper, ExportHelper
57 from bpy.props import (
58 StringProperty,
59 BoolProperty,
60 EnumProperty,
61 IntProperty,
62 FloatProperty,
65 from . import (
66 pdb_gui,
67 xyz_gui,
68 utility_gui,
69 utility_panel
72 # -----------------------------------------------------------------------------
73 # Preferences
75 class AddonPreferences(AddonPreferences):
76 # This must match the addon name, use '__package__'
77 # when defining this in a submodule of a python package.
78 bl_idname = __name__
80 bool_pdb : BoolProperty(
81 name="PDB import/export",
82 default=True,
83 description="Import/export PDB",
85 bool_xyz : BoolProperty(
86 name="XYZ import/export",
87 default=True,
88 description="Import/export XYZ",
90 # This boolean is checked in the poll function in PANEL_PT_prepare
91 # (see utility.py).
92 bool_utility : BoolProperty(
93 name="Utility panel",
94 default=False,
95 description=("Panel with functionalities for modifying " \
96 "atomic structures"),
99 def draw(self, context):
100 layout = self.layout
101 layout.label(text="Choose the importer(s) and a 'utility' panel")
102 layout.prop(self, "bool_pdb")
103 layout.prop(self, "bool_xyz")
104 layout.prop(self, "bool_utility")
107 # -----------------------------------------------------------------------------
108 # Menu
111 # The entry into the menu 'file -> import'
112 def menu_func_import_pdb(self, context):
113 lay = self.layout
114 lay.operator(pdb_gui.IMPORT_OT_pdb.bl_idname,text="Protein Data Bank (.pdb)")
116 def menu_func_import_xyz(self, context):
117 lay = self.layout
118 lay.operator(xyz_gui.IMPORT_OT_xyz.bl_idname,text="XYZ (.xyz)")
120 # The entry into the menu 'file -> export'
121 def menu_func_export_pdb(self, context):
122 lay = self.layout
123 lay.operator(pdb_gui.EXPORT_OT_pdb.bl_idname,text="Protein Data Bank (.pdb)")
125 def menu_func_export_xyz(self, context):
126 lay = self.layout
127 lay.operator(xyz_gui.EXPORT_OT_xyz.bl_idname,text="XYZ (.xyz)")
130 # -----------------------------------------------------------------------------
131 # Register
133 def register():
134 from bpy.utils import register_class
136 register_class(AddonPreferences)
138 register_class(pdb_gui.IMPORT_OT_pdb)
139 register_class(pdb_gui.EXPORT_OT_pdb)
140 bpy.types.TOPBAR_MT_file_import.append(menu_func_import_pdb)
141 bpy.types.TOPBAR_MT_file_export.append(menu_func_export_pdb)
143 register_class(xyz_gui.IMPORT_OT_xyz)
144 register_class(xyz_gui.EXPORT_OT_xyz)
145 bpy.types.TOPBAR_MT_file_import.append(menu_func_import_xyz)
146 bpy.types.TOPBAR_MT_file_export.append(menu_func_export_xyz)
148 classes = (utility_gui.PANEL_PT_prepare,
149 utility_gui.PanelProperties,
150 utility_gui.DatafileApply,
151 utility_gui.DefaultAtom,
152 utility_gui.ReplaceAtom,
153 utility_gui.SeparateAtom,
154 utility_gui.DistanceButton,
155 utility_gui.RadiusAllBiggerButton,
156 utility_gui.RadiusAllSmallerButton,
157 utility_gui.SticksAllBiggerButton,
158 utility_gui.SticksAllSmallerButton)
159 from bpy.utils import register_class
160 utility_panel.read_elements()
161 for cls in classes:
162 register_class(cls)
164 scene = bpy.types.Scene
165 scene.atom_blend = bpy.props.PointerProperty(type=utility_gui.PanelProperties)
168 def unregister():
169 from bpy.utils import unregister_class
171 unregister_class(AddonPreferences)
173 unregister_class(pdb_gui.IMPORT_OT_pdb)
174 unregister_class(pdb_gui.EXPORT_OT_pdb)
175 bpy.types.TOPBAR_MT_file_import.remove(menu_func_import_pdb)
176 bpy.types.TOPBAR_MT_file_export.remove(menu_func_export_pdb)
178 unregister_class(xyz_gui.IMPORT_OT_xyz)
179 unregister_class(xyz_gui.EXPORT_OT_xyz)
180 bpy.types.TOPBAR_MT_file_import.remove(menu_func_import_xyz)
181 bpy.types.TOPBAR_MT_file_export.remove(menu_func_export_xyz)
183 classes = (utility_gui.PANEL_PT_prepare,
184 utility_gui.PanelProperties,
185 utility_gui.DatafileApply,
186 utility_gui.DefaultAtom,
187 utility_gui.ReplaceAtom,
188 utility_gui.SeparateAtom,
189 utility_gui.DistanceButton,
190 utility_gui.RadiusAllBiggerButton,
191 utility_gui.RadiusAllSmallerButton,
192 utility_gui.SticksAllBiggerButton,
193 utility_gui.SticksAllSmallerButton)
194 for cls in classes:
195 unregister_class(cls)
198 # -----------------------------------------------------------------------------
199 # Main
201 if __name__ == "__main__":
203 register()