RNA
[blender.git] / source / blender / editors / space_view3d / view3d_edit.c
index 1e1f235298da75fb1828827546043aac19d051b5..79173d3fec72fd50af9e739aea423a9ee52d436c 100644 (file)
@@ -70,7 +70,7 @@
 #include "RNA_access.h"
 #include "RNA_define.h"
 
-#include "ED_editparticle.h"
+#include "ED_particle.h"
 #include "ED_space_api.h"
 #include "ED_screen.h"
 #include "ED_types.h"
@@ -92,7 +92,7 @@ static void view3d_boxview_clip(ScrArea *sa)
        ARegion *ar;
        BoundBox *bb = MEM_callocN(sizeof(BoundBox), "clipbb");
        float clip[6][4];
-       float x1, y1, z1, ofs[3];
+       float x1= 0.0f, y1= 0.0f, z1= 0.0f, ofs[3];
        int val;
        
        /* create bounding box */
@@ -100,7 +100,7 @@ static void view3d_boxview_clip(ScrArea *sa)
                if(ar->regiontype==RGN_TYPE_WINDOW) {
                        RegionView3D *rv3d= ar->regiondata;
                        
-                       if(rv3d->viewlock) {
+                       if(rv3d->viewlock & RV3D_BOXCLIP) {
                                if(ELEM(rv3d->view, V3D_VIEW_TOP, V3D_VIEW_BOTTOM)) {
                                        if(ar->winx>ar->winy) x1= rv3d->dist;
                                        else x1= ar->winx*rv3d->dist/ar->winy;
@@ -157,7 +157,7 @@ static void view3d_boxview_clip(ScrArea *sa)
                if(ar->regiontype==RGN_TYPE_WINDOW) {
                        RegionView3D *rv3d= ar->regiondata;
                        
-                       if(rv3d->viewlock) {
+                       if(rv3d->viewlock & RV3D_BOXCLIP) {
                                rv3d->rflag |= RV3D_CLIPPING;
                                memcpy(rv3d->clip, clip, sizeof(clip));
                        }
@@ -166,7 +166,7 @@ static void view3d_boxview_clip(ScrArea *sa)
        MEM_freeN(bb);
 }
 
-/* sync ortho view of region to others, for view transforms */
+/* sync center/zoom view of region to others, for view transforms */
 static void view3d_boxview_sync(ScrArea *sa, ARegion *ar)
 {
        ARegion *artest;
@@ -206,7 +206,7 @@ static void view3d_boxview_sync(ScrArea *sa, ARegion *ar)
 }
 
 /* for home, center etc */
-static void view3d_boxview_copy(ScrArea *sa, ARegion *ar)
+void view3d_boxview_copy(ScrArea *sa, ARegion *ar)
 {
        ARegion *artest;
        RegionView3D *rv3d= ar->regiondata;
@@ -503,6 +503,7 @@ static int viewrotate_modal(bContext *C, wmOperator *op, wmEvent *event)
 
                default:
                        if(event->type==vod->origkey && event->val==0) {
+                               request_depth_update(CTX_wm_region_view3d(C));
 
                                MEM_freeN(vod);
                                op->customdata= NULL;
@@ -548,12 +549,16 @@ void VIEW3D_OT_viewrotate(wmOperatorType *ot)
 
        /* identifiers */
        ot->name= "Rotate view";
+       ot->description = "Rotate the view.";
        ot->idname= "VIEW3D_OT_viewrotate";
 
        /* api callbacks */
        ot->invoke= viewrotate_invoke;
        ot->modal= viewrotate_modal;
        ot->poll= ED_operator_view3d_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
 }
 
 /* ************************ viewmove ******************************** */
@@ -575,7 +580,7 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y)
                window_to_3d_delta(vod->ar, dvec, x-vod->oldx, y-vod->oldy);
                VecAddf(vod->rv3d->ofs, vod->rv3d->ofs, dvec);
                
-               if(vod->rv3d->viewlock)
+               if(vod->rv3d->viewlock & RV3D_BOXVIEW)
                        view3d_boxview_sync(vod->sa, vod->ar);
        }
 
@@ -598,6 +603,7 @@ static int viewmove_modal(bContext *C, wmOperator *op, wmEvent *event)
 
                default:
                        if(event->type==vod->origkey && event->val==0) {
+                               request_depth_update(CTX_wm_region_view3d(C));
 
                                MEM_freeN(vod);
                                op->customdata= NULL;
@@ -625,13 +631,17 @@ void VIEW3D_OT_viewmove(wmOperatorType *ot)
 {
 
        /* identifiers */
-       ot->name= "Rotate view";
+       ot->name= "Move view";
+       ot->description = "Move the view.";
        ot->idname= "VIEW3D_OT_viewmove";
 
        /* api callbacks */
        ot->invoke= viewmove_invoke;
        ot->modal= viewmove_modal;
        ot->poll= ED_operator_view3d_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
 }
 
 /* ************************ viewzoom ******************************** */
@@ -734,7 +744,7 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y)
 
 // XXX if(vod->rv3d->persp==V3D_ORTHO || vod->rv3d->persp==V3D_CAMOB) preview3d_event= 0;
 
-       if(vod->rv3d->viewlock)
+       if(vod->rv3d->viewlock & RV3D_BOXVIEW)
                view3d_boxview_sync(vod->sa, vod->ar);
 
        ED_region_tag_redraw(vod->ar);
@@ -753,6 +763,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event)
 
                default:
                        if(event->type==vod->origkey && event->val==0) {
+                               request_depth_update(CTX_wm_region_view3d(C));
 
                                MEM_freeN(vod);
                                op->customdata= NULL;
@@ -786,9 +797,10 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
                else if(rv3d->dist> 0.001*v3d->grid) rv3d->dist*=.83333f;
        }
 
-       if(rv3d->viewlock)
+       if(rv3d->viewlock & RV3D_BOXVIEW)
                view3d_boxview_sync(CTX_wm_area(C), CTX_wm_region(C));
        
+       request_depth_update(CTX_wm_region_view3d(C));
        ED_region_tag_redraw(CTX_wm_region(C));
 
        return OPERATOR_FINISHED;
@@ -814,18 +826,22 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
 }
 
 
-void VIEW3D_OT_viewzoom(wmOperatorType *ot)
+void VIEW3D_OT_zoom(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Rotate view";
-       ot->idname= "VIEW3D_OT_viewzoom";
+       ot->name= "Zoom view";
+       ot->description = "Zoom in/out in the view.";
+       ot->idname= "VIEW3D_OT_zoom";
 
        /* api callbacks */
        ot->invoke= viewzoom_invoke;
        ot->exec= viewzoom_exec;
        ot->modal= viewzoom_modal;
        ot->poll= ED_operator_view3d_active;
-
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
+       
        RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
 }
 
@@ -887,7 +903,7 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
        }
 // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
        
-       if(rv3d->viewlock)
+       if(rv3d->viewlock & RV3D_BOXVIEW)
                view3d_boxview_copy(CTX_wm_area(C), ar);
 
        return OPERATOR_FINISHED;
@@ -897,12 +913,16 @@ void VIEW3D_OT_viewhome(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "View home";
+       ot->description = "View all objects in scene.";
        ot->idname= "VIEW3D_OT_viewhome";
 
        /* api callbacks */
        ot->exec= viewhome_exec;
        ot->poll= ED_operator_view3d_active;
-
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
+       
        RNA_def_boolean(ot->srna, "center", 0, "Center", "");
 }
 
@@ -940,7 +960,7 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with
 
 
        if(obedit) {
-// XXX         ok = minmax_verts(min, max);    /* only selected */
+               ok = minmax_verts(obedit, min, max);    /* only selected */
        }
        else if(ob && (ob->flag & OB_POSEMODE)) {
                if(ob->pose) {
@@ -988,8 +1008,11 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with
        afm[0]= (max[0]-min[0]);
        afm[1]= (max[1]-min[1]);
        afm[2]= (max[2]-min[2]);
-       size= 0.7f*MAX3(afm[0], afm[1], afm[2]);
-
+       size= MAX3(afm[0], afm[1], afm[2]);
+       /* perspective should be a bit farther away to look nice */
+       if(rv3d->persp==V3D_ORTHO)
+               size*= 0.7;
+       
        if(size <= v3d->near*1.5f) size= v3d->near*1.5f;
 
        new_ofs[0]= -(min[0]+max[0])/2.0f;
@@ -1018,21 +1041,26 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with
        }
 
 // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
-       if(rv3d->viewlock)
+       if(rv3d->viewlock & RV3D_BOXVIEW)
                view3d_boxview_copy(CTX_wm_area(C), ar);
 
        return OPERATOR_FINISHED;
 }
+
 void VIEW3D_OT_viewcenter(wmOperatorType *ot)
 {
 
        /* identifiers */
        ot->name= "View center";
+       ot->description = "Move the view to the selection center.";
        ot->idname= "VIEW3D_OT_viewcenter";
 
        /* api callbacks */
        ot->exec= viewcenter_exec;
        ot->poll= ED_operator_view3d_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
 }
 
 /* ********************* Set render border operator ****************** */
@@ -1095,6 +1123,7 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Set Render Border";
+       ot->description = "Set the boundries of the border render and enables border render .";
        ot->idname= "VIEW3D_OT_render_border";
 
        /* api callbacks */
@@ -1104,6 +1133,9 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
        
        ot->poll= ED_operator_view3d_active;
        
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
        /* rna */
        RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
        RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
@@ -1243,7 +1275,7 @@ static int view3d_border_zoom_exec(bContext *C, wmOperator *op)
 
        smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
        
-       if(rv3d->viewlock)
+       if(rv3d->viewlock & RV3D_BOXVIEW)
                view3d_boxview_sync(CTX_wm_area(C), ar);
        
        return OPERATOR_FINISHED;
@@ -1260,12 +1292,13 @@ static int view3d_border_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event
                return OPERATOR_PASS_THROUGH;
 }
 
