Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SbViewportRegion Class Reference

Class for representing a viewport. More...

#include <Inventor/SbViewportRegion.h>

Public Member Functions

 SbViewportRegion ()
 Default constructor.
 
 SbViewportRegion (short width, short height, float newScale=1.0)
 Constructor that takes width and a height in pixels.
 
 SbViewportRegion (SbVec2s winSize, float newScale=1.0)
 Constructor that takes width and a height in pixels.
 
 SbViewportRegion (SbVec2i32 winSize, float newScale=1.0)
 Constructor that takes width and a height in pixels.
 
 SbViewportRegion (const SbViewportRegion &vpReg)
 Constructor that takes a viewport region.
 
void setWindowSize (short width, short height)
 Changes window size to given width and height in pixels.
 
void setWindowSize (SbVec2s winSize)
 Changes window size to given width and height in pixels, given as SbVec2s.
 
void setWindowSize (SbVec2i32 winSize)
 Changes window size to given width and height in pixels, given as SbVec2i32.
 
void setViewport (float left, float bottom, float width, float height)
 Sets viewport to given region, specified as normalized coordinates relative to the current window size, where (0,0) is the lower-left corner and (1,1) is the upper-right.
 
void setViewport (SbVec2f origin, SbVec2f size)
 Sets viewport to given region, specified as normalized coordinates relative to the current window size, where (0,0) is the lower-left corner and (1,1) is the upper-right.
 
void setViewportPixels (short left, short bottom, short width, short height)
 Sets viewport to given region, specified as pixel coordinates in window: (0,0) is the lower-left corner.
 
void setViewportPixels (SbVec2s origin, SbVec2s size)
 Sets viewport to region with given origin (lower-left corner) and size, given as pixel coordinates.
 
void setViewportPixels (SbVec2i32 origin, SbVec2i32 size)
 Sets viewport to region with given origin (lower-left corner) and size, given as pixel coordinates.
 
const SbVec2sgetWindowSize () const
 Returns window size in pixels.
 
const SbVec2i32getWindowSize_i32 () const
 Returns window size in pixels.
 
const SbVec2fgetViewportOrigin () const
 Returns viewport origin in 0..1 normalized coordinates relative to the current window size.
 
const SbVec2sgetViewportOriginPixels () const
 Returns viewport origin in pixels.
 
const SbVec2i32getViewportOriginPixels_i32 () const
 Returns viewport origin in pixels.
 
const SbVec2fgetViewportSize () const
 Returns viewport size in 0..1 normalized coordinates relative to the current window size.
 
const SbVec2sgetViewportSizePixels () const
 Returns viewport size in pixels.
 
const SbVec2i32getViewportSizePixels_i32 () const
 Returns viewport size in pixels.
 
float getViewportAspectRatio () const
 Returns aspect ratio (width/height) of viewport.
 
void scaleWidth (float ratio)
 Scales viewport within window to be the given ratio of its current width, leaving the resulting viewport centered about the same point as the current one.
 
void scaleHeight (float ratio)
 Scales viewport within window to be the given ratio of its current height, leaving the resulting viewport centered about the same point as the current one.
 
void setPixelsPerInch (float ppi)
 Sets the pixel-per-inch ratio for the display device the viewport is part of.
 
float getPixelsPerInch () const
 Returns the pixel-per-inch ratio for the display device the viewport is part of.
 
float getPixelsPerPoint () const
 Convenience function that returns number of pixels per printer's point.
 
SbVec2f normalize (const SbVec2s &position) const
 Compute the 0..1 normalized coordinates of the specified pixel position, relative to the current viewport (not window).
 

Friends

int operator== (const SbViewportRegion &reg1, const SbViewportRegion &reg2)
 Equality comparison operator.
 
int operator!= (const SbViewportRegion &reg1, const SbViewportRegion &reg2)
 Inequality comparison operator.
 

Detailed Description

Class for representing a viewport.

This class represents the active viewport region in a display window. It contains the screen-space (pixels) size of the window as well as the origin and size of the viewport within the window. The viewport origin and size is stored both as pixel values and as normalized values (fraction of the window).

