def node_replacement_menu(self, context, layout): """ Draw menu items with node replacement operators. This is called from `rclick_menu()' method by default. Items are defined by `replacement_nodes' class property. Expected format is replacement_nodes = [ (new_node_bl_idname, inputs_mapping_dict, outputs_mapping_dict) ] where new_node_bl_idname is bl_idname of replacement node class, inputs_mapping_dict is a dictionary mapping names of inputs of this node to names of inputs to new node, and outputs_mapping_dict is a dictionary mapping names of outputs of this node to names of outputs of new node. inputs_mapping_dict and outputs_mapping_dict can be None. """ if hasattr(self, "replacement_nodes"): for bl_idname, inputs_mapping, outputs_mapping in self.replacement_nodes: node_class = get_node_class_reference(bl_idname) if node_class: text = "Replace with {}".format(node_class.bl_label) op = layout.operator("node.sv_replace_node", text=text) op.old_node_name = self.name op.new_bl_idname = bl_idname set_inputs_mapping(op, inputs_mapping) set_outputs_mapping(op, outputs_mapping) else: self.error("Can't build replacement menu: no such node class: %s",bl_idname)
def node_replacement_menu(self, context, layout): """ Draw menu items with node replacement operators. This is called from `rclick_menu()' method by default. Items are defined by `replacement_nodes' class property. Expected format is replacement_nodes = [ (new_node_bl_idname, inputs_mapping_dict, outputs_mapping_dict) ] where new_node_bl_idname is bl_idname of replacement node class, inputs_mapping_dict is a dictionary mapping names of inputs of this node to names of inputs to new node, and outputs_mapping_dict is a dictionary mapping names of outputs of this node to names of outputs of new node. inputs_mapping_dict and outputs_mapping_dict can be None. """ if hasattr(self, "replacement_nodes"): for bl_idname, inputs_mapping, outputs_mapping in self.replacement_nodes: node_class = get_node_class_reference(bl_idname) text = "Replace with {}".format(node_class.bl_label) op = layout.operator("node.sv_replace_node", text=text) op.old_node_name = self.name op.new_bl_idname = bl_idname set_inputs_mapping(op, inputs_mapping) set_outputs_mapping(op, outputs_mapping)
def idname_draw(self, context): if not displaying_sverchok_nodes(context): return layout = self.layout node = context.active_node if not node: return bl_idname = node.bl_idname box = layout.box() col = box.column(align=False) col.scale_y = 0.9 row = col.row(align=True) colom = row.column(align=True) colom.scale_x = 3 colom.label(text=bl_idname + ':') colom = row.column(align=True) colom.operator('node.copy_bl_idname', text='', icon='COPY_ID').name = bl_idname # show these anyway, can fail and let us know.. row = col.row(align=True) row.label(text='Help & Docs:') row = col.row(align=True) row.operator('node.view_node_help', text='Online').kind = 'online' row.operator('node.view_node_help', text='Offline').kind = 'offline' row.operator('node.view_node_help', text='Github').kind = 'github' #, icon='GHOST' col.separator() # view the source of the current node ( warning, some nodes rely on more than one file ) row = col.row(align=True) row.label(text='Edit Source:') row = col.row(align=True) row.operator('node.sv_view_node_source', text='Externally').kind = 'external' row.operator('node.sv_view_node_source', text='Internally').kind = 'internal' if hasattr(node, 'replacement_nodes'): box = col.box() box.label(text="Replace with:") for new_bl_idname, inputs_mapping, outputs_mapping in node.replacement_nodes: node_class = get_node_class_reference(new_bl_idname) text = node_class.bl_label op = box.operator("node.sv_replace_node", text=text) op.old_node_name = node.name op.new_bl_idname = new_bl_idname set_inputs_mapping(op, inputs_mapping) set_outputs_mapping(op, outputs_mapping) row = col.row(align=True) op = row.operator('node.sv_replace_node', text='Re-Create Node') op.old_node_name = node.name op.new_bl_idname = bl_idname
def idname_draw(self, context): if not displaying_sverchok_nodes(context): return layout = self.layout node = context.active_node ntree = node.id_data if not node: return bl_idname = node.bl_idname box = layout.box() col = box.column(align=False) col.scale_y = 0.9 row = col.row(align=True) colom = row.column(align=True) colom.scale_x = 3 colom.label(text=bl_idname + ':') colom = row.column(align=True) colom.operator('node.copy_bl_idname', text='', icon='COPY_ID').name = bl_idname if node_supports_presets(node): box = col.box() box.label(text="Presets:") box.menu("SV_MT_LoadPresetMenu") save_row = box.row() save = save_row.operator(SvSaveSelected.bl_idname, text="Save Node Preset", icon='SOLO_ON') save.id_tree = ntree.name save.category = node.bl_idname save.save_defaults = True selected_nodes = [node for node in ntree.nodes if node.select] save_row.enabled = len(selected_nodes) == 1 # show these anyway, can fail and let us know.. row = col.row(align=True) row.label(text='Help & Docs:') row = col.row(align=True) row.operator('node.view_node_help', text='Online').kind = 'online' row.operator('node.view_node_help', text='Offline').kind = 'offline' row.operator('node.view_node_help', text='Github').kind = 'github' #, icon='GHOST' col.separator() # view the source of the current node ( warning, some nodes rely on more than one file ) row = col.row(align=True) row.label(text='Edit Source:') row = col.row(align=True) row.operator('node.sv_view_node_source', text='Externally').kind = 'external' row.operator('node.sv_view_node_source', text='Internally').kind = 'internal' if hasattr(node, 'replacement_nodes'): box = col.box() box.label(text="Replace with:") for new_bl_idname, inputs_mapping, outputs_mapping in node.replacement_nodes: node_class = get_node_class_reference(new_bl_idname) text = node_class.bl_label op = box.operator("node.sv_replace_node", text=text) op.old_node_name = node.name op.new_bl_idname = new_bl_idname set_inputs_mapping(op, inputs_mapping) set_outputs_mapping(op, outputs_mapping) row = col.row(align=True) op = row.operator('node.sv_replace_node', text='Re-Create Node') op.old_node_name = node.name op.new_bl_idname = bl_idname