Пример #1
0
 def execute(self, context):
     sv_ngs = filter(lambda ng:ng.bl_idname == 'SverchCustomTreeType', bpy.data.node_groups)
     for ng in sv_ngs:
         ng.unfreeze(hard=True)
     build_update_list()
     process_tree()
     return {'FINISHED'}
Пример #2
0
def sv_post_load(scene):
    """
    Upgrade nodes, apply preferences and do an update.
    THe update order is next:
    1. pre_load handler
    2. update methods of trees in a file
    3. post_load handler
    post_load handler is also called when Blender is first ran
    The method should remove throttling trees made in pre_load event,
    initialize Sverchok parts which are required by loaded tree
    and update all Sverchok trees
    """
    from sverchok import node_tree, settings

    # ensure current nodeview view scale / location parameters reflect users' system settings
    node_tree.SverchCustomTree.update_gl_scale_info(None, "sv_post_load")

    # register and mark old and dependent nodes
    with catch_log_error():
        if any(not n.is_registered_node_type() for ng in BlTrees().sv_trees
               for n in ng.nodes):
            old_nodes.register_all()
            old_nodes.mark_all()
            dummy_nodes.register_all()
            dummy_nodes.mark_all()

    with catch_log_error():
        settings.apply_theme_if_necessary()

    # release all trees and update them
    set_first_run(False)
    build_update_list()
    process_tree()
Пример #3
0
 def execute(self, context):
     ng = bpy.data.node_groups.get(self.node_group)
     if ng:
         ng.unfreeze(hard=True)
         build_update_list(ng)
         process_tree(ng)
     return {'FINISHED'}
Пример #4
0
 def execute(self, context):
     sv_ngs = filter(lambda ng:ng.bl_idname == 'SverchCustomTreeType', bpy.data.node_groups)
     for ng in sv_ngs:
         ng.unfreeze(hard=True)
     build_update_list()
     process_tree()
     return {'FINISHED'}
Пример #5
0
 def process_ani(self):
     """
     Process the Sverchok node tree if animation layers show true.
     For animation callback/handler
     """
     if self.sv_animate:
         process_tree(self)
Пример #6
0
 def process_ani(self):
     """
     Process the Sverchok node tree if animation layers show true.
     For animation callback/handler
     """
     if self.sv_animate:
         process_tree(self)
Пример #7
0
 def execute(self, context):
     ng = bpy.data.node_groups.get(self.node_group)
     if ng:
         ng.unfreeze(hard=True)
         build_update_list(ng)
         process_tree(ng)
     return {'FINISHED'}
Пример #8
0
 def execute(self, context):
     try:
         bpy.context.window.cursor_set("WAIT")
         ng = bpy.data.node_groups.get(self.node_group)
         if ng:
             build_update_list(ng)
             process_tree(ng)
     finally:
         bpy.context.window.cursor_set("DEFAULT")
     return {'FINISHED'}
Пример #9
0
 def execute(self, context):
     try:
         bpy.context.window.cursor_set("WAIT")
         sv_ngs = filter(lambda ng: ng.bl_idname == 'SverchCustomTreeType',
                         bpy.data.node_groups)
         build_update_list()
         process_tree()
     finally:
         bpy.context.window.cursor_set("DEFAULT")
     return {'FINISHED'}
Пример #10
0
    def import_into_tree(self, tree: SverchCustomTree, print_log: bool = True):
        """Import json structure into given tree and update it"""
        root_tree_builder = TreeImporter01(tree, self._structure, self._fails_log)
        root_tree_builder.import_tree()
        if print_log:
            self._fails_log.report_log_result()

        # Update tree
        build_update_list(tree)
        process_tree(tree)
Пример #11
0
 def turn_off_ng(self, context):
     """
     Turn on/off displaying objects in viewport generated by viewer nodes
     Viewer nodes should have `show_viewport` method which takes 'to_show' bool argument
     """
     for node in self.nodes:
         try:
             node.show_viewport(self.sv_show)
         except AttributeError:
             pass
     process_tree(self)
