def poll(cls, context): if not displaying_sverchok_nodes(context): return False if not hasattr(context, 'active_node'): return False node = context.active_node return node_supports_presets(node)
def draw(self, context): layout = self.layout layout.operator_context = 'INVOKE_REGION_WIN' tree = context.space_data.edit_tree try: nodes = tree.nodes except: layout.operator("node.new_node_tree", text="New Sverchok Node Tree", icon="RNA_ADD") return node = valid_active_node(nodes) if node: if hasattr(node, "rclick_menu"): node.rclick_menu(context, layout) layout.separator() if len(node.outputs): layout.menu('SV_MT_AllSocketsOptionsMenu', text='Outputs post-process') layout.separator() if node.bl_idname in {'ViewerNode2', 'SvBmeshViewerNodeMK2'}: layout.operator("node.sv_deligate_operator", text="Connect IDXViewer").fn = "+idxv" else: if has_outputs(node): layout.operator("node.sv_deligate_operator", text="Connect ViewerDraw").fn = "vdmk2" # layout.operator("node.sv_deligate_operator", text="Connect ViewerDraw + IDX").fn="vdmk2 + idxv" if len(node.outputs): layout.operator("node.sv_deligate_operator", text="Connect stethoscope").fn = "stethoscope" layout.separator() if node_supports_presets(node): layout.menu('SV_MT_LoadPresetMenu', text="Node Presets") if node and node.bl_idname == 'NodeFrame': # give options for Frame nodes.. col = layout.column(align=True) col.prop(node, 'label', text='', icon='NODE') col.prop(node, 'use_custom_color') if node.use_custom_color: col.prop(node, 'color', text='') col.prop(node, 'label_size', slider=True) col.prop(node, 'shrink') if node and hasattr(node, 'monad'): layout.operator("node.sv_monad_make_unique", icon="RNA_ADD").use_transform = True layout.separator() layout.menu("NODEVIEW_MT_Dynamic_Menu", text='node menu') # layout.operator("node.duplicate_move") self.draw_conveniences(context, node)
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