diff --git a/core/events.py b/core/events.py index c826a63f76..3f413d03ee 100644 --- a/core/events.py +++ b/core/events.py @@ -33,6 +33,7 @@ class TreeEvent: NODES_UPDATE = 'nodes_update' # changes in node properties, update animated nodes FORCE_UPDATE = 'force_update' # rebuild tree and reevaluate every node FRAME_CHANGE = 'frame_change' # unlike other updates this one should be un-cancellable + SCENE_UPDATE = 'scene_update' # something was changed in the scene def __init__(self, event_type: str, tree: SverchCustomTree, updated_nodes: Iterable[SvNode] = None, cancel=True): self.type = event_type @@ -40,6 +41,9 @@ def __init__(self, event_type: str, tree: SverchCustomTree, updated_nodes: Itera self.updated_nodes = updated_nodes self.cancel = cancel + def __repr__(self): + return f"" + class GroupEvent: GROUP_NODE_UPDATE = 'group_node_update' diff --git a/core/handlers.py b/core/handlers.py index 6fda9739cc..e4056dda2a 100644 --- a/core/handlers.py +++ b/core/handlers.py @@ -215,12 +215,19 @@ def update_frame_change_mode(): set_frame_change(mode) +@persistent +def update_trees_scene_change(scene): + for ng in BlTrees().sv_main_trees: + ng.scene_update() + + handler_dict = { 'undo_pre': sv_handler_undo_pre, 'undo_post': sv_handler_undo_post, 'load_pre': sv_pre_load, 'load_post': sv_post_load, - 'depsgraph_update_pre': sv_main_handler + 'depsgraph_update_pre': sv_main_handler, + 'depsgraph_update_post': update_trees_scene_change, } diff --git a/core/main_tree_handler.py b/core/main_tree_handler.py index b17ddeabb1..3325c15346 100644 --- a/core/main_tree_handler.py +++ b/core/main_tree_handler.py @@ -40,6 +40,17 @@ def send(event: TreeEvent): list(global_updater(event.type)) return + # something changed in scene and it duplicates some tree events which should be ignored + elif event.type == TreeEvent.SCENE_UPDATE: + # Either the scene handler was triggered by changes in the tree or tree is still in progress + if NodesUpdater.has_task(): + return # ignore the event + # this event was caused my update system itself and should be ignored + elif 'SKIP_UPDATE' in event.tree: + del event.tree['SKIP_UPDATE'] + return + ContextTrees.mark_nodes_outdated(event.tree, event.updated_nodes) + # mark given nodes as outdated elif event.type == TreeEvent.NODES_UPDATE: ContextTrees.mark_nodes_outdated(event.tree, event.updated_nodes) @@ -239,6 +250,12 @@ def global_updater(event_type: str) -> Generator[Node, None, None]: bl_tree.update_ui() # this only will update UI of main trees trees_ui_to_update.discard(bl_tree) # protection from double updating + # this only need to trigger scene changes handler again + bl_tree.nodes[-1].use_custom_color = not bl_tree.nodes[-1].use_custom_color + bl_tree.nodes[-1].use_custom_color = not bl_tree.nodes[-1].use_custom_color + # this indicates that process of the tree is finished and next scene event can be skipped + bl_tree['SKIP_UPDATE'] = True + # this will update all opened trees (in group editors) # regardless whether the trees was changed or not, including group nodes for bl_tree in trees_ui_to_update: diff --git a/docs/tree_evaluation_system.rst b/docs/tree_evaluation_system.rst index 659e242c53..04cd1834fc 100644 --- a/docs/tree_evaluation_system.rst +++ b/docs/tree_evaluation_system.rst @@ -136,13 +136,6 @@ Node property / socket property changes `Update all` operator (:ref:`layout_manager`) It is the same as `re-update all nodes` operator but effect all trees in a file. -.. _live_update_operator: - -Live update modal operator (:ref:`3d_panel`) - It makes update some nodes, which read information from Blender objects, via timer with update period - about 1/10 second. If the tree did not manage to update while this period next event will be ignored. - In this case there can be a visible lag between user action and tree response. - Frame changes Update upon frame changes. Extra information `Animation`_. @@ -152,19 +145,30 @@ Frame changes Also you can add shortcut for the operator by pressing :kbd:`RMB` on the button of the operator (active tree panel). Another way to update is enabling `Live update` mode. In this case only changed put of the tree will be updated. +Scene changes + This trigger reacts on arbitrary changes in scene. Those can be: moving + objects, changing edit / object mode, mesh editing, assign materials etc. + Modes (:ref:`active_tree_panel`) -------------------------------- Live update - If enabled it means that the tree will be evaluated upon changes in topology or changes in properties of a node - made by user. This property does not effect evaluation upon frame changes or by `re-update all nodes` operator. + If enabled it means that the tree will be evaluated upon changes in its + topology, changes in node properties or scene changes made by user. + This property does not effect evaluation upon frame changes or by + `re-update all nodes` operator. Enabling the property will call the tree topology changes trigger. Animate If enabled the tree will be reevaluated upon frame change. The update can effect not all nodes but only those which have property `to_animate` enabled. +Scene update + If enabled togather with Live Update the tree will be reevaluated upon + changes in the scene. It will effect only nodes with `interactive` + property enabled. + Animation ========= @@ -183,9 +187,10 @@ enabled the node will be update each frame change. This can serve two purposes. - Firstly this can be used for generating animations. In this case :doc:`Frame info node ` will be most useful. -- Secondly updating nodes upon frame change can be used for refreshing nodes which take data from Blender data blocks. - For frame change the left/right arrow buttons can be used. Alternative way is to use - :ref:`Live update operator ` +- **(Deprecated, the Scene trigger is used instead now)** Secondly updating + nodes upon frame change can be used for refreshing nodes which take data from + Blender data blocks. For frame change the left/right arrow buttons can be + used. .. warning:: diff --git a/docs/user_interface/panels.rst b/docs/user_interface/panels.rst index ced5c4bd03..22749093f6 100644 --- a/docs/user_interface/panels.rst +++ b/docs/user_interface/panels.rst @@ -37,6 +37,8 @@ Tree item buttons: Controls all OpenGL viewer of this layout. Viewer, Stethoscope and Viewer Indices Animate layout to animate the layout (or not) - may preserve you time. + Scene Update + Update upon changes in the scene Process layout Automatically evaluate layout while editing, disable for large or complex layouts (F6) Draft Mode @@ -70,10 +72,19 @@ Animate If enabled the tree will be reevaluated upon frame change. The update can effect not all nodes but only those which have property to_animate enabled. +Scene update + If enabled togather with Live Update the tree will be reevaluated upon + changes in the scene. It will effect only nodes with `interactive` + property enabled. + + Live update - If enabled it means that the tree will be evaluated upon changes in topology or changes in properties of a node - made by user. This property does not effect evaluation upon frame changes or by **Re-update all nodes** operator. - Enabling the property will call the tree topology changes :ref:`trigger `. + If enabled it means that the tree will be evaluated upon changes in its + topology, changes in node properties or scene changes made by user. + This property does not effect evaluation upon frame changes or by + `re-update all nodes` operator. + Enabling the property will call the tree topology changes + :ref:`trigger `. Draft mode It switches to draft property in :doc:`A number node <../nodes/number/numbers>` and some others. @@ -397,9 +408,6 @@ With this panel your layout becomes addon itself. So, you making your life easy. Since Blender 2.8 this panel has two instances. One instance located on `N` panel in `Tool` category of `3D` editor. Another located in `Active tool and workspace settings` shelf of `Properties` editor. - -**Start live update** - will start update layouts by a timer (several times in second) - **Update all trees** - manual update of all layouts Node properties list diff --git a/docs/user_interface/shortcuts.rst b/docs/user_interface/shortcuts.rst index 2c285cea96..10a719d1a8 100644 --- a/docs/user_interface/shortcuts.rst +++ b/docs/user_interface/shortcuts.rst @@ -53,8 +53,6 @@ This is a collection of shortcuts useful in the Sverchok node tree, some are Ble .. image:: https://user-images.githubusercontent.com/10011941/78453090-d4c06180-768f-11ea-8631-422fe63f994e.gif -**Ctrl + Shift + F5** in 3D View window - Enables/Disables "Live Update" mode - **F6** - Enables/Disables the processing of the current node-tree **F7** - Enables/Disables the Draft mode of the current node-tree diff --git a/node_tree.py b/node_tree.py index 424797e0c0..3ce419c0f2 100644 --- a/node_tree.py +++ b/node_tree.py @@ -141,6 +141,8 @@ def on_draft_mode_changed(self, context): update=on_draft_mode_changed, options=set(), ) + sv_scene_update: BoolProperty(name="Scene update", description="Update upon changes in the scene", options=set(), + default=True) def update(self): """This method is called if collection of nodes or links of the tree was changed""" @@ -155,14 +157,34 @@ def update_nodes(self, nodes, cancel=True): """This method expects to get list of its nodes which should be updated""" return TreeHandler.send(TreeEvent(TreeEvent.NODES_UPDATE, self, nodes, cancel)) + def scene_update(self): + """This method should be called by scene changes handler + it ignores events related with S + sverchok trees in other cases it updates nodes which read data from Blender""" + def nodes_to_update(): + for node in self.nodes: + try: + if node.is_scene_dependent and node.is_interactive: + yield node + except AttributeError: + pass + if self.sv_scene_update: + TreeHandler.send(TreeEvent(TreeEvent.SCENE_UPDATE, self, nodes_to_update(), cancel=False)) + def process_ani(self): """ Process the Sverchok node tree if animation layers show true. For animation callback/handler """ + def animated_nodes(): + for node in self.nodes: + try: + if node.is_animation_dependent and node.is_animatable: + yield node + except AttributeError: + pass if self.sv_animate: - animated_nodes = (n for n in self.nodes if hasattr(n, 'is_animatable') and n.is_animatable) - TreeHandler.send(TreeEvent(TreeEvent.FRAME_CHANGE, self, animated_nodes)) + TreeHandler.send(TreeEvent(TreeEvent.FRAME_CHANGE, self, animated_nodes())) def update_ui(self): """ The method get information about node statistic of last update from the handler to show in view space @@ -193,6 +215,23 @@ def node_id(self): self.n_id = str(hash(self) ^ hash(time.monotonic())) return self.n_id + def update_interactive_mode(self, context): + if self.is_interactive: + self.process_node(context) + + is_interactive: BoolProperty(default=True, description="Update node upon changes in the scene", + update=update_interactive_mode, name="Interactive") + is_scene_dependent = False # if True and is_interactive then the node will be updated upon scene changes + + def refresh_node(self, context): + if self.refresh: + self.refresh = False + self.process_node(context) + + refresh: BoolProperty(name="Update Node", description="Update Node", update=refresh_node) + is_animatable: BoolProperty(name="Animate Node", description="Update Node on frame change", default=True) + is_animation_dependent = False # if True and is_animatable the the node will be updated on frame change + def sv_init(self, context): """ This method will be called during node creation @@ -417,6 +456,34 @@ class SverchCustomTreeNode(UpdateNodes, NodeUtils): """Base class for all nodes""" _docstring = None # A cache for docstring property + def draw_buttons(self, context, layout): + if self.id_data.bl_idname == SverchCustomTree.bl_idname: + row = layout.row(align=True) + if self.is_animation_dependent: + row.prop(self, 'is_animatable', icon='ANIM', icon_only=True) + if self.is_scene_dependent: + row.prop(self, 'is_interactive', icon='SCENE_DATA', icon_only=True) + if self.is_animation_dependent or self.is_scene_dependent: + row.prop(self, 'refresh', icon='FILE_REFRESH') + self.sv_draw_buttons(context, layout) + + def sv_draw_buttons(self, context, layout): + pass + + def draw_buttons_ext(self, context, layout): + if self.id_data.bl_idname == SverchCustomTree.bl_idname: + row = layout.row(align=True) + if self.is_animation_dependent: + row.prop(self, 'is_animatable', icon='ANIM') + if self.is_scene_dependent: + row.prop(self, 'is_interactive', icon='SCENE_DATA') + if self.is_animation_dependent or self.is_scene_dependent: + row.prop(self, 'refresh', icon='FILE_REFRESH') + self.sv_draw_buttons_ext(context, layout) + + def sv_draw_buttons_ext(self, context, layout): + self.sv_draw_buttons(context, layout) + @classproperty def docstring(cls): """ diff --git a/nodes/analyzer/object_insolation.py b/nodes/analyzer/object_insolation.py index 927ad521b8..741221ec3f 100644 --- a/nodes/analyzer/object_insolation.py +++ b/nodes/analyzer/object_insolation.py @@ -17,16 +17,14 @@ # ##### END GPL LICENSE BLOCK ##### import bpy -import mathutils import numpy as np from mathutils import Vector from mathutils.bvhtree import BVHTree from bpy.props import BoolProperty, IntProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, match_long_repeat, match_cross) -from sverchok.utils.logging import debug, info, error + class FakeObj(object): @@ -56,14 +54,23 @@ def ray_cast(self, a, b): return [True, tv[0], tv[1], tv[2]] - -class SvOBJInsolationNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvOBJInsolationNode(bpy.types.Node, SverchCustomTreeNode): ''' Insolation by RayCast Object ''' bl_idname = 'SvOBJInsolationNode' bl_label = 'Object ID Insolation' bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_INSOLATION' + @property + def is_scene_dependent(self): + return ((not self.inputs['Predator'].is_linked and self.inputs['Predator'].object_ref_pointer) + or (not self.inputs['Victim'].is_linked and self.inputs['Victim'].object_ref_pointer)) + + @property + def is_animation_dependent(self): + return ((not self.inputs['Predator'].is_linked and self.inputs['Predator'].object_ref_pointer) + or (not self.inputs['Victim'].is_linked and self.inputs['Victim'].object_ref_pointer)) + mode: BoolProperty(name='input mode', default=False, update=updateNode) #mode2 = BoolProperty(name='output mode', default=False, update=updateNode) sort_critical: IntProperty(name='sort_critical', default=12, min=1,max=24, update=updateNode) @@ -81,11 +88,7 @@ def sv_init(self, context): so('SvStringsSocket', "Hours") # self.inputs[2].prop[2] = -1 # z down # <--- mayybe? - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) - - def draw_buttons_ext(self, context, layout): - self.draw_animatable_buttons(layout) + def sv_draw_buttons_ext(self, context, layout): row = layout.row(align=True) row.prop(self, "mode", text="In Mode") row.prop(self, "sort_critical",text="Limit") @@ -137,7 +140,6 @@ def colset(rec,OutS_): rec.data.vertex_colors.new(name='SvInsol') colors = rec.data.vertex_colors['SvInsol'].data for i, pol in enumerate(rec.data.polygons): - self.debug(pol.loop_indices,OutS[0][i]) for co in pol.loop_indices: colors[co].color = OutS[0][i] diff --git a/nodes/color/color_ramp.py b/nodes/color/color_ramp.py index a26c69464f..985f07ddb1 100644 --- a/nodes/color/color_ramp.py +++ b/nodes/color/color_ramp.py @@ -21,7 +21,6 @@ from bpy.props import BoolProperty, FloatProperty, EnumProperty, StringProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode from sverchok.utils.sv_itertools import recurse_f_level_control @@ -30,9 +29,7 @@ set_color_ramp, get_color_ramp) -from sverchok.utils.curve import SvScalarFunctionCurve -import numpy as np node_group_name = 'sverchok_helper_group' def color_ramp_mapper(params, constant, matching_f): @@ -46,7 +43,7 @@ def color_ramp_mapper(params, constant, matching_f): result.append([evaluate(v)[:-1] for v in flist]) return result -class SvColorRampNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvColorRampNode(bpy.types.Node, SverchCustomTreeNode): """ Triggers: Color Gradient Tooltip: Map input list to a defined color @@ -56,6 +53,7 @@ class SvColorRampNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): bl_label = 'Color Ramp' bl_icon = 'COLOR' sv_icon = 'SV_COLOR_RAMP' + is_scene_dependent = True value: FloatProperty( name='Value', description='Input value(s)', @@ -71,14 +69,12 @@ def sv_init(self, context): self.outputs.new('SvColorSocket', "Color") _ = get_evaluator(node_group_name, self._get_color_ramp_node_name()) - - def draw_buttons(self, context, layout): + def sv_draw_buttons(self, context, layout): m = bpy.data.node_groups.get(node_group_name) if not m: layout.label(text="Connect input to activate") return try: - self.draw_animatable_buttons(layout, icon_only=True, update_big=True) layout.prop(self, 'use_alpha') tnode = m.nodes[self._get_color_ramp_node_name()] if not tnode: diff --git a/nodes/color/texture_evaluate_mk2.py b/nodes/color/texture_evaluate_mk2.py index 72a70ce57a..5b62fdc1dc 100644 --- a/nodes/color/texture_evaluate_mk2.py +++ b/nodes/color/texture_evaluate_mk2.py @@ -21,7 +21,6 @@ from mathutils import Vector from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.core.socket_data import SvGetSocketInfo from sverchok.utils.sv_IO_pointer_helpers import unpack_pointer_property_name from sverchok.data_structure import (updateNode, list_match_func, numpy_list_match_modes, @@ -75,7 +74,8 @@ def meshes_texture_evaluate(params, constant, matching_f): 'Object': lambda v: Vector(v), } -class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): + +class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode): """ Triggers: Scene Texture In Tooltip: Evaluate Scene texture at input coordinates @@ -86,6 +86,10 @@ class SvTextureEvaluateNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl bl_label = 'Texture Evaluate' bl_icon = 'FORCE_TEXTURE' + @property + def is_scene_dependent(self): + return not self.inputs['Texture'].is_linked and self.texture_pointer + texture_coord_modes = [ ('UV', 'UV coordinates', 'Input UV coordinates to evaluate texture. (0 to 1 as domain)', '', 1), ('Object', 'Object', 'Input Object coordinates to evaluate texture. (-1 to 1 as domain)', '', 2), @@ -144,8 +148,8 @@ def draw_texture_socket(self, socket, context, layout): c.prop_search(self, "texture_pointer", bpy.data, 'textures', text="") else: layout.label(text=socket.name+ '. ' + SvGetSocketInfo(socket)) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + + def sv_draw_buttons(self, context, layout): b = layout.split(factor=0.33, align=True) b.label(text='Mapping:') b.prop(self, 'tex_coord_type', expand=False, text='') @@ -155,9 +159,8 @@ def draw_buttons(self, context, layout): if self.color_channel == 'Color': layout.prop(self, 'use_alpha', text="Use Alpha") - def draw_buttons_ext(self, context, layout): + def sv_draw_buttons_ext(self, context, layout): '''draw buttons on the N-panel''' - self.draw_buttons(context, layout) layout.prop(self, 'list_match', expand=False) def rclick_menu(self, context, layout): diff --git a/nodes/exchange/bezier_in.py b/nodes/exchange/bezier_in.py index 99d6eaa078..c18652634e 100644 --- a/nodes/exchange/bezier_in.py +++ b/nodes/exchange/bezier_in.py @@ -7,10 +7,8 @@ import bpy from bpy.props import FloatProperty, EnumProperty, BoolProperty, StringProperty -from mathutils import Vector from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.utils.nodes_mixins.show_3d_properties import Show3DProperties from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator from sverchok.data_structure import updateNode, zip_long_repeat, split_by_count @@ -31,7 +29,7 @@ def sv_execute(self, context, node): node.get_objects_from_scene(self) -class SvBezierInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvBezierInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode): """ Triggers: Input Bezier Tooltip: Get Bezier Curve objects from scene @@ -41,6 +39,14 @@ class SvBezierInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvA bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_OBJECTS_IN' + @property + def is_scene_dependent(self): + return self.object_names + + @property + def is_animation_dependent(self): + return self.object_names + object_names: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup) sort: BoolProperty( @@ -100,17 +106,13 @@ def draw_obj_names(self, layout): else: layout.label(text='--None--') - def draw_buttons_ext(self, context, layout): - layout.prop(self, "draw_3dpanel") - def draw_buttons_3dpanel(self, layout): row = layout.row(align=True) row.label(text=self.label if self.label else self.name) self.wrapper_tracked_ui_draw_op(row, SvBezierInCallbackOp.bl_idname, text='GET') self.wrapper_tracked_ui_draw_op(row, "node.sv_nodeview_zoom_border", text="", icon="TRACKER_DATA") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): col = layout.column(align=True) row = col.row(align=True) diff --git a/nodes/exchange/nurbs_in.py b/nodes/exchange/nurbs_in.py index ae60273ee0..ea243442f2 100644 --- a/nodes/exchange/nurbs_in.py +++ b/nodes/exchange/nurbs_in.py @@ -10,14 +10,12 @@ from mathutils import Vector from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.utils.nodes_mixins.show_3d_properties import Show3DProperties from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator from sverchok.data_structure import updateNode, zip_long_repeat, split_by_count from sverchok.utils.curve import knotvector as sv_knotvector from sverchok.utils.curve.nurbs import SvNurbsCurve from sverchok.utils.surface.nurbs import SvNurbsSurface -from sverchok.utils.dummy_nodes import add_dummy from sverchok.dependencies import geomdl if geomdl is not None: @@ -39,7 +37,7 @@ def sv_execute(self, context, node): getattr(node, self.fn_name)(self) -class SvExNurbsInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvExNurbsInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode): """ Triggers: Input NURBS Tooltip: Get NURBS curve or surface objects from scene @@ -48,6 +46,8 @@ class SvExNurbsInNode(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, Sv bl_label = 'NURBS In' bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_OBJECTS_IN' + is_scene_dependent = True + is_animation_dependent = True object_names: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup) @@ -118,12 +118,7 @@ def get_implementations(self, context): items = get_implementations, update = updateNode) - def draw_buttons_ext(self, context, layout): - layout.prop(self, "draw_3dpanel") - - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) - + def sv_draw_buttons(self, context, layout): layout.prop(self, 'implementation', text='') col = layout.column(align=True) row = col.row(align=True) diff --git a/nodes/logic/neuro_elman.py b/nodes/logic/neuro_elman.py index f8003f8f8d..65fe1951ee 100644 --- a/nodes/logic/neuro_elman.py +++ b/nodes/logic/neuro_elman.py @@ -22,7 +22,6 @@ from bpy.props import BoolProperty, IntProperty, StringProperty, FloatProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode from sverchok.data_structure import handle_read, handle_write @@ -164,7 +163,7 @@ def learning(self, out_a, out_b, out_c, etalon, maxim, prop): prop['wB'] = weights_b -class SvNeuroElman1LNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvNeuroElman1LNode(bpy.types.Node, SverchCustomTreeNode): ''' Triggers: Neuro Elman 1 Layer Tooltip: Join ETALON data - after animation learning - disconnect ETALON @@ -174,7 +173,7 @@ class SvNeuroElman1LNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode) bl_label = '*Neuro Elman 1 Layer' bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_NEURO' - + is_animation_dependent = True elman = None k_learning: FloatProperty(name='k_learning', default=0.1, update=updateNode, description="Learning rate") @@ -202,8 +201,7 @@ def sv_init(self, context): self.inputs.new('SvStringsSocket', "etalon") self.outputs.new('SvStringsSocket', "result") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): handle_name = self.name + self.id_data.name col_top = layout.column(align=True) diff --git a/nodes/modifier_make/sweep_modulator.py b/nodes/modifier_make/sweep_modulator.py index 856792f316..9a290e58c5 100644 --- a/nodes/modifier_make/sweep_modulator.py +++ b/nodes/modifier_make/sweep_modulator.py @@ -9,7 +9,6 @@ import bpy from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode from sverchok.core.handlers import get_sv_depsgraph, set_sv_depsgraph_need @@ -21,7 +20,7 @@ def interp_v3l_v3v3(a, b, t): else: return ((1.0 - t) * a) + (t * b) -class SvSweepModulator(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvSweepModulator(bpy.types.Node, SverchCustomTreeNode): """ Triggers: SvSweepModulator @@ -31,6 +30,8 @@ class SvSweepModulator(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): bl_idname = 'SvSweepModulator' bl_label = 'Sweep Modulator' bl_icon = 'GP_MULTIFRAME_EDITING' + is_scene_dependent = True + is_animation_dependent = True construct_name: bpy.props.StringProperty(name="construct_name", update=updateNode) active: bpy.props.BoolProperty(name="active", update=updateNode) @@ -49,8 +50,7 @@ def sv_init(self, context): onew("SvStringsSocket", "Edges") onew("SvStringsSocket", "Faces") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): row = layout.row(align=True) row.prop(self, "active", text="ACTIVATE") row = layout.row(align=True) diff --git a/nodes/network/udp_client.py b/nodes/network/udp_client.py index e5763bf14c..25e958d667 100644 --- a/nodes/network/udp_client.py +++ b/nodes/network/udp_client.py @@ -21,17 +21,17 @@ import bpy from bpy.props import IntProperty, FloatProperty, EnumProperty, StringProperty, BoolProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.utils.profile import profile from sverchok.data_structure import updateNode -class UdpClientNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class UdpClientNode(bpy.types.Node, SverchCustomTreeNode): bl_idname = 'UdpClientNode' bl_label = 'UDP Client' sv_icon = 'SV_UDP_CLIENT' - + is_scene_dependent = True + is_animation_dependent = True def send_msg(self, context): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -63,8 +63,7 @@ def recv_msg(self): timeout: FloatProperty(name='timeout', description='Timeout (sec)', default=0.5) active: BoolProperty(default=False, name='Active') - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.prop(self, 'active', text='Active') layout.prop(self, 'ip', text='IP') layout.prop(self, 'port', text='Port') diff --git a/nodes/number/curve_mapper.py b/nodes/number/curve_mapper.py index d7ab210955..eef5ea1674 100644 --- a/nodes/number/curve_mapper.py +++ b/nodes/number/curve_mapper.py @@ -21,7 +21,6 @@ from bpy.props import BoolProperty, FloatProperty, EnumProperty, StringProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode, list_match_func, numpy_list_match_modes, numpy_list_match_func from sverchok.utils.sv_itertools import recurse_f_level_control @@ -36,7 +35,7 @@ from sverchok.utils.curve import SvScalarFunctionCurve -import numpy as np + node_group_name = 'sverchok_helper_group' if (2, 82, 0) > bpy.app.version: @@ -52,7 +51,7 @@ def curve_mapper(params, constant, matching_f): return result -class SvCurveMapperNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvCurveMapperNode(bpy.types.Node, SverchCustomTreeNode): """ Triggers: Manual Curve remap Tooltip: Map input list using a manually defined curve @@ -61,6 +60,7 @@ class SvCurveMapperNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): bl_idname = 'SvCurveMapperNode' bl_label = 'Curve Mapper' bl_icon = 'NORMALIZE_FCURVES' + is_scene_dependent = True value: FloatProperty( name='Value', description='New Max', @@ -75,14 +75,12 @@ def sv_init(self, context): self.outputs.new('SvVerticesSocket', "Control Points") _ = get_evaluator(node_group_name, self._get_curve_node_name()) - - def draw_buttons(self, context, layout): + def sv_draw_buttons(self, context, layout): m = bpy.data.node_groups.get(node_group_name) if not m: layout.label(text="Connect input to activate") return try: - self.draw_animatable_buttons(layout, icon_only=True, update_big=True) tnode = m.nodes[self._get_curve_node_name()] if not tnode: layout.label(text="Connect input to activate") diff --git a/nodes/object_nodes/armature_analyzer.py b/nodes/object_nodes/armature_analyzer.py index d2cabf07b1..2f1cef62c8 100644 --- a/nodes/object_nodes/armature_analyzer.py +++ b/nodes/object_nodes/armature_analyzer.py @@ -18,16 +18,15 @@ import bpy from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode -from sverchok.data_structure import match_long_cycle as mlc, updateNode - -class SvArmaturePropsNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvArmaturePropsNode(bpy.types.Node, SverchCustomTreeNode): '''Armature object props''' bl_idname = 'SvArmaturePropsNode' bl_label = 'Armature Props' bl_icon = 'MOD_ARMATURE' + is_scene_dependent = True + is_animation_dependent = True def sv_init(self, context): self.inputs.new('SvObjectSocket', 'Armature Object') @@ -39,9 +38,6 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Length of bone') self.outputs.new('SvMatrixSocket', "local bone matrix") self.outputs.new('SvObjectSocket', "Armature Object") - - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) def process(self): armobj, selm = self.inputs diff --git a/nodes/object_nodes/assign_materials.py b/nodes/object_nodes/assign_materials.py index 4b8bf38d44..f787c73c7e 100644 --- a/nodes/object_nodes/assign_materials.py +++ b/nodes/object_nodes/assign_materials.py @@ -22,7 +22,6 @@ from bpy.props import StringProperty, IntProperty, CollectionProperty, PointerProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode, match_long_repeat from sverchok.utils.logging import info, debug @@ -120,7 +119,8 @@ def execute(self, context): updateNode(node, context) return {'FINISHED'} -class SvAssignMaterialListNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): + +class SvAssignMaterialListNode(bpy.types.Node, SverchCustomTreeNode): """ Triggers: material list Tooltip: Assign the list of materials to the object @@ -130,6 +130,14 @@ class SvAssignMaterialListNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl bl_label = "Assign Materials List" bl_icon = 'MATERIAL' + @property + def is_scene_dependent(self): + return (not self.inputs['Object'].is_linked) and self.inputs['Object'].object_ref_pointer + + @property + def is_animation_dependent(self): + return (not self.inputs['Object'].is_linked) and self.inputs['Object'].object_ref_pointer + materials : CollectionProperty(type=SvMaterialEntry) selected : IntProperty() @@ -138,8 +146,7 @@ def sv_init(self, context): self.inputs.new('SvObjectSocket', 'Object') self.outputs.new('SvObjectSocket', 'Object') - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.template_list("UI_UL_SvMaterialUiList", "materials", self, "materials", self, "selected") row = layout.row(align=True) diff --git a/nodes/object_nodes/closest_point_on_mesh2.py b/nodes/object_nodes/closest_point_on_mesh2.py index e4358a452c..b487016ecc 100644 --- a/nodes/object_nodes/closest_point_on_mesh2.py +++ b/nodes/object_nodes/closest_point_on_mesh2.py @@ -17,21 +17,21 @@ # ##### END GPL LICENSE BLOCK ##### import bpy -import mathutils from mathutils import Vector from bpy.props import FloatProperty, BoolProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, second_as_first_cycle) -class SvPointOnMeshNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvPointOnMeshNodeMK2(bpy.types.Node, SverchCustomTreeNode): ''' Point on Mesh ''' bl_idname = 'SvPointOnMeshNodeMK2' bl_label = 'Object ID Point on Mesh MK2' #new is pointless name bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_POINT_ON_MESH' + is_animation_dependent = True + is_scene_dependent = True Mdist: FloatProperty(name='Max_Distance', default=10, update=updateNode) mode: BoolProperty(name='for in points', default=False, update=updateNode) @@ -48,10 +48,7 @@ def sv_init(self, context): so('SvVerticesSocket', "Normal_on_mesh") so('SvStringsSocket', "FaceINDEX") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) - def draw_buttons_ext(self, context, layout): - self.draw_animatable_buttons(layout) + def sv_draw_buttons_ext(self, context, layout): row = layout.row(align=True) row.prop(self, "mode", text="In Mode") row.prop(self, "mode2", text="Out Mode") diff --git a/nodes/object_nodes/color_uv_texture.py b/nodes/object_nodes/color_uv_texture.py index c9b41f0715..d7cf6c97fb 100644 --- a/nodes/object_nodes/color_uv_texture.py +++ b/nodes/object_nodes/color_uv_texture.py @@ -22,23 +22,23 @@ import numpy as np from bpy.props import BoolProperty, StringProperty, FloatVectorProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.core.handlers import get_sv_depsgraph, set_sv_depsgraph_need from sverchok.data_structure import (updateNode, second_as_first_cycle as safc) -class SvMeshUVColorNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvMeshUVColorNode(bpy.types.Node, SverchCustomTreeNode): ''' Find pixel on UV texture from mesh object and change its color''' bl_idname = 'SvMeshUVColorNode' bl_label = 'Set UV Color' bl_icon = 'UV_DATA' + is_scene_dependent = True + is_animation_dependent = True image: StringProperty(default='', update=updateNode) unit_color: FloatVectorProperty(name='', default=(1.0, 1.0, 1.0, 1.0), size=4, min=0.0, max=1.0, subtype='COLOR', update=updateNode) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): ob = self.inputs[0].sv_get(default=[[]])[0] if ob and ob.type == 'MESH': layout.prop_search(self, 'image', bpy.data, "images", text="") diff --git a/nodes/object_nodes/copy_modifiers.py b/nodes/object_nodes/copy_modifiers.py index 6e81040355..48b76ab8be 100644 --- a/nodes/object_nodes/copy_modifiers.py +++ b/nodes/object_nodes/copy_modifiers.py @@ -10,11 +10,10 @@ from sverchok.data_structure import repeat_last from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.utils.handle_blender_data import BlModifier -class SvCopyModifiersNode(SvAnimatableNode, SverchCustomTreeNode, bpy.types.Node): +class SvCopyModifiersNode(SverchCustomTreeNode, bpy.types.Node): """ Triggers: modifiers Tooltip: @@ -23,12 +22,22 @@ class SvCopyModifiersNode(SvAnimatableNode, SverchCustomTreeNode, bpy.types.Node bl_label = 'Copy Modifiers' bl_icon = 'MODIFIER_DATA' + @property + def is_scene_dependent(self): + return (not self.inputs['Objects'].is_linked) and (self.inputs['Objects'].object_ref_pointer + or self.object_names) + + @property + def is_animation_dependent(self): + return (not self.inputs['Objects'].is_linked) and (self.inputs['Objects'].object_ref_pointer + or self.object_names) + def sv_init(self, context): self.inputs.new('SvObjectSocket', 'Object To') self.inputs.new('SvObjectSocket', 'Object From') self.outputs.new('SvObjectSocket', 'Object') - def draw_buttons(self, context, layout): + def sv_draw_buttons(self, context, layout): self.draw_animatable_buttons(layout) def process(self): diff --git a/nodes/object_nodes/custom_mesh_normals.py b/nodes/object_nodes/custom_mesh_normals.py index c891e3a299..d104f8abab 100644 --- a/nodes/object_nodes/custom_mesh_normals.py +++ b/nodes/object_nodes/custom_mesh_normals.py @@ -20,18 +20,25 @@ import bpy from bpy.props import EnumProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, second_as_first_cycle as safc) -class SvSetCustomMeshNormals(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvSetCustomMeshNormals(bpy.types.Node, SverchCustomTreeNode): ''' Set custom normals for verts or loops ''' bl_idname = 'SvSetCustomMeshNormals' bl_label = 'Set Custom Normals' bl_icon = 'SNAP_NORMAL' sv_icon = 'SV_CUSTOM_NORMALS' + @property + def is_scene_dependent(self): + return (not self.inputs['Objects'].is_linked) and self.inputs['Objects'].object_ref_pointer + + @property + def is_animation_dependent(self): + return (not self.inputs['Objects'].is_linked) and self.inputs['Objects'].object_ref_pointer + modes = [ ("per_Vert", "per Vert", "", 1), ("per_Loop", "per Loop", "", 2) @@ -39,8 +46,7 @@ class SvSetCustomMeshNormals(bpy.types.Node, SverchCustomTreeNode, SvAnimatableN mode: EnumProperty(items=modes, default='per_Vert', update=updateNode) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.prop(self, "mode", expand=True) def sv_init(self, context): diff --git a/nodes/object_nodes/get_asset_properties_mk2.py b/nodes/object_nodes/get_asset_properties_mk2.py index 90b46e934f..289d73de18 100644 --- a/nodes/object_nodes/get_asset_properties_mk2.py +++ b/nodes/object_nodes/get_asset_properties_mk2.py @@ -8,7 +8,6 @@ import bpy from bpy.props import EnumProperty, PointerProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, no_space, enum_item as e) def frame_from_available(idx, layer): @@ -48,12 +47,14 @@ def frame_from_available2(current_frame, layer): return inp_to_index.get(tval, 0) -class SvGetAssetPropertiesMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvGetAssetPropertiesMK2(bpy.types.Node, SverchCustomTreeNode): ''' Get Asset Props ''' bl_idname = 'SvGetAssetPropertiesMK2' bl_label = 'Object ID Selector+' bl_icon = 'SELECT_SET' sv_icon = 'SV_OBJECT_ID_SELECTOR' + is_scene_dependent = True + is_animation_dependent = True def type_filter(self, object): return object.type == self.Type @@ -196,9 +197,8 @@ def process_mode_images(self): else: return data_list[:] - def draw_buttons(self, context, layout): + def sv_draw_buttons(self, context, layout): # layout.operator('node.' ,text='refresh from scene') - self.draw_animatable_buttons(layout, icon_only=True) layout.row().prop(self, "Mode", text="data") if self.Mode == 'objects': diff --git a/nodes/object_nodes/getsetprop.py b/nodes/object_nodes/getsetprop.py index 0b1c37ff82..8cd74e241d 100644 --- a/nodes/object_nodes/getsetprop.py +++ b/nodes/object_nodes/getsetprop.py @@ -26,7 +26,6 @@ from mathutils import Matrix, Vector, Euler, Quaternion, Color from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import Matrix_generate, updateNode, node_id @@ -158,12 +157,14 @@ def secondary_type_assesment(item): return "SvColorSocket" return None -class SvGetPropNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvGetPropNode(bpy.types.Node, SverchCustomTreeNode): ''' Get property ''' bl_idname = 'SvGetPropNode' bl_label = 'Get property' bl_icon = 'FORCE_VORTEX' sv_icon = 'SV_PROP_GET' + is_animation_dependent = True + is_scene_dependent = True bad_prop: BoolProperty(default=False) @@ -198,10 +199,8 @@ def obj(self): path = parse_to_path(ast_path.body[0].value) return get_object(path) - def draw_buttons(self, context, layout): + def sv_draw_buttons(self, context, layout): layout.alert = self.bad_prop - if len(self.outputs) > 0: - self.draw_animatable_buttons(layout, icon_only=True) layout.prop(self, "prop_name", text="") def process(self): diff --git a/nodes/object_nodes/getsetprop_mk2.py b/nodes/object_nodes/getsetprop_mk2.py index 2ab4f17445..9f43e168ec 100644 --- a/nodes/object_nodes/getsetprop_mk2.py +++ b/nodes/object_nodes/getsetprop_mk2.py @@ -26,7 +26,6 @@ from mathutils import Matrix, Vector, Euler, Quaternion, Color from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import Matrix_generate, updateNode, node_id @@ -221,13 +220,21 @@ def prop_assesment(self): prop_name: StringProperty(name='', update=verify_prop) -class SvGetPropNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvPropNodeMixin, SvAnimatableNode): +class SvGetPropNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvPropNodeMixin): ''' Get property ''' bl_idname = 'SvGetPropNodeMK2' bl_label = 'Get property MK2' bl_icon = 'FORCE_VORTEX' sv_icon = 'SV_PROP_GET' + @property + def is_scene_dependent(self): + return bool(self.outputs) + + @property + def is_animation_dependent(self): + return bool(self.outputs) + def execute_inside_throttle(self): # the name of the method does not have any meaning now s_type = self.type_assesment() @@ -237,8 +244,7 @@ def execute_inside_throttle(self): # the name of the method does not have any m elif s_type: outputs.new(s_type, "Data") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.alert = self.bad_prop layout.prop(self, "prop_name", text="") diff --git a/nodes/object_nodes/lattice_analyzer.py b/nodes/object_nodes/lattice_analyzer.py index d344ead819..73581a10e4 100644 --- a/nodes/object_nodes/lattice_analyzer.py +++ b/nodes/object_nodes/lattice_analyzer.py @@ -18,16 +18,15 @@ import bpy from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode -from sverchok.data_structure import updateNode - -class SvLatticePropsNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvLatticePropsNode(bpy.types.Node, SverchCustomTreeNode): '''Lattice object props''' bl_idname = 'SvLatticePropsNode' bl_label = 'Lattice Props' bl_icon = 'MOD_LATTICE' + is_scene_dependent = True + is_animation_dependent = True def sv_init(self, context): self.inputs.new('SvObjectSocket', 'Lattice Object') @@ -37,9 +36,6 @@ def sv_init(self, context): self.outputs.new('SvVerticesSocket', 'deformed points') self.outputs.new('SvObjectSocket', "Lattice Object") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) - def process(self): lattobj, dep, selm = self.inputs Oorp, Odep, obj = self.outputs diff --git a/nodes/object_nodes/material_index.py b/nodes/object_nodes/material_index.py index 3906e0784e..a3d41c01ee 100644 --- a/nodes/object_nodes/material_index.py +++ b/nodes/object_nodes/material_index.py @@ -22,12 +22,11 @@ from bpy.props import IntProperty, BoolProperty, EnumProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, match_long_repeat, fullList, get_data_nesting_level, describe_data_shape) -class SvMaterialIndexNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvMaterialIndexNode(bpy.types.Node, SverchCustomTreeNode): ''' Triggers: material index Tooltip: Set material index per object face @@ -37,6 +36,14 @@ class SvMaterialIndexNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode bl_label = "Set Material Index" bl_icon = 'MATERIAL' + @property + def is_scene_dependent(self): + return (not self.inputs['Object'].is_linked) and self.inputs['Object'].object_ref_pointer + + @property + def is_animation_dependent(self): + return (not self.inputs['Object'].is_linked) and self.inputs['Object'].object_ref_pointer + def update_all_faces(self, context): self.inputs['FaceIndex'].hide_safe = self.all_faces updateNode(self, context) @@ -68,8 +75,7 @@ def update_all_faces(self, context): default = 'FACE', update = updateNode) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.prop(self, "all_faces", toggle=True) if self.all_faces: layout.prop(self, "matching_mode", text='') diff --git a/nodes/object_nodes/object_raycast2.py b/nodes/object_nodes/object_raycast2.py index c5550c2e5b..0e0ae52e74 100644 --- a/nodes/object_nodes/object_raycast2.py +++ b/nodes/object_nodes/object_raycast2.py @@ -17,12 +17,10 @@ # ##### END GPL LICENSE BLOCK ##### import bpy -import mathutils from mathutils import Vector from mathutils.bvhtree import BVHTree from bpy.props import BoolProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, match_long_repeat) @@ -49,12 +47,14 @@ def ray_cast(self, a, b): return [True, tv[0], tv[1], tv[2]] -class SvOBJRayCastNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvOBJRayCastNodeMK2(bpy.types.Node, SverchCustomTreeNode): ''' RayCast Object ''' bl_idname = 'SvOBJRayCastNodeMK2' bl_label = 'Object ID Raycast MK2' # new is nonsense name bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_RAYCASTER_OBJECT_ID' + is_animation_dependent = True + is_scene_dependent = True mode: BoolProperty(name='input mode', default=False, update=updateNode) mode2: BoolProperty(name='output mode', default=False, update=updateNode) @@ -69,15 +69,11 @@ def sv_init(self, context): so('SvVerticesSocket', "HitNorm") so('SvStringsSocket', "FaceINDEX") # self.inputs[2].prop[2] = -1 # z down # <--- mayybe? - - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) - def draw_buttons_ext(self, context, layout): + def sv_draw_buttons_ext(self, context, layout): row = layout.row(align=True) row.prop(self, "mode", text="In Mode") row.prop(self, "mode2", text="Out Mode") - self.draw_animatable_buttons(layout) def process(self): o,s,e = self.inputs diff --git a/nodes/object_nodes/points_from_uv_to_mesh.py b/nodes/object_nodes/points_from_uv_to_mesh.py index 539c9e093e..636fdef4b9 100644 --- a/nodes/object_nodes/points_from_uv_to_mesh.py +++ b/nodes/object_nodes/points_from_uv_to_mesh.py @@ -23,7 +23,6 @@ import numpy as np from bpy.props import BoolProperty, StringProperty, FloatVectorProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode) @@ -52,17 +51,16 @@ def UV(self, object): return [vertices_new, polygons_new] -class SvUVPointonMeshNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvUVPointonMeshNode(bpy.types.Node, SverchCustomTreeNode): ''' Transform vectors from UV space to Object space ''' bl_idname = 'SvUVPointonMeshNode' bl_label = 'Find UV Coord on Surface' bl_icon = 'GROUP_UVS' + is_scene_dependent = True + is_animation_dependent = True object_ref: StringProperty(default='', update=updateNode) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) - def sv_init(self, context): si, so = self.inputs.new, self.outputs.new si('SvObjectSocket', 'Mesh Object') diff --git a/nodes/object_nodes/sample_uv_color.py b/nodes/object_nodes/sample_uv_color.py index a125e00f9b..41fe7c75ad 100644 --- a/nodes/object_nodes/sample_uv_color.py +++ b/nodes/object_nodes/sample_uv_color.py @@ -22,21 +22,21 @@ import numpy as np from bpy.props import BoolProperty, StringProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.core.handlers import get_sv_depsgraph, set_sv_depsgraph_need from sverchok.data_structure import (updateNode) -class SvSampleUVColorNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvSampleUVColorNode(bpy.types.Node, SverchCustomTreeNode): ''' Sample pixel color on UV texture from surface''' bl_idname = 'SvSampleUVColorNode' bl_label = 'Sample UV Color' bl_icon = 'UV' + is_animation_dependent = True + is_scene_dependent = True image: StringProperty(default='', update=updateNode) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): ob = self.inputs[0].sv_get(default=[[]])[0] if ob and ob.type == 'MESH': layout.prop_search(self, 'image', bpy.data, "images", text="") diff --git a/nodes/object_nodes/scene_raycast2.py b/nodes/object_nodes/scene_raycast2.py index 5ce5ca36ee..7a56593af6 100644 --- a/nodes/object_nodes/scene_raycast2.py +++ b/nodes/object_nodes/scene_raycast2.py @@ -18,16 +18,17 @@ import bpy from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, match_long_repeat) -class SvSCNRayCastNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvSCNRayCastNodeMK2(bpy.types.Node, SverchCustomTreeNode): ''' RayCast Scene ''' bl_idname = 'SvSCNRayCastNodeMK2' bl_label = 'Scene Raycast MK2' #new is nonsense name bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_RAYCASTER_SCENE' + is_scene_dependent = True + is_animation_dependent = True def sv_init(self, context): si,so = self.inputs.new,self.outputs.new @@ -40,9 +41,6 @@ def sv_init(self, context): so("SvObjectSocket", "Objects") so("SvMatrixSocket", "hited object matrix") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) - def process(self): P,N,S,I,O,M = self.outputs rc = [] diff --git a/nodes/object_nodes/select_mesh_verts.py b/nodes/object_nodes/select_mesh_verts.py index 3c8510c3f1..edc3d335c0 100644 --- a/nodes/object_nodes/select_mesh_verts.py +++ b/nodes/object_nodes/select_mesh_verts.py @@ -21,15 +21,16 @@ import numpy as np from bpy.props import StringProperty, BoolProperty, EnumProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, second_as_first_cycle as safc) -class SvSelectMeshVerts(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvSelectMeshVerts(bpy.types.Node, SverchCustomTreeNode): ''' Select vertices of mesh objects ''' bl_idname = 'SvSelectMeshVerts' bl_label = 'Select Object Vertices' bl_icon = 'EDITMODE_HLT' + is_animation_dependent = True + is_scene_dependent = True formula: StringProperty(name='formula', default='val == 0', update=updateNode) deselect_all: BoolProperty(name='deselect', default=False, update=updateNode) @@ -41,8 +42,7 @@ class SvSelectMeshVerts(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): mode: EnumProperty(items=modes, default='vertices', update=updateNode) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.prop(self, "deselect_all", text="clear selection") layout.prop(self, "mode", expand=True) if self.inputs[4].is_linked: diff --git a/nodes/object_nodes/set_blenddata2.py b/nodes/object_nodes/set_blenddata2.py index 57672fdf7e..2d2190348e 100644 --- a/nodes/object_nodes/set_blenddata2.py +++ b/nodes/object_nodes/set_blenddata2.py @@ -18,10 +18,8 @@ import bpy -from mathutils import Matrix from bpy.props import StringProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, second_as_first_cycle as safc) @@ -30,7 +28,7 @@ # pylint: disable=w0613 -class SvSetDataObjectNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvSetDataObjectNodeMK2(bpy.types.Node, SverchCustomTreeNode): """ Triggers: obj id set data Tooltip: Set Object Properties @@ -41,11 +39,12 @@ class SvSetDataObjectNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableN bl_label = 'Object ID Set MK2' bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_OBJECT_ID_SET' + is_scene_dependent = True + is_animation_dependent = True formula: StringProperty(name='formula', default='delta_location', update=updateNode) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.prop(self, "formula", text="") def sv_init(self, context): diff --git a/nodes/object_nodes/set_custom_uv_map.py b/nodes/object_nodes/set_custom_uv_map.py index 3ac8f5b11f..ce108076c1 100644 --- a/nodes/object_nodes/set_custom_uv_map.py +++ b/nodes/object_nodes/set_custom_uv_map.py @@ -13,7 +13,6 @@ from mathutils import Vector from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode, repeat_last from sverchok.utils.sv_bmesh_utils import bmesh_from_edit_mesh @@ -68,7 +67,7 @@ def set_uv_edit_mode(verts: list, faces: list, mesh: bpy.types.Mesh, uv_name: st bml[uv_layer].uv = uv -class SvSetCustomUVMap(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvSetCustomUVMap(bpy.types.Node, SverchCustomTreeNode): """ Triggers: Set custom UV map to Blender mesh @@ -79,11 +78,18 @@ class SvSetCustomUVMap(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): bl_label = 'Set custom UV map' bl_icon = 'GROUP_UVS' + @property + def is_scene_dependent(self): + return (not self.inputs['Objects'].is_linked) and self.inputs['Objects'].object_ref_pointer + + @property + def is_animation_dependent(self): + return (not self.inputs['Objects'].is_linked) and self.inputs['Objects'].object_ref_pointer + uv_name: bpy.props.StringProperty(name='Uv name', default='SVMap', description='Name of UV layer', update=updateNode) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.prop(self, 'uv_name', text='', icon='GROUP_UVS') def sv_init(self, context): diff --git a/nodes/object_nodes/weightsmk2.py b/nodes/object_nodes/weightsmk2.py index 091cd325d3..b137cb77e2 100644 --- a/nodes/object_nodes/weightsmk2.py +++ b/nodes/object_nodes/weightsmk2.py @@ -19,27 +19,27 @@ import bpy from bpy.props import StringProperty, BoolProperty, FloatProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, second_as_first_cycle) -class SvVertexGroupNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvVertexGroupNodeMK2(bpy.types.Node, SverchCustomTreeNode): ''' Vertex Group mk2''' bl_idname = 'SvVertexGroupNodeMK2' bl_label = 'Vertex group weights' bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_VERTEX_WEIGHT' + is_animation_dependent = True + is_scene_dependent = True fade_speed: FloatProperty(name='fade', default=2, update=updateNode) clear: BoolProperty(name='clear w', default=True, update=updateNode) group_name: StringProperty(default='Sv_VGroup', update=updateNode) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.prop(self, "group_name", text="") - def draw_buttons_ext(self, context, layout): + def sv_draw_buttons_ext(self, context, layout): lp = layout.prop lp(self, "clear", text="clear unindexed") lp(self, "fade_speed", text="Clearing speed") diff --git a/nodes/pulga_physics/pulga_physics_lite.py b/nodes/pulga_physics/pulga_physics_lite.py index f1d040fac0..7fbf6ec466 100644 --- a/nodes/pulga_physics/pulga_physics_lite.py +++ b/nodes/pulga_physics/pulga_physics_lite.py @@ -21,7 +21,6 @@ import bpy from bpy.props import IntProperty, StringProperty, BoolProperty, FloatProperty, FloatVectorProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode, node_id, match_long_repeat from sverchok.utils.pulga_physics_core import pulga_system_init @@ -46,7 +45,7 @@ def fill_past_file(p, location): text.clear() text.write(''.join(str(p))) -class SvPulgaPhysicsNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvPulgaPhysicsNode(bpy.types.Node, SverchCustomTreeNode): ''' Triggers: Springs, Cloth Tooltip: Physics Engine @@ -54,6 +53,7 @@ class SvPulgaPhysicsNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode) bl_idname = 'SvPulgaPhysicsNode' bl_label = 'Pulga Physics Lite' bl_icon = 'MOD_PHYSICS' + is_animation_dependent = True n_id : StringProperty() diff --git a/nodes/pulga_physics/pulga_physics_solver.py b/nodes/pulga_physics/pulga_physics_solver.py index 91d3356926..a9731f5aa0 100644 --- a/nodes/pulga_physics/pulga_physics_solver.py +++ b/nodes/pulga_physics/pulga_physics_solver.py @@ -21,12 +21,11 @@ import bpy from bpy.props import IntProperty, StringProperty, BoolProperty, FloatProperty, FloatVectorProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode, match_long_repeat from sverchok.utils.pulga_physics_modular_core import pulga_system_init -class SvPulgaPhysicsSolverNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvPulgaPhysicsSolverNode(bpy.types.Node, SverchCustomTreeNode): ''' Triggers: Simulate Particles Tooltip: Modular Physics Engine @@ -34,6 +33,7 @@ class SvPulgaPhysicsSolverNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatabl bl_idname = 'SvPulgaPhysicsSolverNode' bl_label = 'Pulga Physics Solver' bl_icon = 'MOD_PHYSICS' + is_animation_dependent = True iterations: IntProperty( name='Iterations', description='Number of Iterations', diff --git a/nodes/scene/FCurve_in.py b/nodes/scene/FCurve_in.py index ae3a9ae7a5..cd319cd596 100644 --- a/nodes/scene/FCurve_in.py +++ b/nodes/scene/FCurve_in.py @@ -6,11 +6,8 @@ # License-Filename: LICENSE import bpy -# import mathutils -# from mathutils import Vector from bpy.props import IntProperty, StringProperty, EnumProperty # FloatProperty, BoolProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode from sverchok.utils.sv_operator_mixins import SvGenericCallbackWithParams @@ -20,7 +17,7 @@ class SvFCurveMK1CB(bpy.types.Operator, SvGenericCallbackWithParams): bl_label = "Callback for fcurve sampler node mk1" bl_options = {'INTERNAL'} -class SvFCurveInNodeMK1(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvFCurveInNodeMK1(bpy.types.Node, SverchCustomTreeNode): ''' Triggers: FCurve In Tooltip: Get result of curve evaluated at frame x @@ -31,6 +28,7 @@ class SvFCurveInNodeMK1(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): bl_idname = 'SvFCurveInNodeMK1' bl_label = 'F-Curve In' bl_icon = 'FCURVE' + is_scene_dependent = True def wrapped_update(self, context): @@ -64,8 +62,7 @@ def sv_init(self, context): self.inputs.new("SvStringsSocket", "Frame") self.outputs.new("SvStringsSocket", "Evaluated") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): row = layout.row(align=True) row.prop_search(self, 'object_name', bpy.data, 'objects', text='', icon='OBJECT_DATA') row.operator("node.sv_fcurvenodemk1_callback_with_params", text='', icon="ZOOM_IN").fn_name="add_empty" diff --git a/nodes/scene/collection_picker_mk1.py b/nodes/scene/collection_picker_mk1.py index 17b5b526ba..41bf8d38b7 100644 --- a/nodes/scene/collection_picker_mk1.py +++ b/nodes/scene/collection_picker_mk1.py @@ -8,7 +8,6 @@ import bpy from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode from bpy.props import BoolProperty; @@ -16,7 +15,8 @@ # pylint: disable=c0111 # pylint: disable=c0103 -class SvCollectionPicker(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): + +class SvCollectionPicker(bpy.types.Node, SverchCustomTreeNode): """ Triggers: SvCollectionPicker @@ -28,6 +28,8 @@ class SvCollectionPicker(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode) bl_idname = 'SvCollectionPicker' bl_label = 'Collection Picker' bl_icon = 'GROUP' + is_scene_dependent = True + is_animation_dependent = True def find_collections(self, object): return True @@ -50,8 +52,7 @@ def find_collections(self, object): def sv_init(self, context): self.outputs.new("SvObjectSocket", "Objects") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): col = layout.column() col.prop_search(self, 'collection', bpy.data, 'collections', text='', icon='GROUP') layout.prop(self, "show_all_objects") diff --git a/nodes/scene/curve_in.py b/nodes/scene/curve_in.py index 8e7dceff22..3e8e2945f7 100644 --- a/nodes/scene/curve_in.py +++ b/nodes/scene/curve_in.py @@ -17,11 +17,8 @@ # ##### END GPL LICENSE BLOCK ##### import bpy -import mathutils -# from bpy.props import FloatProperty, BoolProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode from sverchok.utils.sv_extended_curve_utils import get_points_bezier, get_points_nurbs, offset from sverchok.utils.modules.range_utils import frange_count @@ -134,11 +131,13 @@ def interpolate_radii(spline, segments, interpolation_type='LINEAR'): return radii -class SvCurveInputNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvCurveInputNode(bpy.types.Node, SverchCustomTreeNode): ''' Curve data in ''' bl_idname = 'SvCurveInputNode' bl_label = 'Curve Input' bl_icon = 'ROOTCURVE' + is_scene_dependent = True + is_animation_dependent = True object_names: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup) mode_options = [(k, k, '', i) for i, k in enumerate(["LINEAR", "CATMUL"])] @@ -158,8 +157,7 @@ def sv_init(self, context): new_o_put("SvStringsSocket", "radii") new_o_put("SvMatrixSocket", "matrices") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.prop(self, 'selected_mode', expand=True) def get_objects(self): diff --git a/nodes/scene/frame_info_mk2.py b/nodes/scene/frame_info_mk2.py index 6885d115ea..a7311b8cd9 100644 --- a/nodes/scene/frame_info_mk2.py +++ b/nodes/scene/frame_info_mk2.py @@ -19,14 +19,14 @@ import bpy from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode -class SvFrameInfoNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvFrameInfoNodeMK2(bpy.types.Node, SverchCustomTreeNode): ''' Frame Info ''' bl_idname = 'SvFrameInfoNodeMK2' bl_label = 'Frame info' bl_icon = 'TIME' + is_animation_dependent = True def sv_init(self, context): outputs = self.outputs @@ -62,9 +62,8 @@ def draw_buttons(self, context, layout): row.operator("screen.frame_jump", text="", icon='FF').end = True row.prop(scene, "frame_current", text="") - def draw_buttons_ext(self, context, layout): + def sv_draw_buttons_ext(self, context, layout): self.draw_buttons(context, layout) - self.draw_animatable_buttons(layout) def process(self): scene = bpy.context.scene diff --git a/nodes/scene/get_objects_data.py b/nodes/scene/get_objects_data.py index 58ac0e404b..c1d2c7752b 100644 --- a/nodes/scene/get_objects_data.py +++ b/nodes/scene/get_objects_data.py @@ -9,9 +9,7 @@ from bpy.props import BoolProperty, StringProperty, IntProperty import bmesh -import sverchok from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator from sverchok.data_structure import updateNode from sverchok.utils.sv_bmesh_utils import pydata_from_bmesh @@ -78,7 +76,8 @@ def get_vertgroups(mesh): numpy_socket_names = ['Vertices', 'Edges', 'Vertex Normals', 'Material Idx', 'Polygon Areas', 'Polygon Centers', 'Polygon Normals'] -class SvGetObjectsData(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): + +class SvGetObjectsData(Show3DProperties, bpy.types.Node, SverchCustomTreeNode): """ Triggers: Object Info Tooltip: Get Scene Objects into Sverchok Tree @@ -89,6 +88,16 @@ class SvGetObjectsData(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, S bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_OBJECTS_IN' + @property + def is_scene_dependent(self): + return (not self.inputs['Objects'].is_linked) and (self.inputs['Objects'].object_ref_pointer + or self.object_names) + + @property + def is_animation_dependent(self): + return (not self.inputs['Objects'].is_linked) and (self.inputs['Objects'].object_ref_pointer + or self.object_names) + def hide_show_versgroups(self, context): outs = self.outputs showing_vg = 'Vers_grouped' in outs @@ -188,8 +197,7 @@ def draw_obj_names(self, layout): def by_input(self): return self.inputs[0].object_ref_pointer is not None or self.inputs[0].is_linked - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): col = layout.column(align=True) by_input = self.by_input if not by_input: @@ -213,7 +221,7 @@ def draw_buttons(self, context, layout): if not by_input: self.draw_obj_names(layout) - def draw_buttons_ext(self, context, layout): + def sv_draw_buttons_ext(self, context, layout): r = layout.column(align=True) row = r.row(align=True) row.label(text="Output Numpy:") @@ -223,7 +231,6 @@ def draw_buttons_ext(self, context, layout): r.prop(self, "out_np", index=i, text=numpy_socket_names[i], toggle=True) layout.prop(self, 'draw_3dpanel', text="To Control panel") - self.draw_animatable_buttons(layout) def rclick_menu(self, context, layout): '''right click sv_menu items''' diff --git a/nodes/scene/particles_MK2.py b/nodes/scene/particles_MK2.py index d541914e38..372c094218 100644 --- a/nodes/scene/particles_MK2.py +++ b/nodes/scene/particles_MK2.py @@ -20,24 +20,21 @@ import numpy as np from bpy.props import BoolProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode, second_as_first_cycle as safc from sverchok.core.handlers import get_sv_depsgraph, set_sv_depsgraph_need -class SvParticlesMK2Node(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvParticlesMK2Node(bpy.types.Node, SverchCustomTreeNode): ''' Particles input node new ''' bl_idname = 'SvParticlesMK2Node' bl_label = 'ParticlesMK2' bl_icon = 'PARTICLES' + is_animation_dependent = True + is_scene_dependent = True Filt_D: BoolProperty(default=True, update=updateNode) - - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) - - def draw_buttons_ext(self, context, layout): - self.draw_animatable_buttons(layout) + + def sv_draw_buttons_ext(self, context, layout): layout.prop(self, "Filt_D", text="filter death") def sv_init(self, context): diff --git a/nodes/scene/timer.py b/nodes/scene/timer.py index 9082186185..6ef7702128 100644 --- a/nodes/scene/timer.py +++ b/nodes/scene/timer.py @@ -21,7 +21,6 @@ from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import updateNode, match_long_repeat -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.utils.modules.statistics_functions import * from sverchok.utils.logging import debug @@ -323,7 +322,7 @@ def execute(self, context): return {"FINISHED"} -class SvTimerNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvTimerNode(bpy.types.Node, SverchCustomTreeNode): """ Triggers: Timer, Elapse Tooltip: Manage elapsed time via Start, Stop, Pause, Reset, Expire operations. @@ -332,6 +331,10 @@ class SvTimerNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): bl_label = 'Timer' bl_icon = 'PREVIEW_RANGE' + @property + def is_animation_dependent(self): + return not self.inputs['Operation'].is_linked + timers: CollectionProperty(name="Timers", type=SvTimerPropertyGroup) def update_time_slider(self, context): @@ -429,9 +432,8 @@ def draw_buttons(self, context, layout): col = layout.column(align=True) col.prop(self, "normalize", text="Normalize Time") - def draw_buttons_ext(self, context, layout): + def sv_draw_buttons_ext(self, context, layout): self.draw_buttons(context, layout) - self.draw_animatable_buttons(layout) layout.prop(self, "absolute") layout.prop(self, "sticky") diff --git a/nodes/scene/uv_texture.py b/nodes/scene/uv_texture.py index 7a090c28c3..5475199069 100644 --- a/nodes/scene/uv_texture.py +++ b/nodes/scene/uv_texture.py @@ -18,19 +18,20 @@ import bpy from bpy.props import StringProperty, EnumProperty, BoolProperty -import bmesh from sverchok.utils.sv_bmesh_utils import * import numpy as np from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode -class SvUVtextureNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): + +class SvUVtextureNode(bpy.types.Node, SverchCustomTreeNode): ''' UV texture node ''' bl_idname = 'SvUVtextureNode' bl_label = 'UVtextures' bl_icon = 'MATERIAL' + is_animation_dependent = True + is_scene_dependent = True def sv_init(self, context): self.inputs.new('SvObjectSocket', "Object") @@ -57,8 +58,7 @@ def avail_uvs(self, context): uv: EnumProperty(items=avail_uvs, name="UV", description="Choose UV to load", update=updateNode) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): layout.prop(self, 'uv', text='uv') def UV(self, object, uv): diff --git a/nodes/script/mesh_eval.py b/nodes/script/mesh_eval.py index 0812cc5644..b70595cb53 100644 --- a/nodes/script/mesh_eval.py +++ b/nodes/script/mesh_eval.py @@ -8,7 +8,6 @@ # upgraded to pointerproperty import ast -from math import * from collections import defaultdict import numpy as np @@ -19,7 +18,6 @@ import io from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.utils.sv_node_utils import sync_pointer_and_stored_name from sverchok.data_structure import updateNode, dataCorrect, match_long_repeat from sverchok.utils.script_importhelper import safe_names @@ -258,7 +256,7 @@ def write_values(self,text,values): bpy.data.texts[text].clear() bpy.data.texts[text].write(values) -class SvMeshEvalNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvMeshEvalNode(bpy.types.Node, SverchCustomTreeNode): """ Triggers: mesh JSON eval expression Tooltip: Generate mesh from parametric JSON expression @@ -305,7 +303,6 @@ def pointer_update(self, context): update=updateNode) def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) row = layout.row() row.prop_search(self, 'file_pointer', bpy.data, 'texts', text='', icon='TEXT') row = layout.row() diff --git a/nodes/script/multi_exec.py b/nodes/script/multi_exec.py index 884bcca421..dc29212976 100644 --- a/nodes/script/multi_exec.py +++ b/nodes/script/multi_exec.py @@ -18,12 +18,8 @@ import json import bpy -import mathutils -import bmesh as bm -import numpy as np from bpy.props import StringProperty, PointerProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode callback_id = 'node.callback_execnodemod' @@ -69,11 +65,13 @@ def execute(self, context): return {'FINISHED'} -class SvExecNodeMod(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvExecNodeMod(bpy.types.Node, SverchCustomTreeNode): '''Execute small script''' bl_idname = 'SvExecNodeMod' bl_label = 'Exec Node Mod' bl_icon = 'CONSOLE' + is_scene_dependent = True + is_animation_dependent = True # depreciated text: StringProperty(default='', update=updateNode) @@ -84,8 +82,7 @@ class SvExecNodeMod(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): dynamic_strings: bpy.props.CollectionProperty(type=SvExecNodeDynaStringItem) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): row = layout.row(align=True) # add() remove() clear() move() row.operator(callback_id, text='', icon='ZOOM_IN').cmd = 'add_new_line' @@ -121,8 +118,7 @@ def draw_buttons(self, context, layout): opp2.idx = idx - def draw_buttons_ext(self, context, layout): - self.draw_animatable_buttons(layout) + def sv_draw_buttons_ext(self, context, layout): col = layout.column(align=True) col.operator(callback_id, text='copy to node').cmd = 'copy_from_text' col.prop_search(self, 'text_pointer', bpy.data, "texts", text="") diff --git a/nodes/script/profile_mk3.py b/nodes/script/profile_mk3.py index 8581faf973..0a245d2f5c 100644 --- a/nodes/script/profile_mk3.py +++ b/nodes/script/profile_mk3.py @@ -24,7 +24,6 @@ from mathutils import Vector from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.utils.sv_node_utils import sync_pointer_and_stored_name from sverchok.core.socket_data import SvNoDataError from sverchok.data_structure import updateNode, match_long_repeat @@ -400,7 +399,8 @@ def execute(self, context): # Node class ################################# -class SvProfileNodeMK3(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): + +class SvProfileNodeMK3(bpy.types.Node, SverchCustomTreeNode): ''' Triggers: svg-like 2d profiles Tooltip: Generate multiple parameteric 2d profiles using SVG like syntax @@ -474,7 +474,6 @@ def pointer_update(self, context): update = updateNode) def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) layout.prop(self, 'selected_axis', expand=True) row = layout.row(align=True) diff --git a/nodes/script/script1_lite.py b/nodes/script/script1_lite.py index 0824f38b1e..38621a0ce9 100644 --- a/nodes/script/script1_lite.py +++ b/nodes/script/script1_lite.py @@ -19,7 +19,6 @@ import os import sys import ast -import json import textwrap import traceback import numpy as np @@ -34,7 +33,6 @@ from sverchok.utils.snlite_utils import vectorize, ddir, sv_njit, sv_njit_clear from sverchok.utils.sv_bmesh_utils import bmesh_from_pydata, pydata_from_bmesh from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode @@ -107,7 +105,7 @@ def execute(self, context): return {'FINISHED'} -class SvScriptNodeLite(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvScriptNodeLite(bpy.types.Node, SverchCustomTreeNode): """ Triggers: snl @@ -121,6 +119,8 @@ class SvScriptNodeLite(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): bl_idname = 'SvScriptNodeLite' bl_label = 'Scripted Node Lite' bl_icon = 'SCRIPTPLUGINS' + is_scene_dependent = True + is_animation_dependent = True def return_enumeration(self, enum_name=""): ND = self.node_dict.get(hash(self)) @@ -530,8 +530,7 @@ def custom_draw(self, context, layout): if f: f(self, context, layout) - - def draw_buttons(self, context, layout): + def sv_draw_buttons(self, context, layout): sn_callback = 'node.scriptlite_ui_callback' if not self.script_str: @@ -540,7 +539,6 @@ def draw_buttons(self, context, layout): row.prop_search(self, 'script_name', bpy.data, 'texts', text='', icon='TEXT') row.operator(sn_callback, text='', icon='PLUGIN').fn_name = 'load' else: - self.draw_animatable_buttons(layout, icon_only=True) col = layout.column(align=True) row = col.row() row.operator(sn_callback, text='Reload').fn_name = 'load' @@ -548,8 +546,7 @@ def draw_buttons(self, context, layout): self.custom_draw(context, layout) - - def draw_buttons_ext(self, _, layout): + def sv_draw_buttons_ext(self, _, layout): row = layout.row() row.prop(self, 'selected_mode', expand=True) col = layout.column() diff --git a/nodes/script/sn_functor_b.py b/nodes/script/sn_functor_b.py index b5d4f479d1..42b58fc059 100644 --- a/nodes/script/sn_functor_b.py +++ b/nodes/script/sn_functor_b.py @@ -7,21 +7,16 @@ import sys import json -import inspect import imp import types import itertools -from importlib import reload import bpy -from mathutils import Matrix, Vector from bpy.props import FloatProperty, IntProperty, StringProperty, BoolProperty, PointerProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode, node_id from sverchok.utils.sv_operator_mixins import SvGenericCallbackWithParams -from sverchok.utils.sv_bmesh_utils import bmesh_from_pydata, pydata_from_bmesh from sverchok.utils.sv_IO_pointer_helpers import pack_pointer_property_name, unpack_pointer_property_name functions = "draw_buttons", "process", "functor_init" @@ -55,7 +50,7 @@ def clear_sockets(self): self.inputs.clear() self.outputs.clear() -class SvSNFunctorB(bpy.types.Node, SverchCustomTreeNode, SvSNPropsFunctor, SvAnimatableNode): +class SvSNFunctorB(bpy.types.Node, SverchCustomTreeNode, SvSNPropsFunctor): """ Triggers: functorB Tooltip: use a simpler nodescript style @@ -66,6 +61,8 @@ class SvSNFunctorB(bpy.types.Node, SverchCustomTreeNode, SvSNPropsFunctor, SvAni bl_idname = 'SvSNFunctorB' bl_label = 'SN Functor B' bl_icon = 'SYSTEM' + is_scene_dependent = True + is_animation_dependent = True def wrapped_update(self, context): if self.script_pointer: @@ -114,8 +111,7 @@ def handle_execution_nid(self, func_name, msg, args): print('on line # {}'.format(exec_info.tb_lineno)) print('code:', exec_info.tb_frame.f_code) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): if not self.loaded: row = layout.row() row.prop_search(self, 'script_pointer', bpy.data, 'texts', text='') diff --git a/nodes/text/text_in_mk2.py b/nodes/text/text_in_mk2.py index c568b8311a..0eb0faf423 100644 --- a/nodes/text/text_in_mk2.py +++ b/nodes/text/text_in_mk2.py @@ -15,13 +15,11 @@ import collections import json import ast -import sverchok import bpy from bpy.props import BoolProperty, EnumProperty, StringProperty, IntProperty, PointerProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import node_id, multi_socket, updateNode from sverchok.utils.sv_text_io_common import ( @@ -73,7 +71,7 @@ def pop_all_data(node, n_id): node.json_data.pop(n_id, None) -class SvTextInNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvTextInNodeMK2(bpy.types.Node, SverchCustomTreeNode): """ Triggers: Text in from datablock Tooltip: Quickly load text from datablock into NodeView diff --git a/nodes/transforms/texture_displace_mk2.py b/nodes/transforms/texture_displace_mk2.py index 7708d2c864..0b0da4f63a 100644 --- a/nodes/transforms/texture_displace_mk2.py +++ b/nodes/transforms/texture_displace_mk2.py @@ -21,7 +21,6 @@ from mathutils import Vector, Matrix from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.core.socket_data import SvGetSocketInfo from sverchok.data_structure import updateNode, list_match_func, numpy_list_match_modes from sverchok.utils.sv_IO_pointer_helpers import unpack_pointer_property_name @@ -41,7 +40,8 @@ def evaluate(self, vec): 'Texture Matrix': lambda v, m: m @ v } -class SvDisplaceNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): + +class SvDisplaceNodeMk2(bpy.types.Node, SverchCustomTreeNode): """ Triggers: Add texture to verts Tooltip: Affect input verts/mesh with a scene texture. Mimics Blender Displace modifier @@ -51,6 +51,7 @@ class SvDisplaceNodeMk2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): bl_idname = 'SvDisplaceNodeMk2' bl_label = 'Texture Displace' bl_icon = 'MOD_DISPLACE' + is_scene_dependent = True out_modes = [ ('NORMAL', 'Normal', 'Texture displacement along Vertex Normal', '', 1), @@ -166,9 +167,8 @@ def draw_texture_socket(self, socket, context, layout): else: layout.label(text=socket.name+ '. ' + SvGetSocketInfo(socket)) - def draw_buttons(self, context, layout): + def sv_draw_buttons(self, context, layout): is_vector = self.out_mode in ['RGB to XYZ', 'HSV to XYZ', 'HLS to XYZ'] - self.draw_animatable_buttons(layout, icon_only=True) c = layout.split(factor=0.5, align=False) r = c.column(align=False) r.label(text='Direction'+ ':') @@ -182,8 +182,7 @@ def draw_buttons(self, context, layout): r.label(text='Channel'+ ':') r.prop(self, 'color_channel', expand=False, text='') - - def draw_buttons_ext(self, context, layout): + def sv_draw_buttons_ext(self, context, layout): '''draw buttons on the N-panel''' self.draw_buttons(context, layout) layout.prop(self, 'list_match', expand=False) diff --git a/old_nodes/blenddata_to_svdata2.py b/old_nodes/blenddata_to_svdata2.py index 7b4fc5ece2..e33683de41 100644 --- a/old_nodes/blenddata_to_svdata2.py +++ b/old_nodes/blenddata_to_svdata2.py @@ -20,16 +20,16 @@ import bpy from bpy.props import BoolProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode) from sverchok.core.handlers import get_sv_depsgraph, set_sv_depsgraph_need -class SvObjectToMeshNodeMK2(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvObjectToMeshNodeMK2(bpy.types.Node, SverchCustomTreeNode): '''Get Object Data''' bl_idname = 'SvObjectToMeshNodeMK2' bl_label = 'Object ID Out MK2' bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_OBJECT_ID_OUT' + is_animation_dependent = True replacement_nodes = [('SvGetObjectsData', None, @@ -55,8 +55,7 @@ def sv_init(self, context): self.outputs.new('SvVerticesSocket', "PolygonNormals") self.outputs.new('SvMatrixSocket', "Matrices") - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): row = layout.row() row.prop(self, "modifiers", text="Post modifiers") diff --git a/old_nodes/get_asset_properties.py b/old_nodes/get_asset_properties.py index b27ebdb62e..367cc04272 100644 --- a/old_nodes/get_asset_properties.py +++ b/old_nodes/get_asset_properties.py @@ -19,7 +19,6 @@ import bpy from bpy.props import EnumProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import (updateNode, no_space, enum_item as e) def frame_from_available(idx, layer): @@ -59,12 +58,13 @@ def frame_from_available2(current_frame, layer): return inp_to_index.get(tval, 0) -class SvGetAssetProperties(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvGetAssetProperties(bpy.types.Node, SverchCustomTreeNode): ''' Get Asset Props ''' bl_idname = 'SvGetAssetProperties' bl_label = 'Object ID Selector' bl_icon = 'SELECT_SET' sv_icon = 'SV_OBJECT_ID_SELECTOR' + is_animation_dependent = True def pre_updateNode(self, context): ''' must rebuild for each update''' @@ -155,9 +155,8 @@ def draw_gp_options(self, context, layout): layout.prop(self, 'gp_pass_points', text='pass points') - def draw_buttons(self, context, layout): + def sv_draw_buttons(self, context, layout): # layout.operator('node.' ,text='refresh from scene') - self.draw_animatable_buttons(layout, icon_only=True) layout.row().prop(self, "Mode", text="data") if self.Mode == 'objects': diff --git a/old_nodes/objects_mk3.py b/old_nodes/objects_mk3.py index 09a3fd2e3f..24df590036 100644 --- a/old_nodes/objects_mk3.py +++ b/old_nodes/objects_mk3.py @@ -9,9 +9,7 @@ from bpy.props import BoolProperty, StringProperty, IntProperty import bmesh -import sverchok from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator from sverchok.data_structure import updateNode from sverchok.utils.sv_bmesh_utils import pydata_from_bmesh @@ -71,7 +69,7 @@ def sv_execute(self, context, node): getattr(node, self.fn_name)(self) -class SvObjectsNodeMK3(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvObjectsNodeMK3(Show3DProperties, bpy.types.Node, SverchCustomTreeNode): """ Triggers: obj Input Scene Objects pydata Tooltip: Get Scene Objects into Sverchok Tree @@ -81,6 +79,7 @@ class SvObjectsNodeMK3(Show3DProperties, bpy.types.Node, SverchCustomTreeNode, S bl_label = 'Objects in' bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_OBJECTS_IN' + is_animation_dependent = True replacement_nodes = [('SvGetObjectsData', None, @@ -174,10 +173,7 @@ def draw_obj_names(self, layout): else: layout.label(text='--None--') - - - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + def sv_draw_buttons(self, context, layout): col = layout.column(align=True) row = col.row() @@ -197,9 +193,8 @@ def draw_buttons(self, context, layout): row.prop(self, "vergroups", text="VeGr", toggle=True) self.draw_obj_names(layout) - def draw_buttons_ext(self, context, layout): + def sv_draw_buttons_ext(self, context, layout): layout.prop(self, 'draw_3dpanel', text="To Control panel") - self.draw_animatable_buttons(layout) def draw_buttons_3dpanel(self, layout): callback = 'node.ob3_callback' diff --git a/old_nodes/texture_displace.py b/old_nodes/texture_displace.py index 475c754718..5afeff41ca 100644 --- a/old_nodes/texture_displace.py +++ b/old_nodes/texture_displace.py @@ -21,7 +21,6 @@ from mathutils import Vector, Matrix from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.core.socket_data import SvGetSocketInfo from sverchok.data_structure import updateNode, list_match_func, numpy_list_match_modes from sverchok.utils.sv_itertools import recurse_f_level_control @@ -40,7 +39,7 @@ def evaluate(self, vec): 'Texture Matrix': lambda v, m: m @ v } -class SvDisplaceNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): +class SvDisplaceNode(bpy.types.Node, SverchCustomTreeNode): """ Triggers: Add texture to verts Tooltip: Affect input verts/mesh with a scene texture. Mimics Blender Displace modifier @@ -50,7 +49,7 @@ class SvDisplaceNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): bl_idname = 'SvDisplaceNode' bl_label = 'Texture Displace' bl_icon = 'MOD_DISPLACE' - + is_animation_dependent = True replacement_nodes = [('SvDisplaceNodeMk2', None, None)] out_modes = [ @@ -174,9 +173,9 @@ def draw_texture_socket(self, socket, context, layout): c.prop_search(self, "name_texture", bpy.data, 'textures', text="") else: layout.label(text=socket.name+ '. ' + SvGetSocketInfo(socket)) - def draw_buttons(self, context, layout): + + def sv_draw_buttons(self, context, layout): is_vector = self.out_mode in ['RGB to XYZ', 'HSV to XYZ', 'HLS to XYZ'] - self.draw_animatable_buttons(layout, icon_only=True) c = layout.split(factor=0.5, align=False) r = c.column(align=False) r.label(text='Direction'+ ':') @@ -191,7 +190,7 @@ def draw_buttons(self, context, layout): r.prop(self, 'color_channel', expand=False, text='') # layout.prop(self, 'tex_coord_type', text="Tex. Coord") - def draw_buttons_ext(self, context, layout): + def sv_draw_buttons_ext(self, context, layout): '''draw buttons on the N-panel''' self.draw_buttons(context, layout) layout.prop(self, 'list_match', expand=False) diff --git a/old_nodes/texture_evaluate.py b/old_nodes/texture_evaluate.py index 155961cbff..2fc8a80cfe 100644 --- a/old_nodes/texture_evaluate.py +++ b/old_nodes/texture_evaluate.py @@ -21,7 +21,6 @@ from mathutils import Vector from sverchok.node_tree import SverchCustomTreeNode -from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.core.socket_data import SvGetSocketInfo from sverchok.data_structure import (updateNode, list_match_func, numpy_list_match_modes, iter_list_match_func, no_space) @@ -74,7 +73,8 @@ def meshes_texture_evaluate(params, constant, matching_f): 'Object': lambda v: Vector(v), } -class SvTextureEvaluateNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNode): + +class SvTextureEvaluateNode(bpy.types.Node, SverchCustomTreeNode): """ Triggers: Scence Texture In Tooltip: Evaluate Scene texture at input coordinates @@ -84,7 +84,7 @@ class SvTextureEvaluateNode(bpy.types.Node, SverchCustomTreeNode, SvAnimatableNo bl_idname = 'SvTextureEvaluateNode' bl_label = 'Texture Evaluate' bl_icon = 'FORCE_TEXTURE' - + is_animation_dependent = True texture_coord_modes = [ ('UV', 'UV coordinates', 'Input UV coordinates to evaluate texture. (0 to 1 as domain)', '', 1), ('Object', 'Object', 'Input Object coordinates to evaluate texture. (-1 to 1 as domain)', '', 2), @@ -145,8 +145,8 @@ def draw_texture_socket(self, socket, context, layout): c.prop_search(self, "name_texture", bpy.data, 'textures', text="") else: layout.label(text=socket.name+ '. ' + SvGetSocketInfo(socket)) - def draw_buttons(self, context, layout): - self.draw_animatable_buttons(layout, icon_only=True) + + def sv_draw_buttons(self, context, layout): b = layout.split(factor=0.33, align=True) b.label(text='Mapping:') b.prop(self, 'tex_coord_type', expand=False, text='') @@ -156,9 +156,8 @@ def draw_buttons(self, context, layout): if self.color_channel == 'Color': layout.prop(self, 'use_alpha', text="Use Alpha") - def draw_buttons_ext(self, context, layout): + def sv_draw_buttons_ext(self, context, layout): '''draw buttons on the N-panel''' - self.draw_animatable_buttons(layout) self.draw_buttons(context, layout) layout.prop(self, 'list_match', expand=False) diff --git a/ui/nodeview_keymaps.py b/ui/nodeview_keymaps.py index 6a89853565..105ec52042 100644 --- a/ui/nodeview_keymaps.py +++ b/ui/nodeview_keymaps.py @@ -222,12 +222,6 @@ def add_keymap(): kmi = km.keymap_items.new('node.zoom_to_node', 'Z', 'PRESS', alt=True) nodeview_keymaps.append((km, kmi)) - # 3D View - km = kc.keymaps.new(name='3D View', space_type='VIEW_3D') - kmi = km.keymap_items.new('wm.sv_obj_modal_update', 'F5', 'PRESS', ctrl=True, shift=True) - kmi.properties.mode='toggle' - nodeview_keymaps.append((km, kmi)) - def remove_keymap(): diff --git a/ui/sv_3d_panel.py b/ui/sv_3d_panel.py index 43a93e9498..cc6e097dec 100644 --- a/ui/sv_3d_panel.py +++ b/ui/sv_3d_panel.py @@ -8,8 +8,6 @@ import bpy -from sverchok.utils.handle_blender_data import BlTrees - class SV_PT_3DPanel(bpy.types.Panel): """Panel to manipulate parameters in Sverchok layouts""" @@ -21,11 +19,6 @@ class SV_PT_3DPanel(bpy.types.Panel): def draw(self, context): col = self.layout.column() - if context.scene.SvShowIn3D_active: - col.operator('wm.sv_obj_modal_update', text='Stop live update', icon='CANCEL').mode = 'end' - else: - col.operator('wm.sv_obj_modal_update', text='Start live update', icon='EDITMODE_HLT').mode = 'start' - col.operator('node.sverchok_update_all', text='Update all trees') col.operator('node.sv_scan_properties', text='Scan for props') @@ -170,6 +163,7 @@ def draw_tree(list_item, row, ui_list): row.prop(tree, 'sv_show', icon=f"RESTRICT_VIEW_{'OFF' if tree.sv_show else 'ON'}", text=' ') row.prop(tree, 'sv_animate', icon='ANIM', text=' ') + row.prop(tree, 'sv_scene_update', icon='SCENE_DATA', text=' ') row.prop(tree, "sv_process", toggle=True, text="P") row.prop(tree, "sv_draft", toggle=True, text="D") @@ -425,70 +419,6 @@ def draw(self, context): self.layout.prop(self, 'new_tree_name') -class Sv3DViewObjInUpdater(bpy.types.Operator, object): - """For automatic trees reevaluation upon changes in 3D space""" - bl_idname = "wm.sv_obj_modal_update" - bl_label = "start n stop obj updating" - - _timer = None - mode: bpy.props.StringProperty(default='toggle') - speed: bpy.props.FloatProperty(default=1 / 13) - - def modal(self, context, event): - - if not context.scene.SvShowIn3D_active: - self.cancel(context) - return {'FINISHED'} - - elif not (event.type == 'TIMER'): - return {'PASS_THROUGH'} - - ''' reaches here only if event is TIMER and self.active ''' - objects_nodes_set = {'ObjectsNode', 'ObjectsNodeMK2', 'SvObjectsNodeMK3', 'SvExNurbsInNode', 'SvBezierInNode', - 'SvGetObjectsData', 'SvObjectsNodeMK3'} - for ng in BlTrees().sv_main_trees: - ng.update_nodes((n for n in ng.nodes if n.bl_idname in objects_nodes_set), cancel=False) - - return {'PASS_THROUGH'} - - def start(self, context): - context.scene.SvShowIn3D_active = True - - # rate can only be set in event_timer_add (I think...) - # self.speed = 1 / context.node.updateRate - - wm = context.window_manager - self._timer = wm.event_timer_add(self.speed, window=context.window) - wm.modal_handler_add(self) - self.report({'INFO'}, "Live Update mode enabled") - - def stop(self, context): - context.scene.SvShowIn3D_active = False - - def toggle(self, context): - if context.scene.SvShowIn3D_active: - self.stop(context) - else: - self.start(context) - - def event_dispatcher(self, context, type_op): - if type_op == 'start': - self.start(context) - elif type_op == 'end': - self.stop(context) - else: - self.toggle(context) - - def execute(self, context): - self.event_dispatcher(context, self.mode) - return {'RUNNING_MODAL'} - - def cancel(self, context): - wm = context.window_manager - wm.event_timer_remove(self._timer) - self.report({'INFO'}, "Live Update mode disabled") - - classes = [ SV_PT_3DPanel, SV_UL_NodeTreePropertyList, @@ -498,7 +428,6 @@ def cancel(self, context): Sv3dPropRemoveItem, Sv3DNodeProperties, SvPopupEditLabel, - Sv3DViewObjInUpdater, ] diff --git a/ui/sv_panels.py b/ui/sv_panels.py index e5a8c26e99..5f775b2f74 100644 --- a/ui/sv_panels.py +++ b/ui/sv_panels.py @@ -66,6 +66,7 @@ def draw(self, context): col.use_property_split = True col.prop(ng, 'sv_show', text="Viewers", icon=f"RESTRICT_VIEW_{'OFF' if ng.sv_show else 'ON'}") col.prop(ng, 'sv_animate', text="Animation", icon='ANIM') + col.prop(ng, 'sv_scene_update', text="Scene", icon='SCENE_DATA') col.prop(ng, 'sv_process', text="Live update", toggle=True) col.prop(ng, "sv_draft", text="Draft mode", toggle=True) @@ -180,11 +181,12 @@ def draw_item(self, context, layout, data, item, icon, active_data, active_propn # buttons row = row.row(align=True) row.alignment = 'RIGHT' - row.ui_units_x = 4.5 + row.ui_units_x = 5.5 row.operator('node.sverchok_bake_all', text='B').node_tree_name = tree.name row.prop(tree, 'sv_show', icon= f"RESTRICT_VIEW_{'OFF' if tree.sv_show else 'ON'}", text=' ') row.prop(tree, 'sv_animate', icon='ANIM', text=' ') - row.prop(tree, "sv_process", toggle=True, text="P") + row.prop(tree, 'sv_scene_update', icon='SCENE_DATA', text=' ') + row.prop(tree, "sv_process", toggle=True, text="L") row.prop(tree, "sv_draft", toggle=True, text="D") def filter_items(self, context, data, prop_name): @@ -328,13 +330,6 @@ def node_show_tree_mode(self, context): layout.label(text=message, icon=icon) -def view3d_show_live_mode(self, context): - if context.scene.SvShowIn3D_active: - layout = self.layout - OP = 'wm.sv_obj_modal_update' - layout.operator(OP, text='Stop Live Update', icon='CANCEL').mode = 'end' - - sv_tools_classes = [ SV_PT_ToolsMenu, SV_PT_ActiveTreePanel, @@ -352,26 +347,15 @@ def view3d_show_live_mode(self, context): def register(): - bpy.types.Scene.SvShowIn3D_active = bpy.props.BoolProperty( - name='update from 3dview', - default=False, - description='Allows updates directly to object-in nodes from 3d panel') - for class_name in sv_tools_classes: bpy.utils.register_class(class_name) bpy.types.Scene.ui_list_selected_tree = bpy.props.IntProperty() # Pointer to selected item in list of trees bpy.types.NODE_HT_header.append(node_show_tree_mode) - bpy.types.VIEW3D_HT_header.append(view3d_show_live_mode) def unregister(): del bpy.types.Scene.ui_list_selected_tree - for class_name in reversed(sv_tools_classes): - bpy.utils.unregister_class(class_name) - - del bpy.types.Scene.SvShowIn3D_active bpy.types.NODE_HT_header.remove(node_show_tree_mode) - bpy.types.VIEW3D_HT_header.remove(view3d_show_live_mode) diff --git a/utils/nodes_mixins/sv_animatable_nodes.py b/utils/nodes_mixins/sv_animatable_nodes.py deleted file mode 100644 index b1b955f878..0000000000 --- a/utils/nodes_mixins/sv_animatable_nodes.py +++ /dev/null @@ -1,52 +0,0 @@ -# This file is part of project Sverchok. It's copyrighted by the contributors -# recorded in the version control history of the file, available from -# its original location https://github.com/nortikin/sverchok/commit/master -# -# SPDX-License-Identifier: GPL3 -# License-Filename: LICENSE - -from bpy.props import BoolProperty -from sverchok.data_structure import updateNode - -# pylint: disable=c0111 -# pylint: disable=c0103 - - -class SvAnimatableNode(): - ''' - This mixin is used to add is_animatable property to the node. - This property is used on frame change to determine which nodes should be updated - The node file will need to have this code line: - - from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode - - And the node class will need to inherit this class. - - To allow the user to control it just add in draw buttons function: - self.draw_animatable_buttons(layout, icon_only=True) - or/and in the draw_buttons_ext function - self.draw_animatable_buttons(layout) - - ''' - is_animatable: BoolProperty( - name="Animate Node", - description="Update Node on frame change", - default=True - ) - - def refresh_node(self, context): - if self.refresh: - self.refresh = False - updateNode(self, context) - - refresh: BoolProperty( - name="Update Node", - description="Update Node", - default=False, - update=refresh_node - ) - - def draw_animatable_buttons(self, layout, icon_only=False, update_big=False): - row = layout.row(align=True) - row.prop(self, 'is_animatable', icon='ANIM', icon_only=icon_only) - row.prop(self, 'refresh', icon='FILE_REFRESH', icon_only=icon_only and not update_big)