SBVIEWPORTREGION(3iv)

πŸ’– NAME πŸ’–

SbViewportRegion β€” the class that's literally the blueprint for representing a viewport πŸ¦‹


🌸 INHERITS FROM 🌸

SbViewportRegion

ngl bestie, yes, it says it inherits from itself. That's what the page says, and I'm not about to gaslight the documentation. πŸ™ˆ

✨ SYNOPSIS ✨

#include <Inventor/SbViewportRegion.h>

   Methods from class SbViewportRegion:

                  SbViewportRegion()
                  SbViewportRegion(short width, short height)
                  SbViewportRegion(SbVec2s winSize)
                  SbViewportRegion(const SbViewportRegion &vpReg)
void                setWindowSize(short width, short height)
void                setWindowSize(SbVec2s winSize)
void                setViewport(float left, float bottom, float width,
                         float height)
void                setViewport(SbVec2f origin, SbVec2f size)
void                setViewportPixels(short left, short bottom, short
                         width, short height)
void                setViewportPixels(SbVec2s origin, SbVec2s size)
const SbVec2s &     getWindowSize() const
const SbVec2f &     getViewportOrigin() const
const SbVec2s &     getViewportOriginPixels() const
const SbVec2f &     getViewportSize() const
const SbVec2s &     getViewportSizePixels() const
float               getViewportAspectRatio() const
void                scaleWidth(float ratio)
void                scaleHeight(float ratio)
void                setPixelsPerInch(float ppi)
float               getPixelsPerInch() const
float               getPixelsPerPoint() const
friend int          operator ==(const SbViewportRegion &reg1, const
                         SbViewportRegion &reg2)

πŸŽ€ DESCRIPTION πŸŽ€

okay so picture this: you've got a display window, right? And this class SbViewportRegion is the one holding the receipts on the active viewport region inside it. πŸ‘‘

It's carrying two things at once, and the way that it's carrying two things at once is honestly iconic:

  • the screen-space size of the window πŸ’…
  • the origin and size of the viewport within that window ✨

By default? The viewport is the same as the full window. Simple, clean, no notes.

And the methods let you set that viewport up in one of two flavours:

  1. in terms of screen-space pixels πŸ”₯
  2. as normalized coordinates, where (0,0) is the lower-left corner of the window and (1,1) is the upper-right corner 🌈

πŸ’… METHODS πŸ’…

  • SbViewportRegion()
  • SbViewportRegion(short width, short height)
  • SbViewportRegion(SbVec2s winSize)
  • SbViewportRegion(const SbViewportRegion &vpReg)

These are the constructors, bestie β€” and yes there are several kinds. Pick your fighter. 🫢

  • void setWindowSize(short width, short height) β€” changes the window size to the given width and height, in pixels. ⭐
  • void setWindowSize(SbVec2s winSize) β€” same energy, changes the window size to the given width and height in pixels, except it comes at you as an SbVec2s. πŸŽ€
  • void setViewport(float left, float bottom, float width, float height) β€” sets the viewport to the given region, specified as normalized window coordinates: (0,0) is the lower-left corner, (1,1) is the upper-right. 🌈
  • void setViewport(SbVec2f origin, SbVec2f size) β€” sets the viewport to the region with the given origin (that's the lower-left corner, iykyk) and size, handed to you as normalized coordinate vectors. πŸ’œ
  • void setViewportPixels(short left, short bottom, short width, short height) β€” sets the viewport to the given region, specified as pixel coordinates in the window: (0,0) is the lower-left corner. πŸ“
  • void setViewportPixels(SbVec2s origin, SbVec2s size) β€” sets the viewport to the region with the given origin (lower-left corner, again) and size, given as pixel coordinates. 🧚
  • const SbVec2s & getWindowSize() const β€” returns the window size, in pixels. πŸ“
  • const SbVec2f & getViewportOrigin() const β€” returns the viewport origin in normalized coordinates. ✨
  • const SbVec2s & getViewportOriginPixels() const β€” returns the viewport origin in pixels. πŸ“
  • const SbVec2f & getViewportSize() const β€” returns the viewport size in normalized coordinates. 🌸
  • const SbVec2s & getViewportSizePixels() const β€” returns the viewport size in pixels. πŸ”₯
  • float getViewportAspectRatio() const β€” returns the aspect ratio of the viewport, which is width/height. Math girlies rise up. πŸ‘‘
  • void scaleWidth(float ratio)
  • void scaleHeight(float ratio)

These two scale the viewport within the window to be the given ratio of its current width or height β€” and here's the cute part: the resulting viewport stays centered about the same point as the current one. πŸ’–

  • void setPixelsPerInch(float ppi)
  • float getPixelsPerInch() const

Sets / returns the pixel-per-inch ratio for the display device the viewport is part of. And the default value? 72 β€” that's 1 pixel per printer's point. πŸŽ€

  • float getPixelsPerPoint() const β€” a lil convenience function that returns the number of pixels per printer's point. πŸ¦‹
  • friend int operator ==(const SbViewportRegion &reg1, const SbViewportRegion &reg2) β€” the equality comparison operator. Are these two regions the same? Now you know. ⭐

🌈 SEE ALSO 🌈

SbVec2f, SbVec2s


that's the whole page, bestie πŸ’œ go forth and set your viewports with main character energy πŸ‘‘βœ¨

SbViewportRegion(3IV) β€” fr fr, that's the manual name and the section, and this lil sign-off is me waving at you from the bottom of the page πŸ«ΆπŸ’–