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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/object/object_select.c')
-rw-r--r--source/blender/editors/object/object_select.c116
1 files changed, 84 insertions, 32 deletions
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 50ba4ab2934..98603ee843a 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -30,6 +30,8 @@
#include <stdlib.h>
#include <string.h>
+#include "MEM_guardedalloc.h"
+
#include "DNA_group_types.h"
#include "DNA_material_types.h"
#include "DNA_modifier_types.h"
@@ -53,6 +55,7 @@
#include "BKE_property.h"
#include "BKE_report.h"
#include "BKE_scene.h"
+#include "BKE_utildefines.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -117,22 +120,16 @@ void ED_base_object_activate(bContext *C, Base *base)
/********************** Selection Operators **********************/
-static EnumPropertyItem prop_select_types[] = {
- {0, "EXCLUSIVE", 0, "Exclusive", ""},
- {1, "EXTEND", 0, "Extend", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
/************************ Select by Type *************************/
static int object_select_by_type_exec(bContext *C, wmOperator *op)
{
- short obtype, seltype;
+ short obtype, extend;
obtype = RNA_enum_get(op->ptr, "type");
- seltype = RNA_enum_get(op->ptr, "seltype");
+ extend= RNA_boolean_get(op->ptr, "extend");
- if (seltype == 0) {
+ if (extend == 0) {
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
ED_base_object_select(base, BA_DESELECT);
}
@@ -166,9 +163,9 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- RNA_def_enum(ot->srna, "seltype", prop_select_types, 0, "Selection", "Extend selection or clear selection then select");
+ /* properties */
+ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first.");
RNA_def_enum(ot->srna, "type", object_type_items, 1, "Type", "");
-
}
/*********************** Selection by Links *********************/
@@ -192,7 +189,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
Tex *tex=0;
int a, b;
int nr = RNA_enum_get(op->ptr, "type");
- short changed = 0, seltype;
+ short changed = 0, extend;
/* events (nr):
* Object Ipo: 1
* ObData: 2
@@ -202,9 +199,9 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
* PSys: 6
*/
- seltype = RNA_enum_get(op->ptr, "seltype");
+ extend= RNA_boolean_get(op->ptr, "extend");
- if (seltype == 0) {
+ if (extend == 0) {
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
ED_base_object_select(base, BA_DESELECT);
}
@@ -327,9 +324,9 @@ void OBJECT_OT_select_linked(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ /* properties */
+ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first.");
RNA_def_enum(ot->srna, "type", prop_select_linked_types, 0, "Type", "");
- RNA_def_enum(ot->srna, "seltype", prop_select_types, 1, "Selection", "Extend selection or clear selection then select");
-
}
/*********************** Selected Grouped ********************/
@@ -575,11 +572,11 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *ob;
int nr = RNA_enum_get(op->ptr, "type");
- short changed = 0, seltype;
+ short changed = 0, extend;
- seltype = RNA_enum_get(op->ptr, "seltype");
+ extend= RNA_boolean_get(op->ptr, "extend");
- if (seltype == 0) {
+ if (extend == 0) {
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
ED_base_object_select(base, BA_DESELECT);
}
@@ -628,8 +625,8 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
+ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first.");
RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
- RNA_def_enum(ot->srna, "seltype", prop_select_types, 1, "Selection", "Extend selection or clear selection then select");
}
/************************* Select by Layer **********************/
@@ -637,12 +634,12 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot)
static int object_select_by_layer_exec(bContext *C, wmOperator *op)
{
unsigned int layernum;
- short seltype;
+ short extend;
- seltype = RNA_enum_get(op->ptr, "seltype");
+ extend= RNA_boolean_get(op->ptr, "extend");
layernum = RNA_int_get(op->ptr, "layer");
- if (seltype == 0) {
+ if (extend == 0) {
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
ED_base_object_select(base, BA_DESELECT);
}
@@ -676,8 +673,9 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ /* properties */
+ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first.");
RNA_def_int(ot->srna, "layer", 1, 1, 20, "Layer", "", 1, 20);
- RNA_def_enum(ot->srna, "seltype", prop_select_types, 1, "Selection", "Extend selection or clear selection then select");
}
/************************** Select Inverse *************************/
@@ -878,9 +876,9 @@ void object_flip_name (char *name)
static int object_select_mirror_exec(bContext *C, wmOperator *op)
{
char tmpname[32];
- short seltype;
+ short extend;
- seltype = RNA_enum_get(op->ptr, "seltype");
+ extend= RNA_boolean_get(op->ptr, "extend");
CTX_DATA_BEGIN(C, Base*, primbase, selected_bases) {
@@ -894,7 +892,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- if (seltype == 0) ED_base_object_select(primbase, BA_DESELECT);
+ if (extend == 0) ED_base_object_select(primbase, BA_DESELECT);
}
CTX_DATA_END;
@@ -920,7 +918,60 @@ void OBJECT_OT_select_mirror(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- RNA_def_enum(ot->srna, "seltype", prop_select_types, 1, "Selection", "Extend selection or clear selection then select");
+ RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first.");
+}
+
+
+static int object_select_name_exec(bContext *C, wmOperator *op)
+{
+ char *name= RNA_string_get_alloc(op->ptr, "name", NULL, 0);
+ short extend= RNA_boolean_get(op->ptr, "extend");
+ short changed = 0;
+
+ if(!extend) {
+ CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
+ ED_base_object_select(base, BA_DESELECT);
+ }
+ CTX_DATA_END;
+ }
+
+ CTX_DATA_BEGIN(C, Base*, base, selectable_bases) {
+ if(strcmp(name, base->object->id.name+2)==0) {
+ ED_base_object_select(base, BA_SELECT);
+ changed= 1;
+ }
+ }
+ CTX_DATA_END;
+
+ MEM_freeN(name);
+
+ /* undo? */
+ if(changed) {
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+void OBJECT_OT_select_name(wmOperatorType *ot)
+{
+
+ /* identifiers */
+ ot->name= "Select Name";
+ ot->description = "Select an object with this name";
+ ot->idname= "OBJECT_OT_select_name";
+
+ /* api callbacks */
+ ot->exec= object_select_name_exec;
+ ot->poll= ED_operator_scene_editable;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_string(ot->srna, "name", "", 0, "Name", "Object name to select.");
+ RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first.");
}
/**************************** Select Random ****************************/
@@ -928,11 +979,11 @@ void OBJECT_OT_select_mirror(wmOperatorType *ot)
static int object_select_random_exec(bContext *C, wmOperator *op)
{
float percent;
- short seltype;
+ short extend;
- seltype = RNA_enum_get(op->ptr, "seltype");
+ extend= RNA_boolean_get(op->ptr, "extend");
- if (seltype == 0) {
+ if (extend == 0) {
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
ED_base_object_select(base, BA_DESELECT);
}
@@ -967,8 +1018,9 @@ void OBJECT_OT_select_random(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ /* properties */
+ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first.");
RNA_def_float_percentage(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", "percentage of objects to randomly select", 0.0001f, 1.0f);
- RNA_def_enum(ot->srna, "seltype", prop_select_types, 1, "Selection", "Extend selection or clear selection then select");
}