Blender V4.3
node_intern.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
12#include "BLI_math_vector.h"
13#include "BLI_math_vector.hh"
14#include "BLI_vector.hh"
15#include "BLI_vector_set.hh"
16
17#include "BKE_node.hh"
18
19#include "UI_interface.hh"
20#include "UI_view2d.hh"
21
22struct ARegion;
24struct View2D;
25struct bContext;
26struct bNode;
27struct bNodeLink;
28struct bNodeSocket;
29struct wmGizmoGroupType;
30struct wmKeyConfig;
31struct wmWindow;
32
33/* Outside of blender namespace to avoid Python documentation build error with `ctypes`. */
34extern "C" {
35extern const char *node_context_dir[];
36};
37
38namespace blender::ed::asset {
39struct AssetItemTree;
40}
41
44
51
54
57
63
69
70 /* The cursor position, used for drawing a + icon when dragging a node link. */
71 std::array<int, 2> cursor;
72
79
80 bool swap_links = false;
81
82 /* Data for edge panning */
84};
85
87 float aspect;
88
91
97
99 std::unique_ptr<bNodeLinkDrag> linkdrag;
100
101 /* XXX hack for translate_attach op-macros to pass data from transform op to insert_offset op */
104
111
119 std::shared_ptr<asset::AssetItemTree> assets_for_menu;
120};
121
130
131/* Nodes draw without DPI - the view zoom is flexible. */
132#define HIDDEN_RAD (0.75f * U.widget_unit)
133#define BASIS_RAD (0.2f * U.widget_unit)
134#define NODE_DYS (U.widget_unit / 2)
135#define NODE_DY U.widget_unit
136#define NODE_ITEM_SPACING_Y (0.1f * U.widget_unit)
137#define NODE_WIDTH(node) (node.width * UI_SCALE_FAC)
138#define NODE_HEIGHT(node) (node.height * UI_SCALE_FAC)
139#define NODE_MARGIN_X (1.2f * U.widget_unit)
140#define NODE_SOCKSIZE (0.25f * U.widget_unit)
141#define NODE_SOCKSIZE_DRAW_MULIPLIER 2.25f
142#define NODE_SOCK_OUTLINE_SCALE 1.0f
143#define NODE_MULTI_INPUT_LINK_GAP (0.25f * U.widget_unit)
144#define NODE_RESIZE_MARGIN (0.20f * U.widget_unit)
145#define NODE_LINK_RESOL 12
146
147/* `space_node.cc` */
148
153
155
156/* `node_draw.cc` */
157
163 const bNodeTree &ntree,
164 PointerRNA &node_ptr,
165 const bNodeSocket &sock,
166 float r_color[4]);
167
168const char *node_socket_get_label(const bNodeSocket *socket, const char *panel_label);
169
170void node_draw_space(const bContext &C, ARegion &region);
171
172void node_socket_add_tooltip(const bNodeTree &ntree, const bNodeSocket &sock, uiLayout &layout);
173
183
184void node_set_cursor(wmWindow &win, ARegion &region, SpaceNode &snode, const float2 &cursor);
185/* DPI scaled coords */
186float2 node_to_view(const bNode &node, const float2 &co);
187void node_to_updated_rect(const bNode &node, rctf &r_rect);
188float2 node_from_view(const bNode &node, const float2 &co);
189
190/* `node_ops.cc` */
191
192void node_operatortypes();
193void node_keymap(wmKeyConfig *keyconf);
194
195/* `node_select.cc` */
196
197rctf node_frame_rect_inside(const SpaceNode &snode, const bNode &node);
198bool node_or_socket_isect_event(const bContext &C, const wmEvent &event);
199
201void node_socket_select(bNode *node, bNodeSocket &sock);
202void node_socket_deselect(bNode *node, bNodeSocket &sock, bool deselect_node);
203void node_deselect_all_input_sockets(bNodeTree &node_tree, bool deselect_nodes);
204void node_deselect_all_output_sockets(bNodeTree &node_tree, bool deselect_nodes);
209void node_select_single(bContext &C, bNode &node);
210
221
222/* `node_view.cc` */
223
225 bContext &C, SpaceNode &snode, ARegion &region, int node_flag, int smooth_viewtx);
226
229
234
235/* `drawnode.cc` */
236
238 const bNode *node,
239 int x,
240 int y);
241
243void nodelink_batch_end(SpaceNode &snode);
244
248void node_draw_link(const bContext &C,
249 const View2D &v2d,
250 const SpaceNode &snode,
251 const bNodeLink &link,
252 bool selected);
254 const View2D &v2d,
255 const SpaceNode &snode,
256 const bNodeLink &link);
261 const View2D &v2d,
262 const SpaceNode &snode,
263 const bNodeLink &link,
264 int th_col1,
265 int th_col2,
266 int th_col3,
267 bool selected);
268
269std::array<float2, 4> node_link_bezier_points_dragged(const SpaceNode &snode,
270 const bNodeLink &link);
272 std::array<float2, NODE_LINK_RESOL + 1> &coords);
273
274std::optional<float2> link_path_intersection(const bNodeLink &link, Span<float2> path);
275
277 ARegion &region,
278 SpaceNode &snode,
279 bNodeInstanceKey parent_key);
280
281/* `node_add.cc` */
282
283bNode *add_node(const bContext &C, StringRef idname, const float2 &location);
284bNode *add_static_node(const bContext &C, int type, const float2 &location);
285
295
296/* `node_group.cc` */
297
298const char *node_group_idname(bContext *C);
304
306
307/* `node_relationships.cc` */
308
310bool all_links_muted(const bNodeSocket &socket);
313
319
324
326
328
330
331/* `node_edit.cc` */
332
334 int index,
335 int total_inputs);
336
337float node_socket_calculate_height(const bNodeSocket &socket);
338
342
344void node_set_hidden_sockets(bNode *node, int set);
345bool node_is_previewable(const SpaceNode &snode, const bNodeTree &ntree, const bNode &node);
348 ARegion &region,
349 const float2 &cursor,
350 eNodeSocketInOut in_out);
351float node_link_dim_factor(const View2D &v2d, const bNodeLink &link);
352bool node_link_is_hidden_or_dimmed(const View2D &v2d, const bNodeLink &link);
353
354void remap_node_pairing(bNodeTree &dst_tree, const Map<const bNode *, bNode *> &node_map);
355
360
368
371
375
381
383
386
389
390/* `node_gizmo.cc` */
391
396
397/* `node_geometry_attribute_search.cc` */
398
400 const bNode &node,
401 PointerRNA &socket_ptr,
402 uiLayout &layout,
403 StringRefNull placeholder = "");
404
405/* `node_context_path.cc` */
406
408
409/* `link_drag_search.cc` */
410
412 bNode &node,
413 bNodeSocket &socket,
414 const float2 &cursor);
415
416/* `add_menu_assets.cc` */
417
421
422} // namespace blender::ed::space_node
#define ENUM_OPERATORS(_type, _max)
eNodeSocketInOut
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Map
#define C
Definition RandGen.cpp:29
void NODE_OT_parent_set(wmOperatorType *ot)
void NODE_OT_delete(wmOperatorType *ot)
void NODE_OT_cryptomatte_layer_add(wmOperatorType *ot)
void NODE_OT_add_object(wmOperatorType *ot)
Definition node_add.cc:575
float node_socket_calculate_height(const bNodeSocket &socket)
Definition node_edit.cc:108
void NODE_OT_read_viewlayers(wmOperatorType *ot)
rctf node_frame_rect_inside(const SpaceNode &snode, const bNode &node)
void NODE_OT_clipboard_copy(wmOperatorType *ot)
Definition clipboard.cc:329
void node_deselect_all_input_sockets(bNodeTree &node_tree, bool deselect_nodes)
int node_get_resize_cursor(NodeResizeDirection directions)
void nodelink_batch_start(SpaceNode &)
Definition drawnode.cc:2058
void NODE_OT_select_circle(wmOperatorType *ot)
void tree_draw_order_update(bNodeTree &ntree)
Definition node_draw.cc:302
void NODE_OT_add_mask(wmOperatorType *ot)
Definition node_add.cc:931
bool space_node_view_flag(bContext &C, SpaceNode &snode, ARegion &region, int node_flag, int smooth_viewtx)
Definition node_view.cc:76
bNode * add_static_node(const bContext &C, int type, const float2 &location)
Definition node_add.cc:93
void NODE_OT_backimage_sample(wmOperatorType *ot)
Definition node_view.cc:700
void invoke_node_link_drag_add_menu(bContext &C, bNode &node, bNodeSocket &socket, const float2 &cursor)
void NODE_OT_add_reroute(wmOperatorType *ot)
Definition node_add.cc:230
void NODE_OT_node_copy_color(wmOperatorType *ot)
void node_draw_link_bezier(const bContext &C, const View2D &v2d, const SpaceNode &snode, const bNodeLink &link, const int th_col1, const int th_col2, const int th_col3, const bool selected)
Definition drawnode.cc:2318
void NODE_OT_detach(wmOperatorType *ot)
bool composite_node_editable(bContext *C)
Definition node_edit.cc:447
MenuType add_catalog_assets_menu_type()
void NODE_OT_viewer_border(wmOperatorType *ot)
void node_select_paired(bNodeTree &node_tree)
bool all_links_muted(const bNodeSocket &socket)
void nodelink_batch_end(SpaceNode &snode)
Definition drawnode.cc:2063
void NODE_OT_find_node(wmOperatorType *ot)
void NODE_OT_select_lasso(wmOperatorType *ot)
bool node_deselect_all(bNodeTree &node_tree)
void NODE_OT_add_collection(wmOperatorType *ot)
Definition node_add.cc:661
void node_socket_select(bNode *node, bNodeSocket &sock)
MenuType add_unassigned_assets_menu_type()
std::array< float2, 4 > node_link_bezier_points_dragged(const SpaceNode &snode, const bNodeLink &link)
Definition drawnode.cc:2375
bNodeSocket * node_find_indicated_socket(SpaceNode &snode, ARegion &region, const float2 &cursor, const eNodeSocketInOut in_out)
void NODE_OT_backimage_zoom(wmOperatorType *ot)
Definition node_view.cc:347
int node_render_changed_exec(bContext *C, wmOperator *)
void NODE_OT_select(wmOperatorType *ot)
void node_socket_color_get(const bContext &C, const bNodeTree &ntree, PointerRNA &node_ptr, const bNodeSocket &sock, float r_color[4])
void NODE_OT_insert_offset(wmOperatorType *ot)
bNode * add_node(const bContext &C, const StringRef idname, const float2 &location)
Definition node_add.cc:71
Array< bNode * > tree_draw_order_calc_nodes_reversed(bNodeTree &ntree)
Definition node_draw.cc:326
void NODE_OT_group_make(wmOperatorType *ot)
void NODE_OT_deactivate_viewer(wmOperatorType *ot)
void node_set_cursor(wmWindow &win, ARegion &region, SpaceNode &snode, const float2 &cursor)
void node_draw_link(const bContext &C, const View2D &v2d, const SpaceNode &snode, const bNodeLink &link, const bool selected)
Definition drawnode.cc:2337
void NODE_OT_add_group_asset(wmOperatorType *ot)
Definition node_add.cc:492
float2 node_link_calculate_multi_input_position(const float2 &socket_position, const int index, const int total_inputs)
Definition node_edit.cc:118
void NODE_OT_resize(wmOperatorType *ot)
void NODE_OT_backimage_move(wmOperatorType *ot)
Definition node_view.cc:310
void NODE_OT_clipboard_paste(wmOperatorType *ot)
Definition clipboard.cc:492
void NODE_OT_render_changed(wmOperatorType *ot)
void NODE_OT_links_detach(wmOperatorType *ot)
void node_draw_link_dragged(const bContext &C, const View2D &v2d, const SpaceNode &snode, const bNodeLink &link)
Definition drawnode.cc:2389
void NODE_OT_group_insert(wmOperatorType *ot)
void node_socket_deselect(bNode *node, bNodeSocket &sock, bool deselect_node)
void NODE_OT_delete_reconnect(wmOperatorType *ot)
void NODE_OT_shader_script_update(wmOperatorType *ot)
void NODE_GGT_backdrop_corner_pin(wmGizmoGroupType *gzgt)
void NODE_OT_links_cut(wmOperatorType *ot)
void NODE_OT_hide_socket_toggle(wmOperatorType *ot)
void node_set_hidden_sockets(bNode *node, int set)
bool node_is_previewable(const SpaceNode &snode, const bNodeTree &ntree, const bNode &node)
void NODE_OT_select_grouped(wmOperatorType *ot)
void draw_nodespace_back_pix(const bContext &C, ARegion &region, SpaceNode &snode, bNodeInstanceKey parent_key)
Definition drawnode.cc:1641
void remap_node_pairing(bNodeTree &dst_tree, const Map< const bNode *, bNode * > &node_map)
float node_link_dim_factor(const View2D &v2d, const bNodeLink &link)
void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot)
void NODE_OT_join(wmOperatorType *ot)
const char * node_socket_get_label(const bNodeSocket *socket, const char *panel_label)
Definition node_draw.cc:432
void NODE_OT_attach(wmOperatorType *ot)
bool node_link_is_hidden_or_dimmed(const View2D &v2d, const bNodeLink &link)
void NODE_OT_view_selected(wmOperatorType *ot)
Definition node_view.cc:186
std::optional< float2 > link_path_intersection(const bNodeLink &link, const Span< float2 > path)
Definition node_add.cc:119
void NODE_OT_link_viewer(wmOperatorType *ot)
void NODE_GGT_backdrop_crop(wmGizmoGroupType *gzgt)
void NODE_OT_select_linked_from(wmOperatorType *ot)
void node_deselect_all_output_sockets(bNodeTree &node_tree, bool deselect_nodes)
Array< bNode * > tree_draw_order_calc_nodes(bNodeTree &ntree)
Definition node_draw.cc:314
const char * node_group_idname(bContext *C)
Vector< ui::ContextPathItem > context_path_for_space_node(const bContext &C)
void NODE_OT_select_same_type_step(wmOperatorType *ot)
void node_select_single(bContext &C, bNode &node)
float2 space_node_group_offset(const SpaceNode &snode)
void NODE_OT_preview_toggle(wmOperatorType *ot)
void NODE_OT_clear_viewer_border(wmOperatorType *ot)
void NODE_OT_select_linked_to(wmOperatorType *ot)
void NODE_OT_link_make(wmOperatorType *ot)
void node_link_bezier_points_evaluated(const bNodeLink &link, std::array< float2, NODE_LINK_RESOL+1 > &coords)
Definition drawnode.cc:1791
void NODE_OT_view_all(wmOperatorType *ot)
Definition node_view.cc:153
wmKeyMap * node_link_modal_keymap(wmKeyConfig *keyconf)
void NODE_OT_group_edit(wmOperatorType *ot)
bool node_or_socket_isect_event(const bContext &C, const wmEvent &event)
void NODE_GGT_backdrop_transform(wmGizmoGroupType *gzgt)
void NODE_OT_group_separate(wmOperatorType *ot)
float2 node_to_view(const bNode &node, const float2 &co)
Definition node_draw.cc:354
void NODE_OT_duplicate(wmOperatorType *ot)
NodeResizeDirection node_get_resize_direction(const SpaceNode &snode, const bNode *node, const int x, const int y)
Definition drawnode.cc:227
void node_geometry_add_attribute_search_button(const bContext &, const bNode &node, PointerRNA &socket_ptr, uiLayout &layout, const StringRefNull placeholder)
bool node_has_hidden_sockets(bNode *node)
void NODE_GGT_backdrop_sun_beams(wmGizmoGroupType *gzgt)
void NODE_OT_output_file_add_socket(wmOperatorType *ot)
void NODE_OT_options_toggle(wmOperatorType *ot)
void node_keymap(wmKeyConfig *keyconf)
Definition node_ops.cc:118
void NODE_OT_add_group(wmOperatorType *ot)
Definition node_add.cc:370
void NODE_OT_add_file(wmOperatorType *ot)
Definition node_add.cc:863
void node_to_updated_rect(const bNode &node, rctf &r_rect)
Definition node_draw.cc:360
bool composite_node_active(bContext *C)
Definition node_edit.cc:436
void node_draw_space(const bContext &C, ARegion &region)
void NODE_OT_link(wmOperatorType *ot)
void NODE_OT_links_mute(wmOperatorType *ot)
void NODE_OT_default_group_width_set(wmOperatorType *ot)
void NODE_OT_hide_toggle(wmOperatorType *ot)
void NODE_OT_add_material(wmOperatorType *ot)
Definition node_add.cc:1008
void NODE_OT_select_box(wmOperatorType *ot)
void NODE_OT_select_all(wmOperatorType *ot)
bNodeSocket * get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out)
void node_socket_add_tooltip(const bNodeTree &ntree, const bNodeSocket &sock, uiLayout &layout)
void NODE_OT_group_ungroup(wmOperatorType *ot)
void NODE_OT_new_node_tree(wmOperatorType *ot)
Definition node_add.cc:1105
void update_multi_input_indices_for_removed_links(bNode &node)
float2 node_from_view(const bNode &node, const float2 &co)
Definition node_draw.cc:371
void NODE_OT_cryptomatte_layer_remove(wmOperatorType *ot)
void NODE_OT_backimage_fit(wmOperatorType *ot)
Definition node_view.cc:412
void NODE_OT_output_file_move_active_socket(wmOperatorType *ot)
void NODE_OT_mute_toggle(wmOperatorType *ot)
VecBase< float, 2 > float2
const char * node_context_dir[]
std::unique_ptr< bNodeLinkDrag > linkdrag
Map< ComputeContextHash, std::unique_ptr< space_node::NestedTreePreviews > > tree_previews_per_context
std::shared_ptr< asset::AssetItemTree > assets_for_menu
wmOperatorType * ot
Definition wm_files.cc:4125