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:
authorCampbell Barton <ideasman42@gmail.com>2012-12-20 17:32:14 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-20 17:32:14 +0400
commit6332e745a7e1987a19e463a323858cc0ad3409e7 (patch)
tree57d927427aac8ef3065ff9165d09a2848141d81a /space_view3d_math_vis/draw.py
parent2872d0440fd1fdb4048cfd0a135f4763562cf96e (diff)
update for changes to the rna api
Diffstat (limited to 'space_view3d_math_vis/draw.py')
-rw-r--r--space_view3d_math_vis/draw.py54
1 files changed, 44 insertions, 10 deletions
diff --git a/space_view3d_math_vis/draw.py b/space_view3d_math_vis/draw.py
index 509881e0..46004d3a 100644
--- a/space_view3d_math_vis/draw.py
+++ b/space_view3d_math_vis/draw.py
@@ -1,4 +1,4 @@
-#====================== BEGIN GPL LICENSE BLOCK ======================
+# ##### 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
@@ -14,25 +14,57 @@
# 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 ========================
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
import bpy
import blf
from . import utils
from mathutils import Vector, Matrix
+SpaceView3D = bpy.types.SpaceView3D
+callback_handle = []
+
-callbacks = {}
+def tag_redraw_all_view3d():
+ context = bpy.context
+ # Py cant access notifers
+ for window in context.window_manager.windows:
+ for area in window.screen.areas:
+ if area.type == 'VIEW_3D':
+ for region in area.regions:
+ if region.type == 'WINDOW':
+ region.tag_redraw()
-def callbacks_clear():
- for region, handle_pixel, handle_view in callbacks.values():
- region.callback_remove(handle_pixel)
- region.callback_remove(handle_view)
- callbacks.clear()
+def callback_enable():
+ if callback_handle:
+ return
+
+ handle_pixel = SpaceView3D.draw_handler_add(draw_callback_px, (), 'WINDOW', 'POST_PIXEL')
+ handle_view = SpaceView3D.draw_handler_add(draw_callback_view, (), 'WINDOW', 'POST_VIEW')
+ callback_handle[:] = handle_pixel, handle_view
+
+ tag_redraw_all_view3d()
+
+
+def callback_disable():
+ if not callback_handle:
+ return
+
+ handle_pixel, handle_view = callback_handle
+ SpaceView3D.draw_handler_remove(handle_pixel, 'WINDOW')
+ SpaceView3D.draw_handler_remove(handle_view, 'WINDOW')
+ callback_handle[:] = []
+
+ tag_redraw_all_view3d()
+
+
+def draw_callback_px():
+ context = bpy.context
-def draw_callback_px(self, context):
from bgl import glColor3f
font_id = 0 # XXX, need to find out how best to get this.
blf.size(font_id, 12, 72)
@@ -93,7 +125,9 @@ def draw_callback_px(self, context):
draw_text(key, loc)
-def draw_callback_view(self, context):
+def draw_callback_view():
+ context = bpy.context
+
from bgl import glEnable, glDisable, glColor3f, glVertex3f, glPointSize, glLineWidth, glBegin, glEnd, glLineStipple, GL_POINTS, GL_LINE_STRIP, GL_LINES, GL_LINE_STIPPLE
data_matrix, data_quat, data_euler, data_vector, data_vector_array = utils.console_math_data()