Blender  V2.93
Macros | Functions | Variables
node_draw.cc File Reference

higher level node drawing for the node editor. More...

#include "MEM_guardedalloc.h"
#include "DNA_light_types.h"
#include "DNA_linestyle_types.h"
#include "DNA_material_types.h"
#include "DNA_modifier_types.h"
#include "DNA_node_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
#include "BLI_blenlib.h"
#include "BLI_map.hh"
#include "BLI_math.h"
#include "BLI_set.hh"
#include "BLI_span.hh"
#include "BLI_string_ref.hh"
#include "BLI_vector.hh"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_node_ui_storage.hh"
#include "BKE_object.h"
#include "DEG_depsgraph.h"
#include "BLF_api.h"
#include "BIF_glutil.h"
#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "GPU_state.h"
#include "GPU_viewport.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_gpencil.h"
#include "ED_node.h"
#include "ED_space_api.h"
#include "UI_resources.h"
#include "UI_view2d.h"
#include "RNA_access.h"
#include "node_intern.h"

Go to the source code of this file.

Macros

#define MARKER_SHAPE_DIAMOND   0x1
 
#define MARKER_SHAPE_SQUARE   0xC
 
#define MARKER_SHAPE_CIRCLE   0x2
 
#define MARKER_SHAPE_INNER_DOT   0x10
 
#define NODE_HEADER_ICON_SIZE   (0.8f * U.widget_unit)
 
#define USE_DRAW_TOT_UPDATE
 

Functions

void ui_draw_dropshadow (const rctf *rct, float radius, float aspect, float alpha, int select)
 
float ED_node_grid_size (void)
 
void ED_node_tree_update (const bContext *C)
 
static bNodeTreenode_tree_from_ID (ID *id)
 
void ED_node_tag_update_id (ID *id)
 
void ED_node_tag_update_nodetree (Main *bmain, bNodeTree *ntree, bNode *node)
 
static bool compare_nodes (const bNode *a, const bNode *b)
 
void ED_node_sort (bNodeTree *ntree)
 
static void node_uiblocks_init (const bContext *C, bNodeTree *ntree)
 
void node_to_view (const bNode *node, float x, float y, float *rx, float *ry)
 
void node_to_updated_rect (const bNode *node, rctf *r_rect)
 
void node_from_view (const bNode *node, float x, float y, float *rx, float *ry)
 
static void node_update_basis (const bContext *C, bNodeTree *ntree, bNode *node)
 
static void node_update_hidden (bNode *node)
 
void node_update_default (const bContext *C, bNodeTree *ntree, bNode *node)
 
int node_select_area_default (bNode *node, int x, int y)
 
int node_tweak_area_default (bNode *node, int x, int y)
 
int node_get_colorid (bNode *node)
 
static void node_draw_mute_line (const View2D *v2d, const SpaceNode *snode, const bNode *node)
 
static void node_socket_draw (const bNodeSocket *sock, const float color[4], const float color_outline[4], float size, int locx, int locy, uint pos_id, uint col_id, uint shape_id, uint size_id, uint outline_col_id)
 
static void node_socket_draw_multi_input (const float color[4], const float color_outline[4], const float width, const float height, const int locx, const int locy)
 
static void node_socket_outline_color_get (const bool selected, const int socket_type, float r_outline_color[4])
 
void node_socket_color_get (bContext *C, bNodeTree *ntree, PointerRNA *node_ptr, bNodeSocket *sock, float r_color[4])
 
static void node_socket_draw_nested (const bContext *C, bNodeTree *ntree, PointerRNA *node_ptr, bNodeSocket *sock, uint pos_id, uint col_id, uint shape_id, uint size_id, uint outline_col_id, float size, bool selected)
 
void ED_node_socket_draw (bNodeSocket *sock, const rcti *rect, const float color[4], float scale)
 
static void node_draw_preview_background (rctf *rect)
 
