[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1930] Added Cursor Control, Cursor History and Cursor Memory along with the shared modules.
Morgan Mörtsell
morgan at mortsell.com
Sun May 15 19:07:53 CEST 2011
Revision: 1930
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1930
Author: seminumerical
Date: 2011-05-15 17:07:53 +0000 (Sun, 15 May 2011)
Log Message:
-----------
Added Cursor Control, Cursor History and Cursor Memory along with the shared modules.
Added Paths:
-----------
contrib/py/scripts/addons/space_3dview_cursor_control.py
contrib/py/scripts/addons/space_3dview_cursor_history.py
contrib/py/scripts/addons/space_3dview_cursor_memory.py
trunk/py/scripts/addons/modules/constants_utils.py
trunk/py/scripts/addons/modules/cursor_utils.py
trunk/py/scripts/addons/modules/geometry_utils.py
trunk/py/scripts/addons/modules/misc_utils.py
trunk/py/scripts/addons/modules/ui_utils.py
Added: contrib/py/scripts/addons/space_3dview_cursor_control.py
===================================================================
--- contrib/py/scripts/addons/space_3dview_cursor_control.py (rev 0)
+++ contrib/py/scripts/addons/space_3dview_cursor_control.py 2011-05-15 17:07:53 UTC (rev 1930)
@@ -0,0 +1,1074 @@
+# -*- coding: utf-8 -*-
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+
+
+# Blender Add-Ons menu registration (in User Prefs)
+bl_info = {
+ 'name': 'Cursor Control',
+ 'author': 'Morgan Mörtsell (Seminumerical)',
+ 'version': (0, 6, 0),
+ 'blender': (2, 5, 7),
+ 'api': 36147,
+ 'location': 'View3D > Properties > Cursor',
+ 'description': 'Control the Cursor',
+ 'warning': '', # used for warning icon and text in addons panel
+ 'wiki_url': 'http://blenderpythonscripts.wordpress.com/',
+ 'tracker_url': '',
+ 'category': '3D View'}
+
+
+
+"""
+ TODO:
+
+ IDEAS:
+ More saved locations... add, remove, lock, caption
+
+ LATER:
+ Blender SVN upload...
+
+ ISSUES:
+ Bugs:
+ Mites:
+ * History back button does not light up on first cursor move.
+ It does light up on the second, or when mouse enters the tool-area
+ * Switching between local and global view triggers new cursor position in history trace.
+ * Each consecutive click on the linex operator triggers new cursor position in history trace.
+ (2011-01-16) Was not able to fix this because of some strange script behaviour
+ while trying to clear linexChoice from addHistoryLocation
+
+ QUESTIONS:
+
+
+
+ 2011-05-10 - Refactoring: changes due to splitting of misc_utils.py...
+ 2011-05-08 - Refactoring: changes due to seminumerical.py renamed to misc_utils.py...
+ ...and moved bl_info
+--- 0.6.0 ---------------------------------------------------------------------------------------
+ 2011-04-23 - Adaptations for the 2.57 API
+ Matrix.invert() now mutates 'self'
+ Vector.normalize() now mutates 'self'
+ 2011-04-21 - Adaptations for the 2.57 API
+ Updated registration procedures
+ Forced to change some identifiers to all lower case
+ Removed some old code interferring with Cursor History
+--- pre 0.5.0 -----------------------------------------------------------------------------------
+ 2011-01-29 - Refactoring: Cursor Memory extracted to separate source.
+ Refactoring: Cursor History extracted to separate source.
+ Added menu under Mesh->Snap
+ Bugfix: move to and mirror around saved location works again.
+ 2011-01-16 - Small cleanup
+ Step length added to Control panel
+ Added move_to_SL to Control, and reworked SL_recall for Memory panel
+ More changes due to refactoring in the seminumerical module
+ 2011-01-13 - Changes due to refactoring in the seminumerical module
+ Changes due to bugfix in seminumerical module
+ Bugfix: Mirror now correctly ignores additional vertices when a face is selected.
+ Improved history tracker with back and forward buttons.
+ Split addon into three panels (Control, Memory and History)
+ 2011-01-12 - Some buttons are now hidden in edit mode.
+ Changed some icons
+ Changed some operator names
+ Refactored setCursor into the CursorControl class.
+ A working version of the move-to-with-offset feature
+ Changed the workings of move to center of cylinder and sphere.
+ Changed the workings of move to perimeter of cylinder and sphere.
+ Basic history tracker with undo working
+ --- pre 0.4.1 -----------------------------------------------------------------------------------
+ 2011-01-09 - Support for Blender 2.56a
+ --- pre 0.4 -----------------------------------------------------------------------------------
+ 2010-11-15 - Support for Blender 2.55b
+ 2010-10-28 - Added Cursor Location to the panel
+ 2010-10-10 - Refactored drawButton into utility class seminumerical.GUI
+ 2010-10-06 - Desaturated color of SL-cursor
+ 2010-10-02 - SL is now drawn as a dimmed replica of 3D-cursor
+ Four point sphere.
+ 2010-09-27 - Some cleanup and refactoring.
+ Gathered all properties in a single structure (CursorControlData).
+ Updates due to refactoring of the seminumerical module
+ 2010-09-15 - Default value of view3d_cursor_linex_choice is now -1
+ Improved some operator descriptions.
+ Changed bl_addon_info.name
+ --- pre 0.3 -----------------------------------------------------------------------------------
+ 2010-09-15 - Closest point on 3-point sphere
+ Fixed bug in cc_closestP2F. It now works as intended on quad faces.
+ Changed 'circum center' to the more generic 'closest point on cylinder axis'
+ SL is nolonger destroyed by cursor_to_linex
+ Changed some icons in the UI
+ --- pre 0.2.1 -----------------------------------------------------------------------------------
+ 2010-09-14 - Support for Blender 2.54b
+ --- pre 0.2.0 -----------------------------------------------------------------------------------
+ 2010-09-14 - Fixed bug in cursor_to_face
+ 2010-09-13 - Triangle circumcenter (3-point circle center)
+ View now updates when enable/disable draw is clicked
+ Expand / contract SL properties.
+ 2010-09-12 - Fixed enable/disable buttons
+ Move to closest vertex/line/edge/plane/face
+ UI redesigned
+ 2010-09-11 - Local view now works like a charm
+ --- pre 0.1.0 -----------------------------------------------------------------------------------
+ 2010-09-06 - Force update callback was interfering with undo.
+ Thankfully the verts, edge and face select-count updates as it should,
+ so I was able to read get the necessary information from there.
+ Forced update is now done inside the operators where mesh data is accessed.
+ 2010-09-05 - Force update for edit mode is now working.
+ Thanks to Buerbaum Martin (Pontiac). I peeked a bit at his code for registering a callback...
+"""
+
+
+
+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 *
+
+
+
+PRECISION = 4
+
+
+
+class CursorControlData(bpy.types.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)
+ # Property for linex result select...
+ linexChoice = bpy.props.IntProperty(name="",default=-1)
+
+ def hideLinexChoice(self):
+ self.linexChoice = -1
+
+ def cycleLinexCoice(self,limit):
+ qc = self.linexChoice + 1
+ if qc<0:
+ qc = 1
+ if qc>=limit:
+ qc = 0
+ self.linexChoice = qc
+
+ def setCursor(self,v):
+ if self.stepLengthEnable:
+ c = CursorAccess.getCursor()
+ if((Vector(c)-Vector(v)).length>0):
+ if self.stepLengthMode=='Absolute':
+ v = Vector(v)-Vector(c)
+ v.normalize()
+ v = v*self.stepLengthValue + Vector(c)
+ if self.stepLengthMode=='Proportional':
+ v = (Vector(v)-Vector(c))*self.stepLengthValue + Vector(c)
+ CursorAccess.setCursor(Vector(v))
+
+ def guiStates(self,context):
+ tvs = 0
+ tes = 0
+ tfs = 0
+ edit_mode = False
+ obj = context.active_object
+ if (context.mode == 'EDIT_MESH'):
+ if (obj and obj.type=='MESH' and obj.data):
+ tvs = obj.data.total_vert_sel
+
+ tes = obj.data.total_edge_sel
+ tfs = obj.data.total_face_sel
+ edit_mode = True
+ return (tvs, tes, tfs, edit_mode)
+
+
+
+class VIEW3D_OT_cursor_to_origin(bpy.types.Operator):
+ '''Move to world origin.'''
+ bl_idname = "view3d.cursor_to_origin"
+ bl_label = "Move to world origin."
+ bl_options = {'REGISTER'}
+
+ def modal(self, context, event):
+ return {'FINISHED'}
+
+ def execute(self, context):
+ cc = context.scene.cursor_control
+ cc.hideLinexChoice()
+ cc.setCursor([0,0,0])
+ return {'FINISHED'}
+
+
+
+class VIEW3D_OT_cursor_to_active_object_center(bpy.types.Operator):
+ '''Move to active object origin.'''
+ bl_idname = "view3d.cursor_to_active_object_center"
+ bl_label = "Move to active object origin."
+ bl_options = {'REGISTER'}
+
+ def modal(self, context, event):
+ return {'FINISHED'}
+
+ def execute(self, context):
+ cc = context.scene.cursor_control
+ cc.hideLinexChoice()
+ cc.setCursor(context.active_object.location)
+ return {'FINISHED'}
+
+
+
+#class VIEW3D_OT_cursor_to_nearest_object(bpy.types.Operator):
+ #'''Move to center of nearest object.'''
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list