Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SbViewportRegion Class Reference

The SbViewportRegion class is a viewport within a full window. More...

#include <Inventor/SbViewportRegion.h>

Public Member Functions

 SbViewportRegion (const SbViewportRegion &vpReg)
 
 SbViewportRegion (SbVec2s winSize)
 
 SbViewportRegion (short width, short height)
 
 SbViewportRegion (void)
 
float getPixelsPerInch (void) const
 
float getPixelsPerPoint (void) const
 
float getViewportAspectRatio (void) const
 
const SbVec2fgetViewportOrigin (void) const
 
const SbVec2sgetViewportOriginPixels (void) const
 
const SbVec2fgetViewportSize (void) const
 
const SbVec2sgetViewportSizePixels (void) const
 
const SbVec2sgetWindowSize (void) const
 
void print (FILE *file) const
 
void scaleHeight (float ratio)
 
void scaleWidth (float ratio)
 
void setPixelsPerInch (float ppi)
 
void setViewport (float left, float bottom, float width, float height)
 
void setViewport (SbVec2f origin, SbVec2f size)
 
void setViewportPixels (SbVec2s origin, SbVec2s size)
 
void setViewportPixels (short left, short bottom, short width, short height)
 
void setWindowSize (SbVec2s winSize)
 
void setWindowSize (short width, short height)
 

Related Symbols

(Note that these are not member symbols.)

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

Detailed Description

The SbViewportRegion class is a viewport within a full window.

The SbViewportRegion class contains information to represent a subview within a window. It stores information about the origin and size of the subview, as well as the size of the underlying "full" window.

Available methods include inquiries and manipulation in both normalized coordinates and pixel coordinates.

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'.

// Copyright (C) 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
{
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);
root->insertChild(eventcb, 0);
viewer->setViewing(FALSE);
viewer->setDecoration(FALSE);
viewer->setSceneGraph(root);
viewer->show();
SoQt::show(window);
delete viewer;
root->unref();
return 0;
}
The SbList class is a template container class for lists.
Definition SbList.h:70
SbList(const int sizehint=DEFAULTSIZE)
Definition SbList.h:78
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition SbVec2s.h:51
The SbViewportRegion class is a viewport within a full window.
Definition SbViewportRegion.h:40
void unref(void) const
Definition SoBase.cpp:530
void ref(void) const
Definition SoBase.cpp:478
The SoCone class is for rendering cone shapes.
Definition SoCone.h:41
The SoEventCallback class provides functionality for catching events.
Definition SoEventCallback.h:52
The SoEvent class is the base class for all Coin events.
Definition SoEvent.h:45
virtual void insertChild(SoNode *child, int newchildindex)
Definition SoGroup.cpp:470
virtual void addChild(SoNode *node)
Definition SoGroup.cpp:453
static SoType getClassTypeId(void)
Definition SoKeyboardEvent.cpp:225
The SoSeparator class is a state-preserving group node.
Definition SoSeparator.h:44
See also
SbViewVolume

Constructor & Destructor Documentation

◆ SbViewportRegion() [1/4]

SbViewportRegion::SbViewportRegion ( void )

The default SbViewportRegion constructor initializes the viewport to fully cover a [100, 100] size window with 72 pixels per inch resolution.

◆ SbViewportRegion() [2/4]

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.

◆ SbViewportRegion() [3/4]

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.

◆ SbViewportRegion() [4/4]

SbViewportRegion::SbViewportRegion ( const SbViewportRegion & vpReg)

Copy constructor.

Member Function Documentation

◆ getPixelsPerInch()

float SbViewportRegion::getPixelsPerInch ( void ) const

Get pixels per inch.

See also
setPixelsPerInch().

◆ getPixelsPerPoint()

float SbViewportRegion::getPixelsPerPoint ( void ) const

Get pixels per point. A point is defined as something you can put 72 of per inch...

See also
setPixelsPerInch(), getPixelsPerInch().

◆ getViewportAspectRatio()

float SbViewportRegion::getViewportAspectRatio ( void ) const

Returns the aspect ratio of the viewport region. The aspect ratio is calculated as pixelwidth divided on pixelheight.

◆ getViewportOrigin()

const SbVec2f & SbViewportRegion::getViewportOrigin ( void ) const

Return normalized viewport origin coordinates.

See also
setViewport(), getViewportOriginPixels().

◆ getViewportOriginPixels()

const SbVec2s & SbViewportRegion::getViewportOriginPixels ( void ) const

Return viewport origin coordinates in pixel values.

See also
setViewportPixels(), getViewportOrigin().

◆ getViewportSize()

const SbVec2f & SbViewportRegion::getViewportSize ( void ) const

Returns the normalized viewport size.

See also
setViewport(), getViewportSizePixels().

◆ getViewportSizePixels()

const SbVec2s & SbViewportRegion::getViewportSizePixels ( void ) const

Returns viewport size in pixel coordinates.

See also
setViewportPixels(), getViewportSize().

◆ getWindowSize()

const SbVec2s & SbViewportRegion::getWindowSize ( void ) const

Returns window dimensions (which are in absolute (i.e. pixel) coordinates).

See also
setWindowSize().

◆ print()

void SbViewportRegion::print ( FILE * fp) const

Dump the state of this object to the fp file stream. Only works in debug version of library, method does nothing in an optimized build.

◆ 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.

See also
scaleWidth().

◆ scaleWidth()

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.

See also
scaleHeight().

◆ setPixelsPerInch()

void SbViewportRegion::setPixelsPerInch ( float ppi)

Set pixels per inch. Default value is 72.

See also
getPixelsPerInch().

◆ setViewport() [1/2]

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().

◆ setViewport() [2/2]

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.

◆ setViewportPixels() [1/2]

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.

◆ setViewportPixels() [2/2]

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()

◆ setWindowSize() [1/2]

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.

◆ setWindowSize() [2/2]

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

Set the window size in pixels. The viewport rectangle dimensions will stay intact.

See also
getWindowSize()

Friends And Related Symbol Documentation

◆ operator!=()

int operator!= ( const SbViewportRegion & reg1,
const SbViewportRegion & reg2 )
related

Compares two SbViewportRegion instances for inequality.

Since
Coin 2.4

◆ operator==()

int operator== ( const SbViewportRegion & reg1,
const SbViewportRegion & reg2 )
related

Compares two SbViewportRegion instances for equality.


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