static void node_draw_preview (bNodePreview *preview, rctf *prv)
 
static void node_toggle_button_cb (struct bContext *C, void *node_argv, void *op_argv)
 
void node_draw_shadow (const SpaceNode *snode, const bNode *node, float radius, float alpha)
 
void node_draw_sockets (const View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *node, bool draw_outputs, bool select_all)
 
static int node_error_type_to_icon (const NodeWarningType type)
 
static uint8_t node_error_type_priority (const NodeWarningType type)
 
static NodeWarningType node_error_highest_priority (Span< NodeWarning > warnings)
 
static char * node_errors_tooltip_fn (bContext *UNUSED(C), void *argN, const char *UNUSED(tip))
 
static void node_add_error_message_button (const bContext *C, bNodeTree &ntree, bNode &node, const rctf &rect, float &icon_offset)
 
static void node_draw_basis (const bContext *C, const View2D *v2d, const SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key)
 
static void node_draw_hidden (const bContext *C, const View2D *v2d, const SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key))
 
int node_get_resize_cursor (int directions)
 
void node_set_cursor (wmWindow *win, SpaceNode *snode, float cursor[2])
 
void node_draw_default (const bContext *C, ARegion *region, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key)
 
static void node_update (const bContext *C, bNodeTree *ntree, bNode *node)
 
static void count_mutli_input_socket_links (bNodeTree *ntree, SpaceNode *snode)
 
void node_update_nodetree (const bContext *C, bNodeTree *ntree)
 
static void node_draw (const bContext *C, ARegion *region, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key)
 
void node_draw_nodetree (const bContext *C, ARegion *region, SpaceNode *snode, bNodeTree *ntree, bNodeInstanceKey parent_key)
 
static void draw_tree_path (SpaceNode *snode)
 
static void snode_setup_v2d (SpaceNode *snode, ARegion *region, const float center[2])
 
static void draw_nodetree (const bContext *C, ARegion *region, bNodeTree *ntree, bNodeInstanceKey parent_key)
 
static void draw_group_overlay (const bContext *C, ARegion *region)
 
void node_draw_space (const bContext *C, ARegion *region)
 

Variables

static const float virtual_node_socket_outline_color [4] = {0.5, 0.5, 0.5, 1.0}
 

Detailed Description

higher level node drawing for the node editor.

Definition in file node_draw.cc.

Macro Definition Documentation

◆ MARKER_SHAPE_CIRCLE

#define MARKER_SHAPE_CIRCLE   0x2

Definition at line 717 of file node_draw.cc.

◆ MARKER_SHAPE_DIAMOND

#define MARKER_SHAPE_DIAMOND   0x1

Definition at line 715 of file node_draw.cc.

◆ MARKER_SHAPE_INNER_DOT

#define MARKER_SHAPE_INNER_DOT   0x10

Definition at line 718 of file node_draw.cc.

◆ MARKER_SHAPE_SQUARE

#define MARKER_SHAPE_SQUARE   0xC

Definition at line 716 of file node_draw.cc.

◆ NODE_HEADER_ICON_SIZE

#define NODE_HEADER_ICON_SIZE   (0.8f * U.widget_unit)

Definition at line 1254 of file node_draw.cc.

◆ USE_DRAW_TOT_UPDATE

#define USE_DRAW_TOT_UPDATE

Definition at line 1823 of file node_draw.cc.

Function Documentation

◆ compare_nodes()

static bool compare_nodes ( const bNode a,
const bNode b 
)
static

Definition at line 193 of file node_draw.cc.

References Freestyle::a, bNode::flag, NODE_ACTIVE, NODE_BACKGROUND, NODE_SELECT, and bNode::parent.

Referenced by ED_node_sort().

◆ count_mutli_input_socket_links()

static void count_mutli_input_socket_links ( bNodeTree ntree,
SpaceNode snode 
)
static

◆ draw_group_overlay()