-void VIEW3D_OT_border_zoom(wmOperatorType *ot)
+void VIEW3D_OT_zoom_border(wmOperatorType *ot)
 {
        
        /* identifiers */
        ot->name= "Border Zoom";
-       ot->idname= "VIEW3D_OT_border_zoom";
+       ot->description = "Zoom in the view to the nearest object contained in the border.";
+       ot->idname= "VIEW3D_OT_zoom_border";
 
        /* api callbacks */
        ot->invoke= view3d_border_zoom_invoke;
@@ -1274,6 +1307,9 @@ void VIEW3D_OT_border_zoom(wmOperatorType *ot)
        
        ot->poll= ED_operator_view3d_active;
        
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
+       
        /* rna */
        RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
        RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
@@ -1284,23 +1320,14 @@ void VIEW3D_OT_border_zoom(wmOperatorType *ot)
 /* ********************* Changing view operator ****************** */
 
 static EnumPropertyItem prop_view_items[] = {
-       {V3D_VIEW_FRONT, "FRONT", "Front", "View From the Front"},
-       {V3D_VIEW_BACK, "BACK", "Back", "View From the Back"},
-       {V3D_VIEW_LEFT, "LEFT", "Left", "View From the Left"},
-       {V3D_VIEW_RIGHT, "RIGHT", "Right", "View From the Right"},
-       {V3D_VIEW_TOP, "TOP", "Top", "View From the Top"},
-       {V3D_VIEW_BOTTOM, "BOTTOM", "Bottom", "View From the Bottom"},
-       {V3D_VIEW_PERSPORTHO, "PERSPORTHO", "Persp-Ortho", "Switch between Perspecive and Orthographic View"},
-       {V3D_VIEW_CAMERA, "CAMERA", "Camera", "View From the active amera"},
-       {V3D_VIEW_STEPLEFT, "STEPLEFT", "Step Left", "Step the view around to the Left"},
-       {V3D_VIEW_STEPRIGHT, "STEPRIGHT", "Step Right", "Step the view around to the Right"},
-       {V3D_VIEW_STEPUP, "STEPUP", "Step Up", "Step the view Up"},
-       {V3D_VIEW_STEPDOWN, "STEPDOWN", "Step Down", "Step the view Down"},
-       {V3D_VIEW_PANLEFT, "PANLEFT", "Pan Left", "Pan the view to the Left"},
-       {V3D_VIEW_PANRIGHT, "PANRIGHT", "Pan Right", "Pan the view to the Right"},
-       {V3D_VIEW_PANUP, "PANUP", "Pan Up", "Pan the view Up"},
-       {V3D_VIEW_PANDOWN, "PANDOWN", "Pan Down", "Pan the view Down"},
-       {0, NULL, NULL, NULL}};
+       {V3D_VIEW_FRONT, "FRONT", 0, "Front", "View From the Front"},
+       {V3D_VIEW_BACK, "BACK", 0, "Back", "View From the Back"},
+       {V3D_VIEW_LEFT, "LEFT", 0, "Left", "View From the Left"},
+       {V3D_VIEW_RIGHT, "RIGHT", 0, "Right", "View From the Right"},
+       {V3D_VIEW_TOP, "TOP", 0, "Top", "View From the Top"},
+       {V3D_VIEW_BOTTOM, "BOTTOM", 0, "Bottom", "View From the Bottom"},
+       {V3D_VIEW_CAMERA, "CAMERA", 0, "Camera", "View From the active amera"},
+       {0, NULL, 0, NULL, NULL}};
 
 static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, short view, int perspo)
 {
@@ -1346,18 +1373,15 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s
 
 }
 
