fix for various corner cases from testing more sample files.
[blender-addons.git] / space_view3d_3d_navigation.py
blobf12914a5ee9e113d42bf5bc1e22d936ce9221375
1 # 3D NAVIGATION TOOLBAR v1.2 - 3Dview Addon - Blender 2.5x
3 # THIS SCRIPT IS LICENSED UNDER GPL,
4 # please read the license block.
6 # ##### BEGIN GPL LICENSE BLOCK #####
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software Foundation,
20 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 # ##### END GPL LICENSE BLOCK #####
24 bl_info = {
25 "name": "3D Navigation",
26 "author": "Demohero, uriel",
27 "version": (1, 2),
28 "blender": (2, 57, 0),
29 "location": "View3D > Tool Shelf > 3D Nav",
30 "description": "Navigate the Camera & 3D View from the Toolshelf",
31 "warning": "",
32 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"\
33 "Scripts/3D_interaction/3D_Navigation",
34 "tracker_url": "http://projects.blender.org/tracker/index.php?"\
35 "func=detail&aid=23530",
36 "category": "3D View"}
38 # import the basic library
39 import bpy
41 # main class of this toolbar
42 class VIEW3D_PT_3dnavigationPanel(bpy.types.Panel):
43 bl_space_type = "VIEW_3D"
44 bl_region_type = "TOOLS"
45 bl_label = "3D Nav"
46 bl_options = {"DEFAULT_CLOSED"}
48 def draw(self, context):
49 layout = self.layout
50 view = context.space_data
52 # Triple boutons
53 col = layout.column(align=True)
54 col.operator("view3d.viewnumpad", text="View Camera", icon='CAMERA_DATA').type='CAMERA'
55 col.operator("view3d.localview", text="View Global/Local")
56 col.operator("view3d.view_persportho", text="View Persp/Ortho")
58 # group of 6 buttons
59 col = layout.column(align=True)
60 col.label(text="Align view from:")
61 row = col.row()
62 row.operator("view3d.viewnumpad", text="Front").type='FRONT'
63 row.operator("view3d.viewnumpad", text="Back").type='BACK'
64 row = col.row()
65 row.operator("view3d.viewnumpad", text="Left").type='LEFT'
66 row.operator("view3d.viewnumpad", text="Right").type='RIGHT'
67 row = col.row()
68 row.operator("view3d.viewnumpad", text="Top").type='TOP'
69 row.operator("view3d.viewnumpad", text="Bottom").type='BOTTOM'
71 # group of 2 buttons
72 col = layout.column(align=True)
73 col.label(text="View to Object:")
74 col.prop(view, "lock_object", text="")
75 col.operator("view3d.view_selected", text="View to Selected")
77 col = layout.column(align=True)
78 col.label(text="Cursor:")
80 row = col.row()
81 row.operator("view3d.snap_cursor_to_center", text="Center")
82 row.operator("view3d.view_center_cursor", text="View")
84 col.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
86 # register the class
87 def register():
88 bpy.utils.register_module(__name__)
90 pass
92 def unregister():
93 bpy.utils.unregister_module(__name__)
95 pass
97 if __name__ == "__main__":
98 register()