static void draw_group_overlay ( const bContext C,
ARegion region 
)
static

◆ draw_nodetree()

static void draw_nodetree ( const bContext C,
ARegion region,
bNodeTree ntree,
bNodeInstanceKey  parent_key 
)
static

◆ draw_tree_path()

static void draw_tree_path ( SpaceNode snode)
static

◆ ED_node_grid_size()

float ED_node_grid_size ( void  )

Definition at line 96 of file node_draw.cc.

Referenced by initSnapSpatial(), and node_draw_space().

◆ ED_node_socket_draw()

void ED_node_socket_draw ( bNodeSocket sock,
const rcti rect,
const float  color[4],
float  scale 
)

◆ ED_node_sort()

void ED_node_sort ( bNodeTree ntree)

◆ ED_node_tag_update_id()

void ED_node_tag_update_id ( ID id)

◆ ED_node_tag_update_nodetree()

void ED_node_tag_update_nodetree ( Main bmain,
bNodeTree ntree,
bNode node 
)

◆ ED_node_tree_update()

void ED_node_tree_update ( const bContext C)

◆ node_add_error_message_button()

static void node_add_error_message_button ( const bContext C,
bNodeTree ntree,
bNode node,
const rctf rect,
float icon_offset 
)
static

◆ node_draw()

static void node_draw ( const bContext C,
ARegion region,
SpaceNode snode,
bNodeTree ntree,
bNode node,
bNodeInstanceKey  key 
)
static

Definition at line 1811 of file node_draw.cc.

References C, node, and ntree.

Referenced by node_draw_nodetree().

◆ node_draw_basis()

static void node_draw_basis ( const bContext C,
const View2D v2d,
const SpaceNode snode,
bNodeTree ntree,
bNode node,
bNodeInstanceKey  key 
)
static

◆ node_draw_default()

void node_draw_default ( const bContext C,
ARegion region,
SpaceNode snode,
bNodeTree ntree,
bNode node,
bNodeInstanceKey  key 
)

◆ node_draw_hidden()

static void node_draw_hidden ( const bContext C,
const View2D v2d,
const SpaceNode snode,
bNodeTree ntree,
bNode node,
bNodeInstanceKey   UNUSEDkey 
)
static

◆ node_draw_mute_line()

static void node_draw_mute_line ( const View2D v2d,
const SpaceNode snode,
const bNode node 
)
static

◆ node_draw_nodetree()

void node_draw_nodetree ( const bContext C,
ARegion region,
SpaceNode snode,
bNodeTree ntree,
bNodeInstanceKey  parent_key 
)

◆ node_draw_preview()

static void node_draw_preview ( bNodePreview preview,
rctf prv 
)
static

◆ node_draw_preview_background()

static void node_draw_preview_background ( rctf rect)
static

◆ node_draw_shadow()

void node_draw_shadow ( const SpaceNode snode,
const bNode node,
float  radius,
float  alpha 
)

◆ node_draw_sockets()

void node_draw_sockets ( const View2D v2d,
const bContext C,
bNodeTree ntree,
bNode node,
bool  draw_outputs,
bool  select_all 
)

◆ node_draw_space()

void node_draw_space ( const bContext C,
ARegion region 
)

Definition at line 1939 of file node_draw.cc.

