00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef _SB_VIEWPORT_REGION_
00051 #define _SB_VIEWPORT_REGION_
00052
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00066
00067 #include <Inventor/SbLinear.h>
00068
00103 class SbViewportRegion {
00104
00105 public:
00109 SbViewportRegion();
00110
00115 SbViewportRegion(short width, short height, float newScale = 1.0);
00116
00121 SbViewportRegion(SbVec2s winSize, float newScale = 1.0);
00122
00127 SbViewportRegion(SbVec2i32 winSize, float newScale = 1.0);
00128
00132 SbViewportRegion(const SbViewportRegion &vpReg);
00133
00142 void setWindowSize(short width, short height)
00143 { setWindowSize(SbVec2i32(width, height)); }
00144
00153 void setWindowSize(SbVec2s winSize);
00154
00163 void setWindowSize(SbVec2i32 winSize);
00164
00172 void setViewport(float left, float bottom, float width, float height)
00173 { setViewport(SbVec2f(left, bottom), SbVec2f(width, height)); }
00174
00181 void setViewport(SbVec2f origin, SbVec2f size);
00182
00190 void setViewportPixels(short left, short bottom, short width, short height)
00191 { setViewportPixels(SbVec2i32(left, bottom), SbVec2i32(width, height)); }
00192
00200 void setViewportPixels(SbVec2s origin, SbVec2s size);
00201
00209 void setViewportPixels(SbVec2i32 origin, SbVec2i32 size);
00210
00217 const SbVec2s &getWindowSize() const;
00218
00225 const SbVec2i32 &getWindowSize_i32() const;
00226
00231 const SbVec2f &getViewportOrigin() const
00232 { return vpOrigin; }
00233
00237 const SbVec2s &getViewportOriginPixels() const;
00238
00242 const SbVec2i32 &getViewportOriginPixels_i32() const;
00243
00248 const SbVec2f &getViewportSize() const
00249 { return vpSize; }
00250
00254 const SbVec2s &getViewportSizePixels() const;
00255
00259 const SbVec2i32 &getViewportSizePixels_i32() const;
00260
00264 float getViewportAspectRatio() const;
00265
00271 void scaleWidth(float ratio);
00272
00278 void scaleHeight(float ratio);
00279
00284 void setPixelsPerInch(float ppi)
00285 { pixelsPerInch = ppi; }
00286
00291 float getPixelsPerInch() const
00292 { return pixelsPerInch; }
00293
00297 float getPixelsPerPoint() const
00298 { return (pixelsPerInch / s_historicalPixelPerInch); }
00299
00307 SbVec2f normalize( const SbVec2s& position ) const;
00308
00312 friend int operator ==(const SbViewportRegion ®1,
00313 const SbViewportRegion ®2);
00314
00315 private:
00316
00322 SbViewportRegion(SbVec2s viewSize, SbVec2s winSize, float newScale = 1.0);
00323
00324 void setViewportScale(float vpScale)
00325 { viewportScale = vpScale; }
00326
00327 float getViewportScale() const
00328 {return viewportScale; }
00329
00330 static const float s_historicalPixelPerInch;
00331 static float s_defaultPixelsPerInch;
00332 static void setDefaultPixelsPerInch(float ppi)
00333 { s_defaultPixelsPerInch = ppi; }
00334
00335 private:
00336 SbVec2i32 windowSize_i32;
00337 SbVec2s windowSize;
00338 SbVec2f vpOrigin;
00339 SbVec2s vpOriginPix;
00340 SbVec2i32 vpOriginPix_i32;
00341 SbVec2f vpSize;
00342 SbVec2s vpSizePix;
00343 SbVec2i32 vpSizePix_i32;
00344 SbBool vpSet;
00345 float pixelsPerInch;
00346 float viewportScale;
00347
00348
00349 void setFullViewport();
00350
00351
00352 void adjustViewport();
00353 };
00354
00370 class SoGetView {
00371 public:
00375 SoGetView();
00376 virtual ~SoGetView() {};
00377
00382 virtual SbBool getViewportIsEnabled() const;
00383
00387 virtual const SbVec2f getViewportOrigin() const;
00388
00392 virtual const SbVec2f getViewportSize() const;
00393 };
00394
00395 #endif
00396
00397