Blender V5.3
ED_node.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include <optional>
12
13#include "BLI_bounds.hh"
16#include "BLI_string_ref.hh"
17#include "BLI_vector_set.hh"
18
20
22#include "NOD_nested_node_id.hh"
23
24#include "ED_node_c.hh"
25
27
28namespace blender {
29
30struct SpaceNode;
31struct ARegion;
32struct Main;
33struct bContext;
34struct bNodeSocket;
35struct bNodeTree;
38struct Object;
39struct rcti;
40struct rctf;
42
43namespace bke {
44class bNodeTreeZone;
45}
46
47namespace ui {
48struct Layout;
49} // namespace ui
50
51namespace nodes {
52class ItemDeclaration;
53}
54
55namespace ed::space_node {
56
57void tree_update(const bContext *C);
58
59float grid_size_get();
60
61/* Compute the nearest 1D coordinate corresponding to the nearest grid in node editors. */
62float nearest_node_grid_coord(float co);
63
65void snode_set_context(const bContext &C);
66
68
74 const ARegion &region,
75 bool attach_enabled,
76 bool is_new_node);
77
81void node_insert_on_frame_flag_set(SpaceNode &snode, ARegion &region, const int2 &cursor);
83
87void node_insert_on_link_flags(Main &bmain, SpaceNode &snode, bool is_new_node);
89
93void node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4], float scale);
94void node_draw_nodesocket(const rctf *rect,
95 const float color_inner[4],
96 const float color_outline[4],
97 float outline_thickness,
98 int shape,
99 float aspect);
100
101void std_node_socket_colors_get(int socket_type, float *r_color);
102
106std::optional<nodes::FoundNestedNodeID> find_nested_node_id_in_root(const SpaceNode &snode,
107 const bNode &node);
108std::optional<nodes::FoundNestedNodeID> find_nested_node_id_in_root(
109 const bNodeTree &root_tree, const ComputeContext *compute_context, const int node_id);
110
115
117 const Object *object = nullptr;
118 const NodesModifierData *nmd = nullptr;
119};
120
123std::optional<ObjectAndModifier> get_geometry_nodes_modifier_for_node_editor(
124 const SpaceNode &snode);
125
127 const Object &object,
128 const NodesModifierData &nmd);
129
135 const SpaceNode &snode, bke::ComputeContextCache &compute_context_cache);
136
141 const SpaceNode &snode,
142 bke::ComputeContextCache &compute_context_cache,
143 const bNodeSocket &socket);
144
146 const SpaceNode &snode, bke::ComputeContextCache &compute_context_cache, const bNode &node);
147
152[[nodiscard]] const ComputeContext *compute_context_for_zone(
153 const bke::bNodeTreeZone &zone,
154 bke::ComputeContextCache &compute_context_cache,
155 const ComputeContext *parent_compute_context);
156[[nodiscard]] const ComputeContext *compute_context_for_zones(
158 bke::ComputeContextCache &compute_context_cache,
159 const ComputeContext *parent_compute_context);
160
162 const bContext &C,
163 StringRef catalog_path,
164 const ui::NodeAssetMenuOperatorType operator_type);
165
168
170
171const char *node_socket_get_label(const bNodeSocket *socket, const char *panel_label = nullptr);
172
173const char *node_socket_get_description(const bNodeSocket *socket);
174
175std::optional<Bounds<float2>> node_bounds(Span<const bNode *> nodes);
176std::optional<Bounds<float2>> node_location_bounds(Span<const bNode *> nodes);
177
180
181} // namespace ed::space_node
182
183} // namespace blender
#define C
Definition RandGen.cpp:29
float3x3 scale(float3x3 mat, float2 scale)
const ComputeContext * compute_context_for_edittree_socket(const SpaceNode &snode, bke::ComputeContextCache &compute_context_cache, const bNodeSocket &socket)
void ui_template_node_asset_menu_items(ui::Layout &layout, const bContext &C, StringRef catalog_path, const ui::NodeAssetMenuOperatorType operator_type)
void node_insert_on_link_flags_set(SpaceNode &snode, const ARegion &region, bool attach_enabled, bool is_new_node)
void node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[4], float scale)
Object * get_space_editor_object(const bContext *C)
std::optional< ObjectAndModifier > get_geometry_nodes_modifier_for_node_editor(const SpaceNode &snode)
void node_insert_on_frame_flag_set(SpaceNode &snode, ARegion &region, const int2 &cursor)
std::optional< nodes::FoundNestedNodeID > find_nested_node_id_in_root(const SpaceNode &snode, const bNode &node)
void std_node_socket_colors_get(int socket_type, float *r_color)
Definition drawnode.cc:1056
const ComputeContext * compute_context_for_edittree(const SpaceNode &snode, bke::ComputeContextCache &compute_context_cache)
void tree_update(const bContext *C)
Definition node_draw.cc:189
const char * node_socket_get_label(const bNodeSocket *socket, const char *panel_label=nullptr)
Definition node_draw.cc:398
VectorSet< bNode * > get_selected_nodes(bNodeTree &node_tree)
const ComputeContext * compute_context_for_zone(const bke::bNodeTreeZone &zone, bke::ComputeContextCache &compute_context_cache, const ComputeContext *parent_compute_context)
void node_insert_on_link_flags_clear(bNodeTree &node_tree)
void snode_set_context(const bContext &C)
Definition node_edit.cc:191
Map< int, bool > & node_can_sync_cache_get(SpaceNode &snode)
bNode * find_common_parent_node(Span< bNode * > nodes)
const ComputeContext * compute_context_for_zones(const Span< const bke::bNodeTreeZone * > zones, bke::ComputeContextCache &compute_context_cache, const ComputeContext *parent_compute_context)
void node_tree_interface_draw(bContext &C, ui::Layout &layout, bNodeTree &tree)
const char * node_socket_get_description(const bNodeSocket *socket)
Definition node_draw.cc:427
bool node_editor_is_for_geometry_nodes_modifier(const SpaceNode &snode, const Object &object, const NodesModifierData &nmd)
std::optional< Bounds< float2 > > node_location_bounds(Span< const bNode * > nodes)
void node_insert_on_frame_flag_clear(SpaceNode &snode)
const ComputeContext * compute_context_for_edittree_node(const SpaceNode &snode, bke::ComputeContextCache &compute_context_cache, const bNode &node)
std::optional< Bounds< float2 > > node_bounds(Span< const bNode * > nodes)
void node_draw_nodesocket(const rctf *rect, const float color_inner[4], const float color_outline[4], float outline_thickness, int shape, float aspect)
Definition drawnode.cc:1988
void node_insert_on_link_flags(Main &bmain, SpaceNode &snode, bool is_new_node)
float nearest_node_grid_coord(float co)
Definition node_edit.cc:516
BMesh Iterators.
VecBase< int32_t, 2 > int2