Changeset View
Changeset View
Standalone View
Standalone View
space_view3d_math_vis/__init__.py
| Context not available. | |||||
| from . import utils, draw | from . import utils, draw | ||||
| import bpy | import bpy | ||||
| from bpy.props import StringProperty, BoolProperty, FloatProperty, PointerProperty | |||||
| from .utils import var_states | |||||
| class PanelConsoleVars(bpy.types.Panel): | |||||
| bl_space_type = 'VIEW_3D' | |||||
| bl_region_type = 'TOOLS' | |||||
| bl_label = "Console Display Vars" | |||||
| bl_idname = "mathvis.panel_console_vars" | |||||
| bl_category = "Math Vis" | |||||
lijenstina: Spaces around equals | |||||
| bl_options = {'DEFAULT_CLOSED'} | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| box = layout.box() | |||||
| col = box.column(align=True) | |||||
| vars = utils.get_math_data() | |||||
Done Inline Actionsvars is builtin in python, better not to override it… use variables instead? mont29: `vars` is builtin in python, better not to override it… use `variables` instead? | |||||
| for key in sorted(vars): | |||||
| type = vars[key] | |||||
Done Inline Actionstype is also builtin in python, better not to override it… use key_type (or even ktype) instead? mont29: `type` is also builtin in python, better not to override it… use `key_type` (or even `ktype`)… | |||||
| row = col.row(align=True) | |||||
| row.label(text='%s - %s' % (key, type.__name__)) | |||||
| icon = 'RESTRICT_VIEW_OFF' if var_states.is_visible(key) else 'RESTRICT_VIEW_ON' | |||||
| prop = row.operator("mathvis.toggle_display", text='', icon=icon, emboss=False) | |||||
Done Inline Actionsprop.key=key spaces around equals and below (lines 70 and 76) lijenstina: **prop.key=key** spaces around equals and below (lines 70 and 76) | |||||
| prop.key=key | |||||
Done Inline ActionsYou still have some issues with spaces around = :p mont29: You still have some issues with spaces around `=` :p | |||||
| icon = 'LOCKED' if var_states.is_locked(key) else 'UNLOCKED' | |||||
| prop = row.operator("mathvis.toggle_lock", text='', icon=icon, emboss=False) | |||||
| prop.key = key | |||||
| if var_states.is_locked(key): | |||||
| row.label(text='', icon='BLANK1') | |||||
| else: | |||||
| prop = row.operator("mathvis.delete_var", text='', icon='X', emboss=False) | |||||
| prop.key=key | |||||
Done Inline Actions= & spaces again mont29: `=` & spaces again | |||||
| col = box.column() | |||||
| col.prop(bpy.context.scene.MathVisProp,"name_hide") | |||||
| col.prop(bpy.context.scene.MathVisProp,"bbox_hide") | |||||
| col.prop(bpy.context.scene.MathVisProp,"bbox_scale") | |||||
Done Inline Actionsagain spaces, one after comma… mont29: again spaces, one after comma… | |||||
| col.operator("mathvis.cleanup_console") | |||||
| class DeleteVar(bpy.types.Operator): | |||||
| bl_idname = "mathvis.delete_var" | |||||
| bl_label = "Delete Var" | |||||
| bl_description = "Remove the variable from the Console." | |||||
| bl_options = {'REGISTER'} | |||||
| key = StringProperty(name="Key") | |||||
| def execute(self, context): | |||||
| locals = utils.console_namespace() | |||||
| var_states.delete(self.key) | |||||
| del locals[self.key] | |||||
| draw.tag_redraw_all_view3d_areas() | |||||
| return {'FINISHED'} | |||||
| class ToggleDisplay(bpy.types.Operator): | |||||
| bl_idname = "mathvis.toggle_display" | |||||
| bl_label = "Hide/Unhide" | |||||
| bl_description = "Change the display state of the var" | |||||
| bl_options = {'REGISTER'} | |||||
| key = StringProperty(name="Key") | |||||
| def execute(self, context): | |||||
| var_states.toggle_display_state(self.key) | |||||
| draw.tag_redraw_all_view3d_areas() | |||||
| return {'FINISHED'} | |||||
| class ToggleLock(bpy.types.Operator): | |||||
| bl_idname = "mathvis.toggle_lock" | |||||
| bl_label = "Lock/Unlock" | |||||
| bl_description = "Lock the var from being deleted" | |||||
| bl_options = {'REGISTER'} | |||||
| key = StringProperty(name="Key") | |||||
| def execute(self, context): | |||||
| var_states.toggle_lock_state(self.key) | |||||
| draw.tag_redraw_all_view3d_areas() | |||||
| return {'FINISHED'} | |||||
| class ToggleMatrixBBoxDisplay(bpy.types.Operator): | |||||
| bl_idname = "mathvis.show_bbox" | |||||
| bl_label = "Show BBox" | |||||
| bl_description = "Show/Hide the BBox of Matrix items" | |||||
| bl_options = {'REGISTER'} | |||||
| def execute(self, context): | |||||
| var_states.toggle_show_bbox() | |||||
| draw.tag_redraw_all_view3d_areas() | |||||
| return {'FINISHED'} | |||||
| class CleanupConsole(bpy.types.Operator): | |||||
| bl_idname = "mathvis.cleanup_console" | |||||
| bl_label = "Cleanup Math Vis Console" | |||||
| bl_description = "Remove all visualised variables from the Console." | |||||
| bl_options = {'REGISTER'} | |||||
| def execute(self, context): | |||||
| utils.cleanup_math_data() | |||||
| draw.tag_redraw_all_view3d_areas() | |||||
| return {'FINISHED'} | |||||
| def menu_func_cleanup(self, context): | |||||
| self.layout.operator("mathvis.cleanup_console", text="Clear Math Vis") | |||||
| def console_hook(): | def console_hook(): | ||||
| draw.tag_redraw_all_view3d() | draw.tag_redraw_all_view3d_areas() | ||||
| context = bpy.context | |||||
| for window in context.window_manager.windows: | |||||
| window.screen.areas.update() | |||||
| def call_console_hook(self, context): | |||||
| console_hook() | |||||
| class MathVisProp(bpy.types.PropertyGroup): | |||||
| bbox_hide = BoolProperty(name="Hide BBoxes", | |||||
| default=False, | |||||
| description = "Hide the bounding boxes rendered for Matrix like items", | |||||
| update = call_console_hook) | |||||
| name_hide = BoolProperty(name="Hide Names", | |||||
| default=False, | |||||
| description = "Hide the names of the rendered items", | |||||
| update = call_console_hook) | |||||
| bbox_scale = FloatProperty(name="Scale factor", min=0, default=1, | |||||
| description = "Resize the Bounding Box and the coordinate lines for the display of Matrix items") | |||||
| def register(): | def register(): | ||||
| draw.callback_enable() | draw.callback_enable() | ||||
| import console_python | import console_python | ||||
| console_python.execute.hooks.append((console_hook, ())) | console_python.execute.hooks.append((console_hook, ())) | ||||
| bpy.utils.register_module(__name__) | |||||
| bpy.types.CONSOLE_MT_console.prepend(menu_func_cleanup) | |||||
| bpy.types.Scene.MathVisProp = PointerProperty(type = MathVisProp) | |||||
| def unregister(): | def unregister(): | ||||
| draw.callback_disable() | draw.callback_disable() | ||||
| import console_python | import console_python | ||||
| console_python.execute.hooks.remove((console_hook, ())) | console_python.execute.hooks.remove((console_hook, ())) | ||||
| bpy.types.CONSOLE_MT_console.remove(menu_func_cleanup) | |||||
Not Done Inline ActionsDon’t forget to del bpy.types.Scene.MathVisProp mont29: Don’t forget to `del bpy.types.Scene.MathVisProp` | |||||
| bpy.utils.unregister_module(__name__) | |||||
| Context not available. | |||||
Spaces around equals