References BLI_strncpy(), C, center, copy_v2_v2(), CTX_wm_space_node(), CTX_wm_window(), SpaceNode_Runtime::cursor, bNodeTreePath::display_name, draw_group_overlay(), draw_nodespace_back_pix(), draw_nodetree(), draw_tree_path(), ED_annotation_draw_view2d(), ED_node_grid_size(), ED_region_draw_cb_draw(), SpaceNode::edittree, wmWindow::eventstate, SpaceNode::flag, ARegion::gizmo_map, GPU_blend(), GPU_BLEND_ALPHA, GPU_BLEND_NONE, GPU_DEPTH_NONE, GPU_depth_test(), GPU_framebuffer_bind_no_srgb(), GPU_line_smooth(), GPU_matrix_identity_set(), GPU_matrix_pop(), GPU_matrix_projection_get, GPU_matrix_projection_set, GPU_matrix_push(), GPU_scissor_test(), GPU_viewport_framebuffer_overlay_get(), bNodeTree::id, SpaceNode::id, ListBase::last, SpaceNode_Runtime::linkdrag, LISTBASE_FOREACH, bNodeTreePath::next, node_draw_link(), NODE_GRID_STEPS, NODE_INSTANCE_KEY_NONE, bNodeTreePath::nodetree, SpaceNode::nodetree, ntree, bNodeTreePath::parent_key, bNodeTreePath::prev, REGION_DRAW_POST_VIEW, REGION_DRAW_PRE_VIEW, SpaceNode::runtime, snode_set_context(), snode_setup_v2d(), SNODE_SHOW_GPENCIL, SPACE_NODE, STREQ, TH_BACK, TH_GRID, TH_NODE_GRID_LEVELS, TH_NODE_GROUP, SpaceNode::treepath, UI_DPI_FAC, UI_GetThemeValueType(), UI_ThemeClearColor(), UI_view2d_center_get(), UI_view2d_multi_grid_draw(), UI_view2d_region_to_view(), UI_view2d_scrollers_draw(), UI_view2d_view_ortho(), UI_view2d_view_restore(), UNLIKELY, ARegion::v2d, bNodeTree::view_center, bNodeTreePath::view_center, ARegion::winrct, ARegion::winx, ARegion::winy, WM_draw_region_get_viewport(), WM_gizmomap_draw(), WM_GIZMOMAP_DRAWSTEP_2D, wmOrtho2_pixelspace(), wmEvent::x, rcti::xmin, wmEvent::y, and rcti::ymin.

Referenced by node_main_region_draw().

◆ node_error_highest_priority()

static NodeWarningType node_error_highest_priority ( Span< NodeWarning warnings)
static

Definition at line 1218 of file node_draw.cc.

References Info, and node_error_type_priority().

Referenced by node_add_error_message_button().

◆ node_error_type_priority()

static uint8_t node_error_type_priority ( const NodeWarningType  type)
static

Definition at line 1203 of file node_draw.cc.

References BLI_assert, Error, Info, type, and Warning.

Referenced by node_error_highest_priority().

◆ node_error_type_to_icon()

static int node_error_type_to_icon ( const NodeWarningType  type)
static

Definition at line 1188 of file node_draw.cc.

References BLI_assert, Error, Info, type, and Warning.

Referenced by node_add_error_message_button().

◆ node_errors_tooltip_fn()

static char* node_errors_tooltip_fn ( bContext UNUSEDC,
void *  argN,
const char *  UNUSEDtip 
)
static

◆ node_from_view()

void node_from_view ( const bNode node,
float  x,
float  y,
float rx,
float ry 
)

Definition at line 340 of file node_draw.cc.

References node, nodeFromView(), UI_DPI_FAC, x, and y.

Referenced by node_draw_frame_prepare().

◆ node_get_colorid()

int node_get_colorid ( bNode node)

◆ node_get_resize_cursor()

int node_get_resize_cursor ( int  directions)

◆ node_select_area_default()

int node_select_area_default ( bNode node,
int  x,
int  y 
)

Definition at line 651 of file node_draw.cc.

References BLI_rctf_isect_pt(), node, x, and y.

Referenced by ED_init_custom_node_type(), and ED_node_init_butfuncs().

◆ node_set_cursor()

void node_set_cursor ( wmWindow win,
SpaceNode snode,
float  cursor[2] 
)

◆ node_socket_color_get()

void node_socket_color_get ( bContext C,
bNodeTree ntree,
PointerRNA node_ptr,
bNodeSocket sock,
float  r_color[4] 
)

