batch remove .'s used with RNA_def_struct_ui_text
[blender.git] / source / blender / editors / space_view3d / view3d_snap.c
index 933b12ae679b1f24fcc77cfb659cbfd2cfa789a4..807e0790e7982bfdbb51d77c130e81a6eeb7dc43 100644 (file)
@@ -440,12 +440,12 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
        extern float originmat[3][3];   /* XXX object.c */
        Object *obedit= CTX_data_edit_object(C);
        Scene *scene= CTX_data_scene(C);
-       View3D *v3d= CTX_wm_view3d(C);
+       RegionView3D *rv3d= CTX_wm_region_data(C);
        TransVert *tv;
        float gridf, imat[3][3], bmat[3][3], vec[3];
        int a;
 
-       gridf= v3d->gridview;
+       gridf= rv3d->gridview;
 
        if(obedit) {
                tottrans= 0;
@@ -463,9 +463,9 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
                        VECCOPY(vec, tv->loc);
                        mul_m3_v3(bmat, vec);
                        add_v3_v3v3(vec, vec, obedit->obmat[3]);
-                       vec[0]= v3d->gridview*floor(.5+ vec[0]/gridf);
-                       vec[1]= v3d->gridview*floor(.5+ vec[1]/gridf);
-                       vec[2]= v3d->gridview*floor(.5+ vec[2]/gridf);
+                       vec[0]= gridf*floor(.5+ vec[0]/gridf);
+                       vec[1]= gridf*floor(.5+ vec[1]/gridf);
+                       vec[2]= gridf*floor(.5+ vec[2]/gridf);
                        sub_v3_v3v3(vec, vec, obedit->obmat[3]);
                        
                        mul_m3_v3(imat, vec);
@@ -518,9 +518,9 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
                        else {
                                ob->recalc |= OB_RECALC_OB;
                                
-                               vec[0]= -ob->obmat[3][0]+v3d->gridview*floor(.5+ ob->obmat[3][0]/gridf);
-                               vec[1]= -ob->obmat[3][1]+v3d->gridview*floor(.5+ ob->obmat[3][1]/gridf);
-                               vec[2]= -ob->obmat[3][2]+v3d->gridview*floor(.5+ ob->obmat[3][2]/gridf);
+                               vec[0]= -ob->obmat[3][0]+gridf*floor(.5+ ob->obmat[3][0]/gridf);
+                               vec[1]= -ob->obmat[3][1]+gridf*floor(.5+ ob->obmat[3][1]/gridf);
+                               vec[2]= -ob->obmat[3][2]+gridf*floor(.5+ ob->obmat[3][2]/gridf);
                                
                                if(ob->parent) {
                                        where_is_object(scene, ob);
@@ -543,7 +543,8 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op)
                }
                CTX_DATA_END;
        }
-       ED_anim_dag_flush_update(C);
+
+       DAG_ids_flush_update(0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
        return OPERATOR_FINISHED;
@@ -554,7 +555,7 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Selection to Grid";
-       ot->description= "Snap selected item(s) to nearest grid node.";
+       ot->description= "Snap selected item(s) to nearest grid node";
        ot->idname= "VIEW3D_OT_snap_selected_to_grid";
        
        /* api callbacks */
@@ -667,7 +668,8 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op)
                }
                CTX_DATA_END;
        }
-       ED_anim_dag_flush_update(C);
+
+       DAG_ids_flush_update(0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
        return OPERATOR_FINISHED;
@@ -678,7 +680,7 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Selection to Cursor";
-       ot->description= "Snap selected item(s) to cursor.";
+       ot->description= "Snap selected item(s) to cursor";
        ot->idname= "VIEW3D_OT_snap_selected_to_cursor";
        
        /* api callbacks */
@@ -694,17 +696,18 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
 static int snap_curs_to_grid(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
+       RegionView3D *rv3d= CTX_wm_region_data(C);
        View3D *v3d= CTX_wm_view3d(C);
        float gridf, *curs;
 
-       gridf= v3d->gridview;
+       gridf= rv3d->gridview;
        curs= give_cursor(scene, v3d);
 
-       curs[0]= v3d->gridview*floor(.5+curs[0]/gridf);
-       curs[1]= v3d->gridview*floor(.5+curs[1]/gridf);
-       curs[2]= v3d->gridview*floor(.5+curs[2]/gridf);
+       curs[0]= gridf*floor(.5+curs[0]/gridf);
+       curs[1]= gridf*floor(.5+curs[1]/gridf);
+       curs[2]= gridf*floor(.5+curs[2]/gridf);
        
-       WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, scene); // hrm
+       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);        // hrm
        
        return OPERATOR_FINISHED;
 }
@@ -714,7 +717,7 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Cursor to Grid";
-       ot->description= "Snap cursor to nearest grid node.";
+       ot->description= "Snap cursor to nearest grid node";
        ot->idname= "VIEW3D_OT_snap_cursor_to_grid";
        
        /* api callbacks */
