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
00104 class SbViewportRegion {
00105
00106 public:
00110 SbViewportRegion();
00111
00116 SbViewportRegion(short width, short height, float newScale = 1.0);
00117
00122 SbViewportRegion(SbVec2s winSize, float newScale = 1.0);
00123
00128 SbViewportRegion(SbVec2i32 winSize, float newScale = 1.0);
00129
00133 SbViewportRegion(const SbViewportRegion &vpReg);
00134
00143 void setWindowSize(short width, short height)
00144 { setWindowSize(SbVec2i32(width, height)); }
00145
00154 void setWindowSize(SbVec2s winSize);
00155
00164 void setWindowSize(SbVec2i32 winSize);
00165
00173 void setViewport(float left, float bottom, float width, float height)
00174 { setViewport(SbVec2f(left, bottom), SbVec2f(width, height)); }
00175
00182 void setViewport(SbVec2f origin, SbVec2f size);
00183
00191 void setViewportPixels(short left, short bottom, short width, short height)
00192 { setViewportPixels(SbVec2i32(left, bottom), SbVec2i32(width, height)); }
00193
00201 void setViewportPixels(SbVec2s origin, SbVec2s size);
00202
00210 void setViewportPixels(SbVec2i32 origin, SbVec2i32 size);
00211
00218 const SbVec2s &getWindowSize() const;
00219
00226 const SbVec2i32 &getWindowSize_i32() const;
00227
00232 const SbVec2f &getViewportOrigin() const
00233 { return vpOrigin; }
00234
00238 const SbVec2s &getViewportOriginPixels() const;
00239
00243 const SbVec2i32 &getViewportOriginPixels_i32() const;
00244
00249 const SbVec2f &getViewportSize() const
00250 { return vpSize; }
00251
00255 const SbVec2s &getViewportSizePixels() const;
00256
00260 const SbVec2i32 &getViewportSizePixels_i32() const;
00261
00265 float getViewportAspectRatio() const;
00266
00272 void scaleWidth(float ratio);
00273
00279 void scaleHeight(float ratio);
00280
00287 void setPixelsPerInch(float ppi)
00288 { pixelsPerInch = ppi; }
00289
00294 float getPixelsPerInch() const
00295 { return pixelsPerInch; }
00296
00300 float getPixelsPerPoint() const
00301 { return (pixelsPerInch / s_historicalPixelPerInch); }
00302
00310 SbVec2f normalize( const SbVec2s& position ) const;
00311
00315 friend int operator ==(const SbViewportRegion ®1,
00316 const SbViewportRegion ®2);
00317
00318 private:
00319
00325 SbViewportRegion(SbVec2s viewSize, SbVec2s winSize, float newScale = 1.0);
00326
00327 void setViewportScale(float vpScale)
00328 { viewportScale = vpScale; }
00329
00330 float getViewportScale() const
00331 {return viewportScale; }
00332
00333 static const float s_historicalPixelPerInch;
00334 static float s_defaultPixelsPerInch;
00335 static void setDefaultPixelsPerInch(float ppi)
00336 { s_defaultPixelsPerInch = ppi; }
00337
00338 private:
00339 SbVec2i32 windowSize_i32;
00340 SbVec2s windowSize;
00341 SbVec2f vpOrigin;
00342 SbVec2s vpOriginPix;
00343 SbVec2i32 vpOriginPix_i32;
00344 SbVec2f vpSize;
00345 SbVec2s vpSizePix;
00346 SbVec2i32 vpSizePix_i32;
00347 SbBool vpSet;
00348 float pixelsPerInch;
00349 float viewportScale;
00350
00351
00352 void setFullViewport();
00353
00354
00355 void adjustViewport();
00356 };
00357
00374 class SoGetView {
00375 public:
00379 SoGetView();
00380 virtual ~SoGetView() {};
00381
00386 virtual SbBool getViewportIsEnabled() const;
00387
00391 virtual const SbVec2f getViewportOrigin() const;
00392
00396 virtual const SbVec2f getViewportSize() const;
00397 };
00398
00399 #endif
00400
00401