Пример #12
0
    def test_intersect_edges(self):
        process_tree(self.tree)

        node = self.tree.nodes["Intersect Edges MK2"]

        result_verts = get_output_socket_data(node, "Verts_out")
        result_edges = get_output_socket_data(node, "Edges_out")

        #self.store_reference_sverchok_data("intersecting_planes_result_verts.txt", result_verts)
        self.assert_sverchok_data_equals_file(result_verts, "intersecting_planes_result_verts.txt", precision=8)
        #self.store_reference_sverchok_data("intersecting_planes_result_faces.txt", result_edges)
        self.assert_sverchok_data_equals_file(result_edges, "intersecting_planes_result_faces.txt", precision=8)
Пример #13
0
    def process(self):
        """
        process the Sverchok tree upon editor changes from handler
        """
        if self.has_changed:
            self.build_update_list()
            self.has_changed = False
        if self.is_frozen():
            return
        if self.sv_process:
            process_tree(self)

        self.has_changed = False
Пример #14
0
    def process(self):
        """
        process the Sverchok tree upon editor changes from handler
        """
        if self.has_changed:
            self.build_update_list()
            self.has_changed = False
        if self.is_frozen():
            return
        if self.sv_process:
            process_tree(self)

        self.has_changed = False
Пример #15
0
    def execute(self, context):
        try:
            bpy.context.window.cursor_set("WAIT")
            ng = context.space_data.node_tree
            if ng:
                build_update_list(ng)
                process_tree(ng)
        except:
            pass
        finally:
            bpy.context.window.cursor_set("DEFAULT")

        return {'FINISHED'}
Пример #16
0
    def import_into_tree(self, tree: SverchCustomTree, print_log: bool = True):
        """Import json structure into given tree and update it"""
        if self.structure_version < 0.1001:
            root_tree_builder = TreeImporter01(tree, self._structure,
                                               self._fails_log)
            root_tree_builder.import_tree()
        else:
            importer = FileStruct(logger=self._fails_log,
                                  struct=self._structure)
            importer.build_into_tree(tree)

        if print_log:
            self._fails_log.report_log_result()

        # Update tree
        build_update_list(tree)
        process_tree(tree)
Пример #17
0
    def execute(self, context):
        try:
            bpy.context.window.cursor_set("WAIT")
            ng = context.space_data.node_tree
            if ng:
                try:
                    prev_process_state = ng.sv_process
                    ng.sv_process = True
                    ng.unfreeze(hard=True)
                    build_update_list(ng)
                    process_tree(ng)
                finally:
                    ng.sv_process = prev_process_state
        except:
            pass
        finally:
            bpy.context.window.cursor_set("DEFAULT")

        return {'FINISHED'}
Пример #18
0
    def update(self):
        '''
        Rebuild and update the Sverchok node tree, used at editor changes
        '''
        # startup safety net, a lot things will just break if this isn't
        # stopped...
        try:
            l = bpy.data.node_groups[self.id_data.name]
        except:
            return
        if self.is_frozen():
            print("Skippiping update of {}".format(self.name))
            return

        self.adjust_reroutes()

        self.build_update_list()
        if self.sv_process:
            process_tree(self)
Пример #19
0
    def update(self):
        '''
        Rebuild and update the Sverchok node tree, used at editor changes
        '''
        # startup safety net, a lot things will just break if this isn't
        # stopped...
        try:
            l = bpy.data.node_groups[self.id_data.name]
        except:
            return
        if self.is_frozen():
            print("Skippiping update of {}".format(self.name))
            return

        self.adjust_reroutes()

        self.build_update_list()
        if self.sv_process:
            process_tree(self)
Пример #20
0
    def process(self):
        """
        process the Sverchok tree upon editor changes from handler
        """

        if self.configuring_new_node:
            # print('skipping global process during node init')
            return

        if self.has_changed:
            # print('processing build list: because has_changed==True')
            self.build_update_list()
            self.has_changed = False
        if self.is_frozen():
            # print('not processing: because self/tree.is_frozen')
            return
        if self.sv_process:
            process_tree(self)

        self.has_changed = False