-
 static int viewnumpad_exec(bContext *C, wmOperator *op)
 {
-       ARegion *ar= CTX_wm_region(C);
        View3D *v3d = CTX_wm_view3d(C);
        RegionView3D *rv3d= CTX_wm_region_view3d(C);
        Scene *scene= CTX_data_scene(C);
-       float phi, si, q1[4], vec[3];
        static int perspo=V3D_PERSP;
        int viewnum;
 
-       viewnum = RNA_enum_get(op->ptr, "view");
+       viewnum = RNA_enum_get(op->ptr, "type");
 
        /* Use this to test if we started out with a camera */
 
@@ -1386,16 +1410,6 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
                        axis_set_view(C, 0.5, -0.5, -0.5, -0.5, viewnum, perspo);
                        break;
 
-               case V3D_VIEW_PERSPORTHO:
-                       if(rv3d->viewlock==0) {
-                               if(rv3d->persp!=V3D_ORTHO) 
-                                       rv3d->persp=V3D_ORTHO;
-                               else rv3d->persp=V3D_PERSP;
-
-                               ED_region_tag_redraw(ar);
-                       }
-                       break;
-
                case V3D_VIEW_CAMERA:
                        if(rv3d->viewlock==0) {
                                /* lastview -  */
@@ -1439,89 +1453,181 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
                        }
                        break;
 
-               case V3D_VIEW_STEPLEFT:
-               case V3D_VIEW_STEPRIGHT:
-               case V3D_VIEW_STEPUP:
-               case V3D_VIEW_STEPDOWN:
-                       if(rv3d->viewlock==0) {
-
-                               if(rv3d->persp != V3D_CAMOB) {
-                                       if(viewnum == V3D_VIEW_STEPLEFT || viewnum == V3D_VIEW_STEPRIGHT) {
-                                               /* z-axis */
-                                               phi= (float)(M_PI/360.0)*U.pad_rot_angle;
-                                               if(viewnum == V3D_VIEW_STEPRIGHT) phi= -phi;
-                                               si= (float)sin(phi);
-                                               q1[0]= (float)cos(phi);
-                                               q1[1]= q1[2]= 0.0;
-                                               q1[3]= si;
-                                               QuatMul(rv3d->viewquat, rv3d->viewquat, q1);
-                                               rv3d->view= 0;
-                                       }
-                                       if(viewnum == V3D_VIEW_STEPDOWN || viewnum == V3D_VIEW_STEPUP) {
-                                               /* horizontal axis */
-                                               VECCOPY(q1+1, rv3d->viewinv[0]);
-
-                                               Normalize(q1+1);
-                                               phi= (float)(M_PI/360.0)*U.pad_rot_angle;
-                                               if(viewnum == V3D_VIEW_STEPDOWN) phi= -phi;
-                                               si= (float)sin(phi);
-                                               q1[0]= (float)cos(phi);
-                                               q1[1]*= si;
-                                               q1[2]*= si;
-                                               q1[3]*= si;
-                                               QuatMul(rv3d->viewquat, rv3d->viewquat, q1);
-                                               rv3d->view= 0;
-                                       }
-                                       ED_region_tag_redraw(ar);
-                               }
-                       }
+               default :
                        break;
+       }
 
