2.5
[blender.git] / source / blender / editors / space_view3d / view3d_select.c
index 1d1bef89d202f3692870e564a32c55d61f8f0965..2be8df678f0d266fd42a4f0f754a691e6e4a4e78 100644 (file)
@@ -679,49 +679,6 @@ void view3d_lasso_select(Scene *scene, ARegion *ar, View3D *v3d, short mcords[][
        
 }
 
-/* mx my in region coords */
-void mouse_cursor(Scene *scene, ARegion *ar, View3D *v3d, short mx, short my)
-{
-       float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3];
-       short lr_click=0, mval[2];
-       short ctrl= 0; // XXX
-       
-       fp= give_cursor(scene, v3d);
-       
-       if(G.obedit && ctrl) lr_click= 1;
-       VECCOPY(oldcurs, fp);
-       
-       project_short_noclip(ar, v3d, fp, mval);
-
-       initgrabz(v3d, fp[0], fp[1], fp[2]);
-       
-       if(mval[0]!=IS_CLIPPED) {
-               
-               window_to_3d(ar, v3d, dvec, mval[0]-mx, mval[1]-my);
-               VecSubf(fp, fp, dvec);
-               
-       }
-       else {
-
-               dx= ((float)(mx-(ar->winx/2)))*v3d->zfac/(ar->winx/2);
-               dy= ((float)(my-(ar->winy/2)))*v3d->zfac/(ar->winy/2);
-               
-               fz= v3d->persmat[0][3]*fp[0]+ v3d->persmat[1][3]*fp[1]+ v3d->persmat[2][3]*fp[2]+ v3d->persmat[3][3];
-               fz= fz/v3d->zfac;
-               
-               fp[0]= (v3d->persinv[0][0]*dx + v3d->persinv[1][0]*dy+ v3d->persinv[2][0]*fz)-v3d->ofs[0];
-               fp[1]= (v3d->persinv[0][1]*dx + v3d->persinv[1][1]*dy+ v3d->persinv[2][1]*fz)-v3d->ofs[1];
-               fp[2]= (v3d->persinv[0][2]*dx + v3d->persinv[1][2]*dy+ v3d->persinv[2][2]*fz)-v3d->ofs[2];
-       }
-       
-       if(lr_click) {
-// XXX         if(G.obedit->type==OB_MESH) add_click_mesh();
-//             else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) addvert_Nurb(0);
-//             else if (G.obedit->type==OB_ARMATURE) addvert_armature();
-               VECCOPY(fp, oldcurs);
-       }
-       
-}
 
 void deselectall(Scene *scene, View3D *v3d)    /* is toggle */
 {
@@ -1277,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];
+
+       select_type = RNA_enum_get(op->ptr, "select_type");
        
-       /* note; otherwise opengl select won't work. do this for every glSelectBuffer() */
-       wmSubWindowSet(CTX_wm_window(C), ar->swinid);
+       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";
@@ -1303,7 +1292,13 @@ void VIEW3D_OT_select(wmOperatorType *ot)
        
        /* api callbacks */
        ot->invoke= view3d_select_invoke;
-       ot->poll= ED_operator_areaactive;
+       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 ************************************** */
@@ -1671,7 +1666,7 @@ void VIEW3D_OT_borderselect(wmOperatorType *ot)
        ot->exec= view3d_borderselect_exec;
        ot->modal= WM_border_select_modal;
        
-       ot->poll= ED_operator_areaactive;
+       ot->poll= ED_operator_view3d_active;
        
        /* rna */
        RNA_def_property(ot->srna, "event_type", PROP_INT, PROP_NONE);
@@ -1895,7 +1890,7 @@ void VIEW3D_OT_circle_select(wmOperatorType *ot)
        ot->invoke= WM_gesture_circle_invoke;
        ot->modal= WM_gesture_circle_modal;
        ot->exec= view3d_circle_select;
-       ot->poll= WM_operator_winactive;
+       ot->poll= ED_operator_view3d_active;
        
        RNA_def_property(ot->srna, "x", PROP_INT, PROP_NONE);
        RNA_def_property(ot->srna, "y", PROP_INT, PROP_NONE);