Пример #21
0
class SverchCustomTree(NodeTree, SvNodeTreeCommon):
    ''' Sverchok - architectural node programming of geometry in low level '''
    bl_idname = 'SverchCustomTreeType'
    bl_label = 'Sverchok Nodes'
    bl_icon = 'RNA'

    def turn_off_ng(self, context):
        """
        Turn on/off displaying objects in viewport generated by viewer nodes
        Viewer nodes should have `show_viewport` method which takes 'to_show' bool argument
        """
        for node in self.nodes:
            try:
                node.show_viewport(self.sv_show)
            except AttributeError:
                pass

    def on_draft_mode_changed(self, context):
        """
        This is triggered when Draft mode of the tree is toggled.
        """
        draft_nodes = []
        for node in self.nodes:
            if hasattr(node, 'does_support_draft_mode') and node.does_support_draft_mode():
                draft_nodes.append(node)
                node.on_draft_mode_changed(self.sv_draft)

        # From the user perspective, some of node parameters
        # got new parameter values, so the setup should be recalculated;
        # but techically, node properties were not changed
        # (only other properties were shown in UI), so enabling/disabling
        # of draft mode does not automatically trigger tree update.
        # Here we trigger it manually.

        if draft_nodes:
            process_from_nodes(draft_nodes)

    sv_animate: BoolProperty(name="Animate", default=True, description='Animate this layout')
    sv_show: BoolProperty(name="Show", default=True, description='Show this layout', update=turn_off_ng)

    # something related with heat map feature
    # looks like it keeps dictionary of nodes and their user defined colors in string format
    sv_user_colors: StringProperty(default="")

    # option whether error message of nodes should be shown in tree space or not
    # for showing error message all tree should be reevaluated what is not nice
    sv_show_error_in_tree: BoolProperty(
        description="This will show Node Exceptions in the node view, right beside the node",
        name="Show error in tree", default=True, update=lambda s, c: process_tree(s), options=set())

    sv_show_error_details : BoolProperty(
            name = "Show error details",
            description = "Display exception stack in the node view as well",
            default = False, 
            update=lambda s, c: process_tree(s),
            options=set())

    sv_show_socket_menus : BoolProperty(
        name = "Show socket menus",
        description = "Display socket dropdown menu buttons. NOTE: options that are enabled in those menus will be effective regardless of this checkbox!",
        default = False,
        options=set())

    # if several nodes are disconnected this option determine order of their evaluation
    sv_subtree_evaluation_order: EnumProperty(
        name="Subtree eval order",
        items=[(k, k, '', i) for i, k in enumerate(["X", "Y", "None"])],
        description=textwrap.dedent("""\
            This will give you control over the order in which subset graphs are evaluated
            1) X, Y modes evaluate subtrees in sequence of lowest absolute node location, useful when working with real geometry
            2) None does no sorting
        """),
        default="None", update=lambda s, c: process_tree(s), options=set()
    )

    # this mode will replace properties of some nodes so they could have lesser values for draft mode
    sv_draft: BoolProperty(
        name="Draft",
        description="Draft (simplified processing) mode",
        default=False,
        update=on_draft_mode_changed)

    def update(self):
        """
        This method is called if collection of nodes or links of the tree was changed
        First of all it checks is it worth bothering and then gives initiative to `update system`
        """

        CurrentEvents.new_event(BlenderEventsTypes.tree_update, self)

        # this is a no-op if there's no drawing
        clear_exception_drawing_with_bgl(self.nodes)
        if is_first_run():
            return
        if self.skip_tree_update or not self.sv_process:
            return

        self.sv_update()
        self.has_changed = False

    def update_nodes(self, nodes):
        """This method expects to get list of its nodes which should be updated"""
        if len(nodes) == 1:
            # this function actually doing something different unlike `process_from_nodes` function
            # the difference is that process_from_nodes can also update other outdated nodes
            process_from_node(nodes[0])
        process_from_nodes(nodes)

    def process_ani(self):
        """
        Process the Sverchok node tree if animation layers show true.
        For animation callback/handler
        """
        if self.sv_animate:
            self.animation_update()
Пример #22
0
 def turn_off_ng(self, context):
     process_tree(self)
Пример #23
0
 def sv_process_tree_callback(self, context):
     process_tree(self)
Пример #24
0
 def update_ani(self):
     """
     Updates the Sverchok node tree if animation layers show true. For animation callback
     """
     if self.sv_animate:
         process_tree(self)
Пример #25
0
 def turn_off_ng(self, context):
     process_tree(self)
Пример #26
0
 def update_ani(self):
     """
     Updates the Sverchok node tree if animation layers show true. For animation callback
     """
     if self.sv_animate:
         process_tree(self)