SbViewportRegion(3)
๐ SbViewportRegion(3) โ Library Functions Manual ๐
okay bestie, welcome to the Coin docs, this one's from the Library Functions Manual and it's honestly kind of iconic โจ
๐ธ NAME ๐ธ
SbViewportRegion โ the SbViewportRegion class is a viewport within a full window. that's the whole vibe. a little rectangle inside a bigger rectangle. the rectangle-ception of it all ๐
๐ฆ SYNOPSIS ๐ฆ
#include <Inventor/SbViewportRegion.h>
โจ Public Member Functions โจ
no cap, here's the full squad of methods, every single one:
SbViewportRegion (void)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 (void) constconst SbVec2f & getViewportOrigin (void) constconst SbVec2s & getViewportOriginPixels (void) constconst SbVec2f & getViewportSize (void) constconst SbVec2s & getViewportSizePixels (void) constfloat getViewportAspectRatio (void) constvoid scaleWidth (float ratio)void scaleHeight (float ratio)void setPixelsPerInch (float ppi)float getPixelsPerInch (void) constfloat getPixelsPerPoint (void) constvoid print (FILE *file) const
๐ Detailed Description ๐
okay so, the SbViewportRegion class is a viewport within a full window. say it with me.
The SbViewportRegion class contains information to represent a subview within a window. It stores info about the origin and size of that subview, plus the size of the underlying "full" window. it's giving โจnested rectanglesโจ and we're obsessed ๐ซถ
Available methods include inquiries and manipulation in both normalized coordinates and pixel coordinates. so you can speak either language, bilingual queen ๐
Below is a small example showing how the viewport of a viewer class can be modified, within a "proper" Coin and window system context. Hit 'D' or 'U' to move the viewport region 40 pixels down or up, respectively. Click 'Esc' and zoom with left + middle mouse buttons, to see how the region is defined, where no 3D geometry will be visible outside it. Click 'Esc' again to use 'U' and 'D'. literally so fun, go try it ๐ญ
// Copyright (C) 2000-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoEventCallback.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/events/SoKeyboardEvent.h>
// ************************************************************
static void
keypresscbfunc(void * userdata, SoEventCallback * keyboardcb)
{
SoQtExaminerViewer * viewer = (SoQtExaminerViewer *)userdata;
const SoEvent * event = keyboardcb->getEvent();
int shift = 0;
if (SO_KEY_PRESS_EVENT(event, U)) {
shift = 40;
keyboardcb->setHandled();
}
else if (SO_KEY_PRESS_EVENT(event, D)) {
shift = -40;
keyboardcb->setHandled();
}
if (keyboardcb->isHandled()) {
SbViewportRegion vpr = viewer->getViewportRegion();
SbVec2s size = vpr.getViewportSizePixels();
SbVec2s origin = vpr.getViewportOriginPixels();
origin[1] -= shift;
vpr.setViewportPixels(origin, size);
viewer->setViewportRegion(vpr);
}
}
// ************************************************************
int
main(int argc, char ** argv)
{
QWidget * window = SoQt::init(argv[0]);
SoSeparator * root = new SoSeparator;
root->ref();
root->addChild(new SoCone);
SoQtExaminerViewer * viewer = new SoQtExaminerViewer(window);
SoEventCallback * eventcb = new SoEventCallback;
eventcb->addEventCallback(SoKeyboardEvent::getClassTypeId(),
keypresscbfunc, viewer);
root->insertChild(eventcb, 0);
viewer->setViewing(FALSE);
viewer->setDecoration(FALSE);
viewer->setSceneGraph(root);
viewer->show();
SoQt::show(window);
SoQt::mainLoop();
delete viewer;
root->unref();
return 0;
}
๐ See also
SbViewVolume
๐ Constructor & Destructor Documentation ๐
SbViewportRegion::SbViewportRegion (void )
The default SbViewportRegion constructor initializes the viewport to fully cover a [100, 100] size window with 72 pixels per inch resolution. yes bestie, it comes pre-loaded with defaults, main character energy from the jump ๐
SbViewportRegion::SbViewportRegion (short width, short height)
Construct and initialize an SbViewportRegion instance with the given pixel value window dimensions. The viewport within this window will be set to cover the window completely. full coverage, no gaps, we love to see it ๐
SbViewportRegion::SbViewportRegion (SbVec2s winsizearg)
Construct and initialize an SbViewportRegion instance with the given pixel value window dimensions. The viewport within this window will be set to cover the window completely. (same energy, different arg, periodt)
SbViewportRegion::SbViewportRegion (const SbViewportRegion & vpReg)
Copy constructor. it's a clone, it's a twin, it's a dupe that slays ๐ฆ
๐ Member Function Documentation ๐
void SbViewportRegion::setWindowSize (short width, short height)
Set the window size in pixels. The viewport rectangle dimensions will stay intact โ so the viewport itself doesn't move or resize, it's just the window around it changing. lowkey considerate ngl.
See also
getWindowSize()
void SbViewportRegion::setWindowSize (SbVec2s winsizearg)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. same girl, different outfit ๐
void SbViewportRegion::setViewport (float left, float bottom, float width, float height)
Set up the origin and size of the viewport region in normalized coordinates.
See also
getViewportOrigin(),getViewportSize(),setViewportPixels().
void SbViewportRegion::setViewport (SbVec2f origin, SbVec2f size)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. โจ
void SbViewportRegion::setViewportPixels (short left, short bottom, short width, short height)
Set up the origin and size of the viewport region in pixel coordinates.
See also
getViewportOriginPixels(),getViewportSizePixels(),setViewport()
void SbViewportRegion::setViewportPixels (SbVec2s origin, SbVec2s size)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ๐ซถ
const SbVec2s & SbViewportRegion::getWindowSize (void ) const
Returns window dimensions (which are in absolute (i.e. pixel) coordinates).
See also
setWindowSize().
const SbVec2f & SbViewportRegion::getViewportOrigin (void ) const
Return normalized viewport origin coordinates.
See also
setViewport(),getViewportOriginPixels().
const SbVec2s & SbViewportRegion::getViewportOriginPixels (void ) const
Return viewport origin coordinates in pixel values.
See also
setViewportPixels(),getViewportOrigin().
const SbVec2f & SbViewportRegion::getViewportSize (void ) const
Returns the normalized viewport size.
See also
setViewport(),getViewportSizePixels().
const SbVec2s & SbViewportRegion::getViewportSizePixels (void ) const
Returns viewport size in pixel coordinates.
See also
setViewportPixels(),getViewportSize().
float SbViewportRegion::getViewportAspectRatio (void ) const
Returns the aspect ratio of the viewport region. The aspect ratio is calculated as pixelwidth divided on pixelheight. math girlies rise ๐งฎโจ
void SbViewportRegion::scaleWidth (float ratio)
Scale the width of the viewport region.
The scale factor should not make the viewport larger than the window. If this happens, the viewport will be clamped.
The scaling will be done around the viewport region center point, but if this causes the viewport origin to be moved below (0,0), the origin coordinates will be clamped. so it self-corrects, it's got boundaries, we respect that ๐
See also
scaleHeight().
void SbViewportRegion::scaleHeight (float ratio)
Scale the height of the viewport region.
The scale factor should not make the viewport larger than the window. If this happens, the viewport will be clamped.
The scaling will be done around the viewport region center point, but if this causes the viewport origin to be moved below (0,0), the origin coordinates will be clamped. same rules, different axis, twin behaviour fr fr.
See also
scaleWidth().
void SbViewportRegion::setPixelsPerInch (float ppi)
Set pixels per inch. Default value is 72.
See also
getPixelsPerInch().
float SbViewportRegion::getPixelsPerInch (void ) const
Get pixels per inch.
See also
setPixelsPerInch().
float SbViewportRegion::getPixelsPerPoint (void ) const
Get pixels per point. A point is defined as something you can put 72 of per inch... yeah that's the definition, take it up with typography ๐ญ
See also
setPixelsPerInch(),getPixelsPerInch().
void SbViewportRegion::print (FILE * fp) const
Dump the state of this object to the file stream.
Only works in debug version of library, method does nothing in an optimized compile. so if your print is printing nothing, bestie, that's not a bug, that's the build ๐
๐ Author ๐
Generated automatically by Doxygen for Coin from the source code. yeah the robot wrote it, and honestly? it ate.
and that's the whole page, bestie ๐ฅฐ this was Coin, Version 3.1.3, SbViewportRegion(3) โ thanks for reading, mwah ๐๐โจ
๐ฆ where this page comes from
- fedora 43: Coin3-devel 3.1.3-40.fc43 ยท GPL-2.0-only
- fedora 43: Coin3-devel 3.1.3-40.fc43 ยท GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 ยท GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms