Blender V2.61 - r43446
Classes | Defines | Typedefs | Functions | Variables

node_edit.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <errno.h>
#include "MEM_guardedalloc.h"
#include "DNA_ID.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_world_types.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_paint.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_texture.h"
#include "BKE_report.h"
#include "RE_pipeline.h"
#include "IMB_imbuf_types.h"
#include "ED_node.h"
#include "ED_image.h"
#include "ED_screen.h"
#include "ED_space_api.h"
#include "ED_render.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "WM_api.h"
#include "WM_types.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
#include "IMB_imbuf.h"
#include "GPU_material.h"
#include "node_intern.h"

Go to the source code of this file.

Classes

struct  CompoJob
struct  NodeViewMove
struct  ImageSampleInfo
struct  NodeSizeWidget
struct  bNodeListItem

Defines

#define LINK_RESOL   12

Typedefs

typedef struct CompoJob CompoJob
typedef struct NodeViewMove NodeViewMove
typedef struct ImageSampleInfo ImageSampleInfo
typedef struct NodeSizeWidget NodeSizeWidget
typedef struct bNodeListItem bNodeListItem

Functions

static int compo_breakjob (void *cjv)
static void compo_redrawjob (void *cjv, char *UNUSED(str))
static void compo_freejob (void *cjv)
static void compo_initjob (void *cjv)
static void compo_updatejob (void *cjv)
static void compo_progressjob (void *cjv, float progress)
static void compo_startjob (void *cjv, short *stop, short *do_update, float *progress)
void snode_composite_job (const bContext *C, ScrArea *sa)
static int composite_node_active (bContext *C)
static bNodeeditnode_get_active (bNodeTree *ntree)
void snode_dag_update (bContext *UNUSED(C), SpaceNode *snode)
void snode_notify (bContext *C, SpaceNode *snode)
bNodenode_tree_get_editgroup (bNodeTree *nodetree)
void ED_node_shader_default (Scene *scene, ID *id)
void ED_node_composit_default (Scene *sce)
void ED_node_texture_default (Tex *tx)
void node_tree_from_ID (ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype)
void snode_set_context (SpaceNode *snode, Scene *scene)
static void snode_update (SpaceNode *snode, bNode *node)
static int has_nodetree (bNodeTree *ntree, bNodeTree *lookup)
void ED_node_set_active (Main *bmain, bNodeTree *ntree, bNode *node)
static int inside_rctf (rctf *bounds, rctf *rect)
static void node_frame_attach_nodes (bNodeTree *UNUSED(ntree), bNode *frame)
void ED_node_update_hierarchy (bContext *UNUSED(C), bNodeTree *ntree)
void snode_make_group_editable (SpaceNode *snode, bNode *gnode)
static int node_group_edit_exec (bContext *C, wmOperator *UNUSED(op))
static int node_group_edit_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event))
void NODE_OT_group_edit (wmOperatorType *ot)
static int node_group_socket_add_exec (bContext *C, wmOperator *op)
void NODE_OT_group_socket_add (wmOperatorType *ot)
static int node_group_socket_remove_exec (bContext *C, wmOperator *op)
void NODE_OT_group_socket_remove (wmOperatorType *ot)
static int node_group_socket_move_up_exec (bContext *C, wmOperator *op)
void NODE_OT_group_socket_move_up (wmOperatorType *ot)
static int node_group_socket_move_down_exec (bContext *C, wmOperator *op)
void NODE_OT_group_socket_move_down (wmOperatorType *ot)
static int node_group_ungroup_exec (bContext *C, wmOperator *op)
void NODE_OT_group_ungroup (wmOperatorType *ot)
static bNodevisible_node (SpaceNode *snode, rctf *rct)
static int snode_bg_viewmove_modal (bContext *C, wmOperator *op, wmEvent *event)
static int snode_bg_viewmove_invoke (bContext *C, wmOperator *op, wmEvent *event)
static int snode_bg_viewmove_cancel (bContext *UNUSED(C), wmOperator *op)
void NODE_OT_backimage_move (wmOperatorType *ot)
static int backimage_zoom (bContext *C, wmOperator *op)
void NODE_OT_backimage_zoom (wmOperatorType *ot)
static void sample_draw (const bContext *C, ARegion *ar, void *arg_info)
static void sample_apply (bContext *C, wmOperator *op, wmEvent *event)
static void sample_exit (bContext *C, wmOperator *op)
static int sample_invoke (bContext *C, wmOperator *op, wmEvent *event)
static int sample_modal (bContext *C, wmOperator *op, wmEvent *event)
static int sample_cancel (bContext *C, wmOperator *op)
void NODE_OT_backimage_sample (wmOperatorType *ot)
static int node_resize_modal (bContext *C, wmOperator *op, wmEvent *event)
static int node_resize_invoke (bContext *C, wmOperator *op, wmEvent *event)
static int node_resize_cancel (bContext *UNUSED(C), wmOperator *op)
void NODE_OT_resize (wmOperatorType *ot)
int node_has_hidden_sockets (bNode *node, short flag)
void node_set_hidden_sockets (SpaceNode *snode, bNode *node, short flag, int set)
static void node_link_viewer (SpaceNode *snode, bNode *tonode)
static int node_active_link_viewer (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_link_viewer (wmOperatorType *ot)
static int UNUSED_FUNCTION() node_mouse_groupheader (SpaceNode *snode)
static int find_indicated_socket (SpaceNode *snode, bNode **nodep, bNodeSocket **sockp, int in_out)
static int node_socket_hilights (SpaceNode *snode, int in_out)
static int outside_group_rect (SpaceNode *snode)
static int sort_nodes_locx (void *a, void *b)
static int socket_is_available (bNodeTree *UNUSED(ntree), bNodeSocket *sock, int allow_used)
static bNodeSocketbest_socket_output (bNodeTree *ntree, bNode *node, bNodeSocket *sock_target, int allow_multiple)
static bNodeSocketbest_socket_input (bNodeTree *ntree, bNode *node, int num, int replace)
void snode_autoconnect (SpaceNode *snode, int allow_multiple, int replace)
bNodenode_add_node (SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate *ntemp, float locx, float locy)
static int node_duplicate_exec (bContext *C, wmOperator *op)
void NODE_OT_duplicate (wmOperatorType *ot)
static void node_remove_extra_links (SpaceNode *snode, bNodeSocket *tsock, bNodeLink *link)
static int node_link_modal (bContext *C, wmOperator *op, wmEvent *event)
static int node_link_init (SpaceNode *snode, bNodeLinkDrag *nldrag)
static int node_link_invoke (bContext *C, wmOperator *op, wmEvent *event)
static int node_link_cancel (bContext *C, wmOperator *op)
void NODE_OT_link (wmOperatorType *ot)
static int node_make_link_exec (bContext *C, wmOperator *op)
void NODE_OT_link_make (wmOperatorType *ot)
static int cut_links_intersect (bNodeLink *link, float mcoords[][2], int tot)
static int cut_links_exec (bContext *C, wmOperator *op)
void NODE_OT_links_cut (wmOperatorType *ot)
static bNodeSocketsocket_best_match (ListBase *sockets, int type)
static SpaceNodeed_node_link_conditions (ScrArea *sa, bNode **select)
void ED_node_link_insert (ScrArea *sa)
void ED_node_link_intersect_test (ScrArea *sa, int test)
static int node_read_renderlayers_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_read_renderlayers (wmOperatorType *ot)
static int node_read_fullsamplelayers_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_read_fullsamplelayers (wmOperatorType *ot)
int node_render_changed_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_render_changed (wmOperatorType *ot)
static int node_group_make_exec (bContext *C, wmOperator *op)
void NODE_OT_group_make (wmOperatorType *ot)
static void node_flag_toggle_exec (SpaceNode *snode, int toggle_flag)
static int node_hide_toggle_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_hide_toggle (wmOperatorType *ot)
static int node_preview_toggle_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_preview_toggle (wmOperatorType *ot)
static int node_options_toggle_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_options_toggle (wmOperatorType *ot)
static int node_socket_toggle_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_hide_socket_toggle (wmOperatorType *ot)
static int node_mute_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_mute_toggle (wmOperatorType *ot)
static int node_delete_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_delete (wmOperatorType *ot)
static int is_connected_to_input_socket (bNode *node, bNodeLink *link)
static void node_delete_reconnect (bNodeTree *tree, bNode *node)
static int node_delete_reconnect_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_delete_reconnect (wmOperatorType *ot)
static int node_show_cycles_exec (bContext *C, wmOperator *UNUSED(op))
void NODE_OT_show_cyclic_dependencies (wmOperatorType *ot)
static int node_add_file_exec (bContext *C, wmOperator *op)
static int node_add_file_invoke (bContext *C, wmOperator *op, wmEvent *event)
void NODE_OT_add_file (wmOperatorType *ot)
static int new_node_tree_exec (bContext *C, wmOperator *op)
void NODE_OT_new_node_tree (wmOperatorType *ot)

Variables

static EnumPropertyItem socket_in_out_items []

Detailed Description

Definition in file node_edit.c.


Define Documentation

#define LINK_RESOL   12

Definition at line 2557 of file node_edit.c.

Referenced by cut_links_intersect().


Typedef Documentation

typedef struct bNodeListItem bNodeListItem
typedef struct CompoJob CompoJob
typedef struct NodeViewMove NodeViewMove

Function Documentation

static int backimage_zoom ( bContext C,
wmOperator op 
) [static]
static bNodeSocket* best_socket_input ( bNodeTree ntree,
bNode node,
int  num,
int  replace 
) [static]
static bNodeSocket* best_socket_output ( bNodeTree ntree,
bNode node,
bNodeSocket sock_target,
int  allow_multiple 
) [static]
static int compo_breakjob ( void *  cjv) [static]

Definition at line 116 of file node_edit.c.

References CompoJob::stop.

Referenced by compo_startjob().

static void compo_freejob ( void *  cjv) [static]

Definition at line 131 of file node_edit.c.

References CompoJob::localtree, MEM_freeN(), CompoJob::ntree, and ntreeLocalMerge().

Referenced by snode_composite_job().

static void compo_initjob ( void *  cjv) [static]

Definition at line 143 of file node_edit.c.

References CompoJob::localtree, CompoJob::ntree, and ntreeLocalize().

Referenced by snode_composite_job().

static void compo_progressjob ( void *  cjv,
float  progress 
) [static]

Definition at line 158 of file node_edit.c.

References CompoJob::progress.

Referenced by compo_startjob().

static void compo_redrawjob ( void *  cjv,
char *  UNUSEDstr 
) [static]

Definition at line 124 of file node_edit.c.

References CompoJob::do_update.

Referenced by compo_startjob().

static void compo_startjob ( void *  cjv,
short *  stop,
short *  do_update,
float *  progress 
) [static]
static void compo_updatejob ( void *  cjv) [static]

Definition at line 151 of file node_edit.c.

References CompoJob::localtree, CompoJob::ntree, and ntreeLocalSync().

Referenced by snode_composite_job().

static int composite_node_active ( bContext C) [static]
static int cut_links_exec ( bContext C,
wmOperator op 
) [static]
static int cut_links_intersect ( bNodeLink link,
float  mcoords[][2],
int  tot 
) [static]
void ED_node_composit_default ( Scene sce)
static SpaceNode* ed_node_link_conditions ( ScrArea sa,
bNode **  select 
) [static]
void ED_node_link_insert ( ScrArea sa)
void ED_node_link_intersect_test ( ScrArea sa,
int  test 
)
void ED_node_set_active ( Main bmain,
bNodeTree ntree,
bNode node 
)
void ED_node_shader_default ( Scene scene,
ID id 
)
void ED_node_texture_default ( Tex tx)
void ED_node_update_hierarchy ( bContext UNUSEDC,
bNodeTree ntree 
)
static bNode* editnode_get_active ( bNodeTree ntree) [static]
static int find_indicated_socket ( SpaceNode snode,
bNode **  nodep,
bNodeSocket **  sockp,
int  in_out 
) [static]
static int has_nodetree ( bNodeTree ntree,
bNodeTree lookup 
) [static]

Definition at line 588 of file node_edit.c.

References ListBase::first, bNode::id, bNode::next, NODE_GROUP, bNodeTree::nodes, and bNode::type.

Referenced by ED_node_set_active().

static int inside_rctf ( rctf bounds,
rctf rect 
) [static]

Definition at line 694 of file node_edit.c.

References rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.

Referenced by node_frame_attach_nodes().

static int is_connected_to_input_socket ( bNode node,
bNodeLink link 
) [static]
static int new_node_tree_exec ( bContext C,
wmOperator op 
) [static]
static int node_active_link_viewer ( bContext C,
wmOperator UNUSEDop 
) [static]
static int node_add_file_exec ( bContext C,
wmOperator op 
) [static]
static int node_add_file_invoke ( bContext C,
wmOperator op,
wmEvent event 
) [static]
bNode* node_add_node ( SpaceNode snode,
Main bmain,
Scene scene,
bNodeTemplate ntemp,
float  locx,
float  locy 
)
static int node_delete_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static void node_delete_reconnect ( bNodeTree tree,
bNode node 
) [static]
static int node_delete_reconnect_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int node_duplicate_exec ( bContext C,
wmOperator op 
) [static]
static void node_flag_toggle_exec ( SpaceNode snode,
int  toggle_flag 
) [static]
static void node_frame_attach_nodes ( bNodeTree UNUSEDntree,
bNode frame 
) [static]
static int node_group_edit_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int node_group_edit_invoke ( bContext C,
wmOperator op,
wmEvent UNUSEDevent 
) [static]
static int node_group_make_exec ( bContext C,
wmOperator op 
) [static]
static int node_group_socket_add_exec ( bContext C,
wmOperator op 
) [static]
static int node_group_socket_move_down_exec ( bContext C,
wmOperator op 
) [static]
static int node_group_socket_move_up_exec ( bContext C,
wmOperator op 
) [static]
static int node_group_socket_remove_exec ( bContext C,
wmOperator op 
) [static]
static int node_group_ungroup_exec ( bContext C,
wmOperator op 
) [static]
int node_has_hidden_sockets ( bNode node,
short  flag 
)
static int node_hide_toggle_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int node_link_cancel ( bContext C,
wmOperator op 
) [static]
static int node_link_init ( SpaceNode snode,
bNodeLinkDrag nldrag 
) [static]
static int node_link_invoke ( bContext C,
wmOperator op,
wmEvent event 
) [static]
static int node_link_modal ( bContext C,
wmOperator op,
wmEvent event 
) [static]
static void node_link_viewer ( SpaceNode snode,
bNode tonode 
) [static]
static int node_make_link_exec ( bContext C,
wmOperator op 
) [static]
static int UNUSED_FUNCTION() node_mouse_groupheader ( SpaceNode snode) [static]
static int node_mute_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int node_options_toggle_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
void NODE_OT_add_file ( wmOperatorType ot)
void NODE_OT_backimage_move ( wmOperatorType ot)
void NODE_OT_backimage_sample ( wmOperatorType ot)
void NODE_OT_backimage_zoom ( wmOperatorType ot)
void NODE_OT_delete ( wmOperatorType ot)
void NODE_OT_delete_reconnect ( wmOperatorType ot)
void NODE_OT_duplicate ( wmOperatorType ot)
void NODE_OT_group_edit ( wmOperatorType ot)
void NODE_OT_group_make ( wmOperatorType ot)
void NODE_OT_group_socket_add ( wmOperatorType ot)
void NODE_OT_group_socket_move_down ( wmOperatorType ot)
void NODE_OT_group_socket_move_up ( wmOperatorType ot)
void NODE_OT_group_socket_remove ( wmOperatorType ot)
void NODE_OT_group_ungroup ( wmOperatorType ot)
void NODE_OT_hide_socket_toggle ( wmOperatorType ot)
void NODE_OT_hide_toggle ( wmOperatorType ot)
void NODE_OT_link ( wmOperatorType ot)
void NODE_OT_link_make ( wmOperatorType ot)
void NODE_OT_link_viewer ( wmOperatorType ot)
void NODE_OT_links_cut ( wmOperatorType ot)
void NODE_OT_mute_toggle ( wmOperatorType ot)
void NODE_OT_new_node_tree ( wmOperatorType ot)
void NODE_OT_options_toggle ( wmOperatorType ot)
void NODE_OT_preview_toggle ( wmOperatorType ot)
void NODE_OT_read_fullsamplelayers ( wmOperatorType ot)
void NODE_OT_read_renderlayers ( wmOperatorType ot)
void NODE_OT_render_changed ( wmOperatorType ot)
void NODE_OT_resize ( wmOperatorType ot)
void NODE_OT_show_cyclic_dependencies ( wmOperatorType ot)
static int node_preview_toggle_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int node_read_fullsamplelayers_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int node_read_renderlayers_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static void node_remove_extra_links ( SpaceNode snode,
bNodeSocket tsock,
bNodeLink link 
) [static]
int node_render_changed_exec ( bContext C,
wmOperator UNUSEDop 
)
static int node_resize_cancel ( bContext UNUSEDC,
wmOperator op 
) [static]

Definition at line 1579 of file node_edit.c.

References wmOperator::customdata, MEM_freeN(), NULL, and OPERATOR_CANCELLED.

Referenced by NODE_OT_resize().

static int node_resize_invoke ( bContext C,
wmOperator op,
wmEvent event 
) [static]
static int node_resize_modal ( bContext C,
wmOperator op,
wmEvent event 
) [static]
void node_set_hidden_sockets ( SpaceNode snode,
bNode node,
short  flag,
int  set 
)
static int node_show_cycles_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int node_socket_hilights ( SpaceNode snode,
int  in_out 
) [static]
static int node_socket_toggle_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
void node_tree_from_ID ( ID id,
bNodeTree **  ntree,
bNodeTree **  edittree,
int *  treetype 
)
bNode* node_tree_get_editgroup ( bNodeTree nodetree)
static int outside_group_rect ( SpaceNode snode) [static]
static void sample_apply ( bContext C,
wmOperator op,
wmEvent event 
) [static]
static int sample_cancel ( bContext C,
wmOperator op 
) [static]

Definition at line 1470 of file node_edit.c.

References OPERATOR_CANCELLED, and sample_exit().

Referenced by NODE_OT_backimage_sample().

static void sample_draw ( const bContext C,
ARegion ar,
void *  arg_info 
) [static]
static void sample_exit ( bContext C,
wmOperator op 
) [static]
static int sample_invoke ( bContext C,
wmOperator op,
wmEvent event 
) [static]
static int sample_modal ( bContext C,
wmOperator op,
wmEvent event 
) [static]
void snode_autoconnect ( SpaceNode snode,
int  allow_multiple,
int  replace 
)
static int snode_bg_viewmove_cancel ( bContext UNUSEDC,
wmOperator op 
) [static]

Definition at line 1272 of file node_edit.c.

References wmOperator::customdata, MEM_freeN(), NULL, and OPERATOR_CANCELLED.

Referenced by NODE_OT_backimage_move().

static int snode_bg_viewmove_invoke ( bContext C,
wmOperator op,
wmEvent event 
) [static]
static int snode_bg_viewmove_modal ( bContext C,
wmOperator op,
wmEvent event 
) [static]
void snode_composite_job ( const bContext C,
ScrArea sa 
)
void snode_dag_update ( bContext UNUSEDC,
SpaceNode snode 
)
void snode_make_group_editable ( SpaceNode snode,
bNode gnode 
)
void snode_notify ( bContext C,
SpaceNode snode 
)
void snode_set_context ( SpaceNode snode,
Scene scene 
)
static void snode_update ( SpaceNode snode,
bNode node 
) [static]
static bNodeSocket* socket_best_match ( ListBase sockets,
int  type 
) [static]
static int socket_is_available ( bNodeTree UNUSEDntree,
bNodeSocket sock,
int  allow_used 
) [static]

Definition at line 1932 of file node_edit.c.

References bNodeSocket::flag, nodeSocketIsHidden(), and SOCK_IN_USE.

Referenced by best_socket_input(), and best_socket_output().

static int sort_nodes_locx ( void *  a,
void *  b 
) [static]

Definition at line 1919 of file node_edit.c.

References bNode::locx, and bNodeListItem::node.

Referenced by snode_autoconnect().

static bNode* visible_node ( SpaceNode snode,
rctf rct 
) [static]

Variable Documentation

Initial value:
 {
    { SOCK_IN, "SOCK_IN", 0, "Input", "" },
    { SOCK_OUT, "SOCK_OUT", 0, "Output", "" },
    { 0, NULL, 0, NULL, NULL },
}

Definition at line 98 of file node_edit.c.