Blender V5.3
node_select.cc
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#include <array>
10#include <cstdlib>
11#include <fmt/format.h>
12
14#include "DNA_image_types.h"
15#include "DNA_mask_types.h"
16#include "DNA_material_types.h"
17#include "DNA_node_types.h"
18#include "DNA_object_types.h"
19#include "DNA_sound_types.h"
20#include "DNA_text_types.h"
21#include "DNA_vfont_types.h"
23
24#include "BLI_lasso_2d.hh"
25#include "BLI_listbase.hh"
26#include "BLI_math_vector_c.hh"
27#include "BLI_rect.hh"
28#include "BLI_resource_scope.hh"
29#include "BLI_string.hh"
30#include "BLI_string_utf8.hh"
31#include "BLI_utildefines.hh"
32
33#include "BKE_context.hh"
34#include "BKE_idtype.hh"
35#include "BKE_lib_id.hh"
36#include "BKE_main.hh"
38#include "BKE_node.hh"
40#include "BKE_node_runtime.hh"
42#include "BKE_screen.hh"
43#include "BKE_viewer_path.hh"
44#include "BKE_workspace.hh"
45
46#include "ED_node.hh" /* own include */
47#include "ED_screen.hh"
48#include "ED_select_utils.hh"
49#include "ED_view3d.hh"
50#include "ED_viewer_path.hh"
51
52#include "RNA_access.hh"
53#include "RNA_define.hh"
54
55#include "WM_api.hh"
56#include "WM_types.hh"
57
58#include "UI_resources.hh"
59#include "UI_string_search.hh"
60#include "UI_view2d.hh"
61
62#include "DEG_depsgraph.hh"
63
64#include "BLT_translation.hh"
65
66#include "NOD_eval_log.hh"
67
68#include "node_intern.hh" /* own include */
69
71
72static bool is_event_over_node_or_socket(const bContext &C, const wmEvent &event);
73
84 const Scene *scene,
85 const Object *ob)
86{
87 for (wmWindow &win : wm->windows) {
88 if (win.scene != scene) {
89 continue;
90 }
92 for (ScrArea &area : screen->areabase) {
93 if (area.spacetype == SPACE_VIEW3D) {
94 const View3D *v3d = area.spacedata.first_as<View3D>();
95
96 if (ED_view3d_has_workbench_in_texture_color(scene, ob, v3d)) {
97 return true;
98 }
99 }
100 }
101 }
102 return false;
103}
104
105/* -------------------------------------------------------------------- */
108
110{
111 const float margin = 4.0f * NODE_RESIZE_MARGIN * math::max(snode.runtime->aspect, 1.0f);
112 rctf frame_inside = {
113 node.runtime->draw_bounds.xmin,
114 node.runtime->draw_bounds.xmax,
115 node.runtime->draw_bounds.ymin,
116 node.runtime->draw_bounds.ymax,
117 };
118
119 BLI_rctf_pad(&frame_inside, -margin, -margin);
120
121 return frame_inside;
122}
123
125{
126 return is_event_over_node_or_socket(C, event);
127}
128
130 const bNode &node,
131 const float2 &mouse)
132{
133 /* Frame nodes are selectable by their borders (including their whole rect - as for other nodes -
134 * would prevent e.g. box selection of nodes inside that frame). */
135 const rctf frame_inside = node_frame_rect_inside(snode, node);
136 if (BLI_rctf_isect_pt(&node.runtime->draw_bounds, mouse.x, mouse.y) &&
137 !BLI_rctf_isect_pt(&frame_inside, mouse.x, mouse.y))
138 {
139 return true;
140 }
141
142 return false;
143}
144
145bNode *node_under_mouse_get(const SpaceNode &snode, const float2 mouse)
146{
148 switch (node->type_legacy) {
149 case NODE_FRAME: {
150 if (node_frame_select_isect_mouse(snode, *node, mouse)) {
151 return node;
152 }
153 break;
154 }
155 default: {
156 if (BLI_rctf_isect_pt(&node->runtime->draw_bounds, int(mouse.x), int(mouse.y))) {
157 return node;
158 }
159 break;
160 }
161 }
162 }
163 return nullptr;
164}
165
166static bool is_position_over_node_or_socket(SpaceNode &snode, ARegion &region, const float2 &mouse)
167{
168 if (node_under_mouse_get(snode, mouse)) {
169 return true;
170 }
171 if (node_find_indicated_socket(snode, region, mouse, SOCK_IN | SOCK_OUT)) {
172 return true;
173 }
174 return false;
175}
176
177static bool is_event_over_node_or_socket(const bContext &C, const wmEvent &event)
178{
179 SpaceNode &snode = *CTX_wm_space_node(&C);
180 ARegion &region = *CTX_wm_region(&C);
181
182 int2 mval;
183 WM_event_drag_start_mval(&event, &region, mval);
184
185 float2 mouse;
186 ui::view2d_region_to_view(&region.v2d, mval.x, mval.y, &mouse.x, &mouse.y);
187 return is_position_over_node_or_socket(snode, region, mouse);
188}
189
191{
192 sock.flag |= SOCK_SELECT;
193
194 /* select node too */
195 if (node) {
196 node->flag |= NODE_SELECT;
197 }
198}
199
200void node_socket_deselect(bNode *node, bNodeSocket &sock, const bool deselect_node)
201{
202 sock.flag &= ~SOCK_SELECT;
203
204 if (node && deselect_node) {
205 bool sel = false;
206
207 /* if no selected sockets remain, also deselect the node */
208 for (bNodeSocket &input : node->inputs) {
209 if (input.flag & SELECT) {
210 sel = true;
211 break;
212 }
213 }
214 for (bNodeSocket &output : node->outputs) {
215 if (output.flag & SELECT) {
216 sel = true;
217 break;
218 }
219 }
220
221 if (!sel) {
222 node->flag &= ~NODE_SELECT;
223 }
224 }
225}
226
227static void node_socket_toggle(bNode *node, bNodeSocket &sock, bool deselect_node)
228{
229 if (sock.flag & SELECT) {
230 node_socket_deselect(node, sock, deselect_node);
231 }
232 else {
234 }
235}
236
238{
239 bool changed = false;
240 for (bNode *node : node_tree.all_nodes()) {
241 changed |= bke::node_set_selected(*node, false);
242 }
243 return changed;
244}
245
246void node_deselect_all_input_sockets(bNodeTree &node_tree, const bool deselect_nodes)
247{
248 /* XXX not calling node_socket_deselect here each time, because this does iteration
249 * over all node sockets internally to check if the node stays selected.
250 * We can do that more efficiently here.
251 */
252
253 for (bNode *node : node_tree.all_nodes()) {
254 bool sel = false;
255
256 for (bNodeSocket &socket : node->inputs) {
257 socket.flag &= ~SOCK_SELECT;
258 }
259
260 /* If no selected sockets remain, also deselect the node. */
261 if (deselect_nodes) {
262 for (bNodeSocket &socket : node->outputs) {
263 if (socket.flag & SELECT) {
264 sel = true;
265 break;
266 }
267 }
268
269 if (!sel) {
270 node->flag &= ~NODE_SELECT;
271 }
272 }
273 }
274}
275
276void node_deselect_all_output_sockets(bNodeTree &node_tree, const bool deselect_nodes)
277{
278 /* XXX not calling node_socket_deselect here each time, because this does iteration
279 * over all node sockets internally to check if the node stays selected.
280 * We can do that more efficiently here.
281 */
282
283 for (bNode *node : node_tree.all_nodes()) {
284 bool sel = false;
285
286 for (bNodeSocket &socket : node->outputs) {
287 socket.flag &= ~SOCK_SELECT;
288 }
289
290 /* if no selected sockets remain, also deselect the node */
291 if (deselect_nodes) {
292 for (bNodeSocket &socket : node->inputs) {
293 if (socket.flag & SELECT) {
294 sel = true;
295 break;
296 }
297 }
298
299 if (!sel) {
300 node->flag &= ~NODE_SELECT;
301 }
302 }
303 }
304}
305
307{
308 node_tree.ensure_topology_cache();
309 for (const bke::bNodeZoneType *zone_type : bke::all_zone_types()) {
310 for (bNode *input_node : node_tree.nodes_by_type(zone_type->input_idname)) {
311 if (bNode *output_node = zone_type->get_corresponding_output(node_tree, *input_node)) {
312 if (input_node->is_selected()) {
313 output_node->flag |= NODE_SELECT;
314 }
315 if (output_node->is_selected()) {
316 input_node->flag |= NODE_SELECT;
317 }
318 }
319 }
320 }
321}
322
324{
325 VectorSet<bNode *> selected_nodes;
326 for (bNode *node : node_tree.all_nodes()) {
327 if (node->is_selected()) {
328 selected_nodes.add(node);
329 }
330 }
331 return selected_nodes;
332}
333
335
336/* -------------------------------------------------------------------- */
339
340/* Return true if we need redraw, otherwise false. */
341
342static bool node_select_grouped_type(bNodeTree &node_tree, bNode &node_act)
343{
344 bool changed = false;
345 for (bNode *node : node_tree.all_nodes()) {
346 if (!node->is_selected()) {
347 if (node->type_legacy == node_act.type_legacy) {
349 changed = true;
350 }
351 }
352 }
353 return changed;
354}
355
356static bool node_select_grouped_color(bNodeTree &node_tree, bNode &node_act)
357{
358 bool changed = false;
359 for (bNode *node : node_tree.all_nodes()) {
360 if (!node->is_selected()) {
361 if (compare_v3v3(node->color, node_act.color, 0.005f)) {
363 changed = true;
364 }
365 }
366 }
367 return changed;
368}
369
370static bool node_select_grouped_name(bNodeTree &node_tree, bNode &node_act, const bool from_right)
371{
372 bool changed = false;
373 const uint delims[] = {'.', '-', '_', '\0'};
374 size_t pref_len_act, pref_len_curr;
375 const char *sep, *suf_act, *suf_curr;
376
377 pref_len_act = BLI_str_partition_ex_utf8(
378 node_act.name, nullptr, delims, &sep, &suf_act, from_right);
379
380 /* NOTE: in case we are searching for suffix, and found none, use whole name as suffix. */
381 if (from_right && !(sep && suf_act)) {
382 pref_len_act = 0;
383 suf_act = node_act.name;
384 }
385
386 for (bNode *node : node_tree.all_nodes()) {
387 if (node->is_selected()) {
388 continue;
389 }
390 pref_len_curr = BLI_str_partition_ex_utf8(
391 node->name, nullptr, delims, &sep, &suf_curr, from_right);
392
393 /* Same as with active node name! */
394 if (from_right && !(sep && suf_curr)) {
395 pref_len_curr = 0;
396 suf_curr = node->name;
397 }
398
399 if ((from_right && STREQ(suf_act, suf_curr)) ||
400 (!from_right && (pref_len_act == pref_len_curr) &&
401 STREQLEN(node_act.name, node->name, pref_len_act)))
402 {
404 changed = true;
405 }
406 }
407
408 return changed;
409}
410
411enum {
416};
417
419{
420 SpaceNode &snode = *CTX_wm_space_node(C);
421 bNodeTree &node_tree = *snode.edittree;
422 bNode *node_act = bke::node_get_active(*snode.edittree);
423
424 if (node_act == nullptr) {
425 return OPERATOR_CANCELLED;
426 }
427
428 bool changed = false;
429 const bool extend = RNA_boolean_get(op->ptr, "extend");
430 const int type = RNA_enum_get(op->ptr, "type");
431
432 if (!extend) {
433 node_deselect_all(node_tree);
434 }
435 bke::node_set_selected(*node_act, true);
436
437 switch (type) {
439 changed = node_select_grouped_type(node_tree, *node_act);
440 break;
442 changed = node_select_grouped_color(node_tree, *node_act);
443 break;
445 changed = node_select_grouped_name(node_tree, *node_act, false);
446 break;
448 changed = node_select_grouped_name(node_tree, *node_act, true);
449 break;
450 default:
451 break;
452 }
453
454 if (changed) {
455 tree_draw_order_update(node_tree);
457 return OPERATOR_FINISHED;
458 }
459
460 return OPERATOR_CANCELLED;
461}
462
464{
465 PropertyRNA *prop;
466 static const EnumPropertyItem prop_select_grouped_types[] = {
467 {NODE_SELECT_GROUPED_TYPE, "TYPE", 0, "Type", ""},
468 {NODE_SELECT_GROUPED_COLOR, "COLOR", 0, "Color", ""},
469 {NODE_SELECT_GROUPED_PREFIX, "PREFIX", 0, "Prefix", ""},
470 {NODE_SELECT_GROUPED_SUFIX, "SUFFIX", 0, "Suffix", ""},
471 {0, nullptr, 0, nullptr, nullptr},
472 };
473
474 /* identifiers */
475 ot->name = "Select Grouped";
476 ot->description = "Select nodes with similar properties";
477 ot->idname = "NODE_OT_select_grouped";
478
479 /* API callbacks. */
483
484 /* flags */
486
487 /* properties */
488 prop = RNA_def_boolean(ot->srna,
489 "extend",
490 false,
491 "Extend",
492 "Extend selection instead of deselecting everything first");
494 ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
495}
496
498
499/* -------------------------------------------------------------------- */
502
504{
505 Main *bmain = CTX_data_main(&C);
506 SpaceNode &snode = *CTX_wm_space_node(&C);
507 bNodeTree &node_tree = *snode.edittree;
508 const Object *ob = CTX_data_active_object(&C);
509 const Scene *scene = CTX_data_scene(&C);
511 bool active_texture_changed = false;
512
513 for (bNode *node_iter : node_tree.all_nodes()) {
514 if (node_iter != &node) {
515 bke::node_set_selected(*node_iter, false);
516 }
517 }
519
520 ED_node_set_active(bmain, &snode, &node_tree, &node, &active_texture_changed);
522
523 tree_draw_order_update(node_tree);
524 if (active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) {
526 }
527
529}
530
532 const float view_y)
533{
534 const bNodeSocket *best_socket = nullptr;
535 float best_distance = FLT_MAX;
536 for (const bNodeSocket *socket : sockets) {
537 if (!socket->is_icon_visible()) {
538 continue;
539 }
540 const float socket_y = socket->runtime->location.y;
541 const float distance = math::distance(socket_y, view_y);
542 if (distance < best_distance) {
543 best_distance = distance;
544 best_socket = socket;
545 }
546 }
547 return best_socket;
548}
549
551{
552 bNodeTreeInterfacePanel &io_panel = *tree.tree_interface.find_item_parent(io_socket.item, true);
553 bNodeTreeInterfaceItem *item_to_activate = nullptr;
554 if (io_panel.header_toggle_socket() == &io_socket) {
555 item_to_activate = &io_panel.item;
556 }
557 else {
558 item_to_activate = &io_socket.item;
559 }
560 tree.tree_interface.foreach_item([&](bNodeTreeInterfaceItem &item) {
561 item.set_selected(false);
562 return true;
563 });
564 tree.tree_interface.active_item_set(item_to_activate);
565}
566
568 const bNode &group_input_node,
569 const float2 &cursor)
570{
571
572 tree.ensure_topology_cache();
573 tree.ensure_interface_cache();
574 const bNodeSocket *indicated_socket = find_socket_at_mouse_y(
575 group_input_node.output_sockets().drop_back(1), cursor.y);
576 if (!indicated_socket) {
577 return;
578 }
579 const int group_input_i = indicated_socket->index();
580 bNodeTreeInterfaceSocket &io_socket = *tree.interface_inputs()[group_input_i];
581 activate_interface_socket(tree, io_socket);
582}
583
585 const bNode &group_output_node,
586 const float2 &cursor)
587{
588 tree.ensure_topology_cache();
589 tree.ensure_interface_cache();
590 const bNodeSocket *indicated_socket = find_socket_at_mouse_y(
591 group_output_node.input_sockets().drop_back(1), cursor.y);
592 if (!indicated_socket) {
593 return;
594 }
595 const int group_output_i = indicated_socket->index();
596 bNodeTreeInterfaceSocket &io_socket = *tree.interface_outputs()[group_output_i];
597 activate_interface_socket(tree, io_socket);
598}
599
601 wmOperator *op,
602 const int2 mval,
603 const SelectPick_Params &params)
604{
605 Main &bmain = *CTX_data_main(C);
606 SpaceNode &snode = *CTX_wm_space_node(C);
607 bNodeTree &node_tree = *snode.edittree;
608 ARegion &region = *CTX_wm_region(C);
609 const Object *ob = CTX_data_active_object(C);
610 const Scene *scene = CTX_data_scene(C);
612 bNode *node = nullptr;
613 bNodeSocket *sock = nullptr;
614
615 /* Always do socket_select when extending selection. */
616 const bool socket_select = (params.sel_op == SEL_OP_XOR) ||
617 RNA_boolean_get(op->ptr, "socket_select");
618 bool changed = false;
619 bool found = false;
620 bool node_was_selected = false;
621
622 /* Get mouse coordinates in view2d space. */
623 float2 cursor;
624 ui::view2d_region_to_view(&region.v2d, mval.x, mval.y, &cursor.x, &cursor.y);
625
626 /* First do socket selection, these generally overlap with nodes. */
627 if (socket_select) {
628 /* NOTE: unlike nodes #SelectPick_Params isn't fully supported. */
629 const bool extend = (params.sel_op == SEL_OP_XOR);
630 sock = node_find_indicated_socket(snode, region, cursor, SOCK_IN);
631 if (sock) {
632 node = &sock->owner_node();
633 found = true;
634 node_was_selected = node->is_selected();
635
636 /* NOTE: SOCK_IN does not take into account the extend case...
637 * This feature is not really used anyway currently? */
638 node_socket_toggle(node, *sock, true);
639 changed = true;
640 }
641 if (!changed) {
642 sock = node_find_indicated_socket(snode, region, cursor, SOCK_OUT);
643 if (sock) {
644 node = &sock->owner_node();
645 found = true;
646 node_was_selected = node->is_selected();
647
648 if (sock->flag & SELECT) {
649 if (extend) {
650 node_socket_deselect(node, *sock, true);
651 changed = true;
652 }
653 }
654 else {
655 /* Only allow one selected output per node, for sensible linking.
656 * Allow selecting outputs from different nodes though, if extend is true. */
657 for (bNodeSocket *tsock : node->output_sockets()) {
658 if (tsock == sock) {
659 continue;
660 }
661 node_socket_deselect(node, *tsock, true);
662 changed = true;
663 }
664 if (!extend) {
665 for (bNode *tnode : node_tree.all_nodes()) {
666 if (tnode == node) {
667 continue;
668 }
669 for (bNodeSocket *tsock : tnode->output_sockets()) {
670 node_socket_deselect(tnode, *tsock, true);
671 changed = true;
672 }
673 }
674 }
675 node_socket_select(node, *sock);
676 changed = true;
677 }
678 }
679 }
680 }
681
682 if (!sock) {
683
684 /* Find the closest visible node. */
685 node = node_under_mouse_get(snode, cursor);
686 found = (node != nullptr);
687 node_was_selected = node && node->is_selected();
688
689 if (params.sel_op == SEL_OP_SET) {
690 if ((found && params.select_passthrough) && node->is_selected()) {
691 found = false;
692 }
693 else if (found || params.deselect_all) {
694 /* Deselect everything. */
695 changed = node_deselect_all(node_tree);
696 }
697 }
698
699 if (found) {
700 switch (params.sel_op) {
701 case SEL_OP_ADD:
703 break;
704 case SEL_OP_SUB:
706 break;
707 case SEL_OP_XOR: {
708 /* Check active so clicking on an inactive node activates it. */
709 bool is_selected = node->is_selected() && (node->flag & NODE_ACTIVE);
710 bke::node_set_selected(*node, !is_selected);
711 break;
712 }
713 case SEL_OP_SET:
715 break;
716 case SEL_OP_AND:
717 /* Doesn't make sense for picking. */
719 break;
720 }
721
722 if (node->is_group_input()) {
723 handle_group_input_node_selection(node_tree, *node, cursor);
724 }
725 if (node->is_group_output()) {
726 handle_group_output_node_selection(node_tree, *node, cursor);
727 }
728
729 changed = true;
730 }
731 }
732
733 if (RNA_boolean_get(op->ptr, "clear_viewer")) {
734 if (node == nullptr) {
735 /* Disable existing active viewer. */
736 WorkSpace *workspace = CTX_wm_workspace(C);
737 if (const std::optional<viewer_path::ViewerPathForGeometryNodesViewer> parsed_path =
739 {
740 /* The object needs to be reevaluated, because the viewer path is changed which means that
741 * the object may generate different viewer geometry as a side effect. */
742 Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
744 depsgraph, &parsed_path->object->id, ID_RECALC_GEOMETRY);
745 }
748 }
749 }
750
751 if (!(changed || found)) {
752 return false;
753 }
754
755 bool active_texture_changed = false;
756 bool viewer_node_changed = false;
757 if ((node != nullptr) && (node_was_selected == false || params.select_passthrough == false)) {
758 viewer_node_changed = (node->flag & NODE_DO_OUTPUT) == 0 &&
759 node->type_legacy == GEO_NODE_VIEWER;
760 ED_node_set_active(&bmain, &snode, snode.edittree, node, &active_texture_changed);
761 }
762 else if (node != nullptr && node->type_legacy == GEO_NODE_VIEWER) {
764 }
766 tree_draw_order_update(node_tree);
767 if ((active_texture_changed && has_workbench_in_texture_color(wm, scene, ob)) ||
768 viewer_node_changed)
769 {
771 }
772
775
776 BKE_main_ensure_invariants(bmain, node_tree.id);
777
778 return true;
779}
780
782{
783 /* Get settings from RNA properties for operator. */
784 int2 mval;
785 RNA_int_get_array(op->ptr, "location", mval);
786
788
789 /* Perform the selection. */
790 const bool changed = node_mouse_select(C, op, mval, params);
791
792 if (changed) {
794 }
795 /* Nothing selected, just pass through. */
797}
798
800{
801 RNA_int_set_array(op->ptr, "location", event->mval);
802
803 const wmOperatorStatus retval = node_select_exec(C, op);
804
806}
807
809{
810 PropertyRNA *prop;
811
812 /* identifiers */
813 ot->name = "Select";
814 ot->idname = "NODE_OT_select";
815 ot->description = "Select the node under the cursor";
816
817 /* API callbacks. */
822
823 /* flags */
825
826 /* properties */
828
829 prop = RNA_def_int_vector(ot->srna,
830 "location",
831 2,
832 nullptr,
833 INT_MIN,
834 INT_MAX,
835 "Location",
836 "Mouse location",
837 INT_MIN,
838 INT_MAX);
840
841 RNA_def_boolean(ot->srna, "socket_select", false, "Socket Select", "");
842
844 "clear_viewer",
845 false,
846 "Clear Viewer",
847 "Deactivate geometry nodes viewer when clicking in empty space");
848}
849
851
852/* -------------------------------------------------------------------- */
855
857{
858 SpaceNode &snode = *CTX_wm_space_node(C);
859 bNodeTree &node_tree = *snode.edittree;
860 const ARegion &region = *CTX_wm_region(C);
861 rctf rectf;
862
864 ui::view2d_region_to_view_rctf(&region.v2d, &rectf, &rectf);
865
866 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
867 const bool select = (sel_op != SEL_OP_SUB);
868 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
869 node_deselect_all(node_tree);
870 }
871
872 for (bNode *node : node_tree.all_nodes()) {
873 bool is_inside = false;
874
875 switch (node->type_legacy) {
876 case NODE_FRAME: {
877 /* Frame nodes are selectable by their borders (including their whole rect - as for other
878 * nodes - would prevent selection of other nodes inside that frame). */
879 const rctf frame_inside = node_frame_rect_inside(snode, *node);
880 if (BLI_rctf_isect(&rectf, &node->runtime->draw_bounds, nullptr) &&
881 !BLI_rctf_inside_rctf(&frame_inside, &rectf))
882 {
884 is_inside = true;
885 }
886 break;
887 }
888 default: {
889 is_inside = BLI_rctf_isect(&rectf, &node->runtime->draw_bounds, nullptr);
890 break;
891 }
892 }
893
894 if (is_inside) {
896 }
897 }
898
899 tree_draw_order_update(node_tree);
900
903
904 return OPERATOR_FINISHED;
905}
906
908{
909 const bool tweak = RNA_boolean_get(op->ptr, "tweak");
910
911 if (tweak && is_event_over_node_or_socket(*C, *event)) {
913 }
914
915 return WM_gesture_box_invoke(C, op, event);
916}
917
919{
920 /* identifiers */
921 ot->name = "Box Select";
922 ot->idname = "NODE_OT_select_box";
923 ot->description = "Use box selection to select nodes";
924
925 /* API callbacks. */
930
932
933 /* flags */
935
936 /* properties */
938 "tweak",
939 false,
940 "Tweak",
941 "Only activate when mouse is not over a node (useful for tweak gesture)");
942
945}
946
948
949/* -------------------------------------------------------------------- */
952
954{
955 SpaceNode *snode = CTX_wm_space_node(C);
956 ARegion *region = CTX_wm_region(C);
957 bNodeTree &node_tree = *snode->edittree;
958
959 int x, y, radius;
960 float2 offset;
961
962 float zoom = float(BLI_rcti_size_x(&region->winrct)) / BLI_rctf_size_x(&region->v2d.cur);
963
964 const eSelectOp sel_op = ED_select_op_modal(
965 eSelectOp(RNA_enum_get(op->ptr, "mode")),
966 WM_gesture_is_modal_first(static_cast<const wmGesture *>(op->customdata)));
967 const bool select = (sel_op != SEL_OP_SUB);
968 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
969 node_deselect_all(node_tree);
970 }
971
972 /* get operator properties */
973 x = RNA_int_get(op->ptr, "x");
974 y = RNA_int_get(op->ptr, "y");
975 radius = RNA_int_get(op->ptr, "radius");
976
977 ui::view2d_region_to_view(&region->v2d, x, y, &offset.x, &offset.y);
978
979 for (bNode *node : node_tree.all_nodes()) {
980 switch (node->type_legacy) {
981 case NODE_FRAME: {
982 /* Frame nodes are selectable by their borders (including their whole rect - as for other
983 * nodes - would prevent selection of _only_ other nodes inside that frame). */
984 rctf frame_inside = node_frame_rect_inside(*snode, *node);
985 const float radius_adjusted = float(radius) / zoom;
986 BLI_rctf_pad(&frame_inside, -2.0f * radius_adjusted, -2.0f * radius_adjusted);
987 if (BLI_rctf_isect_circle(&node->runtime->draw_bounds, offset, radius_adjusted) &&
988 !BLI_rctf_isect_circle(&frame_inside, offset, radius_adjusted))
989 {
991 }
992 break;
993 }
994 default: {
995 if (BLI_rctf_isect_circle(&node->runtime->draw_bounds, offset, radius / zoom)) {
997 }
998 break;
999 }
1000 }
1001 }
1002
1005
1006 return OPERATOR_FINISHED;
1007}
1008
1010{
1011 /* identifiers */
1012 ot->name = "Circle Select";
1013 ot->idname = "NODE_OT_select_circle";
1014 ot->description = "Use circle selection to select nodes";
1015
1016 /* API callbacks. */
1022
1023 /* flags */
1025
1026 /* properties */
1029}
1030
1032
1033/* -------------------------------------------------------------------- */
1036
1038{
1039 const bool tweak = RNA_boolean_get(op->ptr, "tweak");
1040
1041 if (tweak && is_event_over_node_or_socket(*C, *event)) {
1043 }
1044
1045 return WM_gesture_lasso_invoke(C, op, event);
1046}
1047
1048static bool do_lasso_select_node(bContext *C, const Span<int2> mcoords, eSelectOp sel_op)
1049{
1050 SpaceNode *snode = CTX_wm_space_node(C);
1051 bNodeTree &node_tree = *snode->edittree;
1052
1053 ARegion *region = CTX_wm_region(C);
1054
1055 rcti rect;
1056 bool changed = false;
1057
1058 const bool select = (sel_op != SEL_OP_SUB);
1059 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
1060 node_deselect_all(node_tree);
1061 changed = true;
1062 }
1063
1064 /* Get rectangle from operator. */
1065 BLI_lasso_boundbox(&rect, mcoords);
1066
1067 for (bNode *node : node_tree.all_nodes()) {
1068 if (select && node->is_selected()) {
1069 continue;
1070 }
1071
1072 switch (node->type_legacy) {
1073 case NODE_FRAME: {
1074 /* Frame nodes are selectable by their borders (including their whole rect - as for other
1075 * nodes - would prevent selection of other nodes inside that frame). */
1076 rctf rectf;
1077 BLI_rctf_rcti_copy(&rectf, &rect);
1078 ui::view2d_region_to_view_rctf(&region->v2d, &rectf, &rectf);
1079 const rctf frame_inside = node_frame_rect_inside(*snode, *node);
1080 if (BLI_rctf_isect(&rectf, &node->runtime->draw_bounds, nullptr) &&
1081 !BLI_rctf_inside_rctf(&frame_inside, &rectf))
1082 {
1084 changed = true;
1085 }
1086 break;
1087 }
1088 default: {
1089 int2 screen_co;
1090 const float2 center = {BLI_rctf_cent_x(&node->runtime->draw_bounds),
1091 BLI_rctf_cent_y(&node->runtime->draw_bounds)};
1092
1093 /* marker in screen coords */
1095 &region->v2d, center.x, center.y, &screen_co.x, &screen_co.y) &&
1096 BLI_rcti_isect_pt(&rect, screen_co.x, screen_co.y) &&
1097 BLI_lasso_is_point_inside(mcoords, screen_co.x, screen_co.y, INT_MAX))
1098 {
1100 changed = true;
1101 }
1102 break;
1103 }
1104 }
1105 }
1106
1107 if (changed) {
1110 }
1111
1112 return changed;
1113}
1114
1116{
1117 const Array<int2> mcoords = WM_gesture_lasso_path_to_array(C, op);
1118
1119 if (mcoords.is_empty()) {
1120 return OPERATOR_PASS_THROUGH;
1121 }
1122
1123 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
1124
1125 do_lasso_select_node(C, mcoords, sel_op);
1126
1127 return OPERATOR_FINISHED;
1128}
1129
1131{
1132 /* identifiers */
1133 ot->name = "Lasso Select";
1134 ot->description = "Select nodes using lasso selection";
1135 ot->idname = "NODE_OT_select_lasso";
1136
1137 /* API callbacks. */
1143
1144 /* flags */
1146
1147 /* properties */
1149 "tweak",
1150 false,
1151 "Tweak",
1152 "Only activate when mouse is not over a node (useful for tweak gesture)");
1153
1156}
1157
1159
1160/* -------------------------------------------------------------------- */
1163
1164static bool any_node_selected(const bNodeTree &node_tree)
1165{
1166 for (const bNode *node : node_tree.all_nodes()) {
1167 if (node->is_selected()) {
1168 return true;
1169 }
1170 }
1171 return false;
1172}
1173
1175{
1176 SpaceNode &snode = *CTX_wm_space_node(C);
1177 bNodeTree &node_tree = *snode.edittree;
1178
1179 node_tree.ensure_topology_cache();
1180
1181 int action = RNA_enum_get(op->ptr, "action");
1182 if (action == SEL_TOGGLE) {
1183 if (any_node_selected(node_tree)) {
1184 action = SEL_DESELECT;
1185 }
1186 else {
1187 action = SEL_SELECT;
1188 }
1189 }
1190
1191 switch (action) {
1192 case SEL_SELECT:
1193 for (bNode *node : node_tree.all_nodes()) {
1195 }
1196 break;
1197 case SEL_DESELECT:
1198 node_deselect_all(node_tree);
1199 break;
1200 case SEL_INVERT:
1201 for (bNode *node : node_tree.all_nodes()) {
1202 bke::node_set_selected(*node, !node->is_selected());
1203 }
1204 break;
1205 }
1206
1207 tree_draw_order_update(node_tree);
1208
1211 return OPERATOR_FINISHED;
1212}
1213
1215{
1216 /* identifiers */
1217 ot->name = "(De)select All";
1218 ot->description = "(De)select all nodes";
1219 ot->idname = "NODE_OT_select_all";
1220
1221 /* API callbacks. */
1224
1225 /* flags */
1227
1229}
1230
1232
1233/* -------------------------------------------------------------------- */
1236
1238{
1239 SpaceNode &snode = *CTX_wm_space_node(C);
1240 bNodeTree &node_tree = *snode.edittree;
1241
1242 node_tree.ensure_topology_cache();
1243
1244 VectorSet<bNode *> initial_selection = get_selected_nodes(node_tree);
1245
1246 for (bNode *node : initial_selection) {
1247 for (bNodeSocket *output_socket : node->output_sockets()) {
1248 if (!output_socket->is_available()) {
1249 continue;
1250 }
1251 for (bNodeSocket *input_socket : output_socket->directly_linked_sockets()) {
1252 if (!input_socket->is_available()) {
1253 continue;
1254 }
1255 bke::node_set_selected(input_socket->owner_node(), true);
1256 }
1257 }
1258 }
1259
1260 tree_draw_order_update(node_tree);
1261
1263 return OPERATOR_FINISHED;
1264}
1265
1267{
1268 /* identifiers */
1269 ot->name = "Select Linked To";
1270 ot->description = "Select nodes linked to the selected ones";
1271 ot->idname = "NODE_OT_select_linked_to";
1272
1273 /* API callbacks. */
1276
1277 /* flags */
1279}
1280
1282
1283/* -------------------------------------------------------------------- */
1286
1288{
1289 SpaceNode &snode = *CTX_wm_space_node(C);
1290 bNodeTree &node_tree = *snode.edittree;
1291
1292 node_tree.ensure_topology_cache();
1293
1294 VectorSet<bNode *> initial_selection = get_selected_nodes(node_tree);
1295
1296 for (bNode *node : initial_selection) {
1297 for (bNodeSocket *input_socket : node->input_sockets()) {
1298 if (!input_socket->is_available()) {
1299 continue;
1300 }
1301 for (bNodeSocket *output_socket : input_socket->directly_linked_sockets()) {
1302 if (!output_socket->is_available()) {
1303 continue;
1304 }
1305 bke::node_set_selected(output_socket->owner_node(), true);
1306 }
1307 }
1308 }
1309
1310 tree_draw_order_update(node_tree);
1311
1313 return OPERATOR_FINISHED;
1314}
1315
1317{
1318 /* identifiers */
1319 ot->name = "Select Linked From";
1320 ot->description = "Select nodes linked from the selected ones";
1321 ot->idname = "NODE_OT_select_linked_from";
1322
1323 /* API callbacks. */
1326
1327 /* flags */
1329}
1330
1332
1333/* -------------------------------------------------------------------- */
1336
1337static bool nodes_are_same_type_for_select(const bNode &a, const bNode &b)
1338{
1339 return a.type_legacy == b.type_legacy;
1340}
1341
1343{
1344 SpaceNode *snode = CTX_wm_space_node(C);
1345 ARegion *region = CTX_wm_region(C);
1346 const bool prev = RNA_boolean_get(op->ptr, "prev");
1347 bNode *active_node = bke::node_get_active(*snode->edittree);
1348
1349 if (active_node == nullptr) {
1350 return OPERATOR_CANCELLED;
1351 }
1352
1353 bNodeTree &node_tree = *snode->edittree;
1354 node_tree.ensure_topology_cache();
1355 if (node_tree.all_nodes().size() == 1) {
1356 return OPERATOR_CANCELLED;
1357 }
1358
1359 const Span<const bNode *> toposort = node_tree.toposort_left_to_right();
1360 const int index = toposort.first_index(active_node);
1361
1362 int new_index = index;
1363 while (true) {
1364 new_index += (prev ? -1 : 1);
1365 if (!toposort.index_range().contains(new_index)) {
1366 return OPERATOR_CANCELLED;
1367 }
1368 if (nodes_are_same_type_for_select(*toposort[new_index], *active_node)) {
1369 break;
1370 }
1371 }
1372
1373 bNode *new_active_node = node_tree.all_nodes()[toposort[new_index]->index()];
1374 if (new_active_node == active_node) {
1375 return OPERATOR_CANCELLED;
1376 }
1377
1378 node_select_single(*C, *new_active_node);
1379
1380 if (!BLI_rctf_inside_rctf(&region->v2d.cur, &new_active_node->runtime->draw_bounds)) {
1381 const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
1382 space_node_view_flag(*C, *snode, *region, NODE_SELECT, smooth_viewtx);
1383 }
1384
1385 return OPERATOR_FINISHED;
1386}
1387
1389{
1390 /* identifiers */
1391 ot->name = "Activate Same Type Next/Prev";
1392 ot->description = "Activate and view same node type, step by step";
1393 ot->idname = "NODE_OT_select_same_type_step";
1394
1395 /* API callbacks. */
1398
1399 /* flags */
1401
1402 RNA_def_boolean(ot->srna, "prev", false, "Previous", "");
1403}
1404
1406
1407/* -------------------------------------------------------------------- */
1410
1411static std::string node_find_create_node_label(const bNodeTree &ntree, const bNode &node)
1412{
1413 std::string label = bke::node_label(ntree, node);
1414 if (label == node.name) {
1415 return label;
1416 }
1417 return fmt::format("{} ({})", label, node.name);
1418}
1419
1420static std::string node_find_create_group_input_label(const bNode &node, const bNodeSocket &socket)
1421{
1422 return fmt::format("{}: \"{}\" ({})", TIP_("Input"), socket.name, node.name);
1423}
1424
1425static std::string node_find_create_string_value(const bNode &node, const StringRef str)
1426{
1427 return fmt::format("{}: \"{}\" ({})", TIP_("String"), str, node.name);
1428}
1429
1430static std::string node_find_create_warning(const bNode &node, const nodes::NodeWarning warning)
1431{
1432 return fmt::format(
1433 "{}: \"{}\" ({})", nodes::node_warning_type_name(warning.type), warning.message, node.name);
1434}
1435
1436static std::string node_find_create_data_block_value(const bNode &node, const ID &id)
1437{
1438 const IDTypeInfo *type = BKE_idtype_get_info_from_id(&id);
1439 BLI_assert(type);
1440 StringRef type_name = TIP_(type->name);
1441 if (GS(id.name) == ID_NT) {
1442 type_name = TIP_("Node Group");
1443 }
1444 return fmt::format("{}: \"{}\" ({})", type_name, BKE_id_name(id), node.name);
1445}
1446
1447/* Generic search invoke. */
1448static void node_find_update_fn(const bContext *C,
1449 void * /*arg*/,
1450 const char *str,
1451 ui::SearchItems *items,
1452 const bool /*is_first*/)
1453{
1454 Main *bmain = CTX_data_main(C);
1455 SpaceNode *snode = CTX_wm_space_node(C);
1458 tree_logs.foreach_tree_log(
1459 [&](nodes::eval_log::NodeTreeLog &log) { log.ensure_node_warnings(*bmain); });
1460
1461 struct Item {
1462 bNode *node;
1463 std::string search_str;
1464 };
1465
1467 ResourceScope scope;
1468
1469 auto add_data_block_item = [&](bNode &node, const ID *id) {
1470 if (!id) {
1471 return;
1472 }
1473 const StringRef search_str = scope.add_value(node_find_create_data_block_value(node, *id));
1474 search.add(search_str, &scope.construct<Item>(Item{&node, search_str}));
1475 };
1476
1477 const bNodeTree &ntree = *snode->edittree;
1478 ntree.ensure_topology_cache();
1479 for (bNode *node : snode->edittree->all_nodes()) {
1480 const StringRef name = scope.add_value(node_find_create_node_label(ntree, *node));
1481 search.add(name, &scope.construct<Item>(Item{node, name}));
1482
1483 if (node->is_type("FunctionNodeInputString"_ustr)) {
1484 const auto *storage = static_cast<const NodeInputString *>(node->storage);
1485 const StringRef value_str = storage->string;
1486 if (!value_str.is_empty()) {
1487 const StringRef search_str = scope.add_value(
1488 node_find_create_string_value(*node, value_str));
1489 search.add(search_str, &scope.construct<Item>(Item{node, search_str}));
1490 }
1491 }
1492 if (node->is_group_input()) {
1493 for (const bNodeSocket *socket : node->output_sockets().drop_back(1)) {
1494 if (!socket->is_directly_linked()) {
1495 continue;
1496 }
1497 const StringRef search_str = scope.add_value(
1499 search.add(search_str, &scope.construct<Item>(Item{node, search_str}));
1500 }
1501 }
1502 if (node->id) {
1503 /* Avoid showing referenced node group data-blocks twice. */
1504 const bool skip_data_block =
1505 node->is_group() &&
1506 StringRef(bke::node_label(ntree, *node)).find(BKE_id_name(*node->id)) !=
1508 if (!skip_data_block) {
1509 add_data_block_item(*node, node->id);
1510 }
1511 }
1512 if (nodes::eval_log::NodeTreeLog *tree_log = tree_logs.get_main_tree_log(*node)) {
1513 if (nodes::eval_log::NodeLog *node_log = tree_log->find_node_log(node->identifier)) {
1514 for (const nodes::NodeWarning &warning : node_log->warnings) {
1515 const StringRef search_str = scope.add_value(node_find_create_warning(*node, warning));
1516 search.add(search_str, &scope.construct<Item>(Item{node, search_str}));
1517 }
1518 }
1519 }
1520
1521 for (const bNodeSocket *socket : node->input_sockets()) {
1522 switch (socket->type) {
1523 case SOCK_STRING: {
1524 if (socket->is_logically_linked()) {
1525 continue;
1526 }
1527 const bNodeSocketValueString *value =
1528 socket->default_value_typed<bNodeSocketValueString>();
1529 const StringRef value_str = value->value;
1530 if (!value_str.is_empty()) {
1531 const StringRef search_str = scope.add_value(
1532 node_find_create_string_value(*node, value_str));
1533 search.add(search_str, &scope.construct<Item>(Item{node, search_str}));
1534 }
1535 break;
1536 }
1537 case SOCK_OBJECT: {
1538 add_data_block_item(
1539 *node, id_cast<ID *>(socket->default_value_typed<bNodeSocketValueObject>()->value));
1540 break;
1541 }
1542 case SOCK_MATERIAL: {
1543 add_data_block_item(
1544 *node,
1545 id_cast<ID *>(socket->default_value_typed<bNodeSocketValueMaterial>()->value));
1546 break;
1547 }
1548 case SOCK_COLLECTION: {
1549 add_data_block_item(
1550 *node,
1551 id_cast<ID *>(socket->default_value_typed<bNodeSocketValueCollection>()->value));
1552 break;
1553 }
1554 case SOCK_IMAGE: {
1555 add_data_block_item(
1556 *node, id_cast<ID *>(socket->default_value_typed<bNodeSocketValueImage>()->value));
1557 break;
1558 }
1559 case SOCK_FONT: {
1560 add_data_block_item(
1561 *node, id_cast<ID *>(socket->default_value_typed<bNodeSocketValueFont>()->value));
1562 break;
1563 }
1564 case SOCK_SCENE: {
1565 add_data_block_item(
1566 *node, id_cast<ID *>(socket->default_value_typed<bNodeSocketValueScene>()->value));
1567 break;
1568 }
1569 case SOCK_TEXT_ID: {
1570 add_data_block_item(
1571 *node, id_cast<ID *>(socket->default_value_typed<bNodeSocketValueText>()->value));
1572 break;
1573 }
1574 case SOCK_MASK: {
1575 add_data_block_item(
1576 *node, id_cast<ID *>(socket->default_value_typed<bNodeSocketValueMask>()->value));
1577 break;
1578 }
1579 case SOCK_SOUND: {
1580 add_data_block_item(
1581 *node, id_cast<ID *>(socket->default_value_typed<bNodeSocketValueSound>()->value));
1582 break;
1583 }
1584 default:
1585 break;
1586 }
1587 }
1588 }
1589
1590 const Vector<Item *> filtered_items = search.query(str);
1591 for (const Item *item : filtered_items) {
1592 if (!search_item_add(items, item->search_str, item->node, ICON_NONE, 0, 0)) {
1593 break;
1594 }
1595 }
1596}
1597
1598static void node_find_exec_fn(bContext *C, void * /*arg1*/, void *arg2)
1599{
1600 SpaceNode *snode = CTX_wm_space_node(C);
1601 bNode *active = static_cast<bNode *>(arg2);
1602
1603 if (active) {
1604 ARegion *region = CTX_wm_region(C);
1605 node_select_single(*C, *active);
1606
1607 if (!BLI_rctf_inside_rctf(&region->v2d.cur, &active->runtime->draw_bounds)) {
1608 space_node_view_flag(*C, *snode, *region, NODE_SELECT, U.smooth_viewtx);
1609 }
1610 }
1611}
1612
1613static ui::Block *node_find_menu(bContext *C, ARegion *region, void *arg_optype)
1614{
1615 static char search[256] = "";
1616 ui::Block *block;
1617 ui::Button *but;
1618 wmOperatorType *optype = static_cast<wmOperatorType *>(arg_optype);
1619
1620 block = block_begin(C, region, "_popup", ui::EmbossType::Emboss);
1622 block_theme_style_set(block, ui::BLOCK_THEME_STYLE_POPUP);
1623
1624 const int box_width = ui::searchbox_size_x_guess(C, node_find_update_fn, nullptr);
1625
1626 but = uiDefSearchBut(
1627 block, search, ICON_VIEWZOOM, sizeof(search), 0, 0, box_width, UI_UNIT_Y, "");
1628 button_func_search_set(
1629 but, nullptr, node_find_update_fn, optype, false, nullptr, node_find_exec_fn, nullptr);
1630 button_flag_enable(but, ui::BUT_ACTIVATE_ON_INIT);
1631
1632 /* Fake button holds space for search items. */
1633 const int height = ui::searchbox_size_y() - UI_SEARCHBOX_BOUNDS;
1634 uiDefBut(block,
1636 "",
1637 0,
1638 -height,
1639 box_width,
1640 height,
1641 nullptr,
1642 0,
1643 0,
1644 std::nullopt);
1645
1646 /* Move it downwards, mouse over button. */
1647 std::array<int, 2> bounds_offset = {0, -UI_UNIT_Y};
1648 block_bounds_set_popup(block, UI_SEARCHBOX_BOUNDS, bounds_offset.data());
1649
1650 return block;
1651}
1652
1654 wmOperator *op,
1655 const wmEvent * /*event*/)
1656{
1658 return OPERATOR_CANCELLED;
1659}
1660
1662{
1663 /* identifiers */
1664 ot->name = "Find Node";
1665 ot->description = "Search for a node by name and focus and select it";
1666 ot->idname = "NODE_OT_find_node";
1667
1668 /* API callbacks. */
1671
1672 /* flags */
1674}
1675
1677
1678} // namespace blender::ed::space_node
#define SELECT
Definition BKE_mask.hh:19
#define NODE_FRAME
Definition BKE_node.hh:866
#define GEO_NODE_VIEWER
#define TIP_(msgid)
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
#define SEL_OP_USE_PRE_DESELECT(sel_op)
#define C
Definition RandGen.cpp:29
#define UI_UNIT_Y
#define UI_SEARCHBOX_BOUNDS
#define NC_NODE
Definition WM_types.hh:407
#define NC_VIEWER_PATH
Definition WM_types.hh:419
#define ND_NODE_GIZMO
Definition WM_types.hh:559
#define NA_SELECTED
Definition WM_types.hh:639
#define BLI_assert_unreachable()
#define STREQLEN(a, b, n)
#define STREQ(a, b)
#define output
bool is_empty() const
Definition BLI_array.hh:275
constexpr bool contains(int64_t value) const
T & construct(Args &&...args)
constexpr int64_t first_index(const T &search_value) const
Definition BLI_span.hh:381
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
constexpr StringRef()
bool add(const Key &key)
static constexpr int64_t not_found
constexpr bool is_empty() const
NodeTreeLog * get_main_tree_log(const bke::bNodeTreeZone *zone) const
Definition eval_log.cc:1116
void foreach_tree_log(FunctionRef< void(NodeTreeLog &)> callback) const
Definition eval_log.cc:1143
static ContextualNodeTreeLogs get_contextual_tree_logs(const SpaceNode &snode)
Definition eval_log.cc:1048
void add(const StringRef str, T *user_data, const int weight=0)
Vector< T * > query(const StringRef query) const
#define str(s)
#define FLT_MAX
#define INT_MAX
#define storage(slot, qualifiers)
#define log
float distance(float, float) RET
std::string node_label(const bNodeTree &ntree, const bNode &node)
Definition node.cc:5732
bNode * node_get_active(bNodeTree &ntree)
Definition node.cc:5445
Span< const bNodeZoneType * > all_zone_types()
bool node_set_selected(bNode &node, bool select)
Definition node.cc:5455
static bool has_workbench_in_texture_color(const wmWindowManager *wm, const Scene *scene, const Object *ob)
static std::string node_find_create_warning(const bNode &node, const nodes::NodeWarning warning)
static bool node_select_grouped_type(bNodeTree &node_tree, bNode &node_act)
rctf node_frame_rect_inside(const SpaceNode &snode, const bNode &node)
void node_deselect_all_input_sockets(bNodeTree &node_tree, bool deselect_nodes)
static void node_find_exec_fn(bContext *C, void *, void *arg2)
void NODE_OT_select_circle(wmOperatorType *ot)
static bool is_position_over_node_or_socket(SpaceNode &snode, ARegion &region, const float2 &mouse)
void tree_draw_order_update(bNodeTree &ntree)
Definition node_draw.cc:265
static wmOperatorStatus node_find_node_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus node_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool space_node_view_flag(bContext &C, SpaceNode &snode, ARegion &region, int node_flag, int smooth_viewtx)
Definition node_view.cc:78
static bool node_mouse_select(bContext *C, wmOperator *op, const int2 mval, const SelectPick_Params &params)
static wmOperatorStatus node_select_linked_from_exec(bContext *C, wmOperator *)
static bool do_lasso_select_node(bContext *C, const Span< int2 > mcoords, eSelectOp sel_op)
static wmOperatorStatus node_box_select_exec(bContext *C, wmOperator *op)
static wmOperatorStatus node_lasso_select_exec(bContext *C, wmOperator *op)
void node_select_paired(bNodeTree &node_tree)
static wmOperatorStatus node_select_grouped_exec(bContext *C, wmOperator *op)
void NODE_OT_find_node(wmOperatorType *ot)
void NODE_OT_select_lasso(wmOperatorType *ot)
bool node_deselect_all(bNodeTree &node_tree)
void node_socket_select(bNode *node, bNodeSocket &sock)
bNodeSocket * node_find_indicated_socket(SpaceNode &snode, ARegion &region, const float2 &cursor, const eNodeSocketInOut in_out)
Definition node_edit.cc:793
void NODE_OT_select(wmOperatorType *ot)
static std::string node_find_create_node_label(const bNodeTree &ntree, const bNode &node)
static bool node_select_grouped_name(bNodeTree &node_tree, bNode &node_act, const bool from_right)
Array< bNode * > tree_draw_order_calc_nodes_reversed(bNodeTree &ntree)
Definition node_draw.cc:286
static void node_socket_toggle(bNode *node, bNodeSocket &sock, bool deselect_node)
static bool nodes_are_same_type_for_select(const bNode &a, const bNode &b)
static wmOperatorStatus node_select_same_type_step_exec(bContext *C, wmOperator *op)
static wmOperatorStatus node_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void node_socket_deselect(bNode *node, bNodeSocket &sock, bool deselect_node)
void NODE_OT_select_grouped(wmOperatorType *ot)
static void node_find_update_fn(const bContext *C, void *, const char *str, ui::SearchItems *items, const bool)
static void activate_interface_socket(bNodeTree &tree, bNodeTreeInterfaceSocket &io_socket)
bNode * node_under_mouse_get(const SpaceNode &snode, const float2 mouse)
static void handle_group_output_node_selection(bNodeTree &tree, const bNode &group_output_node, const float2 &cursor)
VectorSet< bNode * > get_selected_nodes(bNodeTree &node_tree)
void NODE_OT_select_linked_from(wmOperatorType *ot)
void node_deselect_all_output_sockets(bNodeTree &node_tree, bool deselect_nodes)
static wmOperatorStatus node_select_exec(bContext *C, wmOperator *op)
void NODE_OT_select_same_type_step(wmOperatorType *ot)
void node_select_single(bContext &C, bNode &node)
static std::string node_find_create_string_value(const bNode &node, const StringRef str)
static bool node_select_grouped_color(bNodeTree &node_tree, bNode &node_act)
void NODE_OT_select_linked_to(wmOperatorType *ot)
static bool any_node_selected(const bNodeTree &node_tree)
bool node_or_socket_isect_event(const bContext &C, const wmEvent &event)
static wmOperatorStatus node_circleselect_exec(bContext *C, wmOperator *op)
static wmOperatorStatus node_select_all_exec(bContext *C, wmOperator *op)
static ui::Block * node_find_menu(bContext *C, ARegion *region, void *arg_optype)
static bool is_event_over_node_or_socket(const bContext &C, const wmEvent &event)
static bool node_frame_select_isect_mouse(const SpaceNode &snode, const bNode &node, const float2 &mouse)
static wmOperatorStatus node_select_linked_to_exec(bContext *C, wmOperator *)
static std::string node_find_create_group_input_label(const bNode &node, const bNodeSocket &socket)
void NODE_OT_select_box(wmOperatorType *ot)
void NODE_OT_select_all(wmOperatorType *ot)
static std::string node_find_create_data_block_value(const bNode &node, const ID &id)
static wmOperatorStatus node_lasso_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static const bNodeSocket * find_socket_at_mouse_y(const Span< const bNodeSocket * > sockets, const float view_y)
static void handle_group_input_node_selection(bNodeTree &tree, const bNode &group_input_node, const float2 &cursor)
void activate_geometry_node(Main &bmain, SpaceNode &snode, bNode &node, std::optional< int > item_identifier=std::nullopt)
std::optional< ViewerPathForGeometryNodesViewer > parse_geometry_nodes_viewer(const ViewerPath &viewer_path)
T distance(const T &a, const T &b)
T max(const T &a, const T &b)
StringRefNull node_warning_type_name(const NodeWarningType type)
Definition warning.cc:65
void popup_block_invoke(bContext *C, BlockCreateFunc func, void *arg, FreeArgFunc arg_free, StructRNA *srna_owner=nullptr)
int searchbox_size_x_guess(const bContext *C, const ButtonSearchUpdateFn update_fn, void *arg)
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1651
bool view2d_view_to_region_clip(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1684
void view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst) ATTR_NONNULL()
Definition view2d.cc:1657
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
std::string ED_select_circle_get_name(wmOperatorType *ot, PointerRNA *ptr)
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool ED_operator_node_active(bContext *C)
void WM_operator_properties_gesture_circle(wmOperatorType *ot)
int RNA_enum_get(PointerRNA *ptr, const char *name)
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_operator_flag_only_pass_through_on_press(wmOperatorStatus retval, const wmEvent *event)
unsigned int uint
Definition BKE_text.h:55
eSelectOp ED_select_op_modal(eSelectOp sel_op, bool is_first)
WorkSpace * CTX_wm_workspace(const bContext *C)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
void ED_node_set_active(Main *bmain, SpaceNode *snode, bNodeTree *ntree, bNode *node, bool *r_active_texture_changed)
Definition node_edit.cc:237
void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
int WM_operator_smooth_viewtx_get(const wmOperator *op)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
int RNA_int_get(PointerRNA *ptr, const char *name)
bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], float radius)
bool ED_view3d_has_workbench_in_texture_color(const Scene *scene, const Object *ob, const View3D *v3d)
bScreen * BKE_workspace_active_screen_get(const WorkSpaceInstanceHook *hook) GETTER_ATTRS
Definition workspace.cc:684
wmOperatorStatus WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
const char * BKE_id_name(const ID &id)
bool BLI_lasso_is_point_inside(Span< int2 > mcoords, int sx, int sy, int error_value)
Definition lasso_2d.cc:42
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
void WM_operator_properties_select_all(wmOperatorType *ot)
void WM_operator_properties_border_to_rctf(wmOperator *op, rctf *r_rect)
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
const IDTypeInfo * BKE_idtype_get_info_from_id(const ID *id)
Definition idtype.cc:232
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void DEG_id_tag_update(ID *id, unsigned int flags)
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
wmWindowManager * CTX_wm_manager(const bContext *C)
bool BLI_rctf_isect_pt(const struct rctf *rect, float x, float y)
void BKE_main_ensure_invariants(Main &bmain, std::optional< Span< ID * > > modified_ids=std::nullopt)
wmOperatorStatus WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_mouse_select(wmOperatorType *ot)
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
Definition rct.cc:195
SpaceNode * CTX_wm_space_node(const bContext *C)
void WM_operator_properties_gesture_box(wmOperatorType *ot)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
void DEG_id_tag_update_for_side_effect_request(Depsgraph *depsgraph, ID *id, unsigned int flags)
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
MINLINE bool compare_v3v3(const float v1[3], const float v2[3], float limit) ATTR_WARN_UNUSED_RESULT
Main * CTX_data_main(const bContext *C)
wmOperatorStatus WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest)
void ED_node_set_active_viewer_key(SpaceNode *snode)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition BLI_rect.hh:198
size_t size_t size_t BLI_str_partition_ex_utf8(const char *str, const char *end, const unsigned int delim[], const char **r_sep, const char **r_suf, bool from_right) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
Scene * CTX_data_scene(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:228
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
bool WM_gesture_is_modal_first(const wmGesture *gesture)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
SelectPick_Params ED_select_pick_params_from_operator(PointerRNA *ptr) ATTR_NONNULL(1)
void BKE_viewer_path_clear(ViewerPath *viewer_path)
wmOperatorStatus WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
Object * CTX_data_active_object(const bContext *C)
std::string ED_select_pick_get_name(wmOperatorType *ot, PointerRNA *ptr)
ARegion * CTX_wm_region(const bContext *C)
void BLI_lasso_boundbox(rcti *rect, Span< int2 > mcoords)
Definition lasso_2d.cc:21
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition BLI_rect.hh:194
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
Definition rct.cc:651
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
#define NODE_RESIZE_MARGIN
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const char * name
ListBaseT< SpaceLink > spacedata
struct bNodeTree * edittree
ed::space_node::SpaceNode_Runtime * runtime
bNodeTreeInterface tree_interface
bke::bNodeRuntime * runtime
ListBaseT< struct ScrArea > areabase
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
std::string(*) get_name(wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1191
struct wmOperatorType * type
struct WorkSpaceInstanceHook * workspace_hook