Initially the viewport is the same as the full window. Methods allow the viewport to be set either in terms of screen-space pixels or as normalized coordinates, where (0,0) is the lower-left corner of the window and (1,1) is the upper-right corner.

Remember that getWindowSize() returns the size of the window, not the viewport. Always call getViewportOriginPixels() and getViewportSizePixels() if you need the actual viewport in pixels.

Also remember:

  • To normalize a point: use the viewport origin and size.
  • To normalize a distance: use only the viewport size.

The normalize() method is convenient for normalizing a point, but note that it normalizes to the range 0..1 and some Open Inventor classes expect values normalized to the the range -1..1. Currently you must do this normalization yourself.

SEE ALSO

SbVec2f, SbVec2s

Definition at line 103 of file SbViewportRegion.h.

Constructor & Destructor Documentation

◆ SbViewportRegion() [1/5]

SbViewportRegion::SbViewportRegion ( )

Default constructor.

Sets window size and viewport to default 100 x 100 pixels.

◆ SbViewportRegion() [2/5]

SbViewportRegion::SbViewportRegion ( short  width,
short  height,
float  newScale = 1.0 
)

Constructor that takes width and a height in pixels.

Sets the window and the viewport.

◆ SbViewportRegion() [3/5]

SbViewportRegion::SbViewportRegion ( SbVec2s  winSize,
float  newScale = 1.0 
)

Constructor that takes width and a height in pixels.

Sets the window and the viewport.

◆ SbViewportRegion() [4/5]

SbViewportRegion::SbViewportRegion ( SbVec2i32  winSize,
float  newScale = 1.0 
)

Constructor that takes width and a height in pixels.

Sets the window and the viewport.

◆ SbViewportRegion() [5/5]

SbViewportRegion::SbViewportRegion ( const SbViewportRegion vpReg)

Constructor that takes a viewport region.

Member Function Documentation

◆ getPixelsPerInch()

float SbViewportRegion::getPixelsPerInch ( ) const
inline

Returns the pixel-per-inch ratio for the display device the viewport is part of.

Definition at line 291 of file SbViewportRegion.h.

◆ getPixelsPerPoint()

float SbViewportRegion::getPixelsPerPoint ( ) const
inline

Convenience function that returns number of pixels per printer's point.

Definition at line 297 of file SbViewportRegion.h.

◆ getViewportAspectRatio()

float SbViewportRegion::getViewportAspectRatio ( ) const

Returns aspect ratio (width/height) of viewport.

◆ getViewportOrigin()

const SbVec2f & SbViewportRegion::getViewportOrigin ( ) const
inline

Returns viewport origin in 0..1 normalized coordinates relative to the current window size.

Definition at line 231 of file SbViewportRegion.h.

◆ getViewportOriginPixels()

const SbVec2s & SbViewportRegion::getViewportOriginPixels ( ) const

Returns viewport origin in pixels.

◆ getViewportOriginPixels_i32()

const SbVec2i32 & SbViewportRegion::getViewportOriginPixels_i32 ( ) const

Returns viewport origin in pixels.

◆ getViewportSize()

const SbVec2f & SbViewportRegion::getViewportSize ( ) const
inline

Returns viewport size in 0..1 normalized coordinates relative to the current window size.

Definition at line 248 of file SbViewportRegion.h.

◆ getViewportSizePixels()

const SbVec2s & SbViewportRegion::getViewportSizePixels ( ) const

Returns viewport size in pixels.

◆ getViewportSizePixels_i32()

const SbVec2i32 & SbViewportRegion::getViewportSizePixels_i32 ( ) const

Returns viewport size in pixels.

◆ getWindowSize()

const SbVec2s & SbViewportRegion::getWindowSize ( ) const

Returns window size in pixels.

NOTE: By default this is also the viewport size in pixels, but in general this is not the viewport size. Use getViewportSizePixels().

◆ getWindowSize_i32()

const SbVec2i32 & SbViewportRegion::getWindowSize_i32 ( ) const

Returns window size in pixels.

NOTE: By default this is also the viewport size in pixels, but in general this is not the viewport size. Use getViewportSizePixels().

◆ normalize()

SbVec2f SbViewportRegion::normalize ( const SbVec2s position) const

Compute the 0..1 normalized coordinates of the specified pixel position, relative to the current viewport (not window).

