Blender V5.0
node_draw.cc File Reference

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

#include <iomanip>
#include "BKE_idprop.hh"
#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_text_types.h"
#include "DNA_world_types.h"
#include "BLI_array.hh"
#include "BLI_bounds.hh"
#include "BLI_convexhull_2d.hh"
#include "BLI_function_ref.hh"
#include "BLI_listbase.h"
#include "BLI_map.hh"
#include "BLI_math_color.h"
#include "BLI_set.hh"
#include "BLI_span.hh"
#include "BLI_string.h"
#include "BLI_string_ref.hh"
#include "BLI_string_utf8.h"
#include "BLI_vector.hh"
#include "BLT_translation.hh"
#include "BKE_compute_context_cache.hh"
#include "BKE_compute_contexts.hh"
#include "BKE_context.hh"
#include "BKE_curves.hh"
#include "BKE_global.hh"
#include "BKE_idtype.hh"
#include "BKE_lib_id.hh"
#include "BKE_library.hh"
#include "BKE_main.hh"
#include "BKE_main_invariants.hh"
#include "BKE_node.hh"
#include "BKE_node_legacy_types.hh"
#include "BKE_node_runtime.hh"
#include "BKE_node_tree_update.hh"
#include "BKE_node_tree_zones.hh"
#include "BKE_object.hh"
#include "BKE_scene.hh"
#include "BKE_scene_runtime.hh"
#include "BKE_screen.hh"
#include "IMB_imbuf.hh"
#include "DEG_depsgraph.hh"
#include "BLF_api.hh"
#include "BIF_glutil.hh"
#include "GPU_framebuffer.hh"
#include "GPU_immediate.hh"
#include "GPU_immediate_util.hh"
#include "GPU_matrix.hh"
#include "GPU_state.hh"
#include "GPU_viewport.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "ED_gpencil_legacy.hh"
#include "ED_node.hh"
#include "ED_node_preview.hh"
#include "ED_screen.hh"
#include "ED_space_api.hh"
#include "ED_viewer_path.hh"
#include "UI_interface.hh"
#include "UI_interface_layout.hh"
#include "UI_resources.hh"
#include "UI_view2d.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "NOD_geometry_nodes_gizmos.hh"
#include "NOD_geometry_nodes_log.hh"
#include "NOD_node_declaration.hh"
#include "NOD_node_extra_info.hh"
#include "NOD_sync_sockets.hh"
#include "NOD_trace_values.hh"
#include "GEO_fillet_curves.hh"
#include "node_intern.hh"
#include <fmt/format.h>
#include <sstream>

Go to the source code of this file.

Classes

struct  blender::ed::space_node::TreeDrawContext
struct  blender::ed::space_node::flat_item::Socket
struct  blender::ed::space_node::flat_item::Separator
struct  blender::ed::space_node::flat_item::PanelHeader
struct  blender::ed::space_node::flat_item::PanelContentBegin
struct  blender::ed::space_node::flat_item::PanelContentEnd
struct  blender::ed::space_node::flat_item::Layout
struct  blender::ed::space_node::FlatNodeItem
struct  blender::ed::space_node::NamedAttributeTooltipArg
struct  blender::ed::space_node::FrameNodeLayout
class  bNodeTreeZone
class  bNodeTreeZones
struct  NestedTreePreviews
struct  NodeExtraInfoRow

Namespaces

namespace  blender
namespace  blender::ed
namespace  blender::ed::space_node
namespace  blender::ed::space_node::flat_item

Macros

#define NODE_ZONE_PADDING   UI_UNIT_X
#define ZONE_ZONE_PADDING   0.3f * UI_UNIT_X
#define EXTRA_INFO_ROW_HEIGHT   (20.0f * UI_SCALE_FAC)
#define NODE_SOCKET_OUTLINE   U.pixelsize
#define NODE_TREE_SCALE_SMALL   0.2f
#define NODE_HEADER_ICON_SIZE   (0.8f * U.widget_unit)
#define USE_DRAW_TOT_UPDATE

Enumerations

enum class  blender::ed::space_node::flat_item::Type {
  blender::ed::space_node::flat_item::Socket , blender::ed::space_node::flat_item::Separator , blender::ed::space_node::flat_item::Layout , blender::ed::space_node::flat_item::PanelHeader ,
  blender::ed::space_node::flat_item::PanelContentBegin , blender::ed::space_node::flat_item::PanelContentEnd
}

