rig_picker/gizmo.py

126 lines
2.7 KiB
Python
Raw Permalink Normal View History

2022-04-06 10:12:32 +02:00
import bpy
from bpy.props import (IntProperty, EnumProperty, BoolProperty)
from bpy.types import (AddonPreferences, GizmoGroup, Operator, Gizmo)
from mathutils import Vector, Matrix, Euler
from .constants import PICKERS
2023-11-09 10:29:56 +01:00
from .core.picker import Picker
2022-04-06 10:12:32 +02:00
'''
class RP_OT_simple_operator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
def invoke(self, context, event):
context.window_manager.modal_handler_add(self)
print('Invoke RP_OT_simple_operator')
bpy.ops.node.rp_box_select('INVOKE_DEFAULT', tweak=True)
#bpy.ops.node.select_box('INVOKE_DEFAULT', wait_for_input=True, tweak=True)
return {'RUNNING_MODAL'}
def modal(self, context, event):
print('modal op', event.type, event.value)
return {'RUNNING_MODAL'}
def execute(self, context):
print('Select Shape')
return {'FINISHED'}
'''
class RP_GT_gizmo(Gizmo):
def test_select(self, context, location):
ob = context.object
picker = PICKERS.get(ob)
if not picker:
return -1
picker.move_event(location)
#if bpy.app.timers.is_registered(tooltip):
# bpy.app.timers.unregister(tooltip)
#context.region.tag_redraw()
#picker.tooltip_event(event='START')
#bpy.app.timers.register(partial(tooltip, context.region), first_interval=1)
#print(location)
context.region.tag_redraw()
2024-02-28 09:59:11 +01:00
#print(location)
2022-04-06 10:12:32 +02:00
return -1
def draw(self, context):
return
'''
def invoke(self, context, event):
print(f'invoke: type={event.type}, value={event.value}, ctrl={event.ctrl}, shift={event.shift}, alt={event.alt}')
return {'RUNNING_MODAL'}
def modal(self, context, event, tweak):
print(f'invoke: type={event.type}, value={event.value}, ctrl={event.ctrl}, shift={event.shift}, alt={event.alt}')
return {'RUNNING_MODAL'}
def exit(self, context, cancel):
print('EXIT')
'''
class RP_GT_gizmogroup(GizmoGroup):
""" test gizmo button 2d """
bl_idname = "view3d.gizmo_button_2d"
bl_label = "Test button 2d"
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'WINDOW'
bl_options = {'PERSISTENT'}
@classmethod
def poll(cls, context):
return context.space_data.tree_type == 'RigPickerTree'
def setup(self, context):
self.gizmo = self.gizmos.new("RP_GT_gizmo")
classes = (
RP_GT_gizmo,
RP_GT_gizmogroup
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)