*******

Made the framework for selection operations ( invert selection, select random) to be handled by a single operator, atm only normal/mouse selection is possible

to be ported
 - invert selection
 - select random
 - select by layer
 - select by type
This commit is contained in:
Michael Fox
2008-12-27 10:54:32 +00:00
parent b6ac77f602
commit 032adf70d9
3 changed files with 47 additions and 7 deletions

View File

@@ -61,6 +61,8 @@ typedef struct ViewDepths {
#define V3D_XRAY 1
#define V3D_TRANSP 2
#define V3D_SELECT_MOUSE 1
/* project short */
#define IS_CLIPPED 12000

View File

@@ -115,7 +115,7 @@ void view3d_keymap(wmWindowManager *wm)
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD6, KM_PRESS, KM_CTRL, 0)->ptr, "viewnum", V3D_VIEW_PANRIGHT);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD8, KM_PRESS, KM_CTRL, 0)->ptr, "viewnum", V3D_VIEW_PANUP);
WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0)->ptr, "select_type", V3D_SELECT_MOUSE);
WM_keymap_add_item(keymap, "VIEW3D_OT_borderselect", BKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_clipping", BKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_circle_select", CKEY, KM_PRESS, 0, 0);

View File

@@ -1234,6 +1234,37 @@ static void mouse_select(Scene *scene, ARegion *ar, View3D *v3d, short *mval)
}
/* *****************Selection Operations Operator******************* */
static EnumPropertyItem prop_select_items[] = {
{V3D_SELECT_MOUSE, "NORMAL", "Normal Select", "Select using the mouse"},
{0, NULL, NULL, NULL}};
static int view3d_select_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);
int select_type;
short mval[2];
select_type = RNA_enum_get(op->ptr, "select_type");
view3d_operator_needs_opengl(C);
printf("about to look at enum");
switch (select_type) {
case V3D_SELECT_MOUSE :
printf("caught event");
mval[0] = RNA_int_get(op->ptr, "mx");
mval[1] = RNA_int_get(op->ptr, "my");
mouse_select(scene, ar, v3d, mval);
printf("selected object");
break;
}
return OPERATOR_FINISHED;
}
static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ScrArea *sa= CTX_wm_area(C);
@@ -1241,18 +1272,19 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
View3D *v3d= sa->spacedata.first;
short mval[2];
/* note; otherwise opengl select won't work. do this for every glSelectBuffer() */
wmSubWindowSet(CTX_wm_window(C), ar->swinid);
mval[0]= event->x - ar->winrct.xmin;
mval[1]= event->y - ar->winrct.ymin;
mouse_select(CTX_data_scene(C), ar, v3d, mval);
return OPERATOR_FINISHED;
RNA_int_set(op->ptr, "mx", mval[0]);
RNA_int_set(op->ptr, "my", mval[1]);
return view3d_select_exec(C,op);
}
void VIEW3D_OT_select(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Activate/Select";
@@ -1261,6 +1293,12 @@ void VIEW3D_OT_select(wmOperatorType *ot)
/* api callbacks */
ot->invoke= view3d_select_invoke;
ot->poll= ED_operator_view3d_active;
prop = RNA_def_property(ot->srna, "select_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_select_items);
prop = RNA_def_property(ot->srna, "mx", PROP_INT, PROP_NONE);
prop = RNA_def_property(ot->srna, "my", PROP_INT, PROP_NONE);
}
/* ******************** border and circle ************************************** */