2.5
authorMichael Fox <mfoxdogg@gmail.com>
Sat, 27 Dec 2008 10:54:32 +0000 (10:54 +0000)
committerMichael Fox <mfoxdogg@gmail.com>
Sat, 27 Dec 2008 10:54:32 +0000 (10:54 +0000)
*******

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

source/blender/editors/space_view3d/view3d_intern.h
source/blender/editors/space_view3d/view3d_ops.c
source/blender/editors/space_view3d/view3d_select.c

index 4a66cb525bba4e39986f3cfb248c27a1c5020e01..929e1f7751d62a9cf789f8bf43709307af405c07 100644 (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
 
index 2589ce7bdb4824ed7489dc9b4d1f0e08f63ebedf..6ac110ea0cf18f74c91b07265e474d34940ebf50 100644 (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);
index dd6899ea12f95622e6dbbfa587a6a63107a66a14..2be8df678f0d266fd42a4f0f754a691e6e4a4e78 100644 (file)
@@ -1234,25 +1234,57 @@ static void mouse_select(Scene *scene, ARegion *ar, View3D *v3d, short *mval)
        
 }
 
-static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
+/* *****************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];
-       
-       /* note; otherwise opengl select won't work. do this for every glSelectBuffer() */
-       wmSubWindowSet(CTX_wm_window(C), ar->swinid);
+
+       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);
+       ARegion *ar= CTX_wm_region(C);
+       View3D *v3d= sa->spacedata.first;
+       short mval[2];  
        
        mval[0]= event->x - ar->winrct.xmin;
        mval[1]= event->y - ar->winrct.ymin;
-       mouse_select(CTX_data_scene(C), ar, v3d, mval);
+       
+       RNA_int_set(op->ptr, "mx", mval[0]);
+       RNA_int_set(op->ptr, "my", mval[1]);
+
+       return view3d_select_exec(C,op);
 
-       return OPERATOR_FINISHED;
 }
 
 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 ************************************** */