Parameters
positionin pixel coordinates
Returns
position in normalized coordinates (0 <= x,y <= 1)

◆ scaleHeight()

void SbViewportRegion::scaleHeight ( float  ratio)

Scales viewport within window to be the given ratio of its current height, leaving the resulting viewport centered about the same point as the current one.

◆ scaleWidth()

void SbViewportRegion::scaleWidth ( float  ratio)

Scales viewport within window to be the given ratio of its current width, leaving the resulting viewport centered about the same point as the current one.

◆ setPixelsPerInch()

void SbViewportRegion::setPixelsPerInch ( float  ppi)
inline

Sets the pixel-per-inch ratio for the display device the viewport is part of.

The default value is 72 (1 pixel per printer's point).

Definition at line 284 of file SbViewportRegion.h.

◆ setViewport() [1/2]

void SbViewportRegion::setViewport ( float  left,
float  bottom,
float  width,
float  height 
)
inline

Sets viewport to given region, specified as normalized coordinates relative to the current window size, where (0,0) is the lower-left corner and (1,1) is the upper-right.

The normalized values are applied to the current window size to compute a new viewport origin and size in pixels.

Definition at line 172 of file SbViewportRegion.h.

◆ setViewport() [2/2]

void SbViewportRegion::setViewport ( SbVec2f  origin,
SbVec2f  size 
)

Sets viewport to given region, specified as normalized coordinates relative to the current window size, where (0,0) is the lower-left corner and (1,1) is the upper-right.

The viewport origin and size in pixels are recomputed.

◆ setViewportPixels() [1/3]

void SbViewportRegion::setViewportPixels ( SbVec2i32  origin,
SbVec2i32  size 
)

Sets viewport to region with given origin (lower-left corner) and size, given as pixel coordinates.

The normalized viewport origin and size are recomputed. The specified values are not clamped to the window size.

◆ setViewportPixels() [2/3]

void SbViewportRegion::setViewportPixels ( SbVec2s  origin,
SbVec2s  size 
)

Sets viewport to region with given origin (lower-left corner) and size, given as pixel coordinates.

The normalized viewport origin and size are recomputed. The specified values are not clamped to the window size.

◆ setViewportPixels() [3/3]

void SbViewportRegion::setViewportPixels ( short  left,
short  bottom,
short  width,
short  height 
)
inline

Sets viewport to given region, specified as pixel coordinates in window: (0,0) is the lower-left corner.

The normalized viewport origin and size are recomputed. The specified values are not clamped to the window size.

Definition at line 190 of file SbViewportRegion.h.

◆ setWindowSize() [1/3]

void SbViewportRegion::setWindowSize ( SbVec2i32  winSize)

Changes window size to given width and height in pixels, given as SbVec2i32.

If viewport has not been explicitly set by the application, the viewport is also changed to the specified width and height. If the viewport has been explicitly set, then the stored normalized values are applied to the new window to compute a new viewport origin and size in pixels.

◆ setWindowSize() [2/3]

void SbViewportRegion::setWindowSize ( SbVec2s  winSize)

Changes window size to given width and height in pixels, given as SbVec2s.

If viewport has not been explicitly set by the application, the viewport is also changed to the specified width and height. If the viewport has been explicitly set, then the stored normalized values are applied to the new window to compute a new viewport origin and size in pixels.

◆ setWindowSize() [3/3]

void SbViewportRegion::setWindowSize ( short  width,
short  height 
)
inline

Changes window size to given width and height in pixels.

If viewport has not been explicitly set by the application, the viewport is also changed to the specified width and height. If the viewport has been explicitly set, then the stored normalized values are applied to the new window to compute a new viewport origin and size in pixels.

Definition at line 142 of file SbViewportRegion.h.

Friends And Related Symbol Documentation

◆ operator!=

int operator!= ( const SbViewportRegion reg1,
const SbViewportRegion reg2 
)
friend

Inequality comparison operator.

Definition at line 318 of file SbViewportRegion.h.

◆ operator==

int operator== ( const SbViewportRegion reg1,
const SbViewportRegion reg2 
)
friend

Equality comparison operator.


The documentation for this class was generated from the following file: