Blender V4.3
view3d_navigate.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "BLI_utildefines.h"
12
17#define V3D_OP_TRACKBALLSIZE (1.1f)
18
19struct ARegion;
20struct Depsgraph;
21struct Dial;
22struct RegionView3D;
23struct Scene;
24struct ScrArea;
25struct View3D;
26struct bContext;
27struct Object;
28struct PointerRNA;
29struct rcti;
30struct wmEvent;
31struct wmKeyConfig;
32struct wmOperator;
33struct wmOperatorType;
34struct wmTimer;
35struct wmWindow;
36struct wmWindowManager;
37
45
53
54/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
55enum {
56 VIEW_MODAL_CANCEL = 0, /* used for all view operations */
57 VIEW_MODAL_CONFIRM = 1, /* used for all view operations */
63};
64
83
86 const char *idname;
87 bool (*poll_fn)(bContext *C);
88 int (*init_fn)(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr);
89 int (*apply_fn)(bContext *C, ViewOpsData *vod, const eV3D_OpEvent event_code, const int xy[2]);
90};
91
100 Depsgraph *depsgraph;
101
104
106 struct {
107
110 float ofs[3]; /* DOLLY, MOVE, ROTATE and ZOOM. */
111 float ofs_lock[2]; /* MOVE. */
112 float camdx, camdy; /* MOVE and ZOOM. */
113 float camzoom; /* ZOOM. */
114 float dist; /* ROTATE and ZOOM. */
115 float quat[4]; /* ROLL and ROTATE. */
116 char persp; /* ROTATE. */
117 char view; /* ROTATE. */
118 char view_axis_roll; /* ROTATE. */
119
125
129 int event_xy[2];
130 /* Offset used when "use_cursor_init" is false to simulate pressing in the middle of the
131 * region. */
135
137 float zfac;
138
140 float trackvec[3];
142 float mousevec[3];
143
147
149 struct {
150 int event_xy[2];
152 double time;
154
156 struct {
160 float viewquat[4];
162
165
166 float reverse;
167 bool axis_snap; /* view rotate only */
168
170 float dyn_ofs[3];
172
181
182 void init_context(bContext *C);
183 void state_backup();
184 void state_restore();
186 const wmEvent *event,
187 const ViewOpsType *nav_type,
188 const float dyn_ofs_override[3] = nullptr,
189 const bool use_cursor_init = false);
190 void end_navigation(bContext *C);
191
192#ifdef WITH_CXX_GUARDEDALLOC
193 MEM_CXX_CLASS_ALLOC_FUNCS("ViewOpsData")
194#endif
195};
196
197/* view3d_navigate.cc */
198
202
204 wmOperator *op,
205 const wmEvent *event,
206 const ViewOpsType *nav_type);
207int view3d_navigate_modal_fn(bContext *C, wmOperator *op, const wmEvent *event);
209
210void calctrackballvec(const rcti *rect, const int event_xy[2], float r_dir[3]);
211void viewmove_apply(ViewOpsData *vod, int x, int y);
212void view3d_orbit_apply_dyn_ofs(float r_ofs[3],
213 const float ofs_old[3],
214 const float viewquat_old[4],
215 const float viewquat_new[4],
216 const float dyn_ofs[3]);
217void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat_new[4]);
218bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]);
219
221
226
231 const wmEvent *event,
232 const ViewOpsType *nav_type,
233 const bool use_cursor_init);
234void axis_set_view(bContext *C,
235 View3D *v3d,
236 ARegion *region,
237 const float quat_[4],
238 char view,
239 char view_axis_roll,
240 int perspo,
241 const float *align_to_quat,
242 const int smooth_viewtx);
243
244/* view3d_navigate_dolly.cc */
245
248
250
251/* view3d_navigate_fly.cc */
252
253void fly_modal_keymap(wmKeyConfig *keyconf);
254void view3d_keymap(wmKeyConfig *keyconf);
256
257/* view3d_navigate_move.cc */
258
261
262extern const ViewOpsType ViewOpsType_move;
263
264/* view3d_navigate_ndof.cc */
265
266#ifdef WITH_INPUT_NDOF
267struct wmNDOFMotionData;
271void view3d_ndof_fly(const wmNDOFMotionData *ndof,
272 View3D *v3d,
273 RegionView3D *rv3d,
274 bool use_precision,
275 short protectflag,
276 bool *r_has_translate,
277 bool *r_has_rotate);
278void VIEW3D_OT_ndof_orbit(wmOperatorType *ot);
279void VIEW3D_OT_ndof_orbit_zoom(wmOperatorType *ot);
280void VIEW3D_OT_ndof_pan(wmOperatorType *ot);
281void VIEW3D_OT_ndof_all(wmOperatorType *ot);
282
283extern const ViewOpsType ViewOpsType_ndof_orbit;
284extern const ViewOpsType ViewOpsType_ndof_orbit_zoom;
285extern const ViewOpsType ViewOpsType_ndof_pan;
286extern const ViewOpsType ViewOpsType_ndof_all;
287#endif /* WITH_INPUT_NDOF */
288
289/* view3d_navigate_roll.cc */
290
292
293extern const ViewOpsType ViewOpsType_roll;
294
295/* view3d_navigate_rotate.cc */
296
299
301
302/* view3d_navigate_smoothview.cc */
303
311 const float *ofs, *quat, *dist, *lens;
312
314 const float *dyn_ofs;
315
317 const char *undo_str;
323};
324
328void ED_view3d_smooth_view_ex(const Depsgraph *depsgraph,
329 wmWindowManager *wm,
330 wmWindow *win,
331 ScrArea *area,
332 View3D *v3d,
333 ARegion *region,
334 int smooth_viewtx,
335 const V3D_SmoothParams *sview);
336
338 bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview);
339
352 const ScrArea *area,
353 const char *undo_str,
354 bool undo_grouped);
355
361
369 wmWindowManager *wm,
370 wmWindow *win,
371 const Scene *scene,
372 View3D *v3d,
373 ARegion *region);
374
376
377/* view3d_navigate_view_all.cc */
378
381
382/* view3d_navigate_view_axis.cc */
383
385
386/* view3d_navigate_view_camera.cc */
387
389
390/* view3d_navigate_view_center_cursor.cc */
391
393
394/* view3d_navigate_view_center_pick.cc */
395
397
398/* view3d_navigate_view_orbit.cc */
399
401
402extern const ViewOpsType ViewOpsType_orbit;
403
404/* view3d_navigate_view_pan.cc */
405
407
408extern const ViewOpsType ViewOpsType_pan;
409
410/* view3d_navigate_walk.cc */
411
412void walk_modal_keymap(wmKeyConfig *keyconf);
414
415/* view3d_navigate_zoom.cc */
416
419
420extern const ViewOpsType ViewOpsType_zoom;
421
422/* view3d_navigate_zoom_border.cc */
423
#define ENUM_OPERATORS(_type, _max)
#define C
Definition RandGen.cpp:29
const Depsgraph * depsgraph
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
const char * undo_str
const float * dyn_ofs
const ViewOpsType * nav_type
struct ViewOpsData::@543 init
char persp_with_auto_persp_applied
void end_navigation(bContext *C)
eViewOpsFlag viewops_flag
bool use_dyn_ofs_ortho_correction
Depsgraph * depsgraph
ARegion * region
struct ViewOpsData::@544 prev
RegionView3D * rv3d
void init_navigation(bContext *C, const wmEvent *event, const ViewOpsType *nav_type, const float dyn_ofs_override[3]=nullptr, const bool use_cursor_init=false)
void init_context(bContext *C)
struct ViewOpsData::@545 curr
const char * idname
eViewOpsFlag flag
int(* init_fn)(bContext *C, ViewOpsData *vod, const wmEvent *event, PointerRNA *ptr)
bool(* poll_fn)(bContext *C)
int(* apply_fn)(bContext *C, ViewOpsData *vod, const eV3D_OpEvent event_code, const int xy[2])
void ED_view3d_smooth_view_undo_begin(bContext *C, const ScrArea *area)
void view3d_navigate_cancel_fn(bContext *C, wmOperator *op)
void viewmove_modal_keymap(wmKeyConfig *keyconf)
const ViewOpsType ViewOpsType_zoom
void view3d_keymap(wmKeyConfig *keyconf)
void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview)
void VIEW3D_OT_view_roll(wmOperatorType *ot)
void VIEW3D_OT_view_axis(wmOperatorType *ot)
const ViewOpsType ViewOpsType_pan
void ED_view3d_smooth_view_force_finish_no_camera_lock(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, const Scene *scene, View3D *v3d, ARegion *region)
void viewops_data_free(bContext *C, ViewOpsData *vod)
const ViewOpsType ViewOpsType_orbit
ViewOpsData * viewops_data_create(bContext *C, const wmEvent *event, const ViewOpsType *nav_type, const bool use_cursor_init)
void VIEW3D_OT_view_orbit(wmOperatorType *ot)
void fly_modal_keymap(wmKeyConfig *keyconf)
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])
eViewOpsFlag
@ VIEWOPS_FLAG_NONE
@ VIEWOPS_FLAG_ORBIT_SELECT
@ VIEWOPS_FLAG_DEPTH_NAVIGATE
@ VIEWOPS_FLAG_INIT_ZFAC
@ VIEWOPS_FLAG_ZOOM_TO_MOUSE
@ VIEWOPS_FLAG_PERSP_ENSURE
void view3d_operator_properties_common(wmOperatorType *ot, const eV3D_OpPropFlag flag)
bool view3d_rotation_poll(bContext *C)
bool view3d_location_poll(bContext *C)
void ED_view3d_smooth_view_ex(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, ScrArea *area, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview)
void VIEW3D_OT_walk(wmOperatorType *ot)
void VIEW3D_OT_zoom_border(wmOperatorType *ot)
void VIEW3D_OT_rotate(wmOperatorType *ot)
const ViewOpsType ViewOpsType_rotate
eV3D_OpEvent
@ VIEW_CONFIRM
@ VIEW_PASS
@ VIEW_CANCEL
@ VIEW_APPLY
@ VIEWROT_MODAL_SWITCH_ROTATE
@ VIEWROT_MODAL_AXIS_SNAP_ENABLE
@ VIEW_MODAL_CANCEL
@ VIEWROT_MODAL_SWITCH_MOVE
@ VIEW_MODAL_CONFIRM
@ VIEWROT_MODAL_SWITCH_ZOOM
@ VIEWROT_MODAL_AXIS_SNAP_DISABLE
ViewOpsType ViewOpsType_dolly
bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
const ViewOpsType ViewOpsType_roll
int view3d_navigate_modal_fn(bContext *C, wmOperator *op, const wmEvent *event)
void viewmove_apply(ViewOpsData *vod, int x, int y)
void calctrackballvec(const rcti *rect, const int event_xy[2], float r_dir[3])
void VIEW3D_OT_view_pan(wmOperatorType *ot)
eV3D_OpPropFlag
@ V3D_OP_PROP_USE_MOUSE_INIT
@ V3D_OP_PROP_DELTA
@ V3D_OP_PROP_USE_ALL_REGIONS
@ V3D_OP_PROP_MOUSE_CO
void axis_set_view(bContext *C, View3D *v3d, ARegion *region, const float quat_[4], char view, char view_axis_roll, int perspo, const float *align_to_quat, const int smooth_viewtx)
void VIEW3D_OT_view_all(wmOperatorType *ot)
void viewzoom_modal_keymap(wmKeyConfig *keyconf)
void VIEW3D_OT_view_selected(wmOperatorType *ot)
int view3d_navigate_invoke_impl(bContext *C, wmOperator *op, const wmEvent *event, const ViewOpsType *nav_type)
void viewrotate_modal_keymap(wmKeyConfig *keyconf)
void VIEW3D_OT_zoom(wmOperatorType *ot)
void VIEW3D_OT_view_camera(wmOperatorType *ot)
void viewdolly_modal_keymap(wmKeyConfig *keyconf)
const ViewOpsType ViewOpsType_move
void VIEW3D_OT_view_center_pick(wmOperatorType *ot)
void VIEW3D_OT_view_center_cursor(wmOperatorType *ot)
void walk_modal_keymap(wmKeyConfig *keyconf)
void viewrotate_apply_dyn_ofs(ViewOpsData *vod, const float viewquat_new[4])
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
void VIEW3D_OT_fly(wmOperatorType *ot)
void VIEW3D_OT_move(wmOperatorType *ot)
bool view3d_zoom_or_dolly_poll(bContext *C)
void VIEW3D_OT_smoothview(wmOperatorType *ot)
void ED_view3d_smooth_view_undo_end(bContext *C, const ScrArea *area, const char *undo_str, bool undo_grouped)
void VIEW3D_OT_dolly(wmOperatorType *ot)
int xy[2]
Definition wm_draw.cc:170
PointerRNA * ptr
Definition wm_files.cc:4126
wmOperatorType * ot
Definition wm_files.cc:4125
uint8_t flag
Definition wm_window.cc:138