Revision: 46878
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46878
Author:   campbellbarton
Date:     2012-05-22 10:48:29 +0000 (Tue, 22 May 2012)
Log Message:
-----------
move select operations into their own file

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/editors/mask/CMakeLists.txt
    branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h
    branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c
    branches/soc-2011-tomato/source/blender/editors/mask/mask_relationships.c

Added Paths:
-----------
    branches/soc-2011-tomato/source/blender/editors/mask/mask_select.c

Modified: branches/soc-2011-tomato/source/blender/editors/mask/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/CMakeLists.txt 
2012-05-22 10:10:14 UTC (rev 46877)
+++ branches/soc-2011-tomato/source/blender/editors/mask/CMakeLists.txt 
2012-05-22 10:48:29 UTC (rev 46878)
@@ -41,6 +41,7 @@
        mask_editor.c
        mask_ops.c
        mask_relationships.c
+       mask_select.c
 
        mask_intern.h
 )

Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h  
2012-05-22 10:10:14 UTC (rev 46877)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h  
2012-05-22 10:48:29 UTC (rev 46878)
@@ -47,19 +47,37 @@
 void MASK_OT_add_feather_vertex(struct wmOperatorType *ot);
 void MASK_OT_cyclic_toggle(struct wmOperatorType *ot);
 
-void MASK_OT_select(struct wmOperatorType *ot);
-void MASK_OT_select_all(struct wmOperatorType *ot);
-
 void MASK_OT_slide_point(struct wmOperatorType *ot);
 
 void MASK_OT_delete(struct wmOperatorType *ot);
 
 void MASK_OT_handle_type_set(struct wmOperatorType *ot);
 
+int ED_mask_feather_find_nearest(
+        struct bContext *C, struct Mask *mask, float normal_co[2], int 
threshold,
+        struct MaskObject **maskobj_r, struct MaskSpline **spline_r, struct 
MaskSplinePoint **point_r,
+        struct MaskSplinePointUW **uw_r, float *score);
+
+struct MaskSplinePoint *ED_mask_point_find_nearest(
+        struct bContext *C, struct Mask *mask, float normal_co[2], int 
threshold,
+        struct MaskObject **maskobj_r, struct MaskSpline **spline_r, int 
*is_handle_r,
+        float *score);
+
 /* mask_relationships.c */
 void MASK_OT_parent_set(struct wmOperatorType *ot);
 void MASK_OT_parent_clear(struct wmOperatorType *ot);
 
+/* mask_select.c */
+void MASK_OT_select(struct wmOperatorType *ot);
+void MASK_OT_select_all(struct wmOperatorType *ot);
+
+int ED_mask_spline_select_check(struct MaskSplinePoint *points, int tot_point);
+int ED_mask_select_check(struct Mask *mask);
+void ED_mask_point_select(struct MaskSplinePoint *point, int action);
+
+void ED_mask_select_toggle_all(struct Mask *mask, int action);
+void ED_mask_select_flush_all(struct Mask *mask);
+
 /* mask_editor.c */
 int ED_maskediting_poll(struct bContext *C);
 int ED_maskediting_mask_poll(struct bContext *C);

Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c     
2012-05-22 10:10:14 UTC (rev 46877)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c     
2012-05-22 10:48:29 UTC (rev 46878)
@@ -57,38 +57,6 @@
 
 /******************** utility functions *********************/
 
-static void spline_point_select(MaskSplinePoint *point, int action)
-{
-       int i;
-
-       switch (action) {
-               case SEL_SELECT:
-                       MASKPOINT_SEL(point);
-                       break;
-               case SEL_DESELECT:
-                       MASKPOINT_DESEL(point);
-                       break;
-               case SEL_INVERT:
-                       MASKPOINT_INVSEL(point);
-                       break;
-       }
-
-       for (i = 0; i < point->tot_uw; i++) {
-               switch (action) {
-                       case SEL_SELECT:
-                               point->uw[i].flag |= SELECT;
-                               break;
-                       case SEL_DESELECT:
-                               point->uw[i].flag &= ~SELECT;
-                               break;
-                       case SEL_INVERT:
-                               point->uw[i].flag ^= SELECT;
-                               break;
-               }
-       }
-}
-
-
 static float projection_on_spline(MaskSpline *spline, MaskSplinePoint *point, 
float start_u, const float co[2])
 {
        const float proj_eps         = 1e-3;
@@ -151,68 +119,11 @@
        return u;
 }
 
