diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-28 19:42:27 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-28 19:42:27 +0400 |
commit | e2c453b5f9d3a0a26333b6585f07ebf9e3a24819 (patch) | |
tree | 837b0b4f8756f9b0dec4b8bae1891e21cd230227 /source/blender/editors/object/object_select.c | |
parent | ef054e165cad35715a5b2388aac3db68a65ea275 (diff) |
style cleanup: editors / mesh & object
Diffstat (limited to 'source/blender/editors/object/object_select.c')
-rw-r--r-- | source/blender/editors/object/object_select.c | 320 |
1 files changed, 160 insertions, 160 deletions
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 386541c5262..7a4db175ee4 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -79,8 +79,8 @@ /************************ Exported **************************/ /* simple API for object selection, rather than just using the flag - * this takes into account the 'restrict selection in 3d view' flag. - * deselect works always, the restriction just prevents selection */ +* this takes into account the 'restrict selection in 3d view' flag. +* deselect works always, the restriction just prevents selection */ /* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or * or a NC_SCENE|ND_OB_VISIBLE in case of visibility toggling */ @@ -88,34 +88,34 @@ void ED_base_object_select(Base *base, short mode) { if (base) { - if (mode==BA_SELECT) { + if (mode == BA_SELECT) { if (!(base->object->restrictflag & OB_RESTRICT_SELECT)) base->flag |= SELECT; } - else if (mode==BA_DESELECT) { + else if (mode == BA_DESELECT) { base->flag &= ~SELECT; } - base->object->flag= base->flag; + base->object->flag = base->flag; } } /* also to set active NULL */ void ED_base_object_activate(bContext *C, Base *base) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); /* sets scene->basact */ - BASACT= base; + BASACT = base; if (base) { /* XXX old signals, remember to handle notifiers now! */ // select_actionchannel_by_name(base->object->action, "Object", 1); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); } else - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, NULL); } /********************** Selection Operators **********************/ @@ -124,7 +124,7 @@ static int objects_selectable_poll(bContext *C) { /* we don't check for linked scenes here, selection is * still allowed then for inspection of scene */ - Object *obact= CTX_data_active_object(C); + Object *obact = CTX_data_active_object(C); if (CTX_data_edit_object(C)) return 0; @@ -141,23 +141,23 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op) short obtype, extend; obtype = RNA_enum_get(op->ptr, "type"); - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (extend == 0) { - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); } CTX_DATA_END; } - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { - if (base->object->type==obtype) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { + if (base->object->type == obtype) { ED_base_object_select(base, BA_SELECT); } } CTX_DATA_END; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -175,7 +175,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -198,11 +198,11 @@ static EnumPropertyItem prop_select_linked_types[] = { static int object_select_linked_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob; void *obdata = NULL; Material *mat = NULL, *mat1; - Tex *tex= NULL; + Tex *tex = NULL; int a, b; int nr = RNA_enum_get(op->ptr, "type"); short changed = 0, extend; @@ -215,77 +215,77 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) * PSys: 6 */ - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (extend == 0) { - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); } CTX_DATA_END; } - ob= OBACT; - if (ob==NULL) { + ob = OBACT; + if (ob == NULL) { BKE_report(op->reports, RPT_ERROR, "No Active Object"); return OPERATOR_CANCELLED; } - if (nr==1) { - // XXX old animation system + if (nr == 1) { + // XXX old animation system //ipo= ob->ipo; //if (ipo==0) return OPERATOR_CANCELLED; return OPERATOR_CANCELLED; } - else if (nr==2) { - if (ob->data==NULL) return OPERATOR_CANCELLED; - obdata= ob->data; + else if (nr == 2) { + if (ob->data == NULL) return OPERATOR_CANCELLED; + obdata = ob->data; } - else if (nr==3 || nr==4) { - mat= give_current_material(ob, ob->actcol); - if (mat==NULL) return OPERATOR_CANCELLED; - if (nr==4) { - if (mat->mtex[ (int)mat->texact ]) tex= mat->mtex[ (int)mat->texact ]->tex; - if (tex==NULL) return OPERATOR_CANCELLED; + else if (nr == 3 || nr == 4) { + mat = give_current_material(ob, ob->actcol); + if (mat == NULL) return OPERATOR_CANCELLED; + if (nr == 4) { + if (mat->mtex[(int)mat->texact]) tex = mat->mtex[(int)mat->texact]->tex; + if (tex == NULL) return OPERATOR_CANCELLED; } } - else if (nr==5) { - if (ob->dup_group==NULL) return OPERATOR_CANCELLED; + else if (nr == 5) { + if (ob->dup_group == NULL) return OPERATOR_CANCELLED; } - else if (nr==6) { - if (ob->particlesystem.first==NULL) return OPERATOR_CANCELLED; + else if (nr == 6) { + if (ob->particlesystem.first == NULL) return OPERATOR_CANCELLED; } - else if (nr==7) { + else if (nr == 7) { /* do nothing */ } - else if (nr==8) { - if (ob->data==NULL) return OPERATOR_CANCELLED; + else if (nr == 8) { + if (ob->data == NULL) return OPERATOR_CANCELLED; } else return OPERATOR_CANCELLED; - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { - if (nr==1) { - // XXX old animation system + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { + if (nr == 1) { + // XXX old animation system //if (base->object->ipo==ipo) base->flag |= SELECT; //changed = 1; } - else if (nr==2) { - if (base->object->data==obdata) base->flag |= SELECT; + else if (nr == 2) { + if (base->object->data == obdata) base->flag |= SELECT; changed = 1; } - else if (nr==3 || nr==4) { - ob= base->object; + else if (nr == 3 || nr == 4) { + ob = base->object; - for (a=1; a<=ob->totcol; a++) { - mat1= give_current_material(ob, a); - if (nr==3) { - if (mat1==mat) base->flag |= SELECT; + for (a = 1; a <= ob->totcol; a++) { + mat1 = give_current_material(ob, a); + if (nr == 3) { + if (mat1 == mat) base->flag |= SELECT; changed = 1; } - else if (mat1 && nr==4) { - for (b=0; b<MAX_MTEX; b++) { + else if (mat1 && nr == 4) { + for (b = 0; b < MAX_MTEX; b++) { if (mat1->mtex[b]) { - if (tex==mat1->mtex[b]->tex) { + if (tex == mat1->mtex[b]->tex) { base->flag |= SELECT; changed = 1; break; @@ -295,19 +295,19 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) } } } - else if (nr==5) { - if (base->object->dup_group==ob->dup_group) { + else if (nr == 5) { + if (base->object->dup_group == ob->dup_group) { base->flag |= SELECT; changed = 1; } } - else if (nr==6) { + else if (nr == 6) { /* loop through other, then actives particles*/ ParticleSystem *psys; ParticleSystem *psys_act; - for (psys=base->object->particlesystem.first; psys; psys=psys->next) { - for (psys_act=ob->particlesystem.first; psys_act; psys_act=psys_act->next) { + for (psys = base->object->particlesystem.first; psys; psys = psys->next) { + for (psys_act = ob->particlesystem.first; psys_act; psys_act = psys_act->next) { if (psys->part == psys_act->part) { base->flag |= SELECT; changed = 1; @@ -320,24 +320,24 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) } } } - else if (nr==7) { + else if (nr == 7) { if (ob->id.lib == base->object->id.lib) { base->flag |= SELECT; - changed= 1; + changed = 1; } } - else if (nr==8) { + else if (nr == 8) { if (base->object->data && ((ID *)ob->data)->lib == ((ID *)base->object->data)->lib) { base->flag |= SELECT; - changed= 1; + changed = 1; } } - base->object->flag= base->flag; + base->object->flag = base->flag; } CTX_DATA_END; if (changed) { - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -357,7 +357,7 @@ void OBJECT_OT_select_linked(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -386,7 +386,7 @@ static short select_grouped_children(bContext *C, Object *ob, int recursive) { short changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if (ob == base->object->parent) { if (!(base->flag & SELECT)) { ED_base_object_select(base, BA_SELECT); @@ -401,17 +401,17 @@ static short select_grouped_children(bContext *C, Object *ob, int recursive) return changed; } -static short select_grouped_parent(bContext *C) /* Makes parent active and de-selected OBACT */ +static short select_grouped_parent(bContext *C) /* Makes parent active and de-selected OBACT */ { - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); short changed = 0; - Base *baspar, *basact= CTX_data_active_base(C); + Base *baspar, *basact = CTX_data_active_base(C); - if (!basact || !(basact->object->parent)) return 0; /* we know OBACT is valid */ + if (!basact || !(basact->object->parent)) return 0; /* we know OBACT is valid */ - baspar= object_in_scene(basact->object->parent, scene); + baspar = object_in_scene(basact->object->parent, scene); /* can be NULL if parent in other scene */ if (baspar && BASE_SELECTABLE(v3d, baspar)) { @@ -424,17 +424,17 @@ static short select_grouped_parent(bContext *C) /* Makes parent active and de-se } -#define GROUP_MENU_MAX 24 -static short select_grouped_group(bContext *C, Object *ob) /* Select objects in the same group as the active */ +#define GROUP_MENU_MAX 24 +static short select_grouped_group(bContext *C, Object *ob) /* Select objects in the same group as the active */ { short changed = 0; Group *group, *ob_groups[GROUP_MENU_MAX]; - int group_count=0, i; + int group_count = 0, i; uiPopupMenu *pup; uiLayout *layout; - for (group=CTX_data_main(C)->group.first; group && group_count < GROUP_MENU_MAX; group=group->id.next) { - if (object_in_group (ob, group)) { + for (group = CTX_data_main(C)->group.first; group && group_count < GROUP_MENU_MAX; group = group->id.next) { + if (object_in_group(ob, group)) { ob_groups[group_count] = group; group_count++; } @@ -444,7 +444,7 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in return 0; else if (group_count == 1) { group = ob_groups[0]; - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (!(base->flag & SELECT) && object_in_group(base->object, group)) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -455,12 +455,12 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in } /* build the menu. */ - pup= uiPupMenuBegin(C, "Select Group", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Select Group", ICON_NONE); + layout = uiPupMenuLayout(pup); - for (i=0; i<group_count; i++) { + for (i = 0; i < group_count; i++) { group = ob_groups[i]; - uiItemStringO(layout, group->id.name+2, 0, "OBJECT_OT_select_same_group", "group", group->id.name); + uiItemStringO(layout, group->id.name + 2, 0, "OBJECT_OT_select_same_group", "group", group->id.name); } uiPupMenuEnd(C, pup); @@ -469,19 +469,19 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in static short select_grouped_object_hooks(bContext *C, Object *ob) { - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); short changed = 0; Base *base; ModifierData *md; HookModifierData *hmd; - for (md = ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Hook) { - hmd= (HookModifierData*) md; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Hook) { + hmd = (HookModifierData *) md; if (hmd->object && !(hmd->object->flag & SELECT)) { - base= object_in_scene(hmd->object, scene); + base = object_in_scene(hmd->object, scene); if (base && (BASE_SELECTABLE(v3d, base))) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -498,8 +498,8 @@ static short select_grouped_siblings(bContext *C, Object *ob) { short changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { - if ((base->object->parent==ob->parent) && !(base->flag & SELECT)) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { + if ((base->object->parent == ob->parent) && !(base->flag & SELECT)) { ED_base_object_select(base, BA_SELECT); changed = 1; } @@ -512,7 +512,7 @@ static short select_grouped_type(bContext *C, Object *ob) { short changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if ((base->object->type == ob->type) && !(base->flag & SELECT)) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -526,7 +526,7 @@ static short select_grouped_layer(bContext *C, Object *ob) { char changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if ((base->lay & ob->lay) && !(base->flag & SELECT)) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -540,7 +540,7 @@ static short select_grouped_index_object(bContext *C, Object *ob) { char changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if ((base->object->index == ob->index) && !(base->flag & SELECT)) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -554,7 +554,7 @@ static short select_grouped_color(bContext *C, Object *ob) { char changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if (!(base->flag & SELECT) && (compare_v3v3(base->object->col, ob->col, 0.005f))) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -569,8 +569,8 @@ static short objects_share_gameprop(Object *a, Object *b) bProperty *prop; /*make a copy of all its properties*/ - for ( prop= a->prop.first; prop; prop = prop->next ) { - if ( get_ob_property(b, prop->name) ) + for (prop = a->prop.first; prop; prop = prop->next) { + if (get_ob_property(b, prop->name) ) return 1; } return 0; @@ -580,7 +580,7 @@ static short select_grouped_gameprops(bContext *C, Object *ob) { char changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if (!(base->flag & SELECT) && (objects_share_gameprop(base->object, ob))) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -602,7 +602,7 @@ static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob)) /* select each object that Keying Set refers to */ // TODO: perhaps to be more in line with the rest of these, we should only take objects // if the passed in object is included in this too - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { /* only check for this object if it isn't selected already, to limit time wasted */ if ((base->flag & SELECT) == 0) { KS_Path *ksp; @@ -627,42 +627,42 @@ static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob)) static int object_select_grouped_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob; int nr = RNA_enum_get(op->ptr, "type"); short changed = 0, extend; - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (extend == 0) { - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); changed = 1; } CTX_DATA_END; } - ob= OBACT; - if (ob==NULL) { + ob = OBACT; + if (ob == NULL) { BKE_report(op->reports, RPT_ERROR, "No Active Object"); return OPERATOR_CANCELLED; } - if (nr==1) changed |= select_grouped_children(C, ob, 1); - else if (nr==2) changed |= select_grouped_children(C, ob, 0); - else if (nr==3) changed |= select_grouped_parent(C); - else if (nr==4) changed |= select_grouped_siblings(C, ob); - else if (nr==5) changed |= select_grouped_type(C, ob); - else if (nr==6) changed |= select_grouped_layer(C, ob); - else if (nr==7) changed |= select_grouped_group(C, ob); - else if (nr==8) changed |= select_grouped_object_hooks(C, ob); - else if (nr==9) changed |= select_grouped_index_object(C, ob); - else if (nr==10) changed |= select_grouped_color(C, ob); - else if (nr==11) changed |= select_grouped_gameprops(C, ob); - else if (nr==12) changed |= select_grouped_keyingset(C, ob); + if (nr == 1) changed |= select_grouped_children(C, ob, 1); + else if (nr == 2) changed |= select_grouped_children(C, ob, 0); + else if (nr == 3) changed |= select_grouped_parent(C); + else if (nr == 4) changed |= select_grouped_siblings(C, ob); + else if (nr == 5) changed |= select_grouped_type(C, ob); + else if (nr == 6) changed |= select_grouped_layer(C, ob); + else if (nr == 7) changed |= select_grouped_group(C, ob); + else if (nr == 8) changed |= select_grouped_object_hooks(C, ob); + else if (nr == 9) changed |= select_grouped_index_object(C, ob); + else if (nr == 10) changed |= select_grouped_color(C, ob); + else if (nr == 11) changed |= select_grouped_gameprops(C, ob); + else if (nr == 12) changed |= select_grouped_keyingset(C, ob); if (changed) { - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -682,7 +682,7 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -696,24 +696,24 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) unsigned int layernum; short extend; - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); layernum = RNA_int_get(op->ptr, "layers"); if (extend == 0) { - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); } CTX_DATA_END; } - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { - if (base->lay == (1<< (layernum -1))) + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { + if (base->lay == (1 << (layernum - 1))) ED_base_object_select(base, BA_SELECT); } CTX_DATA_END; /* undo? */ - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -731,7 +731,7 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -749,7 +749,7 @@ static int object_select_all_exec(bContext *C, wmOperator *op) if (action == SEL_TOGGLE) { action = SEL_SELECT; - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (base->flag & SELECT) { action = SEL_DESELECT; break; @@ -758,27 +758,27 @@ static int object_select_all_exec(bContext *C, wmOperator *op) CTX_DATA_END; } - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { switch (action) { - case SEL_SELECT: - ED_base_object_select(base, BA_SELECT); - break; - case SEL_DESELECT: - ED_base_object_select(base, BA_DESELECT); - break; - case SEL_INVERT: - if (base->flag & SELECT) { - ED_base_object_select(base, BA_DESELECT); - } - else { + case SEL_SELECT: ED_base_object_select(base, BA_SELECT); - } - break; + break; + case SEL_DESELECT: + ED_base_object_select(base, BA_DESELECT); + break; + case SEL_INVERT: + if (base->flag & SELECT) { + ED_base_object_select(base, BA_DESELECT); + } + else { + ED_base_object_select(base, BA_SELECT); + } + break; } } CTX_DATA_END; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -796,7 +796,7 @@ void OBJECT_OT_select_all(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -813,7 +813,7 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "group", group_name); - for (group=CTX_data_main(C)->group.first; group; group=group->id.next) { + for (group = CTX_data_main(C)->group.first; group; group = group->id.next) { if (!strcmp(group->id.name, group_name)) break; } @@ -821,13 +821,13 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op) if (!group) return OPERATOR_PASS_THROUGH; - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (!(base->flag & SELECT) && object_in_group(base->object, group)) ED_base_object_select(base, BA_SELECT); } CTX_DATA_END; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -845,7 +845,7 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_string(ot->srna, "group", "", MAX_ID_NAME, "Group", "Name of the group to select"); } @@ -853,20 +853,20 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) /**************************** Select Mirror ****************************/ static int object_select_mirror_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); short extend; - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); - CTX_DATA_BEGIN (C, Base*, primbase, selected_bases) { + CTX_DATA_BEGIN (C, Base *, primbase, selected_bases) { char tmpname[MAXBONENAME]; - flip_side_name(tmpname, primbase->object->id.name+2, TRUE); + flip_side_name(tmpname, primbase->object->id.name + 2, TRUE); - if (strcmp(tmpname, primbase->object->id.name+2)!=0) { /* names differ */ - Object *ob= (Object *)find_id("OB", tmpname); + if (strcmp(tmpname, primbase->object->id.name + 2) != 0) { /* names differ */ + Object *ob = (Object *)find_id("OB", tmpname); if (ob) { - Base *secbase= object_in_scene(ob, scene); + Base *secbase = object_in_scene(ob, scene); if (secbase) { ED_base_object_select(secbase, BA_SELECT); @@ -880,7 +880,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* undo? */ - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -898,7 +898,7 @@ void OBJECT_OT_select_mirror(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first"); } @@ -911,24 +911,24 @@ static int object_select_random_exec(bContext *C, wmOperator *op) float percent; short extend; - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (extend == 0) { - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); } CTX_DATA_END; } - percent = RNA_float_get(op->ptr, "percent")/100.0f; + percent = RNA_float_get(op->ptr, "percent") / 100.0f; - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (BLI_frand() < percent) { ED_base_object_select(base, BA_SELECT); } } CTX_DATA_END; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -946,7 +946,7 @@ void OBJECT_OT_select_random(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of objects to select randomly", 0.f, 100.0f); |