@@ -811,7 +814,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op)
                        }
                }
        }
-       WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, scene); // hrm
+       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);
        
        return OPERATOR_FINISHED;
 }
@@ -821,7 +824,7 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Cursor to Selected";
-       ot->description= "Snap cursor to center of selected item(s)."; 
+       ot->description= "Snap cursor to center of selected item(s)"; 
        ot->idname= "VIEW3D_OT_snap_cursor_to_selected";
        
        /* api callbacks */
@@ -863,7 +866,7 @@ static int snap_curs_to_active(bContext *C, wmOperator *op)
                }
        }
        
-       WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, scene);
+       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);
        return OPERATOR_FINISHED;
 }
 
@@ -872,7 +875,7 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Cursor to Active";
-       ot->description= "Snap cursor to active item.";
+       ot->description= "Snap cursor to active item";
        ot->idname= "VIEW3D_OT_snap_cursor_to_active";
        
        /* api callbacks */
@@ -1058,7 +1061,7 @@ static int snap_selected_to_center(bContext *C, wmOperator *op)
                CTX_DATA_END;
        }
        
-       ED_anim_dag_flush_update(C);
+       DAG_ids_flush_update(0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
        return OPERATOR_FINISHED;
@@ -1069,7 +1072,7 @@ void VIEW3D_OT_snap_selected_to_center(wmOperatorType *ot)
        
        /* identifiers */
        ot->name= "Snap Selection to Center";
-       ot->description= "Snap selected items to selections geometric center.";
+       ot->description= "Snap selected items to selections geometric center";
        ot->idname= "VIEW3D_OT_snap_selected_to_center";
        
        /* api callbacks */
@@ -1081,6 +1084,43 @@ void VIEW3D_OT_snap_selected_to_center(wmOperatorType *ot)
 }
 
 
+/* **************************************************** */
+/*New Code - Snap Cursor to Center -*/
+static int snap_curs_to_center(bContext *C, wmOperator *op)
+{
+    Scene *scene= CTX_data_scene(C);
+    View3D *v3d= CTX_wm_view3d(C);
+    float *curs;
+    curs= give_cursor(scene, v3d);
+
+    curs[0]= 0.0;
+    curs[1]= 0.0;
+    curs[2]= 0.0;
+       
+    WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d);
+       
+    return OPERATOR_FINISHED;
+}
+
+void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot)
+{
+       
+       /* identifiers */
+       ot->name= "Snap Cursor to Center";
+       ot->description= "Snap cursor to the Center";
+       ot->idname= "VIEW3D_OT_snap_cursor_to_center";
+       
+    /* api callbacks */ 
+    ot->exec= snap_curs_to_center;
+       ot->poll= ED_operator_view3d_active;
+       
+    /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* **************************************************** */
+
+
 int minmax_verts(Object *obedit, float *min, float *max)
 {
        TransVert *tv;
@@ -1110,42 +1150,3 @@ int minmax_verts(Object *obedit, float *min, float *max)
        return 1;
 }
 
-/* ************************************************* */
-
-static int snap_menu_invoke(bContext *C, wmOperator *unused, wmEvent *event)
-{
-       uiPopupMenu *pup= uiPupMenuBegin(C, "Snap", 0);
-       uiLayout *layout= uiPupMenuLayout(pup);
-       
-       uiItemO(layout, "Selected to Grid", 0, "VIEW3D_OT_snap_selected_to_grid");
-       uiItemO(layout, "Selected to Cursor", 0, "VIEW3D_OT_snap_selected_to_cursor");
-       uiItemO(layout, "Selected to Center", 0, "VIEW3D_OT_snap_selected_to_center");
-       uiItemS(layout);
-       uiItemO(layout, "Cursor to Selected", 0, "VIEW3D_OT_snap_cursor_to_selected");
-       uiItemO(layout, "Cursor to Grid", 0, "VIEW3D_OT_snap_cursor_to_grid");
-       uiItemO(layout, "Cursor to Active", 0, "VIEW3D_OT_snap_cursor_to_active");
-       
-       uiPupMenuEnd(C, pup);
-       
-       /* this operator is only for a menu, not used further */
-       return OPERATOR_CANCELLED;
-}
-
-/* only used as menu */
-void VIEW3D_OT_snap_menu(wmOperatorType *ot)
-{
-       /* identifiers */
-       ot->name= "Snap Menu";
-       ot->description= "Display snap menu.";
-       ot->idname= "VIEW3D_OT_snap_menu";
-       
-       /* api callbacks */
-       ot->invoke= snap_menu_invoke;
-       
-       ot->poll= ED_operator_view3d_active;
-       
-       /* flags */
-       ot->flag= 0;
-}
-
-