[Bf-extensions-cvs] [1786d5fd] master: Cursor Control: Cleanup, replace imp calls, fix register
lijenstina
noreply at git.blender.org
Fri Jun 30 04:39:08 CEST 2017
Commit: 1786d5fdf812accb6f954038a5969a9f71b24ad8
Author: lijenstina
Date: Fri Jun 30 04:38:08 2017 +0200
Branches: master
https://developer.blender.org/rBAC1786d5fdf812accb6f954038a5969a9f71b24ad8
Cursor Control: Cleanup, replace imp calls, fix register
Bumped version to 0.7.2
Pep8 cleanup
Replace the deprecated imp imports with importlib
move import bpy bellow the reload block
Replace star imports
Add a new UI class method drawIconButton_poll to
prevent the movement of the cursor with Region Overlap
Part of the T51547:
Fix possible crash after several F8 reloads
prevent the module defines no classes error
===================================================================
M space_view3d_cursor_control/__init__.py
M space_view3d_cursor_control/constants_utils.py
M space_view3d_cursor_control/cursor_utils.py
M space_view3d_cursor_control/data.py
M space_view3d_cursor_control/geometry_utils.py
M space_view3d_cursor_control/history.py
M space_view3d_cursor_control/memory.py
M space_view3d_cursor_control/misc_utils.py
M space_view3d_cursor_control/operators.py
M space_view3d_cursor_control/ui.py
M space_view3d_cursor_control/ui_utils.py
===================================================================
diff --git a/space_view3d_cursor_control/__init__.py b/space_view3d_cursor_control/__init__.py
index 0efcdd89..822736fd 100644
--- a/space_view3d_cursor_control/__init__.py
+++ b/space_view3d_cursor_control/__init__.py
@@ -17,33 +17,26 @@
#
# ##### END GPL LICENSE BLOCK #####
-
-
-# Blender Add-Ons menu registration (in User Prefs)
-
bl_info = {
"name": "Cursor Control",
"author": "Morgan Mörtsell (Seminumerical)",
- "version": (0, 7, 1),
+ "version": (0, 7, 2),
"blender": (2, 65, 4),
"location": "View3D > Properties > Cursor",
"description": "Control the Cursor",
- "warning": "buggy, may crash other addons", # used for warning icon and text in addons panel
+ "warning": "Buggy, may crash other add-ons",
"wiki_url": "http://blenderpythonscripts.wordpress.com/",
"tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
"category": "3D View"}
-import bpy
-
-# To support reload properly, try to access a package var, if it's there, reload everything
-if "local_var" in locals():
- import imp
- imp.reload(data)
- imp.reload(ui)
- imp.reload(operators)
- imp.reload(history)
- imp.reload(memory)
+if "bpy" in locals():
+ import importlib
+ importlib.reload(data)
+ importlib.reload(ui)
+ importlib.reload(operators)
+ importlib.reload(history)
+ importlib.reload(memory)
else:
from . import data
from . import ui
@@ -51,23 +44,150 @@ else:
from . import history
from . import memory
-local_var = True
+import bpy
+from bpy.props import PointerProperty
+
+from .data import CursorControlData
+from .memory import (
+ CursorMemoryData,
+ VIEW3D_PT_cursor_memory_init,
+ VIEW3D_OT_cursor_memory_hide,
+ VIEW3D_OT_cursor_memory_recall,
+ VIEW3D_OT_cursor_memory_save,
+ VIEW3D_OT_cursor_memory_show,
+ VIEW3D_OT_cursor_memory_swap,
+ VIEW3D_PT_cursor_memory,
+ )
+from .history import (
+ CursorHistoryData,
+ cursor_history_draw,
+ VIEW3D_PT_cursor_history_init,
+ VIEW3D_OT_cursor_history_hide,
+ VIEW3D_OT_cursor_history_show,
+ VIEW3D_PT_cursor_history,
+ VIEW3D_OT_cursor_next,
+ VIEW3D_OT_cursor_previous,
+ )
+from .operators import (
+ VIEW3D_OT_ccdelta_add,
+ VIEW3D_OT_ccdelta_invert,
+ VIEW3D_OT_ccdelta_normalize,
+ VIEW3D_OT_ccdelta_sub,
+ VIEW3D_OT_ccdelta_vvdist,
+ VIEW3D_OT_cursor_stepval_phi,
+ VIEW3D_OT_cursor_stepval_phi2,
+ VIEW3D_OT_cursor_stepval_phinv,
+ VIEW3D_OT_cursor_stepval_vvdist,
+ VIEW3D_OT_cursor_to_active_object_center,
+ VIEW3D_OT_cursor_to_cylinderaxis,
+ VIEW3D_OT_cursor_to_edge,
+ VIEW3D_OT_cursor_to_face,
+ VIEW3D_OT_cursor_to_line,
+ VIEW3D_OT_cursor_to_linex,
+ VIEW3D_OT_cursor_to_origin,
+ VIEW3D_OT_cursor_to_perimeter,
+ VIEW3D_OT_cursor_to_plane,
+ VIEW3D_OT_cursor_to_sl,
+ VIEW3D_OT_cursor_to_sl_mirror,
+ VIEW3D_OT_cursor_to_spherecenter,
+ VIEW3D_OT_cursor_to_vertex,
+ VIEW3D_OT_cursor_to_vertex_median,
+ )
+from .ui import (
+ CursorControlMenu,
+ VIEW3D_PT_ccDelta,
+ VIEW3D_PT_cursor,
+ menu_callback,
+ )
+
+
+classes = (
+ CursorControlData,
+ CursorHistoryData,
+ CursorMemoryData,
+
+ VIEW3D_PT_cursor_memory_init,
+ VIEW3D_PT_cursor_history_init,
+
+ VIEW3D_OT_cursor_memory_hide,
+ VIEW3D_OT_cursor_memory_recall,
+ VIEW3D_OT_cursor_memory_save,
+ VIEW3D_OT_cursor_memory_show,
+ VIEW3D_OT_cursor_memory_swap,
+ VIEW3D_PT_cursor_memory,
+
+ VIEW3D_OT_cursor_history_hide,
+ VIEW3D_OT_cursor_history_show,
+ VIEW3D_OT_cursor_next,
+ VIEW3D_OT_cursor_previous,
+ VIEW3D_PT_cursor_history,
+
+ VIEW3D_OT_ccdelta_add,
+ VIEW3D_OT_ccdelta_invert,
+ VIEW3D_OT_ccdelta_normalize,
+ VIEW3D_OT_ccdelta_sub,
+ VIEW3D_OT_ccdelta_vvdist,
+ VIEW3D_OT_cursor_stepval_phi,
+ VIEW3D_OT_cursor_stepval_phi2,
+ VIEW3D_OT_cursor_stepval_phinv,
+ VIEW3D_OT_cursor_stepval_vvdist,
+ VIEW3D_OT_cursor_to_active_object_center,
+ VIEW3D_OT_cursor_to_cylinderaxis,
+ VIEW3D_OT_cursor_to_edge,
+ VIEW3D_OT_cursor_to_face,
+ VIEW3D_OT_cursor_to_line,
+ VIEW3D_OT_cursor_to_linex,
+ VIEW3D_OT_cursor_to_origin,
+ VIEW3D_OT_cursor_to_perimeter,
+ VIEW3D_OT_cursor_to_plane,
+ VIEW3D_OT_cursor_to_sl,
+ VIEW3D_OT_cursor_to_sl_mirror,
+ VIEW3D_OT_cursor_to_spherecenter,
+ VIEW3D_OT_cursor_to_vertex,
+ VIEW3D_OT_cursor_to_vertex_median,
+
+ CursorControlMenu,
+ VIEW3D_PT_ccDelta,
+ VIEW3D_PT_cursor,
+ )
+
def register():
- bpy.utils.register_module(__name__)
+ for cls in classes:
+ bpy.utils.register_class(cls)
+
# Register Cursor Control Structure
- bpy.types.Scene.cursor_control = bpy.props.PointerProperty(type=data.CursorControlData, name="")
- bpy.types.Scene.cursor_history = bpy.props.PointerProperty(type=history.CursorHistoryData, name="")
- bpy.types.Scene.cursor_memory = bpy.props.PointerProperty(type=memory.CursorMemoryData, name="")
+ bpy.types.Scene.cursor_control = PointerProperty(
+ type=CursorControlData,
+ name=""
+ )
+ bpy.types.Scene.cursor_history = PointerProperty(
+ type=CursorHistoryData,
+ name=""
+ )
+ bpy.types.Scene.cursor_memory = PointerProperty(
+ type=CursorMemoryData,
+ name=""
+ )
# Register menu
- bpy.types.VIEW3D_MT_snap.append(ui.menu_callback)
+ bpy.types.VIEW3D_MT_snap.append(menu_callback)
+
def unregister():
history.VIEW3D_PT_cursor_history_init.handle_remove()
memory.VIEW3D_PT_cursor_memory_init.handle_remove()
+ # reset the panel flags if the add-on is toggled off/on
+ history.VIEW3D_PT_cursor_history_init.initDone = False
+ memory.VIEW3D_PT_cursor_memory_init.initDone = False
# Unregister menu
- bpy.types.VIEW3D_MT_snap.remove(ui.menu_callback)
- bpy.utils.unregister_module(__name__)
+ bpy.types.VIEW3D_MT_snap.remove(menu_callback)
+
+ for cls in reversed(classes):
+ bpy.utils.unregister_class(cls)
+
+ del bpy.types.Scene.cursor_control
+ del bpy.types.Scene.cursor_history
+ del bpy.types.Scene.cursor_memory
if __name__ == "__main__":
diff --git a/space_view3d_cursor_control/constants_utils.py b/space_view3d_cursor_control/constants_utils.py
index 153553e7..dcc9b7ef 100644
--- a/space_view3d_cursor_control/constants_utils.py
+++ b/space_view3d_cursor_control/constants_utils.py
@@ -19,16 +19,10 @@
"""
constants_utils.py
-
Useful constants...
-
-
-
"""
-
-
# Golden mean
PHI_INV = 0.61803398874989484820
-PHI = 1.61803398874989484820
+PHI = 1.61803398874989484820
PHI_SQR = 2.61803398874989484820
diff --git a/space_view3d_cursor_control/cursor_utils.py b/space_view3d_cursor_control/cursor_utils.py
index 2fad7ee3..c8a34506 100644
--- a/space_view3d_cursor_control/cursor_utils.py
+++ b/space_view3d_cursor_control/cursor_utils.py
@@ -19,11 +19,7 @@
"""
cursor_utils.py
-
Helper methods for accessing the 3D cursor
-
-
-
"""
@@ -49,7 +45,7 @@ class CursorAccess:
return space
@classmethod
- def setCursor(cls,coordinates):
+ def setCursor(cls, coordinates):
spc = cls.findSpace()
spc.cursor_location = coordinates
diff --git a/space_view3d_cursor_control/data.py b/space_view3d_cursor_control/data.py
index 2a7106b9..c31c2687 100644
--- a/space_view3d_cursor_control/data.py
+++ b/space_view3d_cursor_control/data.py
@@ -18,93 +18,92 @@
# ##### END GPL LICENSE BLOCK #####
-
-"""
- TODO:
-
- IDEAS:
-
- LATER:
-
- ISSUES:
- Bugs:
- Mites:
-
- QUESTIONS:
-
-
-"""
-
-
-
import bpy
-import bgl
-import math
-from mathutils import Vector, Matrix
-from mathutils import geometry
-from .misc_utils import *
-from .constants_utils import *
-from .cursor_utils import *
-from .ui_utils import *
-from .geometry_utils import *
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ FloatVectorProperty,
+ IntProperty,
+ )
+from bpy.types import PropertyGroup
+from mathutils import Vector
+from .constants_utils import PHI
+from .cursor_utils import CursorAccess
PRECISION = 4
-class CursorControlData(bpy.types.PropertyGroup):
+class CursorControlData(PropertyGroup):
# Step length properties
- stepLengthEnable = bpy.props.BoolProperty(name="Use step length",description="Use step length",default=0)
- stepLengthMode = bpy.props.EnumProperty(items=[
- ("Mode", "Mode", "Mode"),
- ("Absolute", "Absolute", "Absolute"),
- ("Proportional", "Proportional", "Proportional")],
- default="Proportional")
- stepLengthValue = bpy.props.FloatProperty(name="",precision=PRECISION,default=PHI)
+ stepLengthEnable = BoolProperty(
+ name="Use step length",
+ description="Use step length",
+ default=0
+ )
+ stepLengthMode = EnumProperty(
+ items=[("Mode", "Mode", "Mode"),
+ ("Absolute", "Absolute", "Absolute"),
+ ("Proportional", "Proportional", "Proportional")],
+ default="Proportional"
+ )
+ stepLengthValue = FloatProperty(
+ name="",
+ precision=PRECISION,
+ default=PHI
+ )
# Property for linex result select...
- linexChoice = bpy.props.IntProperty(name="",default=-1)
- deltaVector = bpy.props.FloatVectorProperty(name="",precision=PRECISION,default=(1,0,0))
+ linexChoice = IntProperty(
+ name="",
+ default=-1
+ )
+ deltaVector = FloatVectorProperty(
+ name="",
+ precision=PRECISION,
+ default=(1, 0, 0)
+ )
def hideLinexChoice(self):
self.linexChoice = -1
- def cycleLinexCoice(self,limit):
+ def cycleLinexCoice(self, l
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list