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);
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;
144 {
return myViewRight - myViewLeft + 1; }
146 {
return myViewTop - myViewBottom + 1; }
150 myViewRight, myViewTop); }
154 void viewToViewportProjectionBounds(
161 {
return myViewLeft - myViewportLeft; }
163 {
return myViewportRight - myViewRight; }
165 {
return myViewBottom - myViewportBottom; }
167 {
return myViewportTop - myViewTop; }
171 bool centre_to_origin =
false,
bool zoom_in =
false);
173 void homeRotation(axis
a);
178 void setDefaultFOV(
fpreal fov_in_degrees);
183 static void getOrientationChangeRotation(
198 void beginContinuouslyExportedOperation();
199 void endContinuouslyExportedOperation();
200 bool continuouslyExportedOperationInProgress()
const;
206 void incrementtrackball(
fpreal dx,
fpreal dy,
int finish);
207 void eulertumble(
fpreal dx,
fpreal dy,
int finish,
bool lock);
216 void worldLockedScroll(
const UT_Vector3R &locked_pos,
220 bool precise_zoom =
false,
221 bool smooth_deltas =
false);
228 void directedDolly(
const UT_Vector3R &unit_worldspace_dir,
229 fpreal dx,
bool precise_zoom =
false,
230 bool smooth_deltas =
false);
237 void zoom(
fpreal dx, GUI_ZoomItem item,
bool precise_zoom =
false);
240 void zoom(
fpreal dx, GUI_ZoomItem item,
242 bool precise_zoom =
false);
249 bool precise_zoom =
false);
252 bool precise_zoom =
false);
266 fpreal orthowidth,
bool is_ortho);
271 static void getFrustumCenter(
fpreal frustum_width,
fpreal aspect,
279 bool isDirty()
const {
return (myFlag.viewportDirty ||
280 myFlag.matrixDirty ||
281 myFlag.iMatrixDirty); }
296 *n = myView.myNearLimit;
297 *f = myView.myFarLimit;
299 void setNearClip(
fpreal near);
308 { mySelectedObjBounds=
b; }
314 static void setExtendedZBufferRangeSupport(
bool has_ext);
317 { myAllowNearFarClipAdapt = allow; }
325 updateWindowOverridesNominal();
342 updateWindowOverridesNominal();
353 {
return myWindowOverridesNominal; }
360 void getViewBoundsRelativeToNominalWindow(
371 convertViewToScreenWindow(myView.myWinX, myView.myWinY,
372 myView.myWinW, myView.myWinH,
377 convertScreenToViewWindow(l, r, b, t,
378 myView.myWinX, myView.myWinY,
379 myView.myWinW, myView.myWinH);
384 myHasSubRegion =
true;
392 myHasSubRegion =
false;
404 return myHasSubRegion;
408 static void convertScreenToViewWindow(
411 static void convertViewToScreenWindow(
422 GUI_VIEW_ADJUST_NONE = 0,
423 GUI_VIEW_ADJUST_FAR = 1,
424 GUI_VIEW_ADJUST_NEAR = 2,
425 GUI_VIEW_ADJUST_BOTH = 3
428 { myAdjustLimits = which; }
433 {
return myFlag.rotoTrackWindow; }
443 myFrustumWidthScale = xsc;
444 myFrustumHeightScale = ysc;
453 { myView.myT =
t; myFlag.matrixDirty=1; myFlag.iMatrixDirty=1;}
462 { myView.myP =
p; myFlag.matrixDirty=1; myFlag.iMatrixDirty=1;}
464 static void setOrientationMode(orientation o);
465 static orientation getOrientationMode();
467 {
return getOrientationMode() ==
Y_UP; }
469 {
return getOrientationMode() ==
Z_UP; }
473 { myTumbleStyle = style; }
476 { myAltKeyViewControls = style; }
479 { myScrollStyle = style; }
487 { myView.myRotateMatrix = mat;
488 myFlag.matrixDirty = 1;
489 myFlag.iMatrixDirty = 1;
490 myFlag.rxyzDirty = 1; }
494 {
return myProjectionOverride ? *myProjectionOverride
495 : myView.myProjectionMatrix; }
497 return myTransformMatrix; }
499 return myItransformMatrix; }
511 myTransformCallback = callback;
512 myTransformCallbackData =
data;
518 int save(std::ostream &os,
519 char separator =
'\n',
520 bool for_view_copy =
false)
const;
525 const char *
className()
const {
return "GUI_ViewParameter"; }
530 { myHomeAxis = homeaxis; myFlag.rxyzDirty = 1; }
540 myCPlaneHomeRotCallback = callback;
541 myCPlaneHomeRotCallbackData =
data;
565 myView.myHApertureOffset =
h;
566 myView.myVApertureOffset =
v;
570 h = myView.myHApertureOffset;
571 v = myView.myVApertureOffset;
599 : myT(0.0, 0.0, 0.1),
602 myProjectionMatrix(1.0),
609 myFocusDistance(5.0),
615 myHApertureOffset(0.0),
616 myVApertureOffset(0.0),
652 { view_state = myView; }
656 myFlag.matrixDirty=1;
657 myFlag.iMatrixDirty=1;
659 updateWindowOverridesNominal();
662 void adjustNearFarClip();
668 GUI_ViewAdjustLimits myAdjustLimits;
690 void updateTransformMatrix();
691 void updateItransformMatrix();
692 void updateRXYZValues();
693 fpreal getDistanceToBoxCenter(
int clamp = 0)
const;
708 bool computeWorldLockedScrollAccel(
fpreal dx,
fpreal dy,
716 void updateWindowOverridesNominal()
718 myWindowOverridesNominal =
719 (myView.myWinX != myNominalWinX ||
720 myView.myWinY != myNominalWinY ||
721 myView.myWinW != myNominalWinW ||
722 myView.myWinH != myNominalWinH);
731 static orientation myOrientationMode;
732 static int myTumbleStyle;
733 static int myAltKeyViewControls;
734 static int myScrollStyle;
735 static axis myDefaultHomingStyle;
744 void *myTransformCallbackData;
747 fpreal myLastHomeDistance;
748 fpreal myLastHomePixelWidthOBSOLETE;
749 fpreal myLastHomeAdjustedBoxWidth;
750 fpreal myLastHomeOrthoWidth;
756 bool myObsoleteScrollIsActive;
762 void *myCPlaneHomeRotCallbackData;
767 class ContinuousExportCache
770 ContinuousExportCache() {}
782 typedef ContinuousExportCache ViewOpCache;
784 ViewOpCache myContinuousExportCache;
785 bool myContinuousExportInProgress;
792 bool myWindowOverridesNominal;
805 int myViewportLeft, myViewportRight;
806 int myViewportBottom, myViewportTop;
812 int myViewLeft, myViewRight;
813 int myViewBottom, myViewTop;
819 bool myHasExtendedZBufferFar;
820 bool myAllowNearFarClipAdapt;
828 #ifdef __DOCUMENTATION__
830 FOV can be computed from aperture and focal
length.
835 +------+------+-----------
839 Unzoomed \ | / Length
844 myFullW and myFullH are the dimensions of the plane onto which the
845 image is projected before
any adjustments
for zoom or window parms.
846 the plane is located at
"myAdjustedNear" along the
z axis.
847 After taking the zoom and win
channels into account, myAdjustedX and
848 myAdjustedY refer to the
center of the
view on the same plane, and
849 myAdjustedW and myAdjustedH contain the dimensions of the adjusted
view.
GLfloat GLfloat GLfloat top
void setLimits(fpreal n, fpreal f)
fpreal getNearClip() const
GLboolean GLboolean GLboolean b
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)
int getView2DVersion() const
GA_API const UT_StringHolder rot
int getBottomMargin() const
int h() const
Get width/height dimensions.
GLenum GLsizei GLenum GLenum const void * image
void setAperture(fpreal a)
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)
void getApertureOffsets(fpreal &h, fpreal &v) const
int getView3DVersion() const
void setFocalUnitScale(fpreal f)
void setViewport(RE_Render *r, const UT_DimRect &viewarea)
void(* GUI_HomeRotCallback)(UT_Matrix3R &, void *)
fpreal getFarLimit() const
void setScreenWindow(fpreal l, fpreal r, fpreal b, fpreal t)
fpreal getAperture() const
GLubyte GLubyte GLubyte GLubyte w
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)
void setWindowAffectRotoscope(int v)
fpreal getFocalUnitScale() const
fpreal myFrustumWidthScale
void setHomeAxis(axis homeaxis)
GLsizei GLsizei GLfloat distance
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
GLboolean GLboolean GLboolean GLboolean a
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)
GLdouble GLdouble GLdouble z
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.
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 GLsizei height
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
GLuint GLsizei GLsizei * length
GLfloat GLfloat GLfloat GLfloat h
static axis getDefaultHomingStyleFlag()
GLsizei const GLint box[]
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()
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)
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)
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