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:
authorRune Morling <ermo.blender.org@spammesenseless.net>2019-12-15 02:01:32 +0300
committerRune Morling <ermo.blender.org@spammesenseless.net>2019-12-15 02:01:32 +0300
commita689eabdf5a05ee28ccb419264a42f3872a07aa8 (patch)
tree8c33ad4c31c2b23b7afb7bb253432d62d811ae4a /precision_drawing_tools
parentf505743b2f9f75f53b1497796869f799aa16020e (diff)
PDT: Add Reset View functionality
- In orthographic mode, will recenter the view and its distance. - In non-orthographic mode, will reset to the Blender default view. - Is hooked up to a button in the PDT View Control UI Panel.
Diffstat (limited to 'precision_drawing_tools')
-rw-r--r--precision_drawing_tools/__init__.py3
-rw-r--r--precision_drawing_tools/pdt_menus.py5
-rw-r--r--precision_drawing_tools/pdt_view.py56
3 files changed, 61 insertions, 3 deletions
diff --git a/precision_drawing_tools/__init__.py b/precision_drawing_tools/__init__.py
index b3c3024d..23dcb654 100644
--- a/precision_drawing_tools/__init__.py
+++ b/precision_drawing_tools/__init__.py
@@ -29,7 +29,7 @@
bl_info = {
"name": "Precision Drawing Tools (PDT)",
"author": "Alan Odom (Clockmender), Rune Morling (ermo)",
- "version": (1, 1, 5),
+ "version": (1, 1, 6),
"blender": (2, 80, 0),
"location": "View3D > UI > PDT",
"description": "Precision Drawing Tools for Acccurate Modelling",
@@ -487,6 +487,7 @@ classes = (
pdt_view.PDT_OT_vRotD,
pdt_view.PDT_OT_vRoll,
pdt_view.PDT_OT_viso,
+ pdt_view.PDT_OT_Reset3DView,
pdt_xall.PDT_OT_IntersectAllEdges,
)
diff --git a/precision_drawing_tools/pdt_menus.py b/precision_drawing_tools/pdt_menus.py
index 0949f7a0..08e5e93e 100644
--- a/precision_drawing_tools/pdt_menus.py
+++ b/precision_drawing_tools/pdt_menus.py
@@ -305,7 +305,10 @@ class PDT_PT_PanelViewControl(Panel):
col = row.column()
col.operator("pdt.viewroll", text="", icon="RECOVER_LAST")
row = box.row()
- row.operator("pdt.viewiso", text="Isometric View")
+ col = row.column()
+ col.operator("pdt.viewiso", text="Isometric")
+ col = row.column()
+ col.operator("pdt.reset_3d_view", text="Reset View")
class PDT_PT_PanelCommandLine(Panel):
diff --git a/precision_drawing_tools/pdt_view.py b/precision_drawing_tools/pdt_view.py
index 77919877..5257515f 100644
--- a/precision_drawing_tools/pdt_view.py
+++ b/precision_drawing_tools/pdt_view.py
@@ -19,13 +19,16 @@
#
# -----------------------------------------------------------------------
# Author: Alan Odom (Clockmender), Rune Morling (ermo) Copyright (c) 2019
+#
+# Contains code which was inspired by the "Reset 3D View" plugin authored
+# by Reiner Prokein (tiles) Copyright (c) 2014 (see T37718)
# -----------------------------------------------------------------------
#
import bpy
from bpy.types import Operator
from math import pi
from mathutils import Quaternion
-from .pdt_functions import euler_to_quaternion
+from .pdt_functions import debug, euler_to_quaternion
class PDT_OT_ViewRot(Operator):
@@ -239,3 +242,54 @@ class PDT_OT_viso(Operator):
(0.8205, 0.4247, -0.1759, -0.3399)
)
return {"FINISHED"}
+
+
+class PDT_OT_Reset3DView(Operator):
+ """Reset 3D View to Blender Defaults."""
+
+ bl_idname = "pdt.reset_3d_view"
+ bl_label = "Reset 3D View"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ def execute(self, context):
+ """Reset 3D View to Blender Defaults.
+
+ Args:
+ context: Blender bpy.context instance.
+
+ Returns:
+ Status Set.
+ """
+
+ # The default view_distance to the origin when starting up Blender
+ default_view_distance = 17.986562728881836
+ # The default view_matrix when starting up Blender
+ default_view_matrix = (
+ (0.41, -0.4017, 0.8188, 0.0),
+ (0.912, 0.1936, -0.3617, 0.0),
+ (-0.0133, 0.8950, 0.4458, 0.0),
+ (0.0, 0.0, -17.9866, 1.0)
+ )
+
+ for area in (a for a in context.screen.areas if a.type == 'VIEW_3D'):
+ view = area.spaces[0].region_3d
+ if view is not None:
+ debug(f"is_orthographic_side_view: {view.is_orthographic_side_view}")
+ if view.is_orthographic_side_view:
+ # When the view is orthographic, reset the distance and location.
+ # The rotation already fits.
+ debug(f"view_distance before reset: {view.view_distance}")
+ debug(f"view_location before reset: {view.view_location}")
+ view.view_distance = default_view_distance
+ view.view_location = (-0.0, -0.0, -0.0)
+ view.update()
+ debug(f"view_distance AFTER reset: {view.view_distance}")
+ debug(f"view_location AFTER reset: {view.view_location}")
+ else:
+ # Otherwise, the view matrix needs to be reset (includes distance).
+ debug(f"view_matrix before reset:\n{view.view_matrix}")
+ view.view_matrix = default_view_matrix
+ view.update()
+ debug(f"view_matrix AFTER reset:\n{view.view_matrix}")
+
+ return {'FINISHED'}