-static int points_has_selection(MaskSplinePoint *points, int tot_point)
+MaskSplinePoint *ED_mask_point_find_nearest(bContext *C, Mask *mask, float 
normal_co[2], int threshold,
+                                            MaskObject **maskobj_r, MaskSpline 
**spline_r, int *is_handle_r,
+                                            float *score)
 {
-       int i;
-
-       for (i = 0; i < tot_point; i++) {
-               MaskSplinePoint *point = &points[i];
-
-               if (MASKPOINT_ISSEL(point))
-                       return TRUE;
-       }
-
-       return FALSE;
-}
-
-static int mask_has_selection(Mask *mask)
-{
        MaskObject *maskobj;
-
-       for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
-               MaskSpline *spline;
-
-               for (spline = maskobj->splines.first; spline; spline = 
spline->next) {
-                       if (points_has_selection(spline->points, 
spline->tot_point)) {
-                               return TRUE;
-                       }
-               }
-       }
-
-       return FALSE;
-}
-
-static void toggle_selection_all(Mask *mask, int action)
-{
-       MaskObject *maskobj;
-
-       if (action == SEL_TOGGLE) {
-               if (mask_has_selection(mask))
-                       action = SEL_DESELECT;
-               else
-                       action = SEL_SELECT;
-       }
-
-       for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
-               MaskSpline *spline;
-
-               for (spline = maskobj->splines.first; spline; spline = 
spline->next) {
-                       int i;
-
-                       for (i = 0; i < spline->tot_point; i++) {
-                               MaskSplinePoint *point = &spline->points[i];
-
-                               spline_point_select(point, action);
-                       }
-               }
-       }
-}
-
-static MaskSplinePoint *find_nearest_point(bContext *C, Mask *mask, float 
normal_co[2], int threshold,
-                                           MaskObject **maskobj_r, MaskSpline 
**spline_r, int *is_handle_r,
-                                           float *score)
-{
-       MaskObject *maskobj;
        MaskObject *point_maskobj = NULL;
        MaskSpline *point_spline = NULL;
        MaskSplinePoint *point = NULL;
@@ -297,9 +208,9 @@
        return NULL;
 }
 
-static int find_nearest_feather(bContext *C, Mask *mask, float normal_co[2], 
int threshold,
-                                MaskObject **maskobj_r, MaskSpline **spline_r, 
MaskSplinePoint **point_r,
-                                MaskSplinePointUW **uw_r, float *score)
+int ED_mask_feather_find_nearest(bContext *C, Mask *mask, float normal_co[2], 
int threshold,
+                                 MaskObject **maskobj_r, MaskSpline 
**spline_r, MaskSplinePoint **point_r,
+                                 MaskSplinePointUW **uw_r, float *score)
 {
        MaskObject *maskobj, *point_maskobj = NULL;
        MaskSpline *point_spline = NULL;
@@ -500,39 +411,6 @@
        return FALSE;
 }
 
