Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2012-02-22 16:24:04 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-02-22 16:24:04 +0400
commit3bae60d0c9e7629d29d1569201dd07e968acd600 (patch)
tree7164d84e77bed4f92e2d935865be9cae1518b057 /source/blender/editors
parentdadc2a26e33fc2046438d4532468783ed8485a6b (diff)
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of possible input slots. It has a base path string that can be set to a general base folder. Every input socket then uses its name as an extension of the base path for file organization. This can include further subfolders on top of the base path. Example: Base path: '/home/user/myproject' Input 1: 'Compo' Input 2: 'Diffuse/' Input 3: 'details/Normals' would create output files in /home/user/myproject: Compo0001.png, Compo0002.png, ... in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base given) in /home/user/myproject/details: Normals0001.png, Normals0002.png, ... Most settings for the node can be found in the sidebar (NKEY). New input sockets can be added with the "Add Input" button. There is a list of input sockets and below that the details for each socket can be changed, including the sub-path and filename. Sockets can be removed here as well. By default each socket uses the render settings file output format, but each can use its own format if necessary. To my knowledge this is the first node making use of such dynamic sockets in trunk. So this is also a design test, other nodes might use this in the future. Adding operator buttons on top of a node is a bit unwieldy atm, because all node operators generally work on selected and/or active node(s). The operator button would therefore either have to make sure the node is activated before the operator is called (block callback maybe?) OR it has to store the node name (risky, weak reference). For now it is only used in the sidebar, where only the active node's buttons are displayed. Also adds a new struct_type value to bNodeSocket, in order to distinguish different socket types with the same data type (file inputs are SOCK_RGBA color sockets). Would be nicer to use data type only for actual data evaluation, but used in too many places, this works ok for now.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_node/drawnode.c160
-rw-r--r--source/blender/editors/space_node/node_draw.c10
-rw-r--r--source/blender/editors/space_node/node_edit.c74
-rw-r--r--source/blender/editors/space_node/node_header.c18
-rw-r--r--source/blender/editors/space_node/node_intern.h3
-rw-r--r--source/blender/editors/space_node/node_ops.c3
6 files changed, 221 insertions, 47 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 143173da5bc..63eead6780f 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -107,16 +107,20 @@ static void node_socket_button_default(const bContext *C, uiBlock *block,
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
const char *name, int x, int y, int width)
{
- PointerRNA ptr;
- uiBut *bt;
-
- RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
-
- bt = uiDefButR(block, NUM, B_NODE_EXEC, name,
- x, y+1, width, NODE_DY-2,
- &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
- if (node)
- uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
+ if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
+ node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
+ else {
+ PointerRNA ptr;
+ uiBut *bt;
+
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
+
+ bt = uiDefButR(block, NUM, B_NODE_EXEC, name,
+ x, y+1, width, NODE_DY-2,
+ &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
+ if (node)
+ uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
+ }
}
typedef struct SocketComponentMenuArgs {
@@ -145,42 +149,80 @@ static void node_socket_button_components(const bContext *C, uiBlock *block,
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
const char *name, int x, int y, int width)
{
- PointerRNA ptr;
- SocketComponentMenuArgs *args;
-
- RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
-
- args= MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
-
- args->ptr = ptr;
- args->x = x;
- args->y = y;
- args->width = width;
- args->cb = node_sync_cb;
- args->arg1 = CTX_wm_space_node(C);
- args->arg2 = node;
-
- uiDefBlockButN(block, socket_component_menu, args, name, x, y+1, width, NODE_DY-2, "");
+ if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
+ node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
+ else {
+ PointerRNA ptr;
+ SocketComponentMenuArgs *args;
+
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
+
+ args= MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
+
+ args->ptr = ptr;
+ args->x = x;
+ args->y = y;
+ args->width = width;
+ args->cb = node_sync_cb;
+ args->arg1 = CTX_wm_space_node(C);
+ args->arg2 = node;
+
+ uiDefBlockButN(block, socket_component_menu, args, name, x, y+1, width, NODE_DY-2, "");
+ }
}
static void node_socket_button_color(const bContext *C, uiBlock *block,
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
const char *name, int x, int y, int width)
{
- PointerRNA ptr;
- uiBut *bt;
- int labelw= width - 40;
-
- RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
-
- bt=uiDefButR(block, COL, B_NODE_EXEC, "",
- x, y+2, (labelw>0 ? 40 : width), NODE_DY-2,
- &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
- if (node)
- uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
+ /* XXX would be nicer to have draw function based on sock->struct_type as well,
+ * but currently socket types are completely identified by data type only.
+ */
- if (name[0]!='\0' && labelw>0)
- uiDefBut(block, LABEL, 0, name, x + 40, y+2, labelw, NODE_DY-2, NULL, 0, 0, 0, 0, "");
+ switch (sock->struct_type) {
+ case SOCK_STRUCT_NONE: {
+ if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
+ node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
+ else {
+ PointerRNA ptr;
+ uiBut *bt;
+ int labelw= width - 40;
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
+
+ bt=uiDefButR(block, COL, B_NODE_EXEC, "",
+ x, y+2, (labelw>0 ? 40 : width), NODE_DY-2,
+ &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
+ if (node)
+ uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
+
+ if (name[0]!='\0' && labelw>0)
+ uiDefBut(block, LABEL, 0, name, x + 40, y+2, labelw, NODE_DY-2, NULL, 0, 0, 0, 0, "");
+ }
+ break;
+ }
+ case SOCK_STRUCT_OUTPUT_MULTI_FILE: {
+ uiLayout *layout, *row;
+ PointerRNA ptr, imfptr;
+ PropertyRNA *imtype_prop;
+ const char *imtype_name;
+ int rx, ry;
+ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
+ imfptr = RNA_pointer_get(&ptr, "format");
+
+ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y+NODE_DY, width, 20, UI_GetStyle());
+ row = uiLayoutRow(layout, 0);
+
+ uiItemL(row, sock->name, 0);
+ imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
+ RNA_property_enum_name((bContext*)C, &imfptr, imtype_prop, RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
+ uiBlockSetEmboss(block, UI_EMBOSSP);
+ uiItemL(row, imtype_name, 0);
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+
+ uiBlockLayoutResolve(block, &rx, &ry);
+ break;
+ }
+ }
}
/* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
@@ -1673,6 +1715,42 @@ static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C)
uiItemR(row, ptr, "frame_end", 0, "End", ICON_NONE);
}
+static void node_composit_buts_multi_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemL(layout, "Base Path:", 0);
+ uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
+}
+static void node_composit_buts_multi_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+ PointerRNA active_input_ptr = RNA_pointer_get(ptr, "active_input");
+
+ node_composit_buts_multi_file_output(layout, C, ptr);
+
+ uiItemO(layout, "Add Input", ICON_ZOOMIN, "NODE_OT_output_multi_file_add_socket");
+
+ uiTemplateList(layout, C, ptr, "inputs", ptr, "active_input_index", NULL, 0, 0, 0);
+
+ if (active_input_ptr.data) {
+ uiLayout *row, *col;
+
+ uiItemS(layout);
+
+ col = uiLayoutColumn(layout, 1);
+ uiItemL(col, "File Path:", 0);
+ row = uiLayoutRow(col, 0);
+ uiItemR(row, &active_input_ptr, "name", 0, "", 0);
+ uiItemFullO(row, "NODE_OT_output_multi_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
+
+ uiItemS(layout);
+ uiItemL(layout, "Format:", 0);
+ uiItemR(layout, &active_input_ptr, "use_render_format", 0, NULL, 0);
+ if (!RNA_boolean_get(&active_input_ptr, "use_render_format")) {
+ PointerRNA imfptr = RNA_pointer_get(&active_input_ptr, "format");
+ uiTemplateImageSettings(layout, &imfptr);
+ }
+ }
+}
+
static void node_composit_buts_scale(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "space", 0, "", ICON_NONE);
@@ -1908,6 +1986,10 @@ static void node_composit_set_butfunc(bNodeType *ntype)
case CMP_NODE_OUTPUT_FILE:
ntype->uifunc= node_composit_buts_file_output;
break;
+ case CMP_NODE_OUTPUT_MULTI_FILE:
+ ntype->uifunc= node_composit_buts_multi_file_output;
+ ntype->uifuncbut= node_composit_buts_multi_file_output_details;
+ break;
case CMP_NODE_DIFF_MATTE:
ntype->uifunc=node_composit_buts_diff_matte;
break;
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index a82ea9e9046..0913c3fb9eb 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -718,14 +718,8 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE);
- if (sock->link || (sock->flag & SOCK_HIDE_VALUE)) {
- uiDefBut(node->block, LABEL, 0, sock->name, sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY, NODE_DY,
- NULL, 0, 0, 0, 0, "");
- }
- else {
- if (stype->buttonfunc)
- stype->buttonfunc(C, node->block, ntree, node, sock, sock->name, sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY);
- }
+ if (stype->buttonfunc)
+ stype->buttonfunc(C, node->block, ntree, node, sock, sock->name, sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY);
}
/* socket outputs */
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 906b5d01e32..d92bdc42958 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -3587,3 +3587,77 @@ void NODE_OT_new_node_tree(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", nodetree_type_items, NTREE_COMPOSIT, "Tree Type", "");
RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME-2, "Name", "");
}
+
+/* ****************** Multi File Output Add Socket ******************* */
+
+static int node_output_multi_file_add_socket_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene= CTX_data_scene(C);
+ SpaceNode *snode= CTX_wm_space_node(C);
+ bNodeTree *ntree = snode->edittree;
+ bNode *node = nodeGetActive(ntree);
+
+ if (!node)
+ return OPERATOR_CANCELLED;
+
+ ntreeCompositOutputMultiFileAddSocket(ntree, node, &scene->r.im_format);
+
+ snode_notify(C, snode);
+
+ return OPERATOR_FINISHED;
+}
+
+static int node_output_multi_file_add_socket_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+{
+ return node_output_multi_file_add_socket_exec(C, op);
+}
+
+void NODE_OT_output_multi_file_add_socket(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Add Multi File Node Socket";
+ ot->description= "Add a new input to a multi file output node";
+ ot->idname= "NODE_OT_output_multi_file_add_socket";
+
+ /* callbacks */
+ ot->exec= node_output_multi_file_add_socket_exec;
+ ot->invoke= node_output_multi_file_add_socket_invoke;
+ ot->poll= composite_node_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* ****************** Multi File Output Remove Socket ******************* */
+
+static int node_output_multi_file_remove_active_socket_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ SpaceNode *snode= CTX_wm_space_node(C);
+ bNodeTree *ntree = snode->edittree;
+ bNode *node = nodeGetActive(ntree);
+
+ if (!node)
+ return OPERATOR_CANCELLED;
+
+ if (!ntreeCompositOutputMultiFileRemoveActiveSocket(ntree, node))
+ return OPERATOR_CANCELLED;
+
+ snode_notify(C, snode);
+
+ return OPERATOR_FINISHED;
+}
+
+void NODE_OT_output_multi_file_remove_active_socket(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Remove Multi File Node Socket";
+ ot->description= "Remove active input from a multi file output node";
+ ot->idname= "NODE_OT_output_multi_file_remove_active_socket";
+
+ /* callbacks */
+ ot->exec= node_output_multi_file_remove_active_socket_exec;
+ ot->poll= composite_node_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c
index 6dd5eeba832..df83afc143e 100644
--- a/source/blender/editors/space_node/node_header.c
+++ b/source/blender/editors/space_node/node_header.c
@@ -110,14 +110,22 @@ static void do_node_add(bContext *C, bNodeTemplate *ntemp)
static void do_node_add_static(bContext *C, void *UNUSED(arg), int event)
{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
bNodeTemplate ntemp;
+
ntemp.type = event;
+ ntemp.main = bmain;
+ ntemp.scene = scene;
+
do_node_add(C, &ntemp);
}
static void do_node_add_group(bContext *C, void *UNUSED(arg), int event)
{
SpaceNode *snode= CTX_wm_space_node(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
bNodeTemplate ntemp;
if (event>=0) {
@@ -143,14 +151,24 @@ static void do_node_add_group(bContext *C, void *UNUSED(arg), int event)
if (!ntemp.ngroup)
return;
+ ntemp.main = bmain;
+ ntemp.scene = scene;
+
do_node_add(C, &ntemp);
}
#if 0 /* disabled */
static void do_node_add_dynamic(bContext *C, void *UNUSED(arg), int event)
{
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
bNodeTemplate ntemp;
+
ntemp.type = NODE_DYNAMIC;
+
+ ntemp.main = bmain;
+ ntemp.scene = scene;
+
do_node_add(C, &ntemp);
}
#endif
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 48501079e60..4bfb62023b5 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -159,6 +159,9 @@ void NODE_OT_add_file(struct wmOperatorType *ot);
void NODE_OT_new_node_tree(struct wmOperatorType *ot);
+void NODE_OT_output_multi_file_add_socket(struct wmOperatorType *ot);
+void NODE_OT_output_multi_file_remove_active_socket(struct wmOperatorType *ot);
+
extern const char *node_context_dir[];
// XXXXXX
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index 508021540b5..493f4747387 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -99,6 +99,9 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_add_file);
WM_operatortype_append(NODE_OT_new_node_tree);
+
+ WM_operatortype_append(NODE_OT_output_multi_file_add_socket);
+ WM_operatortype_append(NODE_OT_output_multi_file_remove_active_socket);
}
void ED_operatormacros_node(void)