58 const bool allow_duplicate_names,
59 const bool do_user_count,
61 const bool snap_to_grid,
68 const char *disabled_hint =
nullptr;
71 if (!
node->typeinfo->poll_instance ||
72 node->typeinfo->poll_instance(
node, &to_tree, &disabled_hint))
80 &to_tree, *
node, flags, std::nullopt, std::nullopt, socket_map, allow_duplicate_names);
93 "Cannot add node %s into node tree %s: %s",
101 "Cannot add node %s into node tree %s",
114 if (new_node->parent) {
115 if (node_map.
contains(new_node->parent)) {
116 new_node->parent = node_map.
lookup(new_node->parent);
150 to_tree.ensure_topology_cache();
156 return node_map.
size();
192 *node_tree, *copy_tree,
true,
false,
float2(0),
false, op->
reports);
193 if (num_copied == 0) {
197 auto add_tree_ids_dependencies_cb = [©_buffer,
203 ID *id_src = *cb_data->id_pointer;
208 ID *id_dst =
nullptr;
210 if (id_src == ©_tree->
id) {
218 const ID_Type id_type = id_deps_src->id_type();
230 id_dst = copy_buffer.
id_add(
233 *cb_data->id_pointer = id_dst;
238 nullptr, ©_tree->
id, add_tree_ids_dependencies_cb,
nullptr,
IDWALK_NOP);
254 ot->
name =
"Copy to Clipboard";
255 ot->
description =
"Copy the selected nodes to the internal clipboard";
256 ot->
idname =
"NODE_OT_clipboard_copy";
303 for (
Scene &scene : bmain_src->
scenes.items_mutable()) {
308 if (!dst_scenes.
contains({scene.id.name, scene_lib_filepath(scene)})) {
316 from_tree = node_tree;
321 if (from_tree ==
nullptr) {
331 Set<ID *> force_merge_ids = {id_cast<ID *>(from_tree)};
333 BKE_main_merge(bmain_dst, &force_merge_ids, &bmain_src, merge_reports);
344 for (
bNode *
node : from_tree->all_nodes()) {
361 *from_tree, *snode->
edittree,
false,
true, offset, snap_to_grid, op->
reports);
362 if (num_copied == 0) {
388 ot->
name =
"Paste from Clipboard";
389 ot->
description =
"Paste nodes from the internal clipboard to the active node tree";
390 ot->
idname =
"NODE_OT_clipboard_paste";
406 "The 2D view location for the center of the new nodes, or unchanged if not set",
#define FOREACH_NODETREE_END
#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
#define BLI_path_join(...)
#define STRNCPY_UTF8(dst, src)
external readfile function prototypes.
#define ID_IS_PACKED(_id)
#define BLI_assert_unreachable()
ValueIterator values() const &
const Value & lookup(const Key &key) const
void add_new(const Key &key, const Value &value)
bool contains(const Key &key) const
bool contains(const Key &key) const
const char * c_str() const
ID * id_add(const ID *id, IDAddOptions options, FunctionRef< IDAddOperations(LibraryIDLinkCallbackData *cb_data, IDAddOptions options)> dependencies_filter_cb=nullptr)
bool write_as_copypaste_buffer(const char *write_filepath, ReportList &reports)
ID * id_create(short id_type, StringRefNull id_name, Library *library, IDAddOptions options)
void node_tree_set_type(bNodeTree &ntree)
void node_detach_node(bNodeTree &ntree, bNode &node)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
bNode * node_copy_with_mapping(bNodeTree *dst_tree, const bNode &node_src, int flag, std::optional< StringRefNull > dst_unique_name, std::optional< int > dst_unique_identifier, Map< const bNodeSocket *, bNodeSocket * > &new_socket_map, bool allow_duplicate_names=false)
void NODE_OT_clipboard_copy(wmOperatorType *ot)
void node_select_paired(bNodeTree &node_tree)
bool node_deselect_all(bNodeTree &node_tree)
static int node_copy_local(bNodeTree &from_tree, bNodeTree &to_tree, const bool allow_duplicate_names, const bool do_user_count, const float2 offset, const bool snap_to_grid, ReportList *reports)
void NODE_OT_clipboard_paste(wmOperatorType *ot)
static wmOperatorStatus node_clipboard_copy_exec(bContext *C, wmOperator *op)
static wmOperatorStatus node_clipboard_paste_exec(bContext *C, wmOperator *op)
static void node_copybuffer_filepath_get(char filepath[FILE_MAX], size_t filepath_maxncpy)
void remap_node_pairing(bNodeTree &dst_tree, const Map< const bNode *, bNode * > &node_map)
VectorSet< bNode * > get_selected_nodes(bNodeTree &node_tree)
static StringRef scene_lib_filepath(const Scene &scene)
void update_multi_input_indices_for_removed_links(bNode &node)
static wmOperatorStatus node_clipboard_paste_invoke(bContext *C, wmOperator *op, const wmEvent *event)
float nearest_node_grid_coord(float co)
T min(const T &a, const T &b)
T max(const T &a, const T &b)
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
bool ED_operator_node_active(bContext *C)
Main * BKE_copybuffer_read(Main &reference_bmain, const char *libname, ReportList *reports, uint64_t id_types_mask)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
void BKE_id_delete(Main *bmain, void *idv, const BKEIDDeleteOptions &options={}) ATTR_NONNULL()
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
bool ED_operator_node_editable(bContext *C)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
void ED_preview_kill_jobs(wmWindowManager *wm, Main *bmain)
VecBase< float, 2 > float2
void BKE_report(ReportList *reports, eReportType type, const char *message)
wmWindowManager * CTX_wm_manager(const bContext *C)
void BKE_main_ensure_invariants(Main &bmain, std::optional< Span< ID * > > modified_ids=std::nullopt)
void BLI_rctf_init_minmax(struct rctf *rect)
SpaceNode * CTX_wm_space_node(const bContext *C)
void BKE_main_merge(Main *bmain_dst, Set< ID * > *force_merge_src_ids, Main **r_bmain_src, MainMergeReport &reports)
const char * BKE_tempdir_base() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void BKE_main_free(Main *bmain)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Main * CTX_data_main(const bContext *C)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
void DEG_relations_tag_update(Main *bmain)
Scene * CTX_data_scene(const bContext *C)
@ IDWALK_CB_EMBEDDED_NOT_OWNING
void BKE_library_foreach_ID_link(Main *bmain, ID *id, FunctionRef< LibraryIDLinkCallback > callback, void *user_data, LibraryForeachIDFlag flag)
ARegion * CTX_wm_region(const bContext *C)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
bke::library::LibraryRuntime * runtime
ListBaseT< Scene > scenes
struct ToolSettings * toolsettings
struct bNodeTree * edittree
ListBaseT< bNodeLink > links
bke::bNodeTreeType * typeinfo
bNodeTreeInterface tree_interface
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports