HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUI_ViewParameter.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GUI_ViewParameter (Geometry Render Library, C++)
7  *
8  * COMMENTS:
9  * ViewParameter contains information relating to the
10  * viewport's physical characteristics, eg aspect ratio,
11  * position, lookat.
12  *
13  */
14 
15 #ifndef __GUI_ViewParameter__
16 #define __GUI_ViewParameter__
17 
18 #include "GUI_API.h"
19 #include <UT/UT_BoundingBox.h>
20 #include <UT/UT_Matrix3.h>
21 #include <UT/UT_Matrix4.h>
22 #include <UT/UT_Quaternion.h>
23 #include <UT/UT_Rect.h>
24 #include <UT/UT_Vector3.h>
25 #include <UT/UT_VectorTypes.h>
26 #include <UT/UT_Plane.h>
27 
28 class RE_Render;
29 
31 typedef void (*GUI_HomeRotCallback)(UT_Matrix3R &, void *);
32 
34 {
35 public:
37  {
38  ortho = 0;
39  applyAspect = 0;
40  matrixDirty = 1;
41  iMatrixDirty = 1;
42  boxZoom = 0;
43  viewportDirty = 0;
44  rotoTrackWindow = 1;
45  initXform = 0;
46  rxyzDirty = 1;
47  }
48 
49  // ASCII methods to save and load flags
50  void save(std::ostream &os) const;
51  bool load(UT_IStream &is);
52 
53  unsigned ortho:1,
54  applyAspect:1,
55  matrixDirty:1,
56  iMatrixDirty:1,
57  boxZoom:1,
58  viewportDirty:1,
59  rotoTrackWindow:1,
60  initXform:1,
61  rxyzDirty:1;
62 };
63 
65 {
66 public:
69 
70  GUI_ViewParameter(const GUI_ViewParameter &) = delete;
71  enum axis { OBLIQUE, CUSTOM, XAXIS, YAXIS, ZAXIS,
72  FRONT, RIGHT, TOP, BACK, LEFT, BOTTOM, CPLANE };
73 
74  enum orientation { Y_UP, Z_UP };
75 
77  {
78  int w,h;
79  getViewportSize(w,h);
80  area.set(myViewportLeft, myViewportBottom, w,h);
81  }
82  void getViewport(int &l, int &r, int &b, int &t) const;
83  void getViewportSize(int &w, int &h) const
84  {
85  // Note that we have inclusive coordinates.
86  w = myViewportRight - myViewportLeft + 1;
87  h = myViewportTop - myViewportBottom + 1;
88  }
89  int getViewportWidth() const
90  { return myViewportRight - myViewportLeft + 1; }
91  int getViewportHeight() const
92  { return myViewportTop - myViewportBottom + 1; }
93  void setViewport(RE_Render *r, int x, int y, int w, int h);
94  void setViewport(RE_Render *r, const UT_DimRect &viewarea)
95  { setViewport(r, viewarea.x(), viewarea.y(),
96  viewarea.w(), viewarea.h()); }
97 
98  // Utility for converting our viewport into a UT_Rect.
100  { return UT_InclusiveRect(myViewportLeft, myViewportBottom,
101  myViewportRight, myViewportTop); }
102 
103 
104  // Both setViewport and setView must be called before setProjection.
105  // r may be NULL to set the projection matrix without loading it into
106  // RE_Render.
107  void setProjection(RE_Render *r);
108 
109  // Returns the projection matrix. If depth_adjust is false, Z is not
110  // mapped to [0,1], and instead remains as-is.
111  void getProjection(UT_Matrix4D &proj, bool depth_adjust=true);
112 
113  void getUnclippedProjection(UT_Matrix4D &project,
114  fpreal left_crop = 0.0,
115  fpreal right_crop = 1.0,
116  fpreal bottom_crop = 0.0,
117  fpreal top_crop = 1.0);
118 
119  // temporarily use this projection matrix. This class does not take
120  // ownership.
121  void setProjectionOverride(UT_Matrix4D *override);
122 
123  // Get the direction a particular point (px, py) in the camera's
124  // near plane is pointing to in world coordinates. The range of
125  // (px, py) is (0, 0) to (1, 1) with (0, 0) representing the
126  // lower-left corner and the default arguments represent the center of
127  // the screen.
128  UT_Vector3 getCameraDir(fpreal px = 0.5, fpreal py = 0.5);
129 
130  // A utility method to return the world space plane representing our
131  // view plane. The point will be set to the center of the view and
132  // the normal will point towards the camera.
133  UT_PlaneD getViewPlane();
134 
135  // The view is a subregion of the viewport that represents the current
136  // "camera" view. Aspect ratio bars are used to dim the parts of the
137  // viewport not in this view. The window coordinates are relative to
138  // this view, not the viewport.
139  void setView(const UT_DimRect &area)
140  { setView(area.x(), area.y(), area.w(), area.h()); }
141  void setView(int x, int y, int w, int h);
142  void getView(int &l, int &r, int &b, int &t) const;
143  int getViewWidth() const
144  { return myViewRight - myViewLeft + 1; }
145  int getViewHeight() const
146  { return myViewTop - myViewBottom + 1; }
147  // Utility for converting our viewport into a UT_Rect.
149  { return UT_InclusiveRect(myViewLeft, myViewBottom,
150  myViewRight, myViewTop); }
151 
152  // A handy method to compute projection bounds for the viewport such
153  // that the specified bounds map to the view subregion.
154  void viewToViewportProjectionBounds(
155  fpreal &left, fpreal &right,
156  fpreal &bottom, fpreal &top) const;
157 
158  // Convenience methods to query the margins on each side of the view
159  // subregion.
160  int getLeftMargin() const
161  { return myViewLeft - myViewportLeft; }
162  int getRightMargin() const
163  { return myViewportRight - myViewRight; }
164  int getBottomMargin() const
165  { return myViewBottom - myViewportBottom; }
166  int getTopMargin() const
167  { return myViewportTop - myViewTop; }
168 
169  void homeToBox(int width, int height, fpreal minzoom,
170  UT_BoundingBox &box, const UT_Matrix3R *rot = NULL,
171  bool centre_to_origin = false, bool zoom_in = false);
172  void homeRotation(axis a, UT_Matrix3R &rot) const;
173  void homeRotation(axis a);
174 
175  void resetFOV();
176 
177  // Set the default camera FOV, 0-180 degrees.
178  void setDefaultFOV(fpreal fov_in_degrees);
179  fpreal getDefaultFOV() const { return myView.myDefaultFOV; }
180 
181  // Query the rotation that converts the view rotation from the old mode
182  // to the new mode.
183  static void getOrientationChangeRotation(
186  UT_Matrix3R &rot);
187 
188  // Convert a view transform relative to the old_mode to the corresponding
189  // view transform relative to the new mode.
190  void convertTransform(GUI_ViewParameter::axis home_axis,
193 
194  // To perform view operations that are being exported continuously, we
195  // need to cache some data to account for view changes that occur as a
196  // result of the exporting. Generally, you'll want to call the begin
197  // method on a UI_VALUE_START and the end method on a UI_VALUE_CHANGED.
198  void beginContinuouslyExportedOperation();
199  void endContinuouslyExportedOperation();
200  bool continuouslyExportedOperationInProgress() const;
201 
202  void rotate(UT_Axis3::axis axis, fpreal dx);
203  void rotate(const UT_Vector3R &axis, fpreal dx);
204  void rotate(const UT_Quaternion &quat);
205  void trackball(fpreal dx, fpreal dy);
206  void incrementtrackball(fpreal dx, fpreal dy, int finish);
207  void eulertumble(fpreal dx, fpreal dy, int finish, bool lock);
208  void dotumble(fpreal dx, fpreal dy, int finish);
209 
210  void scroll(fpreal dx, fpreal dy);
211  // Scroll using the specified viewport size instead of our settings. Used
212  // for scrolling linked ortho viewports.
213  void scroll(fpreal dx, fpreal dy, const UT_InclusiveRect &viewport);
214  // Scroll to maintain the specified world position under the cursor. This
215  // method is unnecessary when using an orthographic projection.
216  void worldLockedScroll(const UT_Vector3R &locked_pos,
217  fpreal dx, fpreal dy);
218 
219  void dolly(fpreal dx,
220  bool precise_zoom = false,
221  bool smooth_deltas = false);
222 
223  // Dolly using a specified world-space direction (instead of towards the
224  // center of the view as in a regular dolly). The use of world space is
225  // a convenience for the GUI_ViewState wrapper that would otherwise have
226  // to transform this to a view space direction for each instance of this
227  // class.
228  void directedDolly(const UT_Vector3R &unit_worldspace_dir,
229  fpreal dx, bool precise_zoom = false,
230  bool smooth_deltas = false);
231 
233  {
235  GUI_ORTHO_WIDTH
236  };
237  void zoom(fpreal dx, GUI_ZoomItem item, bool precise_zoom = false);
238  // Zoom using the specified viewport size instead of our settings. Used
239  // for zooming linked ortho viewports.
240  void zoom(fpreal dx, GUI_ZoomItem item,
241  const UT_InclusiveRect &viewport,
242  bool precise_zoom = false);
243 
244  // Versions of the zoom() methods that center the zoom around the given
245  // (normalized) screen position (sx, sy). This affects either the window
246  // offset, when GUI_WIN_SIZE is specified, or the view position, when
247  // GUI_ORTHO_WIDTH is specified.
248  void offsetZoom(fpreal sx, fpreal sy, fpreal dx, GUI_ZoomItem item,
249  bool precise_zoom = false);
250  void offsetZoom(fpreal sx, fpreal sy, fpreal dx, GUI_ZoomItem item,
251  const UT_InclusiveRect &viewport,
252  bool precise_zoom = false);
253 
254  // Dolly onto a target located at a specified distance.
255  // Note that the location and size of the "box" must be
256  // normalized to [0, 1]
257  // ** Note : Aspect ratio of the box is assumed to match aspect ratio
258  // of the viewport!
259  void boxZoom(fpreal firstx, fpreal firsty, fpreal lastx,
260  fpreal lasty, fpreal distance);
261 
262  void screenScroll(fpreal dx, fpreal dy);
263 
264  // Returns the width of the frustum cross-section at the distance t.
265  static fpreal getFrustumWidth(fpreal t, fpreal aperture, fpreal focal_length,
266  fpreal orthowidth, bool is_ortho);
267 
268  // Returns the centre of the frustum (cx, cy) and the half-width and
269  // half-height (hw, hh), from these, you can compute the corners of the
270  // frustum.
271  static void getFrustumCenter(fpreal frustum_width, fpreal aspect,
272  fpreal x_offset, fpreal y_offset,
273  fpreal x_window_size, fpreal y_window_size,
274  fpreal &cx, fpreal &cy,
275  fpreal &hw, fpreal &hh);
276 
277 // member data access methods
278 
279  bool isDirty() const { return (myFlag.viewportDirty ||
280  myFlag.matrixDirty ||
281  myFlag.iMatrixDirty); }
282  // bumped whenever the view has changed.
283  int getViewVersion() const { return myVersion + myVersion2D; }
284  void bumpViewVersion() { myVersion++; }
285  void bumpView2DVersion() { myVersion2D++; }
286  int getView3DVersion() const { return myVersion; }
287  int getView2DVersion() const { return myVersion2D; }
288 
289  // projection
290  int initialized() const { return myFlag.initXform; }
291  int getOrthoFlag() const { return myFlag.ortho; }
292  void setOrthoFlag(int o) { myFlag.ortho = o; }
293  void setLimits(fpreal n, fpreal f) { setNearClip(n); setFarClip(f); }
295  {
296  *n = myView.myNearLimit;
297  *f = myView.myFarLimit;
298  }
299  void setNearClip(fpreal near);
300  void setFarClip(fpreal far);
301  fpreal getNearClip() const { return myView.myNearLimit; }
302  fpreal getFarClip() const { return myView.myFarLimit; }
303 
305  { mySceneBounds=b; }
306  const UT_BoundingBoxD &getSceneBounds() const { return mySceneBounds; }
308  { mySelectedObjBounds=b; }
309 
310  // In case far/near > 10M, and extended zbuffer range is supported
311  // Far clip will be at this value rather than 1.0.
312  fpreal32 getExtendedZBufferFar() const { return myExtendedZBufferFar; }
313 
314  static void setExtendedZBufferRangeSupport(bool has_ext);
315 
316  void allowNearFarClipAdapt(bool allow)
317  { myAllowNearFarClipAdapt = allow; }
318 
320  {
321  myView.myWinX = x;
322  myView.myWinY = y;
323  myView.myWinW = SYSmax(w, fpreal(0.001));
324  myView.myWinH = SYSmax(h, fpreal(0.001));
325  updateWindowOverridesNominal();
326  }
328  fpreal &w, fpreal &h) const
329  {
330  x = myView.myWinX;
331  y = myView.myWinY;
332  w = myView.myWinW;
333  h = myView.myWinH;
334  }
335 
337  {
338  myNominalWinX = x;
339  myNominalWinY = y;
340  myNominalWinW = SYSmax(w, fpreal(0.001));
341  myNominalWinH = SYSmax(h, fpreal(0.001));
342  updateWindowOverridesNominal();
343  }
345  fpreal &w, fpreal &h) const
346  {
347  x = myNominalWinX;
348  y = myNominalWinY;
349  w = myNominalWinW;
350  h = myNominalWinH;
351  }
353  { return myWindowOverridesNominal; }
354 
355  // A handy method to compute the view region bounds relative to the nominal
356  // window rather than relative to the current window. With bounds relative
357  // to the nominal window, the nominal window is the unit square from (0,0)
358  // to (1,1), in contrast with bounds relative to the current window, which
359  // are themselves always this unit square.
360  void getViewBoundsRelativeToNominalWindow(
361  fpreal &l, fpreal &r, fpreal &b, fpreal &t) const;
362 
363  // The window is stored as an offset from 0, 0 with the scale applied prior
364  // to translation. However, mantra and other renderers expect the window
365  // to be relative to the (0,1) rectangle. getScreenWindow() will translate
366  // the window parameters into a screen window. setScreenWindow() will take
367  // a screen window and set the appropriate parameters.
369  fpreal &b, fpreal &t) const
370  {
371  convertViewToScreenWindow(myView.myWinX, myView.myWinY,
372  myView.myWinW, myView.myWinH,
373  l, r, b, t);
374  }
376  {
377  convertScreenToViewWindow(l, r, b, t,
378  myView.myWinX, myView.myWinY,
379  myView.myWinW, myView.myWinH);
380  }
381 
383  {
384  myHasSubRegion = true;
385  mySubRegionX = x;
386  mySubRegionY = y;
387  mySubRegionW = w;
388  mySubRegionH = h;
389  }
391  {
392  myHasSubRegion = false;
393  mySubRegionX = 0.0;
394  mySubRegionY = 0.0;
395  mySubRegionW = 1.0;
396  mySubRegionH = 1.0;
397  }
399  {
400  x = mySubRegionX;
401  y = mySubRegionY;
402  w = mySubRegionW;
403  h = mySubRegionH;
404  return myHasSubRegion;
405  }
406 
407  static void convertScreenToViewWindow(
409  fpreal &xoff, fpreal &yoff, fpreal &xsize, fpreal &ysz);
410  static void convertViewToScreenWindow(
411  fpreal xoff, fpreal yoff, fpreal xsize, fpreal ysize,
412  fpreal &l, fpreal &r, fpreal &b, fpreal &t);
413 
414  fpreal getWinSizeX() const { return myView.myWinW; }
415  fpreal getWinSizeY() const { return myView.myWinH; }
416  fpreal getWinX() const { return myView.myWinX; }
417  fpreal getWinY() const { return myView.myWinY; }
418 
420  {
421  GUI_VIEW_ADJUST_NONE = 0,
422  GUI_VIEW_ADJUST_FAR = 1,
423  GUI_VIEW_ADJUST_NEAR = 2,
424  GUI_VIEW_ADJUST_BOTH = 3
425  };
427  { myAdjustLimits = which; }
428  GUI_ViewAdjustLimits getAdjustLimits() const { return myAdjustLimits; }
429 
430  void setWindowAffectRotoscope(int v) { myFlag.rotoTrackWindow = v; }
432  { return myFlag.rotoTrackWindow; }
433 
434  // aspectRatio
435  void setApplyAspectFlag(int a) { myFlag.applyAspect = a; }
436  int getApplyAspectFlag() const { return myFlag.applyAspect; }
437  void setAspectRatio(fpreal a) { myViewAspectRatio = a; }
438  fpreal getAspectRatio() const { return myViewAspectRatio; }
439 
441  {
442  myFrustumWidthScale = xsc;
443  myFrustumHeightScale = ysc;
444  }
445 
446  // Return 8 corner points of the frustum, near points first (BL,BR,TL,TR)
447  void getFrustumPoints(UT_Vector3FArray &pnts);
448 
449  // position
451  void setT(const UT_Vector3D &t)
452  { myView.myT = t; myFlag.matrixDirty=1; myFlag.iMatrixDirty=1;}
454  const UT_Vector3D & getT() const { return myView.myT; }
455 
456  // pivot
458  const UT_Vector3D & getP() const { return myView.myP; }
460  void setP(const UT_Vector3D &p)
461  { myView.myP = p; myFlag.matrixDirty=1; myFlag.iMatrixDirty=1;}
462 
463  static void setOrientationMode(orientation o);
464  static orientation getOrientationMode();
465  static bool isOrientationYUp()
466  { return getOrientationMode() == Y_UP; }
467  static bool isOrientationZUp()
468  { return getOrientationMode() == Z_UP; }
469 
470  // Rotation style:
471  static void setTumbleStyleFlag(int style)
472  { myTumbleStyle = style; }
473  static int getTumbleStyleFlag() { return myTumbleStyle; }
474  static void setAltKeyViewControlsFlag(int style)
475  { myAltKeyViewControls = style; }
476  static int getAltKeyViewControlsFlag() { return myAltKeyViewControls; }
477  static void setScrollStyleFlag(int style)
478  { myScrollStyle = style; }
479  static int getScrollStyleFlag() { return myScrollStyle; }
480  static void setDefaultHomingStyleFlag(int style)
481  { myDefaultHomingStyle = GUI_ViewParameter::axis(style); }
482  static axis getDefaultHomingStyleFlag() { return myDefaultHomingStyle; }
483 
484  // the resulting matrices
485  void setRotateMatrix(const UT_Matrix3D &mat)
486  { myView.myRotateMatrix = mat;
487  myFlag.matrixDirty = 1;
488  myFlag.iMatrixDirty = 1;
489  myFlag.rxyzDirty = 1; }
490  const UT_Matrix4D &getRotateMatrix() const { return myView.myRotateMatrix; }
491 
493  { return myProjectionOverride ? *myProjectionOverride
494  : myView.myProjectionMatrix; }
495  const UT_Matrix4D &getTransformMatrix() { updateTransformMatrix();
496  return myTransformMatrix; }
497  const UT_Matrix4D &getItransformMatrix() { updateItransformMatrix();
498  return myItransformMatrix; }
499 
500  // This sets the transform matrix to the given value, bypassing the
501  // PX, TX, etc. The purpose of this is to get accurate camera transforms
502  // you can first set all the PX, Rotate, etc, according to the cracked
503  // values, and then do a forceTransformMatrix to ensure the user sees
504  // the most accurate possible matrix.
505  void forceTransformMatrix(const UT_DMatrix4 &mat);
506  void getTransformMatrix(UT_DMatrix4 &mat, fpreal time);
508  void *data)
509  {
510  myTransformCallback = callback;
511  myTransformCallbackData = data;
512  }
513 
514  // Class I/O methods. They return 0 if successful, -1 if not.
515  // `for_view_copy` is only for temporarily transferring one view parms to
516  // another.
517  int save(std::ostream &os,
518  char separator = '\n',
519  bool for_view_copy = false) const;
520  bool load(UT_IStream &is);
521  bool oldLoad(UT_IStream &is, int version);
522 
523  // inline for non-virtual class
524  const char *className() const { return "GUI_ViewParameter"; }
525 
526  fpreal getLastHomeRadius() const { return myLastHomeRadius; }
527 
528  void setHomeAxis(axis homeaxis)
529  { myHomeAxis = homeaxis; myFlag.rxyzDirty = 1; }
530  axis getHomeAxis() const { return myHomeAxis; }
531  void setCustomHomeRot(UT_Matrix3R &rot) { myCustomHomeRot = rot; }
532  const UT_Matrix3R &getCustomHomeRot() const { return myCustomHomeRot; }
533 
534  // Set a callback to get the home rotation for the construction plane
535  // (axis::CPLANE), to which this class does not have direct access.
537  void *data)
538  {
539  myCPlaneHomeRotCallback = callback;
540  myCPlaneHomeRotCallbackData = data;
541  }
542 
543 
544  void setOrthoWidth(fpreal w) { myView.myOrthoWidth = w; }
545  fpreal getOrthoWidth() const { return myView.myOrthoWidth; }
546 
547  void setFocalLength(fpreal f) { myView.myFocalLength = f; }
548  fpreal getFocalLength() const { return myView.myFocalLength; }
549 
550  void setFocalUnitScale(fpreal f) { myView.myFocalScale = f; }
551  fpreal getFocalUnitScale() const { return myView.myFocalScale; }
552 
553  void setFocusDistance(fpreal f) { myView.myFocusDistance = f; }
554  fpreal getFocusDistance() const { return myView.myFocusDistance; }
555 
556  void setAperture(fpreal a) { myView.myAperture = a; }
557  fpreal getAperture() const { return myView.myAperture; }
558 
559  void setFStop(fpreal fs) { myView.myFStop = fs; }
560  fpreal getFStop() const { return myView.myFStop; }
561 
563  {
564  myView.myHApertureOffset = h;
565  myView.myVApertureOffset = v;
566  }
568  {
569  h = myView.myHApertureOffset;
570  v = myView.myVApertureOffset;
571  }
572 
573  fpreal getNearLimit() const { return myView.myNearLimit; }
574  fpreal getFarLimit() const { return myView.myFarLimit; }
575 
576  fpreal getZBufferNear() const { return myZBufferNear; }
577  fpreal getZBufferFar() const { return myZBufferFar; }
578 
579  // viewport clearing
581 
582  // fog
583  int myFog;
585  float myFogNear;
586  float myFogFar;
587  float myFogColor[3];
588  float myFogAlpha;
589 
590  // used for rotoscoping only
592 
593  // container for all view home information
594  class gui_View
595  {
596  public:
598  : myT(0.0, 0.0, 0.1),
599  myP(0.0, 0.0, 0.0),
600  myRotateMatrix(1.0),
601  myProjectionMatrix(1.0),
602  myWinX(0.0),
603  myWinY(0.0),
604  myWinW(1.0),
605  myWinH(1.0),
606  myOrthoWidth(1.0),
607  myFocalLength(50.0),
608  myFocusDistance(5.0),
609  myAperture(41.4214),
610  myFStop(5.6),
611  myFocalScale(0.001),
612  myNearLimit(0.1),
613  myFarLimit(10000.0),
614  myHApertureOffset(0.0),
615  myVApertureOffset(0.0),
616  myDefaultFOV(90.0)
617  {}
618 
621 
624 
625  // window (zooming)
630 
631  // projection information
632  // ortho specific
634 
635  // perspective specific sSee diagram below)
639  fpreal myFStop; // for dof.
644 
647  };
648 
649  // methods to quickly stash and recall the view state.
650  void getViewState(gui_View &view_state) const
651  { view_state = myView; }
652  void setViewState(const gui_View &view_state)
653  {
654  myView = view_state;
655  myFlag.matrixDirty=1;
656  myFlag.iMatrixDirty=1;
657  myFlag.rxyzDirty=1;
658  updateWindowOverridesNominal();
659  }
660 
661  void adjustNearFarClip();
662 
663  // clipping
664 private:
665  fpreal myZBufferNear;
666  fpreal myZBufferFar;
667  GUI_ViewAdjustLimits myAdjustLimits;
668 
669  // aspect ratio
670  fpreal myViewAspectRatio;
671 public:
672  fpreal myPixelAspect; // depends on output device
673 
674 // projection information (see docs below)
685 
687 
688 private:
689  void updateTransformMatrix();
690  void updateItransformMatrix();
691  void updateRXYZValues();
692  fpreal getDistanceToBoxCenter(int clamp = 0) const;
693 
694  void internalScroll(fpreal dx, fpreal dy,
695  const UT_InclusiveRect &viewport,
696  bool decouple_axes,
697  const UT_Vector3R *locked_pos);
698  void internalZoom(fpreal dx, GUI_ZoomItem item, int width);
699  void internalOffsetZoom(fpreal sx, fpreal sy, fpreal dx,
700  GUI_ZoomItem item,
701  const UT_InclusiveRect &viewport);
702  void internalScreenScroll(fpreal dx, fpreal dy,
703  const UT_InclusiveRect &viewport);
704 
705  void getFrustumClip(fpreal &l, fpreal &r, fpreal &t, fpreal &b,
706  fpreal &n, fpreal &f, bool adjust_zrange);
707  bool computeWorldLockedScrollAccel(fpreal dx, fpreal dy,
708  const UT_Vector3R &locked_pos,
709  fpreal &accelerationx,
710  fpreal &accelerationy);
711  fpreal computeZoomDelta(fpreal dx,
712  bool precise_zoom,
713  bool smooth_deltas);
714 
715  void updateWindowOverridesNominal()
716  {
717  myWindowOverridesNominal =
718  (myView.myWinX != myNominalWinX ||
719  myView.myWinY != myNominalWinY ||
720  myView.myWinW != myNominalWinW ||
721  myView.myWinH != myNominalWinH);
722  }
723 
724  GUI_ViewFlag myFlag;
725 
726 // transform information
727 
728  gui_View myView;
729  fpreal myDx, myDy;
730  static orientation myOrientationMode;
731  static int myTumbleStyle;
732  static int myAltKeyViewControls;
733  static int myScrollStyle;
734  static axis myDefaultHomingStyle;
735 
736  fpreal myRx, myRy, myRz; // Used by euler method. In degrees
737 
738  // always call updateTransformMatrix before using myTransformMatrix.
739  UT_Matrix4D myTransformMatrix; // this one is generated from the above
740  UT_Matrix4D myItransformMatrix; // inverse of myTransformMatrix;
741 
742  GUI_TransformCallback myTransformCallback;
743  void *myTransformCallbackData;
744 
745 // home information to be used in scaling of view transformation
746  fpreal myLastHomeDistance;
747  fpreal myLastHomePixelWidthOBSOLETE;
748  fpreal myLastHomeAdjustedBoxWidth;
749  fpreal myLastHomeOrthoWidth;
750  fpreal myLastHomeRadius;
751 
752  // myLastHomeAdjustedBoxWidth supercedes myLastHomePixelWidth, but to load
753  // view transforms from old hip files without screwed up scrolling, we may
754  // need to use the obsolete quantity until the next manual home operation.
755  bool myObsoleteScrollIsActive;
756 
757  axis myHomeAxis;
758  UT_Matrix3R myCustomHomeRot;
759 
760  GUI_HomeRotCallback myCPlaneHomeRotCallback;
761  void *myCPlaneHomeRotCallbackData;
762 
763  // A collection of data needed for calculating the appropriate changes to
764  // the view transform to perform view operations under continuous export
765  // of view changes to a camera.
766  class ContinuousExportCache
767  {
768  public:
769  ContinuousExportCache() {}
770 
771  UT_Matrix4D myRotateMatrix;
772  UT_Matrix4D myTransformMatrix;
773  UT_Matrix4D myItransformMatrix;
774  fpreal myAdjustedNear;
775  fpreal myAdjustedX;
776  fpreal myAdjustedY;
777  fpreal myTotalScrollX;
778  fpreal myTotalScrollY;
779  };
780 
781  typedef ContinuousExportCache ViewOpCache;
782 
783  ViewOpCache myContinuousExportCache;
784  bool myContinuousExportInProgress;
785 
786  // The nominal window (zooming) for this view. The myView.myWin* members
787  // represent the window used for the current view, but when they are used
788  // to override the camera's screen window, we need to know that this is
789  // the case and what nominal window values to use for properly displaying
790  // overlays like the safe area or field guide.
791  bool myWindowOverridesNominal;
792  fpreal myNominalWinX;
793  fpreal myNominalWinY;
794  fpreal myNominalWinW;
795  fpreal myNominalWinH;
796 
797  bool myHasSubRegion;
798  fpreal mySubRegionX;
799  fpreal mySubRegionY;
800  fpreal mySubRegionW;
801  fpreal mySubRegionH;
802 
803  // These might be needed for other guys.
804  int myViewportLeft, myViewportRight;
805  int myViewportBottom, myViewportTop;
806 
807  // The view is a subregion of the viewport that represents the current
808  // "camera" view. Aspect ratio bars are used to dim the parts of the
809  // viewport not in this view. The window coordinates are relative to
810  // this view, not the viewport.
811  int myViewLeft, myViewRight;
812  int myViewBottom, myViewTop;
813 
814  int myVersion;
815  int myVersion2D;
816 
817  fpreal32 myExtendedZBufferFar;
818  bool myHasExtendedZBufferFar;
819  bool myAllowNearFarClipAdapt;
820  UT_BoundingBoxD mySceneBounds;
821  UT_BoundingBoxD mySelectedObjBounds;
822 
823  UT_Matrix4D *myProjectionOverride;
824 };
825 
826 
827 #ifdef __DOCUMENTATION__
828 
829 FOV can be computed from aperture and focal length.
830 
831  <--aperture--->
832  | |
833  | |
834  +------+------+-----------
835  \ | / ^
836  \ | / |
837  \_--+--_/ Focal
838 Unzoomed \ | / Length
839  FOV --> \ | / |
840  \|/ v
841  +------------------
842 
843 myFullW and myFullH are the dimensions of the plane onto which the
844 image is projected before any adjustments for zoom or window parms.
845 the plane is located at "myAdjustedNear" along the z axis.
846 After taking the zoom and win channels into account, myAdjustedX and
847 myAdjustedY refer to the center of the view on the same plane, and
848 myAdjustedW and myAdjustedH contain the dimensions of the adjusted view.
849 
850 #endif
851 
852 #endif
GLfloat GLfloat GLfloat top
Definition: glew.h:15525
#define SYSmax(a, b)
Definition: SYS_Math.h:1535
void setLimits(fpreal n, fpreal f)
fpreal getNearClip() const
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
int getViewWidth() const
fpreal getNearLimit() const
int rotoscopeTracksWindowVals() const
bool doesWindowOverrideNominal() const
GLenum clamp
Definition: glcorearb.h:1233
void getViewportSize(int &w, int &h) const
void setSelectedObjectBounds(const UT_BoundingBoxD &b)
static void setDefaultHomingStyleFlag(int style)
void
Definition: png.h:1083
GLint left
Definition: glcorearb.h:2004
GT_API const UT_StringHolder time
void setApertureOffsets(fpreal h, fpreal v)
void setWindow(fpreal x, fpreal y, fpreal w, fpreal h)
SYS_FORCE_INLINE void setT(const UT_Vector3D &t)
int getView2DVersion() const
axis getHomeAxis() const
GA_API const UT_StringHolder rot
fpreal getWinX() const
int getBottomMargin() const
int h() const
Get width/height dimensions.
Definition: UT_Rect.h:246
GLenum GLsizei GLenum GLenum const void * image
Definition: glew.h:4973
void setAperture(fpreal a)
void setCPlaneHomeRotCallback(GUI_HomeRotCallback callback, void *data)
GLdouble far
Definition: glcorearb.h:142
3D Vector class.
int getApplyAspectFlag() const
static void setTumbleStyleFlag(int style)
void getLimits(fpreal *n, fpreal *f)
float fpreal32
Definition: SYS_Types.h:200
GLdouble GLdouble t
Definition: glew.h:1403
void setView(const UT_DimRect &area)
GLfloat right
Definition: glew.h:15525
void getApertureOffsets(fpreal &h, fpreal &v) const
int initialized() const
int getView3DVersion() const
void setFocalUnitScale(fpreal f)
void setViewport(RE_Render *r, const UT_DimRect &viewarea)
void(* GUI_HomeRotCallback)(UT_Matrix3R &, void *)
GLdouble l
Definition: glew.h:9164
fpreal getFarLimit() const
int getOrthoFlag() const
GLint GLenum GLint x
Definition: glcorearb.h:408
void setScreenWindow(fpreal l, fpreal r, fpreal b, fpreal t)
fpreal getAperture() const
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
void setFocalLength(fpreal f)
const char * className() const
void setAdjustLimits(GUI_ViewAdjustLimits which)
fpreal getFocalLength() const
void getWindow(fpreal &x, fpreal &y, fpreal &w, fpreal &h) const
int getViewportHeight() const
void setApplyAspectFlag(int a)
SYS_FORCE_INLINE void setP(const UT_Vector3D &p)
bool any(const vbool4 &v)
Definition: simd.h:3446
void setWindowAffectRotoscope(int v)
fpreal getFocalUnitScale() const
#define GUI_API
Definition: GUI_API.h:10
void setHomeAxis(axis homeaxis)
GLsizei GLsizei GLfloat distance
Definition: glew.h:13923
void setOrthoFlag(int o)
void getViewport(UT_DimRect &area) const
const GLdouble * v
Definition: glcorearb.h:836
GUI_ViewAdjustLimits getAdjustLimits() const
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
void set(int v1, int v2, int v3, int v4)
Set the native rect type values.
Definition: UT_Rect.h:135
GLint GLint bottom
Definition: glcorearb.h:2004
void setOrthoWidth(fpreal w)
static bool isOrientationZUp()
void setRotateMatrix(const UT_Matrix3D &mat)
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:847
int getViewHeight() const
void setNominalWindow(fpreal x, fpreal y, fpreal w, fpreal h)
int getViewportWidth() const
GLfloat GLfloat p
Definition: glew.h:16656
int x() const
Get lower-left corner.
Definition: UT_Rect.h:225
void allowNearFarClipAdapt(bool allow)
int w() const
Get width/height dimensions.
Definition: UT_Rect.h:245
fpreal getZBufferFar() const
fpreal getLastHomeRadius() const
ImageBuf OIIO_API rotate(const ImageBuf &src, float angle, string_view filtername=string_view(), float filterwidth=0.0f, bool recompute_roi=false, ROI roi={}, int nthreads=0)
fpreal getWinSizeX() const
static int getScrollStyleFlag()
GLint GLsizei width
Definition: glcorearb.h:102
GLint GLsizei GLsizei height
Definition: glcorearb.h:102
int getRightMargin() const
UT_Rect< UT_InclusiveRectImpl > UT_InclusiveRect
Integer rectangle class which stores its data as inclusive lower-left to upper-right (x1...
Definition: UT_Rect.h:53
fpreal getDefaultFOV() const
GT_API const UT_StringHolder version
GLdouble n
Definition: glcorearb.h:2007
fpreal getWinY() const
const UT_BoundingBoxD & getSceneBounds() const
GLboolean * data
Definition: glcorearb.h:130
IFDmantra py
Definition: HDK_Image.dox:266
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:794
fpreal getFStop() const
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
static axis getDefaultHomingStyleFlag()
GLsizei const GLint box[]
Definition: glew.h:11654
static int getTumbleStyleFlag()
bool getSubRegion(fpreal &x, fpreal &y, fpreal &w, fpreal &h) const
static void setScrollStyleFlag(int style)
static int getAltKeyViewControlsFlag()
void setFocusDistance(fpreal f)
const UT_Matrix4D & getTransformMatrix()
fpreal64 fpreal
Definition: SYS_Types.h:277
fpreal getFocusDistance() const
static void setAltKeyViewControlsFlag(int style)
void getViewState(gui_View &view_state) const
void setSubRegion(fpreal x, fpreal y, fpreal w, fpreal h)
fpreal getAspectRatio() const
bool isDirty() const
static bool isOrientationYUp()
int y() const
Get lower-left corner.
Definition: UT_Rect.h:226
GLfloat f
Definition: glcorearb.h:1925
void setSceneBounds(const UT_BoundingBoxD &b)
void setCustomHomeRot(UT_Matrix3R &rot)
int getTopMargin() const
SYS_FORCE_INLINE const UT_Vector3D & getT() const
void setViewState(const gui_View &view_state)
void getNominalWindow(fpreal &x, fpreal &y, fpreal &w, fpreal &h) const
void setFrustumScale(fpreal xsc, fpreal ysc)
void setAspectRatio(fpreal a)
UT_InclusiveRect getView() const
const UT_Matrix4D & getProjectionMatrix() const
const UT_Matrix4D & getRotateMatrix() const
SYS_FORCE_INLINE const UT_Vector3D & getP() const
int getViewVersion() const
void setTransformCallback(GUI_TransformCallback callback, void *data)
GLboolean r
Definition: glcorearb.h:1221
fpreal getFarClip() const
fpreal getOrthoWidth() const
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER Vec project(const Vec &s, const Vec &t)
Definition: ImathVecAlgo.h:96
const UT_Matrix3R & getCustomHomeRot() const
fpreal getWinSizeY() const
fpreal getZBufferNear() const
void setFStop(fpreal fs)
GLint y
Definition: glcorearb.h:102
void getScreenWindow(fpreal &l, fpreal &r, fpreal &b, fpreal &t) const
void(* GUI_TransformCallback)(UT_DMatrix4 &, fpreal time, void *)
UT_InclusiveRect getViewport() const
GA_API const UT_StringHolder area
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
fpreal32 getExtendedZBufferFar() const
const UT_Matrix4D & getItransformMatrix()
int getLeftMargin() const