Functions

float blender::ed::space_node::grid_size_get ()
void blender::ed::space_node::tree_update (const bContext *C)
static bNodeTreeblender::ed::space_node::node_tree_from_ID (ID *id)
void blender::ed::space_node::tag_update_id (ID *id)
static void blender::ed::space_node::node_socket_add_tooltip_in_node_editor (const bNodeSocket &sock, uiLayout &layout)
static bool blender::ed::space_node::compare_node_depth (const bNode *a, const bNode *b)
void blender::ed::space_node::tree_draw_order_update (bNodeTree &ntree)
Array< bNode * > blender::ed::space_node::tree_draw_order_calc_nodes (bNodeTree &ntree)
Array< bNode * > blender::ed::space_node::tree_draw_order_calc_nodes_reversed (bNodeTree &ntree)
static Array< uiBlock * > blender::ed::space_node::node_uiblocks_init (const bContext &C, const Span< bNode * > nodes)
float2 blender::ed::space_node::node_to_view (const float2 &co)
static rctf blender::ed::space_node::node_to_rect (const bNode &node)
void blender::ed::space_node::node_to_updated_rect (const bNode &node, rctf &r_rect)
float2 blender::ed::space_node::node_from_view (const float2 &co)
static bool blender::ed::space_node::is_node_panels_supported (const bNode &node)
static bool blender::ed::space_node::node_update_basis_buttons (const bContext &C, bNodeTree &ntree, bNode &node, blender::FunctionRef< nodes::DrawNodeLayoutFn > draw_buttons, uiBlock &block, int &dy)
const char * blender::ed::space_node::node_socket_get_label (const bNodeSocket *socket, const char *panel_label=nullptr)
static void blender::ed::space_node::draw_socket_layout (TreeDrawContext &tree_draw_ctx, const bContext &C, uiLayout &layout, bNodeSocket &socket, bNodeTree &ntree, bNode &node, PointerRNA &node_ptr, PointerRNA &socket_ptr, const char *panel_label)
static bool blender::ed::space_node::node_update_basis_socket (TreeDrawContext &tree_draw_ctx, const bContext &C, bNodeTree &ntree, bNode &node, const char *panel_label, bNodeSocket *input_socket, bNodeSocket *output_socket, uiBlock &block, const int &locx, int &locy)
static void blender::ed::space_node::determine_potentially_visible_panels_recursive (const bNode &node, const nodes::PanelDeclaration &panel_decl, MutableSpan< bool > r_result)
static void blender::ed::space_node::determine_potentially_visible_panels (const bNode &node, MutableSpan< bool > r_result)
static void blender::ed::space_node::determine_visible_panels_impl_recursive (const bNode &node, const nodes::PanelDeclaration &panel_decl, const Span< bool > potentially_visible_states, MutableSpan< bool > r_result)
static void blender::ed::space_node::determine_visible_panels_impl (const bNode &node, const Span< bool > potentially_visible_states, MutableSpan< bool > r_result)
static void blender::ed::space_node::determine_visible_panels (const bNode &node, MutableSpan< bool > r_visibility_states)
static void blender::ed::space_node::add_flat_items_for_socket (bNode &node, const nodes::SocketDeclaration &socket_decl, const nodes::PanelDeclaration *panel_decl, const nodes::SocketDeclaration *prev_socket_decl, Vector< FlatNodeItem > &r_items)
static void blender::ed::space_node::add_flat_items_for_separator (Vector< FlatNodeItem > &r_items)
static void blender::ed::space_node::add_flat_items_for_layout (const bNode &node, const nodes::LayoutDeclaration &layout_decl, Vector< FlatNodeItem > &r_items)
static void blender::ed::space_node::add_flat_items_for_panel (bNode &node, const nodes::PanelDeclaration &panel_decl, const Span< bool > panel_visibility, Vector< FlatNodeItem > &r_items)
static Vector< FlatNodeItemblender::ed::space_node::make_flat_node_items (bNode &node)
static float blender::ed::space_node::get_margin_empty ()
static float blender::ed::space_node::get_margin_from_top (const Span< FlatNodeItem > items)
static float blender::ed::space_node::get_margin_to_bottom (const Span< FlatNodeItem > items)
static float blender::ed::space_node::get_margin_between_elements (const Span< FlatNodeItem > items, const int next_index)
static void blender::ed::space_node::mark_sockets_collapsed_recursive (bNode &node, const int node_left_x, const nodes::PanelDeclaration &visible_panel_decl, const nodes::PanelDeclaration &panel_decl)
static void blender::ed::space_node::update_collapsed_sockets_recursive (bNode &node, const int node_left_x, const nodes::PanelDeclaration &panel_decl)
static void blender::ed::space_node::update_collapsed_sockets (bNode &node, const int node_left_x)
static void blender::ed::space_node::tag_final_panel (bNode &node, const Span< FlatNodeItem > items)
static void blender::ed::space_node::node_update_basis_from_declaration (TreeDrawContext &tree_draw_ctx, const bContext &C, bNodeTree &ntree, bNode &node, uiBlock &block, const int locx, int &locy)
static void blender::ed::space_node::node_update_basis_from_socket_lists (TreeDrawContext &tree_draw_ctx, const bContext &C, bNodeTree &ntree, bNode &node, uiBlock &block, const int locx, int &locy)
static void blender::ed::space_node::node_update_basis (const bContext &C, TreeDrawContext &tree_draw_ctx, bNodeTree &ntree, bNode &node, uiBlock &block)
static void blender::ed::space_node::node_update_collapsed (bNode &node, uiBlock &block)
static int blender::ed::space_node::node_get_colorid (TreeDrawContext &tree_draw_ctx, const bNode &node)
static void blender::ed::space_node::node_draw_mute_line (const bContext &C, const View2D &v2d, const SpaceNode &snode, const bNode &node)
static void blender::ed::space_node::node_socket_tooltip_set (uiBlock &block, const int socket_index_in_tree, const float2 location, const float2 size)
static void blender::ed::space_node::node_socket_outline_color_get (const bool selected, const int socket_type, float r_outline_color[4])
void blender::ed::space_node::node_socket_color_get (const bContext &C, const bNodeTree &ntree, PointerRNA &node_ptr, const bNodeSocket &sock, float r_color[4])
void blender::ed::space_node::node_socket_add_tooltip (const bNodeTree &ntree, const bNodeSocket &sock, uiLayout &layout)
void blender::ed::space_node::node_socket_draw (bNodeSocket *sock, const rcti *rect, const float color[4], float scale)
static float blender::ed::space_node::node_tree_view_scale (const SpaceNode &snode)
static bool blender::ed::space_node::draw_node_details (const SpaceNode &snode)
static void blender::ed::space_node::node_draw_preview_background (rctf *rect)
static void blender::ed::space_node::node_draw_preview (const Scene *scene, ImBuf *preview, const rctf *prv)
static void blender::ed::space_node::node_toggle_button_cb (bContext *C, void *node_argv, void *op_argv)
static void blender::ed::space_node::node_draw_shadow (const SpaceNode &snode, const bNode &node, const float radius, const float alpha)
static void blender::ed::space_node::node_draw_node_group_indicator (const SpaceNode &snode, const bNode &node, const rctf &rect, const float radius, const float color[4])
static void blender::ed::space_node::node_draw_socket (const bContext &C, const bNodeTree &ntree, const bNode &node, PointerRNA &node_ptr, uiBlock &block, const bNodeSocket &sock, const float outline_thickness, const bool selected, const float aspect)
static void blender::ed::space_node::node_draw_sockets (const bContext &C, uiBlock &block, const SpaceNode &snode, const bNodeTree &ntree, const bNode &node)
static void blender::ed::space_node::node_panel_toggle_button_cb (bContext *C, void *panel_state_argv, void *ntree_argv)
static void blender::ed::space_node::node_draw_panels_background (const bNode &node)
static bool blender::ed::space_node::panel_has_only_inactive_inputs (const bNode &node, const nodes::PanelDeclaration &panel_decl)
static void blender::ed::space_node::node_draw_panels (bNodeTree &ntree, const bNode &node, uiBlock &block)
static nodes::NodeWarningType blender::ed::space_node::node_error_highest_priority (Span< geo_log::NodeWarning > warnings)
static std::string blender::ed::space_node::node_errors_tooltip_fn (const Span< geo_log::NodeWarning > warnings)
static uiButblender::ed::space_node::add_error_message_button (uiBlock &block, const rctf &rect, const int icon, float &icon_offset, const char *tooltip=nullptr)
static void blender::ed::space_node::node_add_error_message_button (const TreeDrawContext &tree_draw_ctx, const bNodeTree &ntree, const bNode &node, uiBlock &block, const rctf &rect, float &icon_offset)
static std::optional< std::chrono::nanoseconds > blender::ed::space_node::geo_node_get_execution_time (const TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node)
static bNodeInstanceKey blender::ed::space_node::current_node_instance_key (const SpaceNode &snode, const bNode &node)
static std::optional< std::chrono::nanoseconds > blender::ed::space_node::compositor_accumulate_frame_node_execution_time (const TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node)
static std::optional< std::chrono::nanoseconds > blender::ed::space_node::compositor_node_get_execution_time (const TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node)
static std::optional< std::chrono::nanoseconds > blender::ed::space_node::node_get_execution_time (const TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node)
static std::string blender::ed::space_node::node_get_execution_time_label (TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node)
static std::string blender::ed::space_node::named_attribute_tooltip (bContext *, void *argN, const StringRef)
static NodeExtraInfoRow blender::ed::space_node::row_from_used_named_attribute (const Map< StringRefNull, geo_log::NamedAttributeUsage > &usage_by_attribute_name)
static std::optional< NodeExtraInfoRowblender::ed::space_node::node_get_accessed_attributes_row (TreeDrawContext &tree_draw_ctx, const bNode &node)
static std::optional< NodeExtraInfoRowblender::ed::space_node::node_get_execution_time_label_row (TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node)
static void blender::ed::space_node::node_get_compositor_extra_info (TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node, Vector< NodeExtraInfoRow > &rows)
static Vector< NodeExtraInfoRowblender::ed::space_node::node_get_extra_info (const bContext &C, TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node)
static void blender::ed::space_node::node_draw_extra_info_row (const bNode &node, uiBlock &block, const rctf &rect, const int row, const NodeExtraInfoRow &extra_info_row)
static void blender::ed::space_node::node_draw_extra_info_panel_back (const bNode &node, const rctf &extra_info_rect)
static void blender::ed::space_node::node_draw_extra_info_panel (const bContext &C, TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node, ImBuf *preview, uiBlock &block)
static short blender::ed::space_node::get_viewer_shortcut_icon (const bNode &node)
static bool blender::ed::space_node::node_undefined_or_unsupported (const bNodeTree &node_tree, const bNode &node)
static ColorTheme4f blender::ed::space_node::node_header_color_get (const bNodeTree &ntree, const bNode &node, const int color_id)
static void blender::ed::space_node::node_header_custom_tooltip (const bNode &node, uiBut &but)
static void blender::ed::space_node::node_draw_basis (const bContext &C, TreeDrawContext &tree_draw_ctx, const View2D &v2d, const SpaceNode &snode, bNodeTree &ntree, const bNode &node, uiBlock &block, bNodeInstanceKey key)
static void blender::ed::space_node::node_draw_collapsed (const bContext &C, TreeDrawContext &tree_draw_ctx, const View2D &v2d, const SpaceNode &snode, bNodeTree &ntree, bNode &node, uiBlock &block)
int blender::ed::space_node::node_get_resize_cursor (NodeResizeDirection directions)
static const bNodeblender::ed::space_node::find_node_under_cursor (SpaceNode &snode, const float2 &cursor)
void blender::ed::space_node::node_set_cursor (wmWindow &win, ARegion &region, SpaceNode &snode, const float2 &cursor)
static void blender::ed::space_node::count_multi_input_socket_links (bNodeTree &ntree, SpaceNode &snode)
static FrameNodeLayout blender::ed::space_node::frame_node_layout (const bNode &frame_node)
static rctf blender::ed::space_node::calc_node_frame_dimensions (const bContext &C, TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, bNode &node)
static void blender::ed::space_node::reroute_node_prepare_for_draw (bNode &node)
static void blender::ed::space_node::node_update_nodetree (const bContext &C, TreeDrawContext &tree_draw_ctx, bNodeTree &ntree, Span< bNode * > nodes, Span< uiBlock * > blocks)
static void blender::ed::space_node::frame_node_draw_label (TreeDrawContext &tree_draw_ctx, const bNode &node, const SpaceNode &snode)
static void blender::ed::space_node::frame_node_draw_background (const ARegion &region, const SpaceNode &snode, const bNode &node)
static void blender::ed::space_node::frame_node_draw_outline (const ARegion &region, const SpaceNode &snode, const bNode &node)
static void blender::ed::space_node::frame_node_draw_overlay (const bContext &C, TreeDrawContext &tree_draw_ctx, const ARegion &region, const SpaceNode &snode, const bNode &node, uiBlock &block)
static Set< const bNodeSocket * > blender::ed::space_node::find_sockets_on_active_gizmo_paths (const bContext &C, const SpaceNode &snode, bke::ComputeContextCache &compute_context_cache)
static const bNodeblender::ed::space_node::reroute_node_get_linked_reroute (const bNode &reroute)
static StringRef blender::ed::space_node::reroute_node_get_auto_label (TreeDrawContext &tree_draw_ctx, const bNode &src_reroute)
static void blender::ed::space_node::reroute_node_draw_body (const bContext &C, const SpaceNode &snode, const bNodeTree &ntree, const bNode &node, uiBlock &block, const bool selected)
static void blender::ed::space_node::reroute_node_draw_label (TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node, uiBlock &block)
static void blender::ed::space_node::reroute_node_draw (const bContext &C, TreeDrawContext &tree_draw_ctx, ARegion &region, const SpaceNode &snode, bNodeTree &ntree, const bNode &node, uiBlock &block)
static void blender::ed::space_node::node_draw (const bContext &C, TreeDrawContext &tree_draw_ctx, ARegion &region, const SpaceNode &snode, bNodeTree &ntree, bNode &node, uiBlock &block, bNodeInstanceKey key)
static void blender::ed::space_node::add_rect_corner_positions (Vector< float2 > &positions, const rctf &rect)
static void blender::ed::space_node::find_bounds_by_zone_recursive (const SpaceNode &snode, const bNodeTreeZone &zone, const Span< const bNodeTreeZone * > all_zones, MutableSpan< Vector< float2 > > r_bounds_by_zone)
static void blender::ed::space_node::node_draw_zones_and_frames (const ARegion &region, const SpaceNode &snode, const bNodeTree &ntree)
static void blender::ed::space_node::draw_frame_overlays (const bContext &C, TreeDrawContext &tree_draw_ctx, const ARegion &region, const SpaceNode &snode, const bNodeTree &ntree, Span< uiBlock * > blocks)
static std::optional< float2blender::ed::space_node::find_visible_center_of_link (const View2D &v2d, const bNodeLink &link, const float radius, const float region_padding)
static void blender::ed::space_node::draw_link_errors (const bContext &C, SpaceNode &snode, const bNodeLink &link, const Span< bke::NodeLinkError > errors, uiBlock &invalid_links_block)
static uiBlockblender::ed::space_node::invalid_links_uiblock_init (const bContext &C)
static void blender::ed::space_node::node_draw_nodetree (const bContext &C, TreeDrawContext &tree_draw_ctx, ARegion &region, SpaceNode &snode, bNodeTree &ntree, Span< bNode * > nodes, Span< uiBlock * > blocks, bNodeInstanceKey parent_key)
static void blender::ed::space_node::draw_tree_path (const bContext &C, ARegion &region)
static void blender::ed::space_node::snode_setup_v2d (SpaceNode &snode, ARegion &region, const float2 &center)
static Map< const bNode *, const bNode * > blender::ed::space_node::find_menu_switch_sources_for_index_switch_nodes (const SpaceNode &snode, const bNodeTree &ntree, bke::ComputeContextCache &compute_context_cache)
static void blender::ed::space_node::draw_nodetree (const bContext &C, ARegion &region, bNodeTree &ntree, bNodeInstanceKey parent_key)
static void blender::ed::space_node::draw_background_color (const SpaceNode &snode)
void blender::ed::space_node::node_draw_space (const bContext &C, ARegion &region)

Variables

static const float blender::ed::space_node::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

◆ EXTRA_INFO_ROW_HEIGHT

◆ NODE_HEADER_ICON_SIZE

#define NODE_HEADER_ICON_SIZE   (0.8f * U.widget_unit)

◆ NODE_SOCKET_OUTLINE

◆ NODE_TREE_SCALE_SMALL

#define NODE_TREE_SCALE_SMALL   0.2f

Some elements of the node UI are hidden, when they get too small.

Definition at line 1633 of file node_draw.cc.

Referenced by blender::ed::space_node::draw_node_details().

◆ NODE_ZONE_PADDING

◆ USE_DRAW_TOT_UPDATE

#define USE_DRAW_TOT_UPDATE

Definition at line 4619 of file node_draw.cc.

◆ ZONE_ZONE_PADDING

#define ZONE_ZONE_PADDING   0.3f * UI_UNIT_X