diff options
author | Martin Poirier <theeth@yahoo.com> | 2010-01-14 01:17:56 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2010-01-14 01:17:56 +0300 |
commit | 0befa75009a7924aca838cf893c57caca33ba73a (patch) | |
tree | cbb66e7f79e7047c410749dc2e713b0e1b19f499 /source | |
parent | 9bcfcfb8730e2f0d2ae0d988227fb5891640da00 (diff) |
[#20583] Snap Cursor to Center and more View edits
Patches by Jonathan Smith (jaydez)
Add a Cursor Center entry in the snap menu (Shift-S) to reset the cursor to 0,0,0. Also rename the view_center operator to view_selected to reflect better what it does (in the code only, description and name were already ok).
Diffstat (limited to 'source')
4 files changed, 47 insertions, 7 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 288918c3c1e..9bb7d35f96d 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1286,7 +1286,7 @@ void VIEW3D_OT_view_all(wmOperatorType *ot) RNA_def_boolean(ot->srna, "center", 0, "Center", ""); } -static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview without local!, was centerview() in 2.4x */ +static int viewselected_exec(bContext *C, wmOperator *op) /* like a localview without local!, was centerview() in 2.4x */ { ARegion *ar= CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); @@ -1403,16 +1403,16 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with return OPERATOR_FINISHED; } -void VIEW3D_OT_view_center(wmOperatorType *ot) +void VIEW3D_OT_view_selected(wmOperatorType *ot) { /* identifiers */ ot->name= "View Selected"; ot->description = "Move the view to the selection center."; - ot->idname= "VIEW3D_OT_view_center"; + ot->idname= "VIEW3D_OT_view_selected"; /* api callbacks */ - ot->exec= viewcenter_exec; + ot->exec= viewselected_exec; ot->poll= ED_operator_view3d_active; /* flags */ diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index f6d77b1b63d..7d2f6294041 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -73,7 +73,7 @@ void VIEW3D_OT_move(struct wmOperatorType *ot); void VIEW3D_OT_rotate(struct wmOperatorType *ot); void VIEW3D_OT_view_all(struct wmOperatorType *ot); void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot); -void VIEW3D_OT_view_center(struct wmOperatorType *ot); +void VIEW3D_OT_view_selected(struct wmOperatorType *ot); void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot); void VIEW3D_OT_view_pan(struct wmOperatorType *ot); void VIEW3D_OT_view_persportho(struct wmOperatorType *ot); @@ -172,6 +172,7 @@ void VIEW3D_OT_snap_selected_to_grid(struct wmOperatorType *ot); void VIEW3D_OT_snap_selected_to_cursor(struct wmOperatorType *ot); void VIEW3D_OT_snap_selected_to_center(struct wmOperatorType *ot); void VIEW3D_OT_snap_cursor_to_grid(struct wmOperatorType *ot); +void VIEW3D_OT_snap_cursor_to_center(struct wmOperatorType *ot); void VIEW3D_OT_snap_cursor_to_selected(struct wmOperatorType *ot); void VIEW3D_OT_snap_cursor_to_active(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index ea9441ec648..9c0c50790fa 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -70,7 +70,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_view_orbit); WM_operatortype_append(VIEW3D_OT_view_pan); WM_operatortype_append(VIEW3D_OT_view_persportho); - WM_operatortype_append(VIEW3D_OT_view_center); + WM_operatortype_append(VIEW3D_OT_view_selected); WM_operatortype_append(VIEW3D_OT_view_center_cursor); WM_operatortype_append(VIEW3D_OT_select); WM_operatortype_append(VIEW3D_OT_select_border); @@ -96,6 +96,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor); WM_operatortype_append(VIEW3D_OT_snap_selected_to_center); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_grid); + WM_operatortype_append(VIEW3D_OT_snap_cursor_to_center); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected); WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active); @@ -126,7 +127,7 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center", PADPERIOD, KM_PRESS, 0, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_fly", FKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index b56a853d5b7..66d2fe1ef7b 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -1084,6 +1084,44 @@ 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); + RegionView3D *rv3d= CTX_wm_region_data(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_SCENE|ND_TRANSFORM, scene); // hrm + + 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; |