- added particle select_inverse
authorCampbell Barton <ideasman42@gmail.com>
Mon, 9 Nov 2009 08:51:34 +0000 (08:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 9 Nov 2009 08:51:34 +0000 (08:51 +0000)
- added select root/tip to the select menu
- selection drawing updates for select more/less were not working

release/scripts/ui/space_view3d.py
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/physics_intern.h
source/blender/editors/physics/physics_ops.c

index a3c2166d506419fd5ec28a33af71a4a34ee331ea..09043c3407cbf51de2527b6a51bac8afbfaf6151 100644 (file)
@@ -306,12 +306,18 @@ class VIEW3D_MT_select_particle(bpy.types.Menu):
 
         layout.itemO("particle.select_all_toggle", text="Select/Deselect All")
         layout.itemO("particle.select_linked")
+        layout.itemO("particle.select_inverse")
 
         layout.itemS()
 
         layout.itemO("particle.select_more")
         layout.itemO("particle.select_less")
 
+        layout.itemS()
+
+        layout.itemO("particle.select_first", text="Roots")
+        layout.itemO("particle.select_last", text="Tips")
+
 
 class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
     bl_label = "Select"
index 438150b25ac0f729fa3194ffaef7acc48fa7a60b..75c56575474f576bf26e9ce938942fc312ff6789 100644 (file)
@@ -1347,6 +1347,7 @@ int PE_mouse_particles(bContext *C, short *mval, int extend)
 static void select_root(PEData *data, int point_index)
 {
        data->edit->points[point_index].keys->flag |= PEK_SELECT;
+       data->edit->points[point_index].flag |= PEP_EDIT_RECALC; /* redraw selection only */
 }
 
 static int select_first_exec(bContext *C, wmOperator *op)
@@ -1355,6 +1356,8 @@ static int select_first_exec(bContext *C, wmOperator *op)
 
        PE_set_data(C, &data);
        foreach_point(&data, select_root);
+
+       PE_update_selection(data.scene, data.ob, 1);
        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
 
        return OPERATOR_FINISHED;
@@ -1380,6 +1383,7 @@ static void select_tip(PEData *data, int point_index)
 {
        PTCacheEditPoint *point = data->edit->points + point_index;
        point->keys[point->totkey - 1].flag |= PEK_SELECT;
+       point->flag |= PEP_EDIT_RECALC; /* redraw selection only */
 }
 
 static int select_last_exec(bContext *C, wmOperator *op)
@@ -1388,6 +1392,8 @@ static int select_last_exec(bContext *C, wmOperator *op)
 
        PE_set_data(C, &data);
        foreach_point(&data, select_tip);
+
+       PE_update_selection(data.scene, data.ob, 1);
        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
 
        return OPERATOR_FINISHED;
@@ -1693,8 +1699,10 @@ static void select_less_keys(PEData *data, int point_index)
        }
 
        LOOP_KEYS {
-               if(key->flag&PEK_TAG)
+               if(key->flag&PEK_TAG) {
                        key->flag &= ~(PEK_TAG|PEK_SELECT);
+                       point->flag |= PEP_EDIT_RECALC; /* redraw selection only */
+               }
        }
 }
 
@@ -1704,6 +1712,8 @@ static int select_less_exec(bContext *C, wmOperator *op)
 
        PE_set_data(C, &data);
        foreach_point(&data, select_less_keys);
+
+       PE_update_selection(data.scene, data.ob, 1);
        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
 
        return OPERATOR_FINISHED;
@@ -1752,6 +1762,7 @@ static void select_more_keys(PEData *data, int point_index)
                if(key->flag&PEK_TAG) {
                        key->flag &= ~PEK_TAG;
                        key->flag |= PEK_SELECT;
+                       point->flag |= PEP_EDIT_RECALC; /* redraw selection only */
                }
        }
 }
@@ -1762,6 +1773,8 @@ static int select_more_exec(bContext *C, wmOperator *op)
 
        PE_set_data(C, &data);
        foreach_point(&data, select_more_keys);
+
+       PE_update_selection(data.scene, data.ob, 1);
        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
 
        return OPERATOR_FINISHED;
@@ -1781,6 +1794,43 @@ void PARTICLE_OT_select_more(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+static int select_inverse_exec(bContext *C, wmOperator *op)
+{
+       PEData data;
+       PTCacheEdit *edit;
+       POINT_P; KEY_K;
+
+       PE_set_data(C, &data);
+
+       edit= PE_get_current(data.scene, data.ob);
+
+       LOOP_VISIBLE_POINTS {
+               LOOP_KEYS {
+                       key->flag ^= PEK_SELECT;
+                       point->flag |= PEP_EDIT_RECALC; /* redraw selection only */
+               }
+       }
+
+       PE_update_selection(data.scene, data.ob, 1);
+       WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void PARTICLE_OT_select_inverse(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Select Inverse";
+       ot->idname= "PARTICLE_OT_select_inverse";
+
+       /* api callbacks */
+       ot->exec= select_inverse_exec;
+       ot->poll= PE_poll;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 /************************ rekey operator ************************/
 
 static void rekey_particle(PEData *data, int pa_index)
index babaaefe155973e1956f83f9001f36b13f16cde0..e8169adc8dc91b6d00116f6352f914273567e71e 100644 (file)
@@ -42,6 +42,7 @@ void PARTICLE_OT_select_last(struct wmOperatorType *ot);
 void PARTICLE_OT_select_linked(struct wmOperatorType *ot);
 void PARTICLE_OT_select_less(struct wmOperatorType *ot);
 void PARTICLE_OT_select_more(struct wmOperatorType *ot);
+void PARTICLE_OT_select_inverse(struct wmOperatorType *ot);
 
 void PARTICLE_OT_hide(struct wmOperatorType *ot);
 void PARTICLE_OT_reveal(struct wmOperatorType *ot);
index 8fb91a6c29680daf6b3b2297190ee85e30f0a2f1..1b9ebf27edcd86451e203303056758cd901af08a 100644 (file)
@@ -49,6 +49,7 @@ static void operatortypes_particle(void)
        WM_operatortype_append(PARTICLE_OT_select_linked);
        WM_operatortype_append(PARTICLE_OT_select_less);
        WM_operatortype_append(PARTICLE_OT_select_more);
+       WM_operatortype_append(PARTICLE_OT_select_inverse);
 
        WM_operatortype_append(PARTICLE_OT_hide);
        WM_operatortype_append(PARTICLE_OT_reveal);
@@ -98,6 +99,7 @@ static void keymap_particle(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "PARTICLE_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "PARTICLE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
        RNA_boolean_set(WM_keymap_add_item(keymap, "PARTICLE_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1);
+       WM_keymap_add_item(keymap, "PARTICLE_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
 
        WM_keymap_add_item(keymap, "PARTICLE_OT_delete", XKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "PARTICLE_OT_delete", DELKEY, KM_PRESS, 0, 0);