[Bf-blender-cvs] [9466f8f5315] master: Cleanup: use doxygen groups for view3d_edit.c

Campbell Barton noreply at git.blender.org
Tue Jan 23 09:41:50 CET 2018


Commit: 9466f8f53150659c8aed6cced7f66b11a794a4a4
Author: Campbell Barton
Date:   Tue Jan 23 19:48:49 2018 +1100
Branches: master
https://developer.blender.org/rB9466f8f53150659c8aed6cced7f66b11a794a4a4

Cleanup: use doxygen groups for view3d_edit.c

===================================================================

M	source/blender/editors/space_view3d/view3d_edit.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 5203e0617ee..c401b6618f2 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -26,6 +26,8 @@
 
 /** \file blender/editors/space_view3d/view3d_edit.c
  *  \ingroup spview3d
+ *
+ * 3D view manipulation/operators.
  */
 
 #include <string.h>
@@ -87,12 +89,66 @@
 
 static bool view3d_ensure_persp(struct View3D *v3d, ARegion *ar);
 
+/* -------------------------------------------------------------------- */
+/** \name View Utilities
+ *
+ * Lock the camera to the view-port, allowing view manipulation to transform the camera.
+ * \{ */
+
+/**
+ * Use to store the last view, before entering camera view.
+ */
+void ED_view3d_lastview_store(RegionView3D *rv3d)
+{
+	copy_qt_qt(rv3d->lviewquat, rv3d->viewquat);
+	rv3d->lview = rv3d->view;
+	if (rv3d->persp != RV3D_CAMOB) {
+		rv3d->lpersp = rv3d->persp;
+	}
+}
+
+void ED_view3D_lock_clear(View3D *v3d)
+{
+	v3d->ob_centre = NULL;
+	v3d->ob_centre_bone[0] = '\0';
+	v3d->ob_centre_cursor = false;
+	v3d->flag2 &= ~V3D_LOCK_CAMERA;
+}
+
 bool ED_view3d_offset_lock_check(const  View3D *v3d, const  RegionView3D *rv3d)
 {
 	return (rv3d->persp != RV3D_CAMOB) && (v3d->ob_centre_cursor || v3d->ob_centre);
 }
 
-/* ********************** view3d_edit: view manipulations ********************* */
+/**
+ * For viewport operators that exit camera persp.
+ *
+ * \note This differs from simply setting ``rv3d->persp = persp`` because it
+ * sets the ``ofs`` and ``dist`` values of the viewport so it matches the camera,
+ * otherwise switching out of camera view may jump to a different part of the scene.
+ */
+static void view3d_persp_switch_from_camera(View3D *v3d, RegionView3D *rv3d, const char persp)
+{
+	BLI_assert(rv3d->persp == RV3D_CAMOB);
+	BLI_assert(persp != RV3D_CAMOB);
+
+	if (v3d->camera) {
+		rv3d->dist = ED_view3d_offset_distance(v3d->camera->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK);
+		ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
+	}
+
+	if (!ED_view3d_camera_lock_check(v3d, rv3d)) {
+		rv3d->persp = persp;
+	}
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Camera Lock API
+ *
+ * Lock the camera to the view-port, allowing view manipulation to transform the camera.
+ * \{ */
 
 /**
  * \return true when the view-port is locked to its camera.
@@ -253,29 +309,13 @@ bool ED_view3d_camera_lock_autokey(
 	}
 }
 
-/**
- * For viewport operators that exit camera persp.
- *
- * \note This differs from simply setting ``rv3d->persp = persp`` because it
- * sets the ``ofs`` and ``dist`` values of the viewport so it matches the camera,
- * otherwise switching out of camera view may jump to a different part of the scene.
- */
-static void view3d_persp_switch_from_camera(View3D *v3d, RegionView3D *rv3d, const char persp)
-{
-	BLI_assert(rv3d->persp == RV3D_CAMOB);
-	BLI_assert(persp != RV3D_CAMOB);
-
-	if (v3d->camera) {
-		rv3d->dist = ED_view3d_offset_distance(v3d->camera->obmat, rv3d->ofs, VIEW3D_DIST_FALLBACK);
-		ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
-	}
-
-	if (!ED_view3d_camera_lock_check(v3d, rv3d)) {
-		rv3d->persp = persp;
-	}
-}
+/** \} */
 
-/* ********************* box view support ***************** */
+/* -------------------------------------------------------------------- */
+/** \name Box View Support
+ *
+ * Use with quad-split so each view is clipped by the bounds of each view axis.
+ * \{ */
 
 static void view3d_boxview_clip(ScrArea *sa)
 {
@@ -518,7 +558,11 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, bool do_clip)
 	ED_area_tag_redraw(sa);
 }
 
-/* ************************** init for view ops **********************************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Generic View Operator Custom-Data
+ * \{ */
 
 typedef struct ViewOpsData {
 	/* context pointers (assigned by viewops_data_alloc) */
@@ -577,13 +621,6 @@ static void calctrackballvec(const rcti *rect, int mx, int my, float vec[3])
 	vec[2] = -z;     /* yah yah! */
 }
 
-
-/* -------------------------------------------------------------------- */
-/* ViewOpsData */
-
-/** \name Generic View Operator Custom-Data.
- * \{ */
-
 /**
  * Allocate and fill in context pointers for #ViewOpsData
  */
@@ -886,10 +923,12 @@ static void viewops_data_free(bContext *C, wmOperator *op)
 	if (p && (p->flags & PAINT_FAST_NAVIGATE))
 		ED_region_tag_redraw(ar);
 }
-/** \} */
 
+/** \} */
 
-/* ************************** viewrotate **********************************/
+/* -------------------------------------------------------------------- */
+/** \name View Rotate
+ * \{ */
 
 enum {
 	VIEW_PASS = 0,
@@ -898,12 +937,14 @@ enum {
 };
 
 /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
-#define VIEW_MODAL_CONFIRM              1 /* used for all view operations */
-#define VIEWROT_MODAL_AXIS_SNAP_ENABLE  2
-#define VIEWROT_MODAL_AXIS_SNAP_DISABLE 3
-#define VIEWROT_MODAL_SWITCH_ZOOM       4
-#define VIEWROT_MODAL_SWITCH_MOVE       5
-#define VIEWROT_MODAL_SWITCH_ROTATE     6
+enum {
+	VIEW_MODAL_CONFIRM              = 1, /* used for all view operations */
+	VIEWROT_MODAL_AXIS_SNAP_ENABLE  = 2,
+	VIEWROT_MODAL_AXIS_SNAP_DISABLE = 3,
+	VIEWROT_MODAL_SWITCH_ZOOM       = 4,
+	VIEWROT_MODAL_SWITCH_MOVE       = 5,
+	VIEWROT_MODAL_SWITCH_ROTATE     = 6,
+};
 
 /* called in transform_ops.c, on each regeneration of keymaps  */
 void viewrotate_modal_keymap(wmKeyConfig *keyconf)
@@ -1353,11 +1394,13 @@ void VIEW3D_OT_rotate(wmOperatorType *ot)
 	ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR;
 }
 
-#ifdef WITH_INPUT_NDOF
+/** \} */
 
+/* -------------------------------------------------------------------- */
 /** \name NDOF Utility Functions
  * \{ */
 
+#ifdef WITH_INPUT_NDOF
 #define NDOF_HAS_TRANSLATE ((!ED_view3d_offset_lock_check(v3d, rv3d)) && !is_zero_v3(ndof->tvec))
 #define NDOF_HAS_ROTATE    (((rv3d->viewlock & RV3D_LOCKED) == 0) && !is_zero_v3(ndof->rvec))
 
@@ -1407,8 +1450,9 @@ static float view3d_ndof_pan_speed_calc(RegionView3D *rv3d)
  *
  * \param has_zoom zoom, otherwise dolly, often `!rv3d->is_persp` since it doesnt make sense to dolly in ortho.
  */
-static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof, ScrArea *sa, ARegion *ar,
-                                 const bool has_translate, const bool has_zoom)
+static void view3d_ndof_pan_zoom(
+        const struct wmNDOFMotionData *ndof, ScrArea *sa, ARegion *ar,
+        const bool has_translate, const bool has_zoom)
 {
 	RegionView3D *rv3d = ar->regiondata;
 	float view_inv[4];
@@ -1469,9 +1513,10 @@ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof, ScrArea *s
 }
 
 
-static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof, ScrArea *sa, ARegion *ar,
-                              /* optional, can be NULL*/
-                              ViewOpsData *vod)
+static void view3d_ndof_orbit(
+        const struct wmNDOFMotionData *ndof, ScrArea *sa, ARegion *ar,
+        /* optional, can be NULL*/
+        ViewOpsData *vod)
 {
 	View3D *v3d = sa->spacedata.first;
 	RegionView3D *rv3d = ar->regiondata;
@@ -1656,11 +1701,14 @@ void view3d_ndof_fly(
 
 /** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name NDOF Operators
+ *
+ * - "orbit" navigation (trackball/turntable)
+ * - zooming
+ * - panning in rotationally-locked views
+ * \{ */
 
-/* -- "orbit" navigation (trackball/turntable)
- * -- zooming
- * -- panning in rotationally-locked views
- */
 static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
 	
@@ -1924,8 +1972,11 @@ void VIEW3D_OT_ndof_all(struct wmOperatorType *ot)
 
 #endif /* WITH_INPUT_NDOF */
 
-/* ************************ viewmove ******************************** */
+/** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name View Move (Pan) Operator
+ * \{ */
 
 /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
 
@@ -2105,7 +2156,11 @@ void VIEW3D_OT_move(wmOperatorType *ot)
 	ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR;
 }
 
-/* ************************ viewzoom ******************************** */
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name View Zoom Operator
+ * \{ */
 
 /* viewdolly_modal_keymap has an exact copy of this, apply fixes to both */
 /* called in transform_ops.c, on each regeneration of keymaps  */
@@ -2499,41 +2554,6 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
 	return OPERATOR_FINISHED;
 }
 
-/* this is an exact copy of viewzoom_modal_keymap */
-/* called in transform_ops.c, on each regeneration of keymaps  */
-void viewdolly_modal_keymap(wmKeyConfig *keyconf)
-{
-	static const EnumPropertyItem modal_items[] = {
-		{VIEW_MODAL_CONFIRM,    "CONFIRM", 0, "Confirm", ""},
-
-		{VIEWROT_MODAL_SWITCH_ROTATE, "SWITCH_TO_ROTATE", 0, "Switch to Rotate"},
-		{VIEWROT_MODAL_SWITCH_MOVE, "SWITCH_TO_MOVE", 0, "Switch to Move"},
-
-		{0, NULL, 0, NULL, NULL}
-	};
-
-	wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Dolly Modal");
-
-	/* this function is called for each spacetype, only needs to add map once */
-	if (keymap && keymap->modal_items) return;
-
-	keymap = WM_modalkeymap_add(keyconf, "View3D Dolly Modal", modal_items);
-
-	/* items for modal map */
-	WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM);
-	WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, VIEW_MODAL_CONFIRM);
-
-	/* disabled mode switching for now, can re-implement better, later on */
-#if 0
-	WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE);
-	WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_SWITCH_ROTATE);
-	WM_modalkeymap_add_item(keymap, LEFTSHIFTKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_SWITCH_MOVE);
-#endif
-	
-	/* assign map to operators */
-	WM_modalkeymap_assign

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list