-               case V3D_VIEW_PANRIGHT:
-               case V3D_VIEW_PANLEFT:
-               case V3D_VIEW_PANUP:
-               case V3D_VIEW_PANDOWN:
+       if(rv3d->persp != V3D_CAMOB) perspo= rv3d->persp;
 
-                       initgrabz(rv3d, 0.0, 0.0, 0.0);
+       return OPERATOR_FINISHED;
+}
+void VIEW3D_OT_viewnumpad(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "View numpad";
+       ot->description = "Set the view.";
+       ot->idname= "VIEW3D_OT_viewnumpad";
 
-                       if(viewnum == V3D_VIEW_PANRIGHT) window_to_3d_delta(ar, vec, -32, 0);
-                       else if(viewnum == V3D_VIEW_PANLEFT) window_to_3d_delta(ar, vec, 32, 0);
-                       else if(viewnum == V3D_VIEW_PANUP) window_to_3d_delta(ar, vec, 0, -25);
-                       else if(viewnum == V3D_VIEW_PANDOWN) window_to_3d_delta(ar, vec, 0, 25);
-                       rv3d->ofs[0]+= vec[0];
-                       rv3d->ofs[1]+= vec[1];
-                       rv3d->ofs[2]+= vec[2];
+       /* api callbacks */
+       ot->exec= viewnumpad_exec;
+       ot->poll= ED_operator_view3d_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
+       
+       RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "The Type of view");
+}
 
