Blender V5.3
NOD_socket_search_link.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 <functional>
12
13#include "BLI_set.hh"
14#include "BLI_string_ref.hh"
15#include "BLI_vector.hh"
16
17#include "DNA_node_types.h" /* Necessary for eNodeSocketInOut. */
18
20
21namespace blender {
22
23struct bContext;
24struct SpaceNode;
25
26namespace nodes {
27
32 private:
36 Vector<bNode *> &added_nodes_;
37
38 public:
39 const bContext &C;
49
52 bNode &node,
54 Vector<bNode *> &added_nodes)
55 : added_nodes_(added_nodes), C(C), node_tree(node_tree), node(node), socket(socket)
56 {
57 }
58
59 bNode &add_node(UString idname);
60 bNode &add_node(const bke::bNodeType &node_type);
65 void connect_available_socket(bNode &new_node, UString socket_name);
66 void connect_available_socket_by_identifier(bNode &new_node, UString socket_identifier);
67 void connect_socket(bNode &new_node, bNodeSocket &new_socket);
71 void update_and_connect_available_socket(bNode &new_node, UString socket_name);
73 UString socket_identifier);
74};
75
77 using LinkSocketFn = std::function<void(LinkSearchOpParams &link_params)>;
78
79 std::string name;
81 int weight = 0;
82};
83
86 const bke::bNodeType &node_type_;
87
88 const SpaceNode &snode_;
89 const bNodeTree &node_tree_;
90
91 const bNodeSocket &other_socket_;
92
93 /* The operations currently being built. Owned by the caller. */
95
96 public:
98 const SpaceNode &snode,
99 const bNodeTree &node_tree,
102 : node_type_(node_type),
103 snode_(snode),
104 node_tree_(node_tree),
105 other_socket_(other_socket),
106 items_(items)
107 {
108 }
109
113 const bNodeSocket &other_socket() const;
114
118 const SpaceNode &space_node() const;
119
123 const bNodeTree &node_tree() const;
124
128 const bke::bNodeType &node_type() const;
129
133 eNodeSocketInOut in_out() const;
134
142 void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight = 0);
143
148 void add_item_full_name(std::string name, SocketLinkOperation::LinkSocketFn fn, int weight = 0);
149};
150
164
169 const Set<UString> &skip_socket_identifiers);
170
172 Span<SocketDeclaration *> declarations);
173
174} // namespace nodes
175} // namespace blender
const bke::bNodeType & node_type() const
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
GatherLinkSearchOpParams(const bke::bNodeType &node_type, const SpaceNode &snode, const bNodeTree &node_tree, const bNodeSocket &other_socket, Vector< SocketLinkOperation > &items)
void add_item_full_name(std::string name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
LinkSearchOpParams(const bContext &C, bNodeTree &node_tree, bNode &node, bNodeSocket &socket, Vector< bNode * > &added_nodes)
void connect_available_socket_by_identifier(bNode &new_node, UString socket_identifier)
void update_and_connect_available_socket(bNode &new_node, UString socket_name)
void connect_socket(bNode &new_node, bNodeSocket &new_socket)
void connect_available_socket(bNode &new_node, UString socket_name)
void update_and_connect_available_socket_by_identifier(bNode &new_node, UString socket_identifier)
void search_link_ops_for_basic_node(GatherLinkSearchOpParams &params)
void search_link_ops_for_declarations(GatherLinkSearchOpParams &params, Span< SocketDeclaration * > declarations)
void search_filtered_link_ops_for_basic_node(GatherLinkSearchOpParams &params, const Set< UString > &skip_socket_identifiers)
BMesh Iterators.
Defines a node type.
Definition BKE_node.hh:265
std::function< void(LinkSearchOpParams &link_params)> LinkSocketFn