◆ node_socket_draw()

static void node_socket_draw ( const bNodeSocket sock,
const float  color[4],
const float  color_outline[4],
float  size,
int  locx,
int  locy,
uint  pos_id,
uint  col_id,
uint  shape_id,
uint  size_id,
uint  outline_col_id 
)
static

◆ node_socket_draw_multi_input()

static void node_socket_draw_multi_input ( const float  color[4],
const float  color_outline[4],
const float  width,
const float  height,
const int  locx,
const int  locy 
)
static

◆ node_socket_draw_nested()

static void node_socket_draw_nested ( const bContext C,
bNodeTree ntree,
PointerRNA node_ptr,
bNodeSocket sock,
uint  pos_id,
uint  col_id,
uint  shape_id,
uint  size_id,
uint  outline_col_id,
float  size,
bool  selected 
)
static

◆ node_socket_outline_color_get()

static void node_socket_outline_color_get ( const bool  selected,
const int  socket_type,
float  r_outline_color[4] 
)
static

◆ node_to_updated_rect()

void node_to_updated_rect ( const bNode node,
rctf r_rect 
)

Definition at line 330 of file node_draw.cc.

References node, node_to_view(), rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.

Referenced by node_link_insert_offset_ntree().

◆ node_to_view()

void node_to_view ( const bNode node,
float  x,
float  y,
float rx,
float ry 
)

◆ node_toggle_button_cb()

static void node_toggle_button_cb ( struct bContext C,
void *  node_argv,
void *  op_argv 
)
static

◆ node_tree_from_ID()

static bNodeTree* node_tree_from_ID ( ID id)
static

Definition at line 112 of file node_draw.cc.

References GS, id, ID_NT, ID::name, and ntreeFromID().

Referenced by ED_node_tag_update_id().

◆ node_tweak_area_default()

int node_tweak_area_default ( bNode node,
int  x,
int  y 
)

Definition at line 656 of file node_draw.cc.

References BLI_rctf_isect_pt(), node, x, and y.

Referenced by ED_init_custom_node_type(), and ED_node_init_butfuncs().

◆ node_uiblocks_init()

static void node_uiblocks_init ( const bContext C,
bNodeTree ntree 
)
static

◆ node_update()

static void node_update ( const bContext C,
bNodeTree ntree,
bNode node 
)
static

Definition at line 1762 of file node_draw.cc.

References C, node, and ntree.

Referenced by node_update_nodetree().

◆ node_update_basis()

static void node_update_basis ( const bContext C,
bNodeTree ntree,
bNode node 
)
static

◆ node_update_default()

void node_update_default ( const bContext C,
bNodeTree ntree,
bNode node 
)

◆ node_update_hidden()

static void node_update_hidden ( bNode node)
static

Based on settings in node, sets drawing rect info.

Definition at line 578 of file node_draw.cc.

References cosf, float(), HIDDEN_RAD, LISTBASE_FOREACH, M_PI, MAX2, max_ff(), node, NODE_DY, NODE_SOCKSIZE, node_to_view(), NODE_WIDTH, nodeSocketIsHidden(), sinf, and UI_block_bounds_set_explicit().

Referenced by node_update_default().

◆ node_update_nodetree()

void node_update_nodetree ( const bContext C,
bNodeTree ntree 
)

◆ snode_setup_v2d()

static void snode_setup_v2d ( SpaceNode snode,
ARegion region,
const float  center[2] 
)
static

◆ ui_draw_dropshadow()

void ui_draw_dropshadow ( const rctf rct,
float  radius,
float  aspect,
float  alpha,
int  select 
)

Referenced by node_draw_shadow().

Variable Documentation

◆ virtual_node_socket_outline_color

const float virtual_node_socket_outline_color[4] = {0.5, 0.5, 0.5, 1.0}
static

Definition at line 786 of file node_draw.cc.

Referenced by node_socket_outline_color_get().