15 #ifndef __GUI_ViewParameter__
16 #define __GUI_ViewParameter__
50 void save(std::ostream &os)
const;
72 FRONT, RIGHT,
TOP, BACK, LEFT, BOTTOM, CPLANE };
80 area.
set(myViewportLeft, myViewportBottom, w,h);
82 void getViewport(
int &l,
int &
r,
int &
b,
int &
t)
const;
86 w = myViewportRight - myViewportLeft + 1;
87 h = myViewportTop - myViewportBottom + 1;
90 {
return myViewportRight - myViewportLeft + 1; }
92 {
return myViewportTop - myViewportBottom + 1; }
95 { setViewport(r, viewarea.
x(), viewarea.
y(),
96 viewarea.
w(), viewarea.
h()); }
101 myViewportRight, myViewportTop); }
111 void getProjection(
UT_Matrix4D &proj,
bool depth_adjust=
true);
117 bool infinite_far_plane);
146 { setView(area.
x(), area.
y(), area.
w(), area.
h()); }
147 void setView(
int x,
int y,
int w,
int h);
148 void getView(
int &l,
int &
r,
int &
b,
int &
t)
const;
150 {
return myViewRight - myViewLeft + 1; }
152 {
return myViewTop - myViewBottom + 1; }
156 myViewRight, myViewTop); }
160 void viewToViewportProjectionBounds(
167 {
return myViewLeft - myViewportLeft; }
169 {
return myViewportRight - myViewRight; }
171 {
return myViewBottom - myViewportBottom; }
173 {
return myViewportTop - myViewTop; }
177 bool centre_to_origin =
false,
bool zoom_in =
false);
179 void homeRotation(axis
a);
184 void setDefaultFOV(
fpreal fov_in_degrees);
189 static void getOrientationChangeRotation(
204 void beginContinuouslyExportedOperation();
205 void endContinuouslyExportedOperation();
206 bool continuouslyExportedOperationInProgress()
const;
212 void incrementtrackball(
fpreal dx,
fpreal dy,
int finish);
213 void eulertumble(
fpreal dx,
fpreal dy,
int finish,
bool lock);
222 void worldLockedScroll(
const UT_Vector3R &locked_pos,
226 bool precise_zoom =
false,
227 bool smooth_deltas =
false);
234 void directedDolly(
const UT_Vector3R &unit_worldspace_dir,
235 fpreal dx,
bool precise_zoom =
false,
236 bool smooth_deltas =
false);
243 void zoom(
fpreal dx, GUI_ZoomItem item,
bool precise_zoom =
false);
246 void zoom(
fpreal dx, GUI_ZoomItem item,
248 bool precise_zoom =
false);
255 bool precise_zoom =
false);
258 bool precise_zoom =
false);
272 fpreal orthowidth,
bool is_ortho);
277 static void getFrustumCenter(
fpreal frustum_width,
fpreal aspect,
285 bool isDirty()
const {
return (myFlag.viewportDirty ||
286 myFlag.matrixDirty ||
287 myFlag.iMatrixDirty); }
305 *n = myView.myNearLimit;
306 *f = myView.myFarLimit;
308 void setNearClip(
fpreal near);
313 void setMaxNearClip(
bool limit,
fpreal near_max);
321 { mySelectedObjBounds=
b; }
327 static void setExtendedZBufferRangeSupport(
bool has_ext);
330 { myAllowNearFarClipAdapt = allow; }
342 updateWindowOverridesNominal();
359 updateWindowOverridesNominal();
370 {
return myWindowOverridesNominal; }
377 void getViewBoundsRelativeToNominalWindow(
388 convertViewToScreenWindow(myView.myWinX, myView.myWinY,
389 myView.myWinW, myView.myWinH,
394 convertScreenToViewWindow(l, r, b, t,
395 myView.myWinX, myView.myWinY,
396 myView.myWinW, myView.myWinH);
401 myHasSubRegion =
true;
409 myHasSubRegion =
false;
421 return myHasSubRegion;
425 static void convertScreenToViewWindow(
428 static void convertViewToScreenWindow(
439 GUI_VIEW_ADJUST_NONE = 0,
440 GUI_VIEW_ADJUST_FAR = 1,
441 GUI_VIEW_ADJUST_NEAR = 2,
442 GUI_VIEW_ADJUST_BOTH = 3
445 { myAdjustLimits = which; }
450 {
return myFlag.rotoTrackWindow; }
460 myFrustumWidthScale = xsc;
461 myFrustumHeightScale = ysc;
470 { myView.myT =
t; myFlag.matrixDirty=1; myFlag.iMatrixDirty=1;}
479 { myView.myP = p; myFlag.matrixDirty=1; myFlag.iMatrixDirty=1;}
481 static void setOrientationMode(orientation o);
482 static orientation getOrientationMode();
484 {
return getOrientationMode() ==
Y_UP; }
486 {
return getOrientationMode() ==
Z_UP; }
490 { myTumbleStyle = style; }
493 { myAltKeyViewControls = style; }
496 { myScrollStyle = style; }
504 { myView.myRotateMatrix = mat;
505 myFlag.matrixDirty = 1;
506 myFlag.iMatrixDirty = 1;
507 myFlag.rxyzDirty = 1; }
511 {
return myProjectionOverride ? *myProjectionOverride
512 : myView.myProjectionMatrix; }
514 return myTransformMatrix; }
516 return myItransformMatrix; }
528 myTransformCallback = callback;
529 myTransformCallbackData =
data;
535 int save(std::ostream &os,
536 char separator =
'\n',
537 bool for_view_copy =
false)
const;
542 const char *
className()
const {
return "GUI_ViewParameter"; }
547 { myHomeAxis = homeaxis; myFlag.rxyzDirty = 1; }
557 myCPlaneHomeRotCallback = callback;
558 myCPlaneHomeRotCallbackData =
data;
582 myView.myHApertureOffset =
h;
583 myView.myVApertureOffset =
v;
587 h = myView.myHApertureOffset;
588 v = myView.myVApertureOffset;
616 : myT(0.0, 0.0, 0.1),
619 myProjectionMatrix(1.0),
626 myFocusDistance(5.0),
632 myHApertureOffset(0.0),
633 myVApertureOffset(0.0),
669 { view_state = myView; }
673 myFlag.matrixDirty=1;
674 myFlag.iMatrixDirty=1;
676 updateWindowOverridesNominal();
679 void adjustNearFarClip();
685 GUI_ViewAdjustLimits myAdjustLimits;
686 bool myInfiniteFarPlane =
false;
687 bool myIsFreeCam =
true;
709 void updateTransformMatrix();
710 void updateItransformMatrix();
711 void updateRXYZValues();
712 fpreal getDistanceToBoxCenter(
int clamp = 0)
const;
727 bool computeWorldLockedScrollAccel(
fpreal dx,
fpreal dy,
735 void updateWindowOverridesNominal()
737 myWindowOverridesNominal =
738 (myView.myWinX != myNominalWinX ||
739 myView.myWinY != myNominalWinY ||
740 myView.myWinW != myNominalWinW ||
741 myView.myWinH != myNominalWinH);
750 static orientation myOrientationMode;
751 static int myTumbleStyle;
752 static int myAltKeyViewControls;
753 static int myScrollStyle;
754 static axis myDefaultHomingStyle;
763 void *myTransformCallbackData;
766 fpreal myLastHomeDistance;
767 fpreal myLastHomePixelWidthOBSOLETE;
768 fpreal myLastHomeAdjustedBoxWidth;
769 fpreal myLastHomeOrthoWidth;
775 bool myObsoleteScrollIsActive;
781 void *myCPlaneHomeRotCallbackData;
786 class ContinuousExportCache
789 ContinuousExportCache() {}
801 typedef ContinuousExportCache ViewOpCache;
803 ViewOpCache myContinuousExportCache;
804 bool myContinuousExportInProgress;
811 bool myWindowOverridesNominal;
824 int myViewportLeft, myViewportRight;
825 int myViewportBottom, myViewportTop;
831 int myViewLeft, myViewRight;
832 int myViewBottom, myViewTop;
838 bool myHasExtendedZBufferFar;
839 bool myAllowNearFarClipAdapt;
844 bool myLimitNearClip =
false;
845 fpreal myMaxNearClip = 1.0;
849 #ifdef __DOCUMENTATION__
851 FOV can be computed from aperture and focal
length.
856 +------+------+-----------
860 Unzoomed \ | / Length
865 myFullW and myFullH are the dimensions of the plane onto which the
866 image is projected before
any adjustments
for zoom or window parms.
867 the plane is located at
"myAdjustedNear" along the
z axis.
868 After taking the zoom and win
channels into account, myAdjustedX and
869 myAdjustedY refer to the
center of the
view on the same plane, and
870 myAdjustedW and myAdjustedH contain the dimensions of the adjusted
view.
void setLimits(fpreal n, fpreal f)
fpreal getNearClip() const
fpreal getNearLimit() const
int rotoscopeTracksWindowVals() const
bool doesWindowOverrideNominal() const
fpreal myFrustumHeightScale
void getViewportSize(int &w, int &h) const
void setSelectedObjectBounds(const UT_BoundingBoxD &b)
static void setDefaultHomingStyleFlag(int style)
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)
bool getInfiniteFarPlane() const
int getView2DVersion() const
GA_API const UT_StringHolder rot
GLdouble GLdouble GLdouble z
int getBottomMargin() const
int h() const
Get width/height dimensions.
GLboolean GLboolean GLboolean GLboolean a
void setInfiniteFarPlane(bool enable)
GLuint GLsizei GLsizei * length
void setAperture(fpreal a)
GLenum GLenum GLsizei void * image
void setCPlaneHomeRotCallback(GUI_HomeRotCallback callback, void *data)
int getApplyAspectFlag() const
static void setTumbleStyleFlag(int style)
void getLimits(fpreal *n, fpreal *f)
void setView(const UT_DimRect &area)
Temporary container for either a RV_Render and an RE_Render.
void getApertureOffsets(fpreal &h, fpreal &v) const
int getView3DVersion() const
void setFocalUnitScale(fpreal f)
void(* GUI_HomeRotCallback)(UT_Matrix3R &, void *)
fpreal getFarLimit() const
void setScreenWindow(fpreal l, fpreal r, fpreal b, fpreal t)
fpreal getAperture() const
void setFocalLength(fpreal f)
const char * className() const
void setAdjustLimits(GUI_ViewAdjustLimits which)
GLint GLsizei GLsizei height
fpreal getFocalLength() const
void getWindow(fpreal &x, fpreal &y, fpreal &w, fpreal &h) const
fpreal getMaxNearClip() const
int getViewportHeight() const
void setApplyAspectFlag(int a)
SYS_FORCE_INLINE void setP(const UT_Vector3D &p)
bool any(const vbool4 &v)
void setWindowAffectRotoscope(int v)
fpreal getFocalUnitScale() const
fpreal myFrustumWidthScale
void setHomeAxis(axis homeaxis)
void getViewport(UT_DimRect &area) const
UT_Vector2T< T > project(const UT_Vector2T< T > &u, const UT_Vector2T< T > &v)
The orthogonal projection of a vector u onto a vector v.
GUI_ViewAdjustLimits getAdjustLimits() const
UT_Matrix4D myRotateMatrix
void set(int v1, int v2, int v3, int v4)
Set the native rect type values.
void setOrthoWidth(fpreal w)
static bool isOrientationZUp()
void setRotateMatrix(const UT_Matrix3D &mat)
int getViewHeight() const
void setNominalWindow(fpreal x, fpreal y, fpreal w, fpreal h)
int getViewportWidth() const
int x() const
Get lower-left corner.
void allowNearFarClipAdapt(bool allow)
int w() const
Get width/height dimensions.
GLboolean GLboolean GLboolean b
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()
void setIsFreeCam(bool free_cam)
int getRightMargin() const
UT_Rect< UT_InclusiveRectImpl > UT_InclusiveRect
Integer rectangle class which stores its data as inclusive lower-left to upper-right (x1...
fpreal getDefaultFOV() const
GT_API const UT_StringHolder version
const UT_BoundingBoxD & getSceneBounds() const
GLfloat GLfloat GLfloat GLfloat h
static axis getDefaultHomingStyleFlag()
static int getTumbleStyleFlag()
bool getSubRegion(fpreal &x, fpreal &y, fpreal &w, fpreal &h) const
static void setScrollStyleFlag(int style)
bool hasMaxNearClip() const
static int getAltKeyViewControlsFlag()
void setFocusDistance(fpreal f)
const UT_Matrix4D & getTransformMatrix()
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
static bool isOrientationYUp()
int y() const
Get lower-left corner.
void setSceneBounds(const UT_BoundingBoxD &b)
void setCustomHomeRot(UT_Matrix3R &rot)
GLdouble GLdouble GLdouble top
void setViewport(RE_RenderContext r, const UT_DimRect &viewarea)
SYS_FORCE_INLINE const UT_Vector3D & getT() const
void setViewState(const gui_View &view_state)
GLubyte GLubyte GLubyte GLubyte w
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
SIM_API const UT_StringHolder distance
void setTransformCallback(GUI_TransformCallback callback, void *data)
bool hasSubRegion() const
fpreal getFarClip() const
fpreal getOrthoWidth() const
const UT_Matrix3R & getCustomHomeRot() const
fpreal getWinSizeY() const
fpreal getZBufferNear() const
UT_Matrix4D myProjectionMatrix
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