[Bf-extensions-cvs] [04a688cc] master: 3D Navigation: Update panel Rename, fix the view_pan context
lijenstina
noreply at git.blender.org
Wed May 31 06:27:02 CEST 2017
Commit: 04a688cca54be0280491a81089310b88d11683ba
Author: lijenstina
Date: Wed May 31 06:26:08 2017 +0200
Branches: master
https://developer.blender.org/rBA04a688cca54be0280491a81089310b88d11683ba
3D Navigation: Update panel Rename, fix the view_pan context
Bumped version to 1.2.2
Pep8 cleanup
As a part of the task T50726:
Update the Panel rename code to more generic one
Small cleanup merge the pan Operators into one
fix the error with the invoke context of the view_pan
needed INVOKE_REGION_WIN to be passed on
===================================================================
M space_view3d_3d_navigation.py
===================================================================
diff --git a/space_view3d_3d_navigation.py b/space_view3d_3d_navigation.py
index 9218d5f5..a4c359cc 100644
--- a/space_view3d_3d_navigation.py
+++ b/space_view3d_3d_navigation.py
@@ -2,7 +2,7 @@
#
# THIS SCRIPT IS LICENSED UNDER GPL,
# please read the license block.
-#
+
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
@@ -25,203 +25,198 @@
bl_info = {
"name": "3D Navigation",
"author": "Demohero, uriel",
- "version": (1, 2, 1),
+ "version": (1, 2, 2),
"blender": (2, 77, 0),
"location": "View3D > Tool Shelf > Display Tab",
"description": "Navigate the Camera & 3D View from the Toolshelf",
"warning": "",
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
"Scripts/3D_interaction/3D_Navigation",
"category": "3D View",
}
-# import the basic library
import bpy
+from bpy.types import (
+ AddonPreferences,
+ Operator,
+ Panel,
+ )
+from bpy.props import StringProperty
+
# main class of this toolbar
-## re-ordered (reversed) Orbit Operators
-class OrbitUpView1(bpy.types.Operator):
- bl_idname = 'opr.orbit_up_view1'
- bl_label = 'Orbit Up View'
- bl_description = 'Orbit the view towards you'
+# re-ordered (reversed) Orbit Operators
+class OrbitUpView1(Operator):
+ bl_idname = "opr.orbit_up_view1"
+ bl_label = "Orbit Up View"
+ bl_description = "Orbit the view towards you"
def execute(self, context):
bpy.ops.view3d.view_orbit(type='ORBITUP')
return {'FINISHED'}
-class OrbitLeftView1(bpy.types.Operator):
- bl_idname = 'opr.orbit_left_view1'
- bl_label = 'Orbit Left View'
- bl_description = 'Orbit the view around to your Right'
+class OrbitLeftView1(Operator):
+ bl_idname = "opr.orbit_left_view1"
+ bl_label = "Orbit Left View"
+ bl_description = "Orbit the view around to your Right"
def execute(self, context):
bpy.ops.view3d.view_orbit(type='ORBITLEFT')
return {'FINISHED'}
-class OrbitRightView1(bpy.types.Operator):
- bl_idname = 'opr.orbit_right_view1'
- bl_label = 'Orbit Right View'
- bl_description = 'Orbit the view around to your Left'
+class OrbitRightView1(Operator):
+ bl_idname = "opr.orbit_right_view1"
+ bl_label = "Orbit Right View"
+ bl_description = "Orbit the view around to your Left"
def execute(self, context):
bpy.ops.view3d.view_orbit(type='ORBITRIGHT')
return {'FINISHED'}
-class OrbitDownView1(bpy.types.Operator):
- bl_idname = 'opr.orbit_down_view1'
- bl_label = 'Orbit Down View'
- bl_description = 'Orbit the view away from you'
+class OrbitDownView1(Operator):
+ bl_idname = "opr.orbit_down_view1"
+ bl_label = "Orbit Down View"
+ bl_description = "Orbit the view away from you"
def execute(self, context):
bpy.ops.view3d.view_orbit(type='ORBITDOWN')
return {'FINISHED'}
-## re-ordered (reversed) Pan Operators
-class PanUpView1(bpy.types.Operator):
- bl_idname = 'opr.pan_up_view1'
- bl_label = 'Pan Up View'
- bl_description = 'Pan the view Down'
- def execute(self, context):
- bpy.ops.view3d.view_pan(type='PANUP')
- return {'FINISHED'}
+# re-ordered (reversed) Pan Operators
+# just pass the enum from the VIEW3D_PT_pan_navigation1 Panel
+class PanUpViewsAll(Operator):
+ bl_idname = "opr.pan_up_views_all"
+ bl_label = "Pan View"
+ bl_description = "Pan the 3D View"
-
-class PanLeftView1(bpy.types.Operator):
- bl_idname = 'opr.pan_left_view1'
- bl_label = 'Pan Right View'
- bl_description = 'Pan the view to your Right'
+ panning = StringProperty(
+ default="PANUP",
+ options={"HIDDEN"}
+ )
def execute(self, context):
- bpy.ops.view3d.view_pan(type='PANLEFT')
- return {'FINISHED'}
+ try:
+ bpy.ops.view3d.view_pan("INVOKE_REGION_WIN", type=self.panning)
+ except Exception as e:
+ self.report({"WARNING"},
+ "Pan Views could not be completed. Operation Cancelled")
+ print("\n[3D Navigation]\nOperator: opr.pan_up_views_all\n {}\n".format(e))
+ return {"CANCELLED"}
-class PanRightView1(bpy.types.Operator):
- bl_idname = 'opr.pan_right_view1'
- bl_label = 'Pan Left View'
- bl_description = 'Pan the view to your Left'
-
- def execute(self, context):
- bpy.ops.view3d.view_pan(type='PANRIGHT')
return {'FINISHED'}
-class PanDownView1(bpy.types.Operator):
- bl_idname = 'opr.pan_down_view1'
- bl_label = 'Pan Down View'
- bl_description = 'Pan the view Up'
-
- def execute(self, context):
- bpy.ops.view3d.view_pan(type='PANDOWN')
- return {'FINISHED'}
-
-## Zoom Operators
-class ZoomInView1(bpy.types.Operator):
- bl_idname = 'opr.zoom_in_view1'
- bl_label = 'Zoom In View'
- bl_description = 'Zoom In the View/Camera View'
+# Zoom Operators
+class ZoomInView1(Operator):
+ bl_idname = "opr.zoom_in_view1"
+ bl_label = "Zoom In View"
+ bl_description = "Zoom In the View/Camera View"
def execute(self, context):
bpy.ops.view3d.zoom(delta=1)
return {'FINISHED'}
-class ZoomOutView1(bpy.types.Operator):
- bl_idname = 'opr.zoom_out_view1'
- bl_label = 'Zoom Out View'
- bl_description = 'Zoom out In the View/Camera View'
+class ZoomOutView1(Operator):
+ bl_idname = "opr.zoom_out_view1"
+ bl_label = "Zoom Out View"
+ bl_description = "Zoom out In the View/Camera View"
def execute(self, context):
bpy.ops.view3d.zoom(delta=-1)
return {'FINISHED'}
-## Roll Operators
-class RollLeftView1(bpy.types.Operator):
- bl_idname = 'opr.roll_left_view1'
- bl_label = 'Roll Left View'
- bl_description = 'Roll the view Left'
+
+# Roll Operators
+class RollLeftView1(Operator):
+ bl_idname = "opr.roll_left_view1"
+ bl_label = "Roll Left View"
+ bl_description = "Roll the view Left"
def execute(self, context):
bpy.ops.view3d.view_roll(angle=-0.261799)
return {'FINISHED'}
-class RollRightView1(bpy.types.Operator):
- bl_idname = 'opr.roll_right_view1'
- bl_label = 'Roll Right View'
- bl_description = 'Roll the view Right'
+class RollRightView1(Operator):
+ bl_idname = "opr.roll_right_view1"
+ bl_label = "Roll Right View"
+ bl_description = "Roll the view Right"
def execute(self, context):
bpy.ops.view3d.view_roll(angle=0.261799)
return {'FINISHED'}
-## View Operators
-class LeftViewpoint1(bpy.types.Operator):
- bl_idname = 'opr.left_viewpoint1'
- bl_label = 'Left Viewpoint'
- bl_description = 'View from the Left'
+
+# View Operators
+class LeftViewpoint1(Operator):
+ bl_idname = "opr.left_viewpoint1"
+ bl_label = "Left Viewpoint"
+ bl_description = "View from the Left"
def execute(self, context):
bpy.ops.view3d.viewnumpad(type='LEFT')
return {'FINISHED'}
-class RightViewpoint1(bpy.types.Operator):
- bl_idname = 'opr.right_viewpoint1'
- bl_label = 'Right Viewpoint'
- bl_description = 'View from the Right'
+class RightViewpoint1(Operator):
+ bl_idname = "opr.right_viewpoint1"
+ bl_label = "Right Viewpoint"
+ bl_description = "View from the Right"
def execute(self, context):
bpy.ops.view3d.viewnumpad(type='RIGHT')
return {'FINISHED'}
-class FrontViewpoint1(bpy.types.Operator):
- bl_idname = 'opr.front_viewpoint1'
- bl_label = 'Front Viewpoint'
- bl_description = 'View from the Front'
+class FrontViewpoint1(Operator):
+ bl_idname = "opr.front_viewpoint1"
+ bl_label = "Front Viewpoint"
+ bl_description = "View from the Front"
def execute(self, context):
bpy.ops.view3d.viewnumpad(type='FRONT')
return {'FINISHED'}
-class BackViewpoint1(bpy.types.Operator):
- bl_idname = 'opr.back_viewpoint1'
- bl_label = 'Back Viewpoint'
- bl_description = 'View from the Back'
+class BackViewpoint1(Operator):
+ bl_idname = "opr.back_viewpoint1"
+ bl_label = "Back Viewpoint"
+ bl_description = "View from the Back"
def execute(self, context):
bpy.ops.view3d.viewnumpad(type='BACK')
return {'FINISHED'}
-class TopViewpoint1(bpy.types.Operator):
- bl_idname = 'opr.top_viewpoint1'
- bl_label = 'Top Viewpoint'
- bl_description = 'View from the Top'
+class TopViewpoint1(Operator):
+ bl_idname = "opr.top_viewpoint1"
+ bl_label = "Top Viewpoint"
+ bl_description = "View from the Top"
def execute(self, context):
bpy.ops.view3d.viewnumpad(type='TOP')
return {'FINISHED'}
-class BottomViewpoint1(bpy.types.Operator):
- bl_idname = 'opr.bottom_viewpoint1'
- bl_label = 'Bottom Viewpoint'
- bl_description = 'View from the Bottom'
+class BottomViewpoint1(Operator):
+ bl_idname = "opr.bottom_viewpoint1"
+ bl_label = "Bottom Viewpoint"
+ bl_description = "View from the Bottom"
def execute(self, context):
bpy.ops.view3d.viewnumpad(type='BOTTOM')
return {'FINISHED'}
+
# Panel class of this toolbar
-class VIEW3D_PT_3dnavigationPanel(bpy.types.Panel):
+class VIEW3D_PT_3dnavigationPanel(Panel):
bl_category = "Display"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
@@ -231,15 +226,15 @@ class VIEW3D_PT_3dnavigationPanel(bpy.types.Panel):
layout = self.layout
view = context.space_data
-# Triple boutons
+ # Triple buttons
col = layout.column(align=True)
- col.operator("view3d.localview", text="View Global/Local")
- col.operator("view3d.view_persportho", text="View Persp/Ortho")
+ col.operator("view3d.localview", text="View Global / Local")
+ col.operator("view3d.view_persportho", text="View Persp / Ortho")
col.operator("view3d.viewnumpad", text="View Camera", icon='CAMERA_DATA').type = 'CAMERA'
-# group of 6 buttons
+ # group of 6 buttons
col = layout.column(align=True)
- col.label(text="Align view from:"
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list