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
00318 friend int operator !=( const SbViewportRegion ®1, const SbViewportRegion ®2 )
00319 {
00320 return !operator==( reg1, reg2 );
00321 }
00322
00323 private:
00324
00330 SbViewportRegion(SbVec2s viewSize, SbVec2s winSize, float newScale = 1.0);
00331
00332 void setViewportScale(float vpScale)
00333 { viewportScale = vpScale; }
00334
00335 float getViewportScale() const
00336 {return viewportScale; }
00337
00338 static const float s_historicalPixelPerInch;
00339 static float s_defaultPixelsPerInch;
00340 static void setDefaultPixelsPerInch(float ppi)
00341 { s_defaultPixelsPerInch = ppi; }
00342
00343 private:
00344 SbVec2i32 windowSize_i32;
00345 SbVec2s windowSize;
00346 SbVec2f vpOrigin;
00347 SbVec2s vpOriginPix;
00348 SbVec2i32 vpOriginPix_i32;
00349 SbVec2f vpSize;
00350 SbVec2s vpSizePix;
00351 SbVec2i32 vpSizePix_i32;
00352 SbBool vpSet;
00353 float pixelsPerInch;
00354 float viewportScale;
00355
00356
00357 void setFullViewport();
00358
00359
00360 void adjustViewport();
00361 };
00362
00378 class SoGetView {
00379 public:
00383 SoGetView();
00384 virtual ~SoGetView() {};
00385
00390 virtual SbBool getViewportIsEnabled() const;
00391
00395 virtual const SbVec2f getViewportOrigin() const;
00396
00400 virtual const SbVec2f getViewportSize() const;
00401 };
00402
00403 #endif
00404
00405