[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2912] contrib/py/scripts/addons/ space_view3d_enhanced_3d_cursor.py: strip trailing space
Campbell Barton
ideasman42 at gmail.com
Wed Jan 18 07:31:30 CET 2012
Revision: 2912
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2912
Author: campbellbarton
Date: 2012-01-18 06:31:29 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
strip trailing space
Modified Paths:
--------------
contrib/py/scripts/addons/space_view3d_enhanced_3d_cursor.py
Modified: contrib/py/scripts/addons/space_view3d_enhanced_3d_cursor.py
===================================================================
--- contrib/py/scripts/addons/space_view3d_enhanced_3d_cursor.py 2012-01-18 05:24:59 UTC (rev 2911)
+++ contrib/py/scripts/addons/space_view3d_enhanced_3d_cursor.py 2012-01-18 06:31:29 UTC (rev 2912)
@@ -100,7 +100,7 @@
"""Cursor history and bookmarks; drag/snap cursor."""
bl_idname = "view3d.cursor3d_enhanced"
bl_label = "Enhanced Set Cursor"
-
+
key_char_map = {
'PERIOD':".", 'NUMPAD_PERIOD':".",
'MINUS':"-", 'NUMPAD_MINUS':"-",
@@ -120,7 +120,7 @@
'SLASH':"/", 'NUMPAD_SLASH':"/",
'NUMPAD_ASTERIX':"*",
}
-
+
key_coordsys_map = {
'LEFT_BRACKET':-1,
'RIGHT_BRACKET':1,
@@ -131,7 +131,7 @@
'N':'NORMAL',
'M':"Scaled",
}
-
+
key_pivot_map = {
'H':'ACTIVE',
'U':'CURSOR',
@@ -139,20 +139,20 @@
'O':'CENTER',
'P':'MEDIAN',
}
-
+
key_snap_map = {
'C':'INCREMENT',
'V':'VERTEX',
'E':'EDGE',
'F':'FACE',
}
-
+
key_tfm_mode_map = {
'G':'MOVE',
'R':'ROTATE',
'S':'SCALE',
}
-
+
key_map = {
"confirm":{'ACTIONMOUSE'}, # also 'RET' ?
"cancel":{'SELECTMOUSE', 'ESC'},
@@ -177,66 +177,66 @@
"paste_axes":{'V'},
"cut_axes":{'X'},
}
-
+
gizmo_factor = 0.15
click_period = 0.25
-
+
angle_grid_steps = {True:1.0, False:5.0}
scale_grid_steps = {True:0.01, False:0.1}
-
+
# ====== OPERATOR METHOD OVERLOADS ====== #
@classmethod
def poll(cls, context):
area_types = {'VIEW_3D',} # also: IMAGE_EDITOR ?
return (context.area.type in area_types) and \
(context.region.type == "WINDOW")
-
+
def modal(self, context, event):
context.area.tag_redraw()
return self.try_process_input(context, event)
-
+
def invoke(self, context, event):
# Attempt to launch the monitor
if bpy.ops.view3d.cursor3d_monitor.poll():
bpy.ops.view3d.cursor3d_monitor()
-
+
# Don't interfere with these modes when only mouse is pressed
if ('SCULPT' in context.mode) or ('PAINT' in context.mode):
if "MOUSE" in event.type:
return {'CANCELLED'}
-
+
CursorDynamicSettings.active_transform_operator = self
-
+
tool_settings = context.tool_settings
-
+
settings = find_settings()
tfm_opts = settings.transform_options
-
+
settings_scene = context.scene.cursor_3d_tools_settings
-
+
self.setup_keymaps(context)
-
+
# Coordinate System Utility
self.particles, self.csu = gather_particles(context=context)
self.particles = [View3D_Cursor(context)]
-
+
self.csu.source_pos = self.particles[0].get_location()
self.csu.source_rot = self.particles[0].get_rotation()
self.csu.source_scale = self.particles[0].get_scale()
-
+
# View3D Utility
self.vu = ViewUtility(context.region, context.space_data,
context.region_data)
-
+
# Snap Utility
self.su = SnapUtility(context)
-
+
# turn off view locking for the duration of the operator
self.view_pos = self.vu.get_position(True)
self.vu.set_position(self.vu.get_position(), True)
self.view_locks = self.vu.get_locks()
self.vu.set_locks({})
-
+
# Initialize runtime states
self.initiated_by_mouse = ("MOUSE" in event.type)
self.free_mouse = not self.initiated_by_mouse
@@ -250,37 +250,37 @@
self.coord_format = "{:." + str(settings.free_coord_precision) + "f}"
self.transform_mode = 'MOVE'
self.init_xy_angle_distance(context, event)
-
+
self.click_start = time.time()
if not self.initiated_by_mouse:
self.click_start -= self.click_period
-
+
self.stick_obj_name = settings_scene.stick_obj_name
self.stick_obj_pos = settings_scene.stick_obj_pos
-
+
# Initial run
self.try_process_input(context, event, True)
-
+
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
-
+
def cancel(self, context):
for particle in self.particles:
particle.revert()
-
+
set_stick_obj(context.scene, self.stick_obj_name, self.stick_obj_pos)
-
+
self.finalize(context)
return {'CANCELLED'}
-
+
# ====== CLEANUP/FINALIZE ====== #
def finalize(self, context):
# restore view locking
self.vu.set_locks(self.view_locks)
self.vu.set_position(self.view_pos, True)
-
+
self.cleanup(context)
-
+
# This is to avoid "blinking" of
# between-history-positions line
settings = find_settings()
@@ -288,12 +288,12 @@
# make sure the most recent history entry is displayed
history.curr_id = 0
history.last_id = 0
-
+
# Ensure there are no leftovers from draw_callback
context.area.tag_redraw()
-
+
return {'FINISHED'}
-
+
def cleanup(self, context):
self.particles = None
self.csu = None
@@ -301,13 +301,13 @@
if self.su is not None:
self.su.dispose()
self.su = None
-
+
CursorDynamicSettings.active_transform_operator = None
-
+
# ====== USER INPUT PROCESSING ====== #
def setup_keymaps(self, context):
self.key_map = self.key_map.copy()
-
+
# There is no such event as 'ACTIONMOUSE',
# it's always 'LEFTMOUSE' or 'RIGHTMOUSE'
select_mouse = context.user_preferences.inputs.select_mouse
@@ -317,7 +317,7 @@
else:
self.key_map["confirm"] = {'RIGHTMOUSE'}
self.key_map["cancel"] = {'LEFTMOUSE', 'ESC'}
-
+
# Use user-defined "free mouse" key, if it exists
wm = context.window_manager
if '3D View' in wm.keyconfigs.user.keymaps:
@@ -327,7 +327,7 @@
if kmi.map_type == 'KEYBOARD':
self.key_map["free_mouse"] = {kmi.type,}
break
-
+
def try_process_input(self, context, event, initial_run=False):
try:
return self.process_input(context, event, initial_run)
@@ -335,31 +335,31 @@
# If anything fails, at least dispose the resources
self.cleanup(context)
raise
-
+
def process_input(self, context, event, initial_run=False):
wm = context.window_manager
v3d = context.space_data
-
+
if event.type in self.key_map["confirm"]:
if self.free_mouse:
finished = (event.value == 'PRESS')
else:
finished = (event.value == 'RELEASE')
-
+
if finished:
return self.finalize(context)
-
+
if event.type in self.key_map["cancel"]:
return self.cancel(context)
-
+
tool_settings = context.tool_settings
-
+
settings = find_settings()
tfm_opts = settings.transform_options
-
+
make_snapshot = False
tangential_snapshot = False
-
+
if event.value == 'PRESS':
if event.type in self.key_map["free_mouse"]:
if self.free_mouse and (not initial_run):
@@ -367,10 +367,10 @@
return self.finalize(context)
else:
self.free_mouse = True
-
+
if event.type in self.key_tfm_mode_map:
new_mode = self.key_tfm_mode_map[event.type]
-
+
if self.transform_mode != new_mode:
# snap cursor to its initial state
if new_mode != 'MOVE':
@@ -379,37 +379,37 @@
particle.set_matrix(initial_matrix)
# reset intial mouse position
self.init_xy_angle_distance(context, event)
-
+
self.transform_mode = new_mode
-
+
if event.type in self.key_map["make_normal_snapshot"]:
make_snapshot = True
tangential_snapshot = False
-
+
if event.type in self.key_map["make_tangential_snapshot"]:
make_snapshot = True
tangential_snapshot = True
-
+
if event.type in self.key_map["snap_to_raw_mesh"]:
tool_settings.use_snap_self = \
not tool_settings.use_snap_self
-
+
if (not event.alt) and (event.type in {'X', 'Y', 'Z'}):
axis_lock = [(event.type == 'X') != event.shift,
(event.type == 'Y') != event.shift,
(event.type == 'Z') != event.shift]
-
+
if self.allowed_axes != axis_lock:
self.allowed_axes = axis_lock
else:
self.allowed_axes = [True, True, True]
-
+
if event.type in self.key_map["use_absolute_coords"]:
tfm_opts.use_relative_coords = \
not tfm_opts.use_relative_coords
-
+
self.update_origin_projection(context)
-
+
incr = 0
if event.type in self.key_map["change_current_axis"]:
incr = (-1 if event.shift else 1)
@@ -417,27 +417,27 @@
incr = 1
elif event.type in self.key_map["prev_axis"]:
incr = -1
-
+
if incr != 0:
self.current_axis = (self.current_axis + incr) % 3
self.caret_pos = len(self.axes_values[self.current_axis])
-
+
incr = 0
if event.type in self.key_map["precision_up"]:
incr = 1
elif event.type in self.key_map["precision_down"]:
incr = -1
-
+
if incr != 0:
settings.free_coord_precision += incr
self.coord_format = "{:." + \
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list