[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4558] contrib/py/scripts/addons/ node_categories/__init__.py: Deleted the node_categories addon.
Lukas Toenne
lukas.toenne at googlemail.com
Sun Jun 9 13:16:47 CEST 2013
Revision: 4558
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4558
Author: lukastoenne
Date: 2013-06-09 11:16:46 +0000 (Sun, 09 Jun 2013)
Log Message:
-----------
Deleted the node_categories addon. This was broken for some time now and would need to be rewritten from scratch anyway.
There is now a shiny new node categories system in trunk (see custom_nodes.py template or release/scripts/startup/nodeitems_builtins.py for basic usage). This system could be extended in a new py addon
to provide the functionality of this addon in a nicer way.
Removed Paths:
-------------
contrib/py/scripts/addons/node_categories/__init__.py
Deleted: contrib/py/scripts/addons/node_categories/__init__.py
===================================================================
--- contrib/py/scripts/addons/node_categories/__init__.py 2013-06-07 01:08:26 UTC (rev 4557)
+++ contrib/py/scripts/addons/node_categories/__init__.py 2013-06-09 11:16:46 UTC (rev 4558)
@@ -1,505 +0,0 @@
-#
-# Copyright 2011, Blender Foundation.
-#
-# 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.
-#
-
-# <pep8 compliant>
-
-bl_info = {
- "name": "Node Categories",
- "author": "Lukas Toenne",
- "blender": (2, 64, 0),
- "location": "Node editor toolbar",
- "description": "Panels for adding nodes, sorted by category",
- "warning": "",
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Nodes/Node_Categories",
- "tracker_url": "",
- "support": "TESTING",
- "category": "Node"}
-
-import bpy
-from bpy.types import PropertyGroup, Panel, Operator, Menu
-from bpy.props import CollectionProperty, PointerProperty, StringProperty, BoolProperty, EnumProperty, IntProperty
-from bl_operators.node import NodeAddOperator
-
-
-# Types
-
-# Get an iterator over all actual node classes
-def gen_node_subclasses(base):
- for nodeclass in base.__subclasses__():
- # get_node_type used to distinguish base classes from actual node type classes
- if hasattr(nodeclass, 'get_node_type'):
- yield nodeclass
- # call recursively for subclasses
- for subclass in gen_node_subclasses(nodeclass):
- yield subclass
-
-
-# Enum items callback to get a list of possible node types from context.
-# Used for both the node item and operator properties.
-# self argument is unused, can be None
-def node_type_items(self, context):
- node_tree = context.space_data.edit_tree
-
- # XXX In customnodes branch, node will use a poll function to determine possible types in the context tree.
- # For now just use a poll function based on node subclass base
- if node_tree.type == 'SHADER':
- poll = lambda nodeclass: issubclass(nodeclass, bpy.types.ShaderNode) or issubclass(nodeclass, bpy.types.SpecialNode)
- elif node_tree.type == 'COMPOSITING':
- poll = lambda nodeclass: issubclass(nodeclass, bpy.types.CompositorNode) or issubclass(nodeclass, bpy.types.SpecialNode)
- elif node_tree.type == 'TEXTURE':
- poll = lambda nodeclass: issubclass(nodeclass, bpy.types.TextureNode) or issubclass(nodeclass, bpy.types.SpecialNode)
-
- return [(nc.get_node_type(), nc.bl_rna.name, nc.bl_rna.description) for nc in gen_node_subclasses(bpy.types.Node) if (poll is None) or poll(nc)]
-
-
-node_class_dict = { nc.get_node_type() : nc for nc in set(gen_node_subclasses(bpy.types.Node)) }
-
-
-class NodeCategoryItemSetting(PropertyGroup):
- value = StringProperty(name="Value", description="Initial value to assign to the node property")
-
-bpy.utils.register_class(NodeCategoryItemSetting)
-
-
-class NodeCategoryItem(PropertyGroup):
- def node_type_update(self, context):
- # convenience feature: reset to default label when changing the node type
- # XXX might be better to check if the label has actually been modified?
- self.label = node_class_dict[self.node_type].bl_rna.name
-
- node_type = EnumProperty(name="Node Type", description="Node type identifier", items=node_type_items, update=node_type_update)
- label = StringProperty(name="Label")
-
- settings = CollectionProperty(name="Settings", description="Initial settings of the node", type=NodeCategoryItemSetting)
-
- # internal edit values
- edit = BoolProperty(name="Edit", description="Toggle edit mode of this item", default=False) # only used when general category edit is on
-
-bpy.utils.register_class(NodeCategoryItem)
-
-
-def node_category_update_name(self, context):
- wm = context.window_manager
- if self.panel_type:
- unregister_node_panel(self)
- register_node_panel(self)
-
-class NodeCategory(PropertyGroup):
- type_items = [
- ("SHADER", "Shader", "Shader node category"),
- ("TEXTURE", "Texture", "Texture node category"),
- ("COMPOSITING", "Compositing", "Compositing node category"),
- ]
-
- name = StringProperty(name="Name", update=node_category_update_name)
- type = EnumProperty(name="Type", description="Category type used to check visibility", items=type_items)
- items = CollectionProperty(name="Items", description="Node items in this category", type=NodeCategoryItem)
-
- panel_type = StringProperty(name="Panel Type", description="Identifier of the associated panel type")
-
-bpy.utils.register_class(NodeCategory)
-
-
-# XXX window manager properties don't seem to be saved and reloaded, using Scene for now ...
-#bpy.types.WindowManager.node_categories = CollectionProperty(type=NodeCategory)
-#bpy.types.WindowManager.node_categories_edit = BoolProperty(name="Edit Node Categories", default=False)
-bpy.types.Scene.node_categories = CollectionProperty(type=NodeCategory)
-bpy.types.Scene.node_categories_edit = BoolProperty(name="Edit Node Categories", default=False)
-
-
-
-# Panels & Menus
-
-class NodePanel():
- bl_space_type = 'NODE_EDITOR'
- bl_region_type = 'TOOLS'
-
- @classmethod
- def poll(cls, context):
- space = context.space_data
- return space.edit_tree
-
-
-class NODE_MT_category_add_node_type(Menu):
- '''Select a node type'''
- bl_label = "Node Type"
-
- def draw(self, context):
- layout = self.layout
- node_tree = context.space_data.edit_tree
- node_types = node_type_items(None, context)
-
- for nt in node_types:
- identifier = nt[0]
- name = nt[1]
-
- op = layout.operator("node.category_add_item", text=name)
- op.node_type = identifier
- op.label = name
-
-
-class NODE_MT_category_add_setting(Menu):
- '''Select a node setting'''
- bl_label = "Node Setting"
-
- def draw(self, context):
- layout = self.layout
-
- for prop in bpy.types.Node.bl_rna.properties:
- if prop.is_hidden or prop.is_readonly:
- continue
-
- op = layout.operator("node.category_add_setting", text=prop.name)
- op.setting = prop.identifier
-
- layout.separator()
-
- layout.operator("node.category_add_setting", text="Custom ...")
- # op.setting is undefined, so the operator opens a popup to get it
-
-
-def gen_valid_identifier(seq):
- # get an iterator
- itr = iter(seq)
- # pull characters until we get a legal one for first in identifer
- for ch in itr:
- if ch == '_' or ch.isalpha():
- yield ch
- break
- # pull remaining characters and yield legal ones for identifier
- for ch in itr:
- if ch == '_' or ch.isalpha() or ch.isdigit():
- yield ch
-
-
-def get_unique_identifier(prefix, name):
- base = prefix + ''.join(gen_valid_identifier(name))
-
- identifier = base
- index = 1
- while hasattr(bpy.types, identifier):
- identifier = base + str(index)
- index += 1
-
- return identifier
-
-
-def register_node_panel(_category):
- identifier = get_unique_identifier("NODE_PT_category_", _category.name)
-
- @classmethod
- def panel_poll(cls, context):
- space = context.space_data
- category = context.scene.node_categories[cls.category]
- return space.tree_type == category.type
-
- def panel_draw_header(self, context):
- layout = self.layout
- category = context.scene.node_categories[self.category]
- edit = context.scene.node_categories_edit
-
- if edit:
- row = layout.row()
- row.prop(category, "name", text="")
- op = row.operator("node.remove_category", text="", icon='X')
- op.category_name = self.category
-
- def panel_draw(self, context):
- layout = self.layout
- category = context.scene.node_categories[self.category]
- edit = context.scene.node_categories_edit
-
- layout.context_pointer_set("node_category", category)
-
- if edit:
- for index, item in enumerate(category.items):
- layout.context_pointer_set("node_category_item", item)
-
- if item.edit:
- row = layout.row(align=True)
- row.prop(item, "edit", icon='TRIA_DOWN', text="", icon_only=True, toggle=True)
-
- box = row.box()
-
- sub = box.row(align=True)
- sub.prop(item, "label", text="")
- op = sub.operator("node.category_remove_item", text="", icon='X')
- op.index = index
-
- box.prop_menu_enum(item, "node_type", text="Node: "+node_class_dict[item.node_type].bl_rna.name, icon='NODE')
-
- for setting_index, setting in enumerate(item.settings):
- row = box.row(align=True)
- row.label(text=setting.name + " = ")
- row.prop(setting, "value", text="")
-
- op = row.operator("node.category_remove_setting", text="", icon='X')
- op.index = setting_index
-
- box.menu("NODE_MT_category_add_setting", text="Add Setting", icon='ZOOMIN')
- else:
- row = layout.row(align=True)
- row.prop(item, "edit", icon='TRIA_RIGHT', text="", icon_only=True, toggle=True)
- row.label(text=item.label)
-
- layout.menu("NODE_MT_category_add_node_type", text="Add Node", icon='ZOOMIN')
- else:
- for item in category.items:
- layout.context_pointer_set("node_category_item", item)
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list