-static void mask_flush_selection(Mask *mask)
-{
-       MaskObject *maskobj;
-
-       for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
-               MaskSpline *spline;
-
-               for (spline = maskobj->splines.first; spline; spline = 
spline->next) {
-                       int i;
-
-                       spline->flag &= ~SELECT;
-
-                       for (i = 0; i < spline->tot_point; i++) {
-                               MaskSplinePoint *cur_point = &spline->points[i];
-
-                               if (MASKPOINT_ISSEL(cur_point)) {
-                                       spline->flag |= SELECT;
-                               }
-                               else {
-                                       int j;
-
-                                       for (j = 0; j < cur_point->tot_uw; j++) 
{
-                                               if (cur_point->uw[j].flag & 
SELECT) {
-                                                       spline->flag |= SELECT;
-                                                       break;
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-}
-
 /******************** create new mask *********************/
 
 static int mask_new_exec(bContext *C, wmOperator *op)
@@ -677,9 +555,9 @@
        ED_mask_mouse_pos(C, event, co);
        ED_mask_size(C, &width, &height);
 
-       cv_point = find_nearest_point(C, mask, co, threshold, &cv_maskobj, 
&cv_spline, &is_handle, &cv_score);
+       cv_point = ED_mask_point_find_nearest(C, mask, co, threshold, 
&cv_maskobj, &cv_spline, &is_handle, &cv_score);
 
-       if (find_nearest_feather(C, mask, co, threshold, &feather_maskobj, 
&feather_spline, &feather_point, &uw, &feather_score)) {
+       if (ED_mask_feather_find_nearest(C, mask, co, threshold, 
&feather_maskobj, &feather_spline, &feather_point, &uw, &feather_score)) {
                if (slide_feather || !cv_point || feather_score < cv_score) {
                        action = SLIDE_ACTION_FEATHER;
 
@@ -756,19 +634,19 @@
 
                if (slidedata->uw) {
                        if ((slidedata->uw->flag & SELECT) == 0) {
-                               toggle_selection_all(mask, SEL_DESELECT);
+                               ED_mask_select_toggle_all(mask, SEL_DESELECT);
 
                                slidedata->uw->flag |= SELECT;
 
-                               mask_flush_selection(mask);
+                               ED_mask_select_flush_all(mask);
                        }
                }
                else if (!MASKPOINT_ISSEL(slidedata->point)) {
-                       toggle_selection_all(mask, SEL_DESELECT);
+                       ED_mask_select_toggle_all(mask, SEL_DESELECT);
 
-                       spline_point_select(slidedata->point, SEL_SELECT);
+                       ED_mask_point_select(slidedata->point, SEL_SELECT);
 
-                       mask_flush_selection(mask);
+                       ED_mask_select_flush_all(mask);
                }
 
                slidedata->maskobj->act_spline = slidedata->spline;
@@ -934,132 +812,6 @@
        RNA_def_boolean(ot->srna, "slide_feather", 0, "Slide Feather", "First 
try to slide slide feather instead of vertex");
 }
 
-/******************** toggle selection *********************/
-
-static int select_all_exec(bContext *C, wmOperator *op)
-{
-       Mask *mask = CTX_data_edit_mask(C);
-       int action = RNA_enum_get(op->ptr, "action");
-
-       toggle_selection_all(mask, action);
-       mask_flush_selection(mask);
-
-       WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
-
-       return OPERATOR_FINISHED;
-}
-
-void MASK_OT_select_all(wmOperatorType *ot)
-{
-       /* identifiers */
-       ot->name = "Select or Deselect All";
-       ot->description = "Change selection of all curve points";
-       ot->idname = "MASK_OT_select_all";
-
-       /* api callbacks */
-       ot->exec = select_all_exec;
-       ot->poll = ED_maskediting_mask_poll;
-
-       /* flags */
-       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
-       /* properties */
-       WM_operator_properties_select_all(ot);
-}
-
-/******************** select *********************/
-
-static int select_exec(bContext *C, wmOperator *op)
-{
-       Mask *mask = CTX_data_edit_mask(C);
-       MaskObject *maskobj;
-       MaskSpline *spline;
-       MaskSplinePoint *point = NULL;
-       float co[2];
-       int extend = RNA_boolean_get(op->ptr, "extend");
-       int is_handle = 0;
-       const float threshold = 19;
-
-       RNA_float_get_array(op->ptr, "location", co);
-
-       point = find_nearest_point(C, mask, co, threshold, &maskobj, &spline, 
&is_handle, NULL);
-
-       if (point) {
-               if (!extend)
-                       toggle_selection_all(mask, SEL_DESELECT);
-
-               if (is_handle) {
-                       MASKPOINT_HANDLE_SEL(point);
-               }
-               else {
-                       spline_point_select(point, SEL_SELECT);
-               }
-
-               maskobj->act_spline = spline;
-               maskobj->act_point = point;
-
-               mask_flush_selection(mask);
-
-               WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
-
-               return OPERATOR_FINISHED;
-       }
-       else {
-               MaskSplinePointUW *uw;
-
-               if (find_nearest_feather(C, mask, co, threshold, &maskobj, 
&spline, &point, &uw, NULL)) {
-                       if (!extend)
-                               toggle_selection_all(mask, SEL_DESELECT);
-
-                       uw->flag |= SELECT;
-
-                       maskobj->act_spline = spline;
-                       maskobj->act_point = point;
-
-                       mask_flush_selection(mask);
-

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to