-                       if(rv3d->viewlock)
-                               view3d_boxview_sync(CTX_wm_area(C), ar);
+static EnumPropertyItem prop_view_orbit_items[] = {
+       {V3D_VIEW_STEPLEFT, "ORBITLEFT", 0, "Orbit Left", "Orbit the view around to the Left"},
+       {V3D_VIEW_STEPRIGHT, "ORBITRIGHT", 0, "Orbit Right", "Orbit the view around to the Right"},
+       {V3D_VIEW_STEPUP, "ORBITUP", 0, "Orbit Up", "Orbit the view Up"},
+       {V3D_VIEW_STEPDOWN, "ORBITDOWN", 0, "Orbit Down", "Orbit the view Down"},
+       {0, NULL, 0, NULL, NULL}};
 
-                       ED_region_tag_redraw(ar);
-                       break;
+static int vieworbit_exec(bContext *C, wmOperator *op)
+{
+       ARegion *ar= CTX_wm_region(C);
+       RegionView3D *rv3d= CTX_wm_region_view3d(C);
+       float phi, si, q1[4];           
+       int orbitdir;
 
-               default :
-                       break;
+       orbitdir = RNA_enum_get(op->ptr, "type");
+       
+       if(rv3d->viewlock==0) {
+
+               if(rv3d->persp != V3D_CAMOB) {
+                       if(orbitdir == V3D_VIEW_STEPLEFT || orbitdir == V3D_VIEW_STEPRIGHT) {
+                               /* z-axis */
+                               phi= (float)(M_PI/360.0)*U.pad_rot_angle;
+                               if(orbitdir == V3D_VIEW_STEPRIGHT) phi= -phi;
+                               si= (float)sin(phi);
+                               q1[0]= (float)cos(phi);
+                               q1[1]= q1[2]= 0.0;
+                               q1[3]= si;
+                               QuatMul(rv3d->viewquat, rv3d->viewquat, q1);
+                               rv3d->view= 0;
+                       }
+                       if(orbitdir == V3D_VIEW_STEPDOWN || orbitdir == V3D_VIEW_STEPUP) {
+                               /* horizontal axis */
+                               VECCOPY(q1+1, rv3d->viewinv[0]);
+
+                               Normalize(q1+1);
+                               phi= (float)(M_PI/360.0)*U.pad_rot_angle;
+                               if(orbitdir == V3D_VIEW_STEPDOWN) phi= -phi;
+                               si= (float)sin(phi);
+                               q1[0]= (float)cos(phi);
+                               q1[1]*= si;
+                               q1[2]*= si;
+                               q1[3]*= si;
+                               QuatMul(rv3d->viewquat, rv3d->viewquat, q1);
+                               rv3d->view= 0;
+                       }
+                       ED_region_tag_redraw(ar);
+               }
        }
 
-       if(rv3d->persp != V3D_CAMOB) perspo= rv3d->persp;
+       return OPERATOR_FINISHED;       
+}
 
-       return OPERATOR_FINISHED;
+void VIEW3D_OT_view_orbit(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "View Orbit";
+       ot->description = "Orbit the view.";
+       ot->idname= "VIEW3D_OT_view_orbit";
+
+       /* api callbacks */
+       ot->exec= vieworbit_exec;
+       ot->poll= ED_operator_view3d_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
+       RNA_def_enum(ot->srna, "type", prop_view_orbit_items, 0, "Orbit", "Direction of View Orbit");
 }
 
+static EnumPropertyItem prop_view_pan_items[] = {
+       {V3D_VIEW_PANLEFT, "PANLEFT", 0, "Pan Left", "Pan the view to the Left"},
+       {V3D_VIEW_PANRIGHT, "PANRIGHT", 0, "Pan Right", "Pan the view to the Right"},
+       {V3D_VIEW_PANUP, "PANUP", 0, "Pan Up", "Pan the view Up"},
+       {V3D_VIEW_PANDOWN, "PANDOWN", 0, "Pan Down", "Pan the view Down"},
+       {0, NULL, 0, NULL, NULL}};
 
-void VIEW3D_OT_viewnumpad(wmOperatorType *ot)
+static int viewpan_exec(bContext *C, wmOperator *op)
+{
+       ARegion *ar= CTX_wm_region(C);
+       RegionView3D *rv3d= CTX_wm_region_view3d(C);    
+       float vec[3];   
+       int pandir;
+
+       pandir = RNA_enum_get(op->ptr, "type");
+       
+       initgrabz(rv3d, 0.0, 0.0, 0.0);
+
+       if(pandir == V3D_VIEW_PANRIGHT) window_to_3d_delta(ar, vec, -32, 0);
+       else if(pandir == V3D_VIEW_PANLEFT) window_to_3d_delta(ar, vec, 32, 0);
+       else if(pandir == V3D_VIEW_PANUP) window_to_3d_delta(ar, vec, 0, -25);
+       else if(pandir == V3D_VIEW_PANDOWN) window_to_3d_delta(ar, vec, 0, 25);
+       rv3d->ofs[0]+= vec[0];
+       rv3d->ofs[1]+= vec[1];
+       rv3d->ofs[2]+= vec[2];
+
+       if(rv3d->viewlock & RV3D_BOXVIEW)
+               view3d_boxview_sync(CTX_wm_area(C), ar);
+
+       ED_region_tag_redraw(ar);
+
+       return OPERATOR_FINISHED;       
+}
+
+void VIEW3D_OT_view_pan(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "View numpad";
-       ot->idname= "VIEW3D_OT_viewnumpad";
+       ot->name= "View Pan";
+       ot->description = "Pan the view.";
+       ot->idname= "VIEW3D_OT_view_pan";
 
        /* api callbacks */
-       ot->exec= viewnumpad_exec;
+       ot->exec= viewpan_exec;
        ot->poll= ED_operator_view3d_active;
+       
+       /* flags */
        ot->flag= OPTYPE_REGISTER;
+       RNA_def_enum(ot->srna, "type", prop_view_pan_items, 0, "Pan", "Direction of View Pan");
+}
+
+static int viewpersportho_exec(bContext *C, wmOperator *op)
+{
+       ARegion *ar= CTX_wm_region(C);
+       RegionView3D *rv3d= CTX_wm_region_view3d(C);    
+       
+       if(rv3d->viewlock==0) {
+               if(rv3d->persp!=V3D_ORTHO) 
+                       rv3d->persp=V3D_ORTHO;
+               else rv3d->persp=V3D_PERSP;
+               ED_region_tag_redraw(ar);
+       }
 
-       RNA_def_enum(ot->srna, "view", prop_view_items, 0, "View", "");
+       return OPERATOR_FINISHED;
+       
 }
 
