Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

back-end sanitizing, joining files. #4076

Merged
merged 2 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nodes/exchange/bezier_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator
from sverchok.data_structure import updateNode, zip_long_repeat, split_by_count
from sverchok.utils.curve.algorithms import concatenate_curves
from sverchok.utils.curve.bezier import SvCubicBezierCurve
Expand Down
2 changes: 1 addition & 1 deletion nodes/exchange/nurbs_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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_utils import SvGenericNodeLocator
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
Expand Down
2 changes: 1 addition & 1 deletion nodes/list_mutators/multi_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import changable_sockets, dataCorrect, updateNode, zip_long_repeat
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator


class SvvMultiCacheReset(bpy.types.Operator, SvGenericNodeLocator):
Expand Down
2 changes: 1 addition & 1 deletion nodes/logic/evolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
from sverchok.core.update_system import make_tree_from_nodes, do_update
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator
from sverchok.utils.listutils import (
listinput_getI,
listinput_getF,
Expand Down
2 changes: 1 addition & 1 deletion nodes/logic/genes_holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import dataCorrect, updateNode
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator


class SvGenesHolderReset(bpy.types.Operator, SvGenericNodeLocator):
Expand Down
2 changes: 1 addition & 1 deletion nodes/network/file_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, match_long_repeat
from sverchok.utils.modules import sv_bmesh
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator


class SvFilePathFinder(bpy.types.Operator, SvGenericNodeLocator):
Expand Down
2 changes: 1 addition & 1 deletion nodes/scene/objects_in_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sverchok
from sverchok.utils.mesh_repr_utils import flatten, unflatten, generate_object
from sverchok.utils.sv_bmesh_utils import bmesh_from_pydata
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode

Expand Down
2 changes: 1 addition & 1 deletion nodes/scene/objects_mk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sverchok
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator
from sverchok.data_structure import updateNode
from sverchok.utils.sv_bmesh_utils import pydata_from_bmesh
from sverchok.core.handlers import get_sv_depsgraph, set_sv_depsgraph_need
Expand Down
2 changes: 1 addition & 1 deletion nodes/solid/export_solid.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import flatten_data, map_recursive
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator
from sverchok.utils.curve.core import SvCurve
from sverchok.utils.surface.core import SvSurface
from sverchok.utils.logging import debug
Expand Down
2 changes: 1 addition & 1 deletion nodes/svg/svg_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import sverchok
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator

evolver_mem = {}

Expand Down
2 changes: 1 addition & 1 deletion nodes/viz/viewer_waveform_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from mathutils import Vector

from sverchok.utils.context_managers import sv_preferences
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode, node_id
from sverchok.ui import bgl_callback_nodeview as nvBGL
Expand Down
2 changes: 1 addition & 1 deletion ui/nodeview_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# SPDX-License-Identifier: GPL3
# License-Filename: LICENSE

from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator
import bpy

class SvNodeViewZoomBorder(bpy.types.Operator, SvGenericNodeLocator):
Expand Down
7 changes: 2 additions & 5 deletions utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,9 @@ def auto_gather_node_classes(start_module = None):


def get_node_class_reference(bl_idname):
# formerly stuff like:
# cls = getattr(bpy.types, self.cls_bl_idname, None)

if bl_idname == "NodeReroute":
return getattr(bpy.types, bl_idname)
# this will also return a Nonetype if the ref isn't found, and the class ref if found

return node_classes.get(bl_idname)


Expand Down Expand Up @@ -138,7 +135,7 @@ def app_handler_ops(append=None, remove=None):
"text_editor_submenu", "text_editor_plugins",
# UI operators and tools
"sv_IO_pointer_helpers",
"sv_IO_monad_helpers", "sv_operator_utils",
"sv_IO_monad_helpers", "sv_operator_mixins",
"sv_gist_tools", "sv_IO_panel_tools", "sv_load_archived_blend",
"monad", "sv_help", "sv_default_macros", "sv_macro_utils", "sv_extra_search", "sv_3dview_tools",
"sv_update_utils", "sv_obj_helper", "sv_batch_primitives", "sv_idx_viewer28_draw",
Expand Down
2 changes: 1 addition & 1 deletion utils/sv_3dview_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from sverchok.core.socket_conversions import is_matrix
from sverchok.utils.modules import geom_utils
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator


def get_matrix(socket):
Expand Down
2 changes: 1 addition & 1 deletion utils/sv_obj_baker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from mathutils import Vector, Matrix

from sverchok.data_structure import node_id, dataCorrect, dataCorrect_np
from sverchok.utils.sv_operator_utils import SvGenericNodeLocator
from sverchok.utils.sv_operator_mixins import SvGenericNodeLocator

cache_viewer_baker = {}

Expand Down
90 changes: 73 additions & 17 deletions utils/sv_operator_mixins.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# 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


import bpy
from bpy.props import StringProperty

class SvGenericNodeLocator():
"""
usage:
add this to an Operator class definition if you need to track the origin
of a click.

see at the bottom of this file in " class SvGenericCallbackOldOp " how to use it.
you can then use the "node.wrapper_tracked_ui_draw_op", in the UI draw function..

f.ex:
callback = "node.sverchok_mesh_baker_mk3"
self.wrapper_tracked_ui_draw_op(row, callback, icon='', text='')

"""
tree_name: StringProperty(default='', description="name of the node tree")
node_name: StringProperty(default='', description="name of the node")

def get_node(self, context):
""" context.node is usually provided, else tree_name/node_name must be passed """
if self.tree_name and self.node_name:
return bpy.data.node_groups[self.tree_name].nodes[self.node_name]

if hasattr(context, "node"):
return context.node

print("treename or nodename not supplied, node not found in available trees")
print(f"received tree_name: {tree_name} and node_name: {node_name}")
return None

def get_tree(self):
return bpy.data.node_groups.get(self.tree_name)


class SvGenericCallbackWithParams():
Expand Down Expand Up @@ -159,3 +182,36 @@ def invoke(self, context, event):
wm = context.window_manager
wm.fileselect_add(self)
return {'RUNNING_MODAL'}


class SvGenericCallbackOldOp(bpy.types.Operator, SvGenericNodeLocator):
"""
This operator is generic and will call .fn_name on the instance of the caller node
"""
bl_idname = "node.sverchok_generic_callback_old"
bl_label = "Sverchok text input"
bl_options = {'REGISTER', 'UNDO'}

fn_name: StringProperty(name='function name')

def execute(self, context):
n = self.get_node(context)
if not n:
return {'CANCELLED'}

f = getattr(n, self.fn_name, None)
if not f:
msg = f"{n.name} has no function named '{self.fn_name}'"
self.report({"WARNING"}, msg)
return {'CANCELLED'}
f()

return {'FINISHED'}


def register():
bpy.utils.register_class(SvGenericCallbackOldOp)


def unregister():
bpy.utils.unregister_class(SvGenericCallbackOldOp)
72 changes: 0 additions & 72 deletions utils/sv_operator_utils.py

This file was deleted.