Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2008-12-28 21:10:24 +0300
committerTon Roosendaal <ton@blender.org>2008-12-28 21:10:24 +0300
commit9b2dec96317d067ecca0d010d0ae72a20223ad63 (patch)
tree3839d06074944329a74161ebceb20e6e632e15bb /source
parent7209837f2eb0c3943a7b0e2fafff2182ad50f96b (diff)
2.5
Recode of 'select all objects by type' to show how to use itterators.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_context.h3
-rw-r--r--source/blender/blenkernel/intern/context.c10
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c40
4 files changed, 35 insertions, 32 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index e8bd72ac3f3..791d7251ef5 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -137,6 +137,9 @@ void CTX_data_scene_set(bContext *C, struct Scene *bmain);
int CTX_data_selected_objects(const bContext *C, ListBase *list);
int CTX_data_selected_bases(const bContext *C, ListBase *list);
+int CTX_data_visible_objects(const bContext *C, ListBase *list);
+int CTX_data_visible_bases(const bContext *C, ListBase *list);
+
struct Object *CTX_data_active_object(const bContext *C);
struct Base *CTX_data_active_base(const bContext *C);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 703bb4c2b00..fa5740f74e9 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -365,6 +365,16 @@ int CTX_data_selected_bases(const bContext *C, ListBase *list)
return ctx_data_collection_get(C, CTX_data_selected_bases, list);
}
+int CTX_data_visible_objects(const bContext *C, ListBase *list)
+{
+ return ctx_data_collection_get(C, CTX_data_visible_objects, list);
+}
+
+int CTX_data_visible_bases(const bContext *C, ListBase *list)
+{
+ return ctx_data_collection_get(C, CTX_data_visible_bases, list);
+}
+
struct Object *CTX_data_active_object(const bContext *C)
{
return ctx_data_pointer_get(C, CTX_data_active_object);
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index b523810fbd8..1503dd878d3 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -266,6 +266,20 @@ static int view3d_context(const bContext *C, const bContextDataMember *member, b
return 1;
}
+ else if(ELEM(member, CTX_data_visible_objects, CTX_data_visible_bases)) {
+ for(base=scene->base.first; base; base=base->next) {
+ if(base->lay & v3d->lay) {
+ if((base->object->restrictflag & OB_RESTRICT_VIEW)==0) {
+ if(member == CTX_data_selected_objects)
+ CTX_data_list_add(result, base->object);
+ else
+ CTX_data_list_add(result, base);
+ }
+ }
+ }
+
+ return 1;
+ }
else if(member == CTX_data_active_base) {
if(scene->basact && (scene->basact->lay & v3d->lay))
if((scene->basact->object->restrictflag & OB_RESTRICT_VIEW)==0)
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 89f2650affc..7bb2c9d1162 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -194,6 +194,7 @@ void select_base_v3d(Base *base, short mode)
else if (mode==BA_DESELECT) {
base->flag &= ~SELECT;
}
+ base->object->flag= base->flag;
}
}
@@ -762,25 +763,6 @@ void selectrandom(Scene *scene, View3D *v3d, short randfac)
BIF_undo_push("Select Random");
}
-/* selects all objects of a particular type, on currently visible layers */
-void selectall_type(Scene *scene, View3D *v3d, short obtype)
-{
- Base *base;
-
- base= FIRSTBASE;
- while(base) {
- if((base->lay & v3d->lay) &&
- (base->object->type == obtype) &&
- (base->object->restrictflag & OB_RESTRICT_VIEW)==0
- ) {
- select_base_v3d(base, BA_SELECT);
- base->object->flag= base->flag;
- }
- base= base->next;
- }
-
- BIF_undo_push("Select all per type");
-}
/* selects all objects on a particular layer */
void selectall_layer(Scene *scene, unsigned int layernum)
{
@@ -792,7 +774,6 @@ void selectall_layer(Scene *scene, unsigned int layernum)
(base->object->restrictflag & OB_RESTRICT_VIEW)==0
) {
select_base_v3d(base, BA_SELECT);
- base->object->flag= base->flag;
}
base= base->next;
}
@@ -903,7 +884,6 @@ static void deselectall_except(Scene *scene, Base *b) /* deselect all except b
if (base->flag & SELECT) {
if(b!=base) {
select_base_v3d(base, BA_DESELECT);
- base->object->flag= base->flag;
}
}
}
@@ -1207,9 +1187,6 @@ static void mouse_select(Scene *scene, ARegion *ar, View3D *v3d, short *mval)
else select_base_v3d(basact, BA_SELECT);
}
- /* copy */
- basact->object->flag= basact->flag;
-
if(oldbasact != basact) {
set_active_base(scene, basact);
}
@@ -1565,8 +1542,6 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
select_base_v3d(base, BA_SELECT);
else
select_base_v3d(base, BA_DESELECT);
-
- base->object->flag= base->flag;
}
col+=4; /* next color */
@@ -1660,16 +1635,19 @@ static EnumPropertyItem prop_select_object_types[] = {
static int view3d_select_by_type_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
- View3D *v3d= sa->spacedata.first;
- Scene *scene= CTX_data_scene(C);
short obtype;
obtype = RNA_enum_get(op->ptr, "type");
- selectall_type(scene, v3d, obtype);
+ CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
+ if(base->object->type==obtype) {
+ select_base_v3d(base, BA_SELECT);
+ }
+ }
+ CTX_DATA_END;
+ /* undo? */
ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
@@ -1980,9 +1958,7 @@ static int view3d_circle_select(bContext *C, wmOperator *op)
int dx= base->sx-x;
int dy= base->sy-y;
if( dx*dx + dy*dy < radius*radius)
-
select_base_v3d(base, BA_SELECT);
- base->object->flag= base->flag;
}
}
}