+void VIEW3D_OT_view_persportho(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "View persp/ortho";
+       ot->description = "Switch the current view from perspective/orthographic.";
+       ot->idname= "VIEW3D_OT_view_persportho";
+
+       /* api callbacks */
+       ot->exec= viewpersportho_exec;
+       ot->poll= ED_operator_view3d_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
+}
+
+
 /* ********************* set clipping operator ****************** */
 
 static int view3d_clipping_exec(bContext *C, wmOperator *op)
@@ -1608,7 +1714,8 @@ void VIEW3D_OT_clipping(wmOperatorType *ot)
 {
 
        /* identifiers */
-       ot->name= "Border Select";
+       ot->name= "Clipping Border";
+       ot->description = "Set the view clipping border.";
        ot->idname= "VIEW3D_OT_clipping";
 
        /* api callbacks */
@@ -1617,7 +1724,10 @@ void VIEW3D_OT_clipping(wmOperatorType *ot)
        ot->modal= WM_border_select_modal;
 
        ot->poll= ED_operator_view3d_active;
-
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
+       
        /* rna */
        RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
        RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
@@ -1659,6 +1769,7 @@ void VIEW3D_OT_drawtype(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Change draw type";
+       ot->description = "Change the draw type of the view.";
        ot->idname= "VIEW3D_OT_drawtype";
 
        /* api callbacks */
@@ -1666,7 +1777,10 @@ void VIEW3D_OT_drawtype(wmOperatorType *ot)
        ot->exec= view3d_drawtype_exec;
 
        ot->poll= ED_operator_view3d_active;
-
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER;
+       
        /* rna XXX should become enum */
        RNA_def_int(ot->srna, "draw_type", 0, INT_MIN, INT_MAX, "Draw Type", "", INT_MIN, INT_MAX);
        RNA_def_int(ot->srna, "draw_type_alternate", -1, INT_MIN, INT_MAX, "Draw Type Alternate", "", INT_MIN, INT_MAX);
@@ -1721,7 +1835,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
 //             VECCOPY(fp, oldcurs);
 //     }
        // XXX notifier for scene */
-       ED_region_tag_redraw(ar);
+       ED_area_tag_redraw(CTX_wm_area(C));
        
        /* prevent other mouse ops to fail */
        return OPERATOR_PASS_THROUGH;
@@ -1732,6 +1846,7 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Set 3D Cursor";
+       ot->description = "Set the location of the 3D cursor.";
        ot->idname= "VIEW3D_OT_cursor3d";
        
        /* api callbacks */