Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_navigate.h')
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate.h282
1 files changed, 282 insertions, 0 deletions
diff --git a/source/blender/editors/space_view3d/view3d_navigate.h b/source/blender/editors/space_view3d/view3d_navigate.h
new file mode 100644
index 00000000000..792d2a83bc2
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_navigate.h
@@ -0,0 +1,282 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup spview3d
+ */
+
+#pragma once
+
+/**
+ * Size of the sphere being dragged for trackball rotation within the view bounds.
+ * also affects speed (smaller is faster).
+ */
+#define V3D_OP_TRACKBALLSIZE (1.1f)
+
+struct ARegion;
+struct bContext;
+struct Depsgraph;
+struct Dial;
+struct Main;
+struct rcti;
+struct RegionView3D;
+struct Scene;
+struct ScrArea;
+struct View3D;
+struct wmEvent;
+struct wmOperator;
+
+enum eV3D_OpPropFlag {
+ V3D_OP_PROP_MOUSE_CO = (1 << 0),
+ V3D_OP_PROP_DELTA = (1 << 1),
+ V3D_OP_PROP_USE_ALL_REGIONS = (1 << 2),
+ V3D_OP_PROP_USE_MOUSE_INIT = (1 << 3),
+};
+
+enum {
+ VIEW_PASS = 0,
+ VIEW_APPLY,
+ VIEW_CONFIRM,
+};
+
+/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
+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,
+};
+
+enum eViewOpsFlag {
+ /** When enabled, rotate around the selection. */
+ VIEWOPS_FLAG_ORBIT_SELECT = (1 << 0),
+ /** When enabled, use the depth under the cursor for navigation. */
+ VIEWOPS_FLAG_DEPTH_NAVIGATE = (1 << 1),
+ /**
+ * When enabled run #ED_view3d_persp_ensure this may switch out of camera view
+ * when orbiting or switch from orthographic to perspective when auto-perspective is enabled.
+ * Some operations don't require this (view zoom/pan or NDOF where subtle rotation is common
+ * so we don't want it to trigger auto-perspective). */
+ VIEWOPS_FLAG_PERSP_ENSURE = (1 << 2),
+ /** When set, ignore any options that depend on initial cursor location. */
+ VIEWOPS_FLAG_USE_MOUSE_INIT = (1 << 3),
+};
+
+/** Generic View Operator Custom-Data */
+typedef struct ViewOpsData {
+ /** Context pointers (assigned by #viewops_data_create). */
+ struct Main *bmain;
+ struct Scene *scene;
+ struct ScrArea *area;
+ struct ARegion *region;
+ struct View3D *v3d;
+ struct RegionView3D *rv3d;
+ struct Depsgraph *depsgraph;
+
+ /** Needed for continuous zoom. */
+ struct wmTimer *timer;
+
+ /** Viewport state on initialization, don't change afterwards. */
+ struct {
+ float dist;
+ float camzoom;
+ float quat[4];
+ /** #wmEvent.xy. */
+ int event_xy[2];
+ /** Offset to use when #VIEWOPS_FLAG_USE_MOUSE_INIT is not set.
+ * so we can simulate pressing in the middle of the screen. */
+ int event_xy_offset[2];
+ /** #wmEvent.type that triggered the operator. */
+ int event_type;
+ float ofs[3];
+ /** Initial distance to 'ofs'. */
+ float zfac;
+
+ /** Trackball rotation only. */
+ float trackvec[3];
+ /** Dolly only. */
+ float mousevec[3];
+
+ /**
+ * #RegionView3D.persp set after auto-perspective is applied.
+ * If we want the value before running the operator, add a separate member.
+ */
+ char persp;
+
+ /** Used for roll */
+ struct Dial *dial;
+ } init;
+
+ /** Previous state (previous modal event handled). */
+ struct {
+ int event_xy[2];
+ /** For operators that use time-steps (continuous zoom). */
+ double time;
+ } prev;
+
+ /** Current state. */
+ struct {
+ /** Working copy of #RegionView3D.viewquat, needed for rotation calculation
+ * so we can apply snap to the 3D Viewport while keeping the unsnapped rotation
+ * here to use when snap is disabled and for continued calculation. */
+ float viewquat[4];
+ } curr;
+
+ float reverse;
+ bool axis_snap; /* view rotate only */
+
+ /** Use for orbit selection and auto-dist. */
+ float dyn_ofs[3];
+ bool use_dyn_ofs;
+} ViewOpsData;
+
+/* view3d_navigate.c */
+bool view3d_location_poll(struct bContext *C);
+bool view3d_rotation_poll(struct bContext *C);
+bool view3d_zoom_or_dolly_poll(struct bContext *C);
+
+enum eViewOpsFlag viewops_flag_from_prefs(void);
+void calctrackballvec(const struct rcti *rect, const int event_xy[2], float r_dir[3]);
+void viewmove_apply(ViewOpsData *vod, int x, int y);
+void view3d_orbit_apply_dyn_ofs(float r_ofs[3],
+ const float ofs_old[3],
+ const float viewquat_old[4],
+ const float viewquat_new[4],
+ const float dyn_ofs[3]);
+void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat_new[4]);
+bool view3d_orbit_calc_center(struct bContext *C, float r_dyn_ofs[3]);
+
+void view3d_operator_properties_common(struct wmOperatorType *ot, const enum eV3D_OpPropFlag flag);
+
+/**
+ * Allocate and fill in context pointers for #ViewOpsData
+ */
+void viewops_data_free(struct bContext *C, ViewOpsData *vod);
+
+/**
+ * Allocate, fill in context pointers and calculate the values for #ViewOpsData
+ */
+ViewOpsData *viewops_data_create(struct bContext *C,
+ const struct wmEvent *event,
+ enum eViewOpsFlag viewops_flag);
+
+void VIEW3D_OT_view_all(struct wmOperatorType *ot);
+void VIEW3D_OT_view_selected(struct wmOperatorType *ot);
+void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot);
+void VIEW3D_OT_view_center_pick(struct wmOperatorType *ot);
+void VIEW3D_OT_view_axis(struct wmOperatorType *ot);
+void VIEW3D_OT_view_camera(struct wmOperatorType *ot);
+void VIEW3D_OT_view_orbit(struct wmOperatorType *ot);
+void VIEW3D_OT_view_pan(struct wmOperatorType *ot);
+
+/* view3d_navigate_dolly.c */
+void viewdolly_modal_keymap(struct wmKeyConfig *keyconf);
+void VIEW3D_OT_dolly(struct wmOperatorType *ot);
+
+/* view3d_navigate_fly.c */
+void fly_modal_keymap(struct wmKeyConfig *keyconf);
+void view3d_keymap(struct wmKeyConfig *keyconf);
+void VIEW3D_OT_fly(struct wmOperatorType *ot);
+
+/* view3d_navigate_move.c */
+void viewmove_modal_keymap(struct wmKeyConfig *keyconf);
+void VIEW3D_OT_move(struct wmOperatorType *ot);
+
+/* view3d_navigate_ndof.c */
+#ifdef WITH_INPUT_NDOF
+struct wmNDOFMotionData;
+
+/**
+ * Called from both fly mode and walk mode,
+ */
+void view3d_ndof_fly(const struct wmNDOFMotionData *ndof,
+ struct View3D *v3d,
+ struct RegionView3D *rv3d,
+ bool use_precision,
+ short protectflag,
+ bool *r_has_translate,
+ bool *r_has_rotate);
+void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot);
+void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot);
+void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot);
+void VIEW3D_OT_ndof_all(struct wmOperatorType *ot);
+#endif /* WITH_INPUT_NDOF */
+
+/* view3d_navigate_roll.c */
+void VIEW3D_OT_view_roll(struct wmOperatorType *ot);
+
+/* view3d_navigate_rotate.c */
+void viewrotate_modal_keymap(struct wmKeyConfig *keyconf);
+void VIEW3D_OT_rotate(struct wmOperatorType *ot);
+
+/* view3d_navigate_smoothview.c */
+
+/**
+ * Parameters for setting the new 3D Viewport state.
+ *
+ * Each of the struct members may be NULL to signify they aren't to be adjusted.
+ */
+typedef struct V3D_SmoothParams {
+ struct Object *camera_old, *camera;
+ const float *ofs, *quat, *dist, *lens;
+
+ /** Alternate rotation center, when set `ofs` must be NULL. */
+ const float *dyn_ofs;
+} V3D_SmoothParams;
+
+/**
+ * The arguments are the desired situation.
+ */
+void ED_view3d_smooth_view_ex(const struct Depsgraph *depsgraph,
+ struct wmWindowManager *wm,
+ struct wmWindow *win,
+ struct ScrArea *area,
+ struct View3D *v3d,
+ struct ARegion *region,
+ int smooth_viewtx,
+ const V3D_SmoothParams *sview);
+
+void ED_view3d_smooth_view(struct bContext *C,
+ struct View3D *v3d,
+ struct ARegion *region,
+ int smooth_viewtx,
+ const V3D_SmoothParams *sview);
+
+/**
+ * Apply the smooth-view immediately, use when we need to start a new view operation.
+ * (so we don't end up half-applying a view operation when pressing keys quickly).
+ */
+void ED_view3d_smooth_view_force_finish(struct bContext *C,
+ struct View3D *v3d,
+ struct ARegion *region);
+
+void VIEW3D_OT_smoothview(struct wmOperatorType *ot);
+
+/* view3d_navigate_walk.c */
+void walk_modal_keymap(struct wmKeyConfig *keyconf);
+void VIEW3D_OT_walk(struct wmOperatorType *ot);
+
+/* view3d_navigate_zoom.c */
+void viewzoom_modal_keymap(struct wmKeyConfig *keyconf);
+void VIEW3D_OT_zoom(struct wmOperatorType *ot);
+
+/* view3d_navigate_zoom_border.c */
+void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);