Blender V4.3
mask_select.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "MEM_guardedalloc.h"
10
11#include "BLI_lasso_2d.hh"
12#include "BLI_listbase.h"
13#include "BLI_math_base.h"
15#include "BLI_rect.h"
16#include "BLI_utildefines.h"
17
18#include "BKE_context.hh"
19#include "BKE_mask.h"
20
21#include "DEG_depsgraph.hh"
23
24#include "DNA_mask_types.h"
25
26#include "WM_api.hh"
27#include "WM_types.hh"
28
29#include "ED_clip.hh"
30#include "ED_mask.hh" /* own include */
31#include "ED_select_utils.hh"
32
33#include "RNA_access.hh"
34#include "RNA_define.hh"
35
36#include "mask_intern.hh" /* own include */
37
38using blender::Array;
39using blender::int2;
40using blender::Span;
41
42/* -------------------------------------------------------------------- */
47{
48 for (int i = 0; i < spline->tot_point; i++) {
49 MaskSplinePoint *point = &spline->points[i];
50
51 if (MASKPOINT_ISSEL_ANY(point)) {
52 return true;
53 }
54 }
55
56 return false;
57}
58
60{
61 if (mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
62 return false;
63 }
64
65 LISTBASE_FOREACH (const MaskSpline *, spline, &mask_layer->splines) {
66 if (ED_mask_spline_select_check(spline)) {
67 return true;
68 }
69 }
70
71 return false;
72}
73
74bool ED_mask_select_check(const Mask *mask)
75{
76 LISTBASE_FOREACH (const MaskLayer *, mask_layer, &mask->masklayers) {
77 if (ED_mask_layer_select_check(mask_layer)) {
78 return true;
79 }
80 }
81
82 return false;
83}
84
85void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select)
86{
87 if (do_select) {
88 spline->flag |= SELECT;
89 }
90 else {
91 spline->flag &= ~SELECT;
92 }
93
94 for (int i = 0; i < spline->tot_point; i++) {
95 MaskSplinePoint *point = &spline->points[i];
96
97 BKE_mask_point_select_set(point, do_select);
98 }
99}
100
101void ED_mask_layer_select_set(MaskLayer *mask_layer, const bool do_select)
102{
103 if (mask_layer->visibility_flag & MASK_HIDE_SELECT) {
104 if (do_select == true) {
105 return;
106 }
107 }
108
109 LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
110 ED_mask_spline_select_set(spline, do_select);
111 }
112}
113
114void ED_mask_select_toggle_all(Mask *mask, int action)
115{
116 if (action == SEL_TOGGLE) {
117 if (ED_mask_select_check(mask)) {
118 action = SEL_DESELECT;
119 }
120 else {
121 action = SEL_SELECT;
122 }
123 }
124
125 LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
126
127 if (mask_layer->visibility_flag & MASK_HIDE_VIEW) {
128 continue;
129 }
130
131 if (action == SEL_INVERT) {
132 /* we don't have generic functions for this, its restricted to this operator
133 * if one day we need to re-use such functionality, they can be split out */
134
135 if (mask_layer->visibility_flag & MASK_HIDE_SELECT) {
136 continue;
137 }
138 LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
139 for (int i = 0; i < spline->tot_point; i++) {
140 MaskSplinePoint *point = &spline->points[i];
142 }
143 }
144 }
145 else {
146 ED_mask_layer_select_set(mask_layer, (action == SEL_SELECT) ? true : false);
147 }
148 }
149}
150
152{
153 LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
154 LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
155 spline->flag &= ~SELECT;
156
157 /* Intentionally *don't* do this in the mask layer loop
158 * so we clear flags on all splines. */
159 if (mask_layer->visibility_flag & MASK_HIDE_VIEW) {
160 continue;
161 }
162
163 for (int i = 0; i < spline->tot_point; i++) {
164 MaskSplinePoint *cur_point = &spline->points[i];
165
166 if (MASKPOINT_ISSEL_ANY(cur_point)) {
167 spline->flag |= SELECT;
168 }
169 else {
170 int j;
171
172 for (j = 0; j < cur_point->tot_uw; j++) {
173 if (cur_point->uw[j].flag & SELECT) {
174 spline->flag |= SELECT;
175 break;
176 }
177 }
178 }
179 }
180 }
181 }
182}
183
185{
186 Mask *mask = CTX_data_edit_mask(C);
187 if (mask) {
192 }
193}
194
197/* -------------------------------------------------------------------- */
202{
203 Mask *mask = CTX_data_edit_mask(C);
204 int action = RNA_enum_get(op->ptr, "action");
205
206 MaskViewLockState lock_state;
207 ED_mask_view_lock_state_store(C, &lock_state);
208
209 ED_mask_select_toggle_all(mask, action);
211
214
216
217 return OPERATOR_FINISHED;
218}
219
221{
222 /* identifiers */
223 ot->name = "(De)select All";
224 ot->description = "Change selection of all curve points";
225 ot->idname = "MASK_OT_select_all";
226
227 /* api callbacks */
230
231 /* flags */
233
234 /* properties */
236}
237
240/* -------------------------------------------------------------------- */
244static int select_exec(bContext *C, wmOperator *op)
245{
246 Mask *mask = CTX_data_edit_mask(C);
247 MaskLayer *mask_layer;
248 MaskSpline *spline;
249 MaskSplinePoint *point = nullptr;
250 float co[2];
251 bool extend = RNA_boolean_get(op->ptr, "extend");
252 bool deselect = RNA_boolean_get(op->ptr, "deselect");
253 bool toggle = RNA_boolean_get(op->ptr, "toggle");
254 const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
255 eMaskWhichHandle which_handle;
256 const float threshold = 19;
257
258 MaskViewLockState lock_state;
259 ED_mask_view_lock_state_store(C, &lock_state);
260
261 RNA_float_get_array(op->ptr, "location", co);
262
264 C, mask, co, threshold, &mask_layer, &spline, &which_handle, nullptr);
265
266 if (extend == false && deselect == false && toggle == false) {
268 }
269
270 if (point) {
271 if (which_handle != MASK_WHICH_HANDLE_NONE) {
272 if (extend) {
273 mask_layer->act_spline = spline;
274 mask_layer->act_point = point;
275
276 BKE_mask_point_select_set_handle(point, which_handle, true);
277 }
278 else if (deselect) {
279 BKE_mask_point_select_set_handle(point, which_handle, false);
280 }
281 else {
282 mask_layer->act_spline = spline;
283 mask_layer->act_point = point;
284
285 if (!MASKPOINT_ISSEL_HANDLE(point, which_handle)) {
286 BKE_mask_point_select_set_handle(point, which_handle, true);
287 }
288 else if (toggle) {
289 BKE_mask_point_select_set_handle(point, which_handle, false);
290 }
291 }
292 }
293 else {
294 if (extend) {
295 mask_layer->act_spline = spline;
296 mask_layer->act_point = point;
297
298 BKE_mask_point_select_set(point, true);
299 }
300 else if (deselect) {
301 BKE_mask_point_select_set(point, false);
302 }
303 else {
304 mask_layer->act_spline = spline;
305 mask_layer->act_point = point;
306
307 if (!MASKPOINT_ISSEL_ANY(point)) {
308 BKE_mask_point_select_set(point, true);
309 }
310 else if (toggle) {
311 BKE_mask_point_select_set(point, false);
312 }
313 }
314 }
315
316 mask_layer->act_spline = spline;
317 mask_layer->act_point = point;
318
320
323
325
327 }
328
330
332 C, mask, co, threshold, &mask_layer, &spline, &point, &uw, nullptr))
333 {
334
335 if (extend) {
336 mask_layer->act_spline = spline;
337 mask_layer->act_point = point;
338
339 if (uw) {
340 uw->flag |= SELECT;
341 }
342 }
343 else if (deselect) {
344 if (uw) {
345 uw->flag &= ~SELECT;
346 }
347 }
348 else {
349 mask_layer->act_spline = spline;
350 mask_layer->act_point = point;
351
352 if (uw) {
353 if (!(uw->flag & SELECT)) {
354 uw->flag |= SELECT;
355 }
356 else if (toggle) {
357 uw->flag &= ~SELECT;
358 }
359 }
360 }
361
363
366
368
370 }
371 if (deselect_all) {
375 }
376
378}
379
380static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
381{
382 ScrArea *area = CTX_wm_area(C);
383 ARegion *region = CTX_wm_region(C);
384
385 float co[2];
386
387 ED_mask_mouse_pos(area, region, event->mval, co);
388
389 RNA_float_set_array(op->ptr, "location", co);
390
391 const int retval = select_exec(C, op);
392
394}
395
397{
398 /* identifiers */
399 ot->name = "Select";
400 ot->description = "Select spline points";
401 ot->idname = "MASK_OT_select";
402
403 /* api callbacks */
408
409 /* flags */
411
412 /* properties */
414
416 "location",
417 2,
418 nullptr,
419 -FLT_MAX,
420 FLT_MAX,
421 "Location",
422 "Location of vertex in normalized space",
423 -1.0f,
424 1.0f);
425}
426
429/* -------------------------------------------------------------------- */
434{
435 ScrArea *area = CTX_wm_area(C);
436 ARegion *region = CTX_wm_region(C);
437
438 Mask *mask_orig = CTX_data_edit_mask(C);
440 Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
441
442 rcti rect;
443 rctf rectf;
444 bool changed = false;
445
446 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
447 const bool select = (sel_op != SEL_OP_SUB);
448 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
450 changed = true;
451 }
452
453 /* get rectangle from operator */
455
456 ED_mask_point_pos(area, region, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
457 ED_mask_point_pos(area, region, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
458
459 /* do actual selection */
460 for (MaskLayer *mask_layer_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
461 *mask_layer_eval = static_cast<MaskLayer *>(mask_eval->masklayers.first);
462 mask_layer_orig != nullptr;
463 mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
464 {
465 if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
466 continue;
467 }
468 for (MaskSpline *spline_orig = static_cast<MaskSpline *>(mask_layer_orig->splines.first),
469 *spline_eval = static_cast<MaskSpline *>(mask_layer_eval->splines.first);
470 spline_orig != nullptr;
471 spline_orig = spline_orig->next, spline_eval = spline_eval->next)
472 {
473
474 MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline_eval);
475
476 for (int i = 0; i < spline_orig->tot_point; i++) {
477 MaskSplinePoint *point = &spline_orig->points[i];
478 MaskSplinePoint *point_deform = &points_array[i];
479
480 /* TODO: handles? */
481 /* TODO: uw? */
482 if (BLI_rctf_isect_pt_v(&rectf, point_deform->bezt.vec[1])) {
485 changed = true;
486 }
487 }
488 }
489 }
490
491 if (changed) {
492 ED_mask_select_flush_all(mask_orig);
493
495 WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask_orig);
496
497 return OPERATOR_FINISHED;
498 }
499
500 return OPERATOR_CANCELLED;
501}
502
504{
505 /* identifiers */
506 ot->name = "Box Select";
507 ot->description = "Select curve points using box selection";
508 ot->idname = "MASK_OT_select_box";
509
510 /* api callbacks */
515
516 /* flags */
518
519 /* properties */
522}
523
526/* -------------------------------------------------------------------- */
530static bool do_lasso_select_mask(bContext *C, const Span<int2> mcoords, const eSelectOp sel_op)
531{
532 ScrArea *area = CTX_wm_area(C);
533 ARegion *region = CTX_wm_region(C);
534
535 Mask *mask_orig = CTX_data_edit_mask(C);
537 Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
538
539 rcti rect;
540 bool changed = false;
541
542 const bool select = (sel_op != SEL_OP_SUB);
543 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
545 changed = true;
546 }
547
548 /* get rectangle from operator */
549 BLI_lasso_boundbox(&rect, mcoords);
550
551 /* do actual selection */
552 for (MaskLayer *mask_layer_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
553 *mask_layer_eval = static_cast<MaskLayer *>(mask_eval->masklayers.first);
554 mask_layer_orig != nullptr;
555 mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
556 {
557 if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
558 continue;
559 }
560 for (MaskSpline *spline_orig = static_cast<MaskSpline *>(mask_layer_orig->splines.first),
561 *spline_eval = static_cast<MaskSpline *>(mask_layer_eval->splines.first);
562 spline_orig != nullptr;
563 spline_orig = spline_orig->next, spline_eval = spline_eval->next)
564 {
565
566 MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline_eval);
567
568 for (int i = 0; i < spline_orig->tot_point; i++) {
569 MaskSplinePoint *point = &spline_orig->points[i];
570 MaskSplinePoint *point_deform = &points_array[i];
571
572 /* TODO: handles? */
573 /* TODO: uw? */
574
575 if (MASKPOINT_ISSEL_ANY(point) && select) {
576 continue;
577 }
578
579 float screen_co[2];
580
581 /* point in screen coords */
583 region,
584 point_deform->bezt.vec[1][0],
585 point_deform->bezt.vec[1][1],
586 &screen_co[0],
587 &screen_co[1]);
588
589 if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
590 BLI_lasso_is_point_inside(mcoords, screen_co[0], screen_co[1], INT_MAX))
591 {
594 changed = true;
595 }
596 }
597 }
598 }
599
600 if (changed) {
601 ED_mask_select_flush_all(mask_orig);
602
604 WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask_orig);
605 }
606
607 return changed;
608}
609
611{
612 const Array<int2> mcoords = WM_gesture_lasso_path_to_array(C, op);
613 if (mcoords.is_empty()) {
615 }
616
617 const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode"));
618 do_lasso_select_mask(C, mcoords, sel_op);
619
620 return OPERATOR_FINISHED;
621}
622
624{
625 /* identifiers */
626 ot->name = "Lasso Select";
627 ot->description = "Select curve points using lasso selection";
628 ot->idname = "MASK_OT_select_lasso";
629
630 /* api callbacks */
636
637 /* flags */
639
640 /* properties */
643}
644
647/* -------------------------------------------------------------------- */
652 const float offset[2],
653 const float ellipse[2])
654{
655 /* normalized ellipse: ell[0] = scaleX, ell[1] = scaleY */
656 float x, y;
657
658 x = (bezt->vec[1][0] - offset[0]) * ellipse[0];
659 y = (bezt->vec[1][1] - offset[1]) * ellipse[1];
660
661 return x * x + y * y < 1.0f;
662}
663
665{
666 ScrArea *area = CTX_wm_area(C);
667 ARegion *region = CTX_wm_region(C);
668
669 Mask *mask_orig = CTX_data_edit_mask(C);
671 Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
672
673 float zoomx, zoomy, offset[2], ellipse[2];
674 int width, height;
675 bool changed = false;
676
677 /* get operator properties */
678 const int x = RNA_int_get(op->ptr, "x");
679 const int y = RNA_int_get(op->ptr, "y");
680 const int radius = RNA_int_get(op->ptr, "radius");
681
682 /* compute ellipse and position in unified coordinates */
683 ED_mask_get_size(area, &width, &height);
684 ED_mask_zoom(area, region, &zoomx, &zoomy);
685 width = height = max_ii(width, height);
686
687 ellipse[0] = width * zoomx / radius;
688 ellipse[1] = height * zoomy / radius;
689
690 ED_mask_point_pos(area, region, x, y, &offset[0], &offset[1]);
691
692 const eSelectOp sel_op = ED_select_op_modal(
693 eSelectOp(RNA_enum_get(op->ptr, "mode")),
694 WM_gesture_is_modal_first(static_cast<wmGesture *>(op->customdata)));
695 const bool select = (sel_op != SEL_OP_SUB);
696 if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
698 changed = true;
699 }
700
701 /* do actual selection */
702 for (MaskLayer *mask_layer_orig = static_cast<MaskLayer *>(mask_orig->masklayers.first),
703 *mask_layer_eval = static_cast<MaskLayer *>(mask_eval->masklayers.first);
704 mask_layer_orig != nullptr;
705 mask_layer_orig = mask_layer_orig->next, mask_layer_eval = mask_layer_eval->next)
706 {
707 if (mask_layer_orig->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
708 continue;
709 }
710 for (MaskSpline *spline_orig = static_cast<MaskSpline *>(mask_layer_orig->splines.first),
711 *spline_eval = static_cast<MaskSpline *>(mask_layer_eval->splines.first);
712 spline_orig != nullptr;
713 spline_orig = spline_orig->next, spline_eval = spline_eval->next)
714 {
715
716 MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline_eval);
717
718 for (int i = 0; i < spline_orig->tot_point; i++) {
719 MaskSplinePoint *point = &spline_orig->points[i];
720 MaskSplinePoint *point_deform = &points_array[i];
721
722 if (mask_spline_point_inside_ellipse(&point_deform->bezt, offset, ellipse)) {
725
726 changed = true;
727 }
728 }
729 }
730 }
731
732 if (changed) {
733 ED_mask_select_flush_all(mask_orig);
734
736 WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask_orig);
737
738 return OPERATOR_FINISHED;
739 }
740
741 return OPERATOR_CANCELLED;
742}
743
745{
746 /* identifiers */
747 ot->name = "Circle Select";
748 ot->description = "Select curve points using circle selection";
749 ot->idname = "MASK_OT_select_circle";
750
751 /* api callbacks */
757
758 /* flags */
760
761 /* properties */
764}
765
768/* -------------------------------------------------------------------- */
773{
774 ScrArea *area = CTX_wm_area(C);
775 ARegion *region = CTX_wm_region(C);
776
777 Mask *mask = CTX_data_edit_mask(C);
778 MaskLayer *mask_layer;
779 MaskSpline *spline;
780 MaskSplinePoint *point = nullptr;
781 float co[2];
782 bool do_select = !RNA_boolean_get(op->ptr, "deselect");
783 const float threshold = 19;
784 bool changed = false;
785
786 ED_mask_mouse_pos(area, region, event->mval, co);
787
789 C, mask, co, threshold, &mask_layer, &spline, nullptr, nullptr);
790
791 if (point) {
792 ED_mask_spline_select_set(spline, do_select);
793 mask_layer->act_spline = spline;
794 mask_layer->act_point = point;
795
796 changed = true;
797 }
798
799 if (changed) {
801
804
805 return OPERATOR_FINISHED;
806 }
807
808 return OPERATOR_CANCELLED;
809}
810
812{
813 /* identifiers */
814 ot->name = "Select Linked";
815 ot->idname = "MASK_OT_select_linked_pick";
816 ot->description = "(De)select all points linked to the curve under the mouse cursor";
817
818 /* api callbacks */
821
822 /* flags */
824
825 RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "");
826}
827
830/* -------------------------------------------------------------------- */
835{
836 Mask *mask = CTX_data_edit_mask(C);
837
838 bool changed = false;
839
840 /* do actual selection */
841 LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
842 if (mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
843 continue;
844 }
845
846 LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
847 if (ED_mask_spline_select_check(spline)) {
848 ED_mask_spline_select_set(spline, true);
849 changed = true;
850 }
851 }
852 }
853
854 if (changed) {
856
859
860 return OPERATOR_FINISHED;
861 }
862
863 return OPERATOR_CANCELLED;
864}
865
867{
868 /* identifiers */
869 ot->name = "Select Linked All";
870 ot->idname = "MASK_OT_select_linked";
871 ot->description = "Select all curve points linked to already selected ones";
872
873 /* api callbacks */
876
877 /* flags */
879}
880
883/* -------------------------------------------------------------------- */
887static int mask_select_more_less(bContext *C, bool more)
888{
889 Mask *mask = CTX_data_edit_mask(C);
890
891 LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
892 if (mask_layer->visibility_flag & (MASK_HIDE_VIEW | MASK_HIDE_SELECT)) {
893 continue;
894 }
895
896 LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
897 const bool cyclic = (spline->flag & MASK_SPLINE_CYCLIC) != 0;
898 bool start_sel, end_sel, prev_sel, cur_sel;
899
900 /* Re-select point if any handle is selected to make the result more predictable. */
901 for (int i = 0; i < spline->tot_point; i++) {
902 BKE_mask_point_select_set(spline->points + i, MASKPOINT_ISSEL_ANY(spline->points + i));
903 }
904
905 /* select more/less does not affect empty/single point splines */
906 if (spline->tot_point < 2) {
907 continue;
908 }
909
910 if (cyclic) {
911 start_sel = !!MASKPOINT_ISSEL_KNOT(spline->points);
912 end_sel = !!MASKPOINT_ISSEL_KNOT(&spline->points[spline->tot_point - 1]);
913 }
914 else {
915 start_sel = false;
916 end_sel = false;
917 }
918
919 for (int i = 0; i < spline->tot_point; i++) {
920 if (i == 0 && !cyclic) {
921 continue;
922 }
923
924 prev_sel = (i > 0) ? !!MASKPOINT_ISSEL_KNOT(&spline->points[i - 1]) : end_sel;
925 cur_sel = !!MASKPOINT_ISSEL_KNOT(&spline->points[i]);
926
927 if (cur_sel != more) {
928 if (prev_sel == more) {
929 BKE_mask_point_select_set(&spline->points[i], more);
930 }
931 i++;
932 }
933 }
934
935 for (int i = spline->tot_point - 1; i >= 0; i--) {
936 if (i == spline->tot_point - 1 && !cyclic) {
937 continue;
938 }
939
940 prev_sel = (i < spline->tot_point - 1) ? !!MASKPOINT_ISSEL_KNOT(&spline->points[i + 1]) :
941 start_sel;
942 cur_sel = !!MASKPOINT_ISSEL_KNOT(&spline->points[i]);
943
944 if (cur_sel != more) {
945 if (prev_sel == more) {
946 BKE_mask_point_select_set(&spline->points[i], more);
947 }
948 i--;
949 }
950 }
951 }
952 }
953
956
957 return OPERATOR_FINISHED;
958}
959
961{
962 return mask_select_more_less(C, true);
963}
964
966{
967 /* identifiers */
968 ot->name = "Select More";
969 ot->idname = "MASK_OT_select_more";
970 ot->description = "Select more spline points connected to initial selection";
971
972 /* api callbacks */
975
976 /* flags */
978}
979
981{
982 return mask_select_more_less(C, false);
983}
984
986{
987 /* identifiers */
988 ot->name = "Select Less";
989 ot->idname = "MASK_OT_select_less";
990 ot->description = "Deselect spline points at the boundary of each selection region";
991
992 /* api callbacks */
995
996 /* flags */
998}
999
Mask * CTX_data_edit_mask(const bContext *C)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
#define MASKPOINT_ISSEL_ANY(p)
Definition BKE_mask.h:297
void BKE_mask_point_select_set(struct MaskSplinePoint *point, bool do_select)
eMaskWhichHandle
Definition BKE_mask.h:32
@ MASK_WHICH_HANDLE_NONE
Definition BKE_mask.h:33
@ MASK_WHICH_HANDLE_BOTH
Definition BKE_mask.h:37
#define MASKPOINT_ISSEL_KNOT(p)
Definition BKE_mask.h:298
#define MASKPOINT_ISSEL_HANDLE(point, which_handle)
Definition BKE_mask.h:300
void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point, eMaskWhichHandle which_handle, bool do_select)
struct MaskSplinePoint * BKE_mask_spline_point_array(struct MaskSpline *spline)
bool BLI_lasso_is_point_inside(blender::Span< blender::int2 > mcoords, int sx, int sy, int error_value)
void BLI_lasso_boundbox(rcti *rect, blender::Span< blender::int2 > mcoords)
#define LISTBASE_FOREACH(type, var, list)
MINLINE int max_ii(int a, int b)
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
void DEG_id_tag_update(ID *id, unsigned int flags)
ID * DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1068
@ MASK_SPLINE_CYCLIC
@ MASK_HIDE_SELECT
@ MASK_HIDE_VIEW
@ OPERATOR_PASS_THROUGH
void ED_mask_mouse_pos(ScrArea *area, ARegion *region, const int mval[2], float r_co[2])
void ED_mask_point_pos(ScrArea *area, ARegion *region, float x, float y, float *r_x, float *r_y)
void ED_mask_zoom(ScrArea *area, ARegion *region, float *r_zoomx, float *r_zoomy)
void ED_mask_get_size(ScrArea *area, int *r_width, int *r_height)
void ED_mask_point_pos__reverse(ScrArea *area, ARegion *region, float x, float y, float *r_x, float *r_y)
bool ED_maskedit_mask_visible_splines_poll(bContext *C)
Definition mask_edit.cc:78
eSelectOp ED_select_op_modal(eSelectOp sel_op, bool is_first)
#define SEL_OP_USE_PRE_DESELECT(sel_op)
std::string ED_select_circle_get_name(wmOperatorType *ot, PointerRNA *ptr)
@ SEL_SELECT
@ SEL_INVERT
@ SEL_DESELECT
@ SEL_TOGGLE
void std::string ED_select_pick_get_name(wmOperatorType *ot, PointerRNA *ptr)
eSelectOp
@ SEL_OP_SUB
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:198
@ OPTYPE_UNDO
Definition WM_types.hh:162
@ OPTYPE_REGISTER
Definition WM_types.hh:160
#define ND_SELECT
Definition WM_types.hh:474
#define NC_MASK
Definition WM_types.hh:365
bool is_empty() const
Definition BLI_array.hh:253
#define SELECT
const Depsgraph * depsgraph
void ED_mask_view_lock_state_restore_no_jump(const bContext *C, const MaskViewLockState *state)
Definition mask_edit.cc:217
void ED_mask_view_lock_state_store(const bContext *C, MaskViewLockState *state)
Definition mask_edit.cc:209
MaskSplinePoint * ED_mask_point_find_nearest(const bContext *C, Mask *mask_orig, const float normal_co[2], float threshold, MaskLayer **r_mask_layer, MaskSpline **r_spline, eMaskWhichHandle *r_which_handle, float *r_score)
bool ED_mask_feather_find_nearest(const bContext *C, Mask *mask_orig, const float normal_co[2], float threshold, MaskLayer **r_mask_layer, MaskSpline **r_spline, MaskSplinePoint **r_point, MaskSplinePointUW **r_uw, float *r_score)
void MASK_OT_select_circle(wmOperatorType *ot)
static int mask_select_more_less(bContext *C, bool more)
static int select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool ED_mask_spline_select_check(const MaskSpline *spline)
static int select_exec(bContext *C, wmOperator *op)
void MASK_OT_select_more(wmOperatorType *ot)
static int select_all_exec(bContext *C, wmOperator *op)
static int box_select_exec(bContext *C, wmOperator *op)
void MASK_OT_select(wmOperatorType *ot)
bool ED_mask_select_check(const Mask *mask)
static int mask_spline_point_inside_ellipse(BezTriple *bezt, const float offset[2], const float ellipse[2])
static int clip_lasso_select_exec(bContext *C, wmOperator *op)
void ED_mask_layer_select_set(MaskLayer *mask_layer, const bool do_select)
static bool do_lasso_select_mask(bContext *C, const Span< int2 > mcoords, const eSelectOp sel_op)
void MASK_OT_select_less(wmOperatorType *ot)
static int circle_select_exec(bContext *C, wmOperator *op)
void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select)
void MASK_OT_select_linked(wmOperatorType *ot)
static int mask_select_linked_exec(bContext *C, wmOperator *)
static int mask_select_more_exec(bContext *C, wmOperator *)
bool ED_mask_layer_select_check(const MaskLayer *mask_layer)
void MASK_OT_select_box(wmOperatorType *ot)
void ED_mask_select_flush_all(Mask *mask)
void MASK_OT_select_all(wmOperatorType *ot)
void MASK_OT_select_lasso(wmOperatorType *ot)
static int mask_select_less_exec(bContext *C, wmOperator *)
void ED_mask_select_toggle_all(Mask *mask, int action)
void ED_mask_deselect_all(const bContext *C)
static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void MASK_OT_select_linked_pick(wmOperatorType *ot)
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
int RNA_int_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float_vector(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)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
#define FLT_MAX
Definition stdcycles.h:14
float vec[3][3]
void * first
char visibility_flag
ListBase splines
struct MaskSplinePoint * act_point
struct MaskSpline * act_spline
MaskSplinePointUW * uw
struct MaskSpline * next
ListBase masklayers
float xmax
float xmin
float ymax
float ymin
int ymin
int ymax
int xmin
int xmax
int mval[2]
Definition WM_types.hh:728
const char * name
Definition WM_types.hh:990
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1042
const char * idname
Definition WM_types.hh:992
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1036
std::string(* get_name)(wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1068
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1022
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1006
const char * description
Definition WM_types.hh:996
StructRNA * srna
Definition WM_types.hh:1080
void(* cancel)(bContext *C, wmOperator *op)
Definition WM_types.hh:1028
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4125
bool WM_gesture_is_modal_first(const wmGesture *gesture)
int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Array< int2 > WM_gesture_lasso_path_to_array(bContext *, wmOperator *op)
int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_border_to_rcti(wmOperator *op, rcti *r_rect)
void WM_operator_properties_gesture_box(wmOperatorType *ot)
void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
void WM_operator_properties_gesture_circle(wmOperatorType *ot)
void WM_operator_properties_select_all(wmOperatorType *ot)
void WM_operator_properties_mouse_select(wmOperatorType *ot)
int WM_operator_flag_only_pass_through_on_press(int retval, const wmEvent *event)