- added particle select_inverse

- added select root/tip to the select menu
- selection drawing updates for select more/less were not working
This commit is contained in:
Campbell Barton 2009-11-09 08:51:34 +00:00
parent ae91ca7217
commit 97e7e26bab
4 changed files with 60 additions and 1 deletions

@ -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_all_toggle", text="Select/Deselect All")
layout.itemO("particle.select_linked") layout.itemO("particle.select_linked")
layout.itemO("particle.select_inverse")
layout.itemS() layout.itemS()
layout.itemO("particle.select_more") layout.itemO("particle.select_more")
layout.itemO("particle.select_less") 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): class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
bl_label = "Select" bl_label = "Select"

@ -1347,6 +1347,7 @@ int PE_mouse_particles(bContext *C, short *mval, int extend)
static void select_root(PEData *data, int point_index) static void select_root(PEData *data, int point_index)
{ {
data->edit->points[point_index].keys->flag |= PEK_SELECT; 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) 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); PE_set_data(C, &data);
foreach_point(&data, select_root); 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); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -1380,6 +1383,7 @@ static void select_tip(PEData *data, int point_index)
{ {
PTCacheEditPoint *point = data->edit->points + point_index; PTCacheEditPoint *point = data->edit->points + point_index;
point->keys[point->totkey - 1].flag |= PEK_SELECT; 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) 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); PE_set_data(C, &data);
foreach_point(&data, select_tip); 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); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -1693,8 +1699,10 @@ static void select_less_keys(PEData *data, int point_index)
} }
LOOP_KEYS { LOOP_KEYS {
if(key->flag&PEK_TAG) if(key->flag&PEK_TAG) {
key->flag &= ~(PEK_TAG|PEK_SELECT); 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); PE_set_data(C, &data);
foreach_point(&data, select_less_keys); 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); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -1752,6 +1762,7 @@ static void select_more_keys(PEData *data, int point_index)
if(key->flag&PEK_TAG) { if(key->flag&PEK_TAG) {
key->flag &= ~PEK_TAG; key->flag &= ~PEK_TAG;
key->flag |= PEK_SELECT; 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); PE_set_data(C, &data);
foreach_point(&data, select_more_keys); 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); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@ -1781,6 +1794,43 @@ void PARTICLE_OT_select_more(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; 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 ************************/ /************************ rekey operator ************************/
static void rekey_particle(PEData *data, int pa_index) static void rekey_particle(PEData *data, int pa_index)

@ -42,6 +42,7 @@ void PARTICLE_OT_select_last(struct wmOperatorType *ot);
void PARTICLE_OT_select_linked(struct wmOperatorType *ot); void PARTICLE_OT_select_linked(struct wmOperatorType *ot);
void PARTICLE_OT_select_less(struct wmOperatorType *ot); void PARTICLE_OT_select_less(struct wmOperatorType *ot);
void PARTICLE_OT_select_more(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_hide(struct wmOperatorType *ot);
void PARTICLE_OT_reveal(struct wmOperatorType *ot); void PARTICLE_OT_reveal(struct wmOperatorType *ot);

@ -49,6 +49,7 @@ static void operatortypes_particle(void)
WM_operatortype_append(PARTICLE_OT_select_linked); WM_operatortype_append(PARTICLE_OT_select_linked);
WM_operatortype_append(PARTICLE_OT_select_less); WM_operatortype_append(PARTICLE_OT_select_less);
WM_operatortype_append(PARTICLE_OT_select_more); 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_hide);
WM_operatortype_append(PARTICLE_OT_reveal); 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_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "PARTICLE_OT_select_linked", LKEY, KM_PRESS, 0, 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); 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", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PARTICLE_OT_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PARTICLE_OT_delete", DELKEY, KM_PRESS, 0, 0);