NAME
SoImage -
The SoImage class draws a 2D image on the viewport.
An image can be specified either by using the image field, or by
specifying a filename. If width and or height is specified, the image
will be resized to match those values before it is displayed.
SYNOPSIS
#include <Inventor/nodes/SoImage.h>
Inherits SoShape.
Public Types
enum VertAlignment { BOTTOM, HALF, TOP }
enum HorAlignment { LEFT, CENTER, RIGHT }
Public Member Functions
SoImage (void)
virtual void GLRender (SoGLRenderAction *action)
virtual void rayPick (SoRayPickAction *action)
virtual void getPrimitiveCount (SoGetPrimitiveCountAction *action)
Static Public Member Functions
static void initClass (void)
Public Attributes
SoSFInt32 width
SoSFInt32 height
SoSFEnum vertAlignment
SoSFEnum horAlignment
SoSFImage image
SoSFString filename
Protected Member Functions
virtual ~SoImage ()
virtual void generatePrimitives (SoAction *action)
virtual void computeBBox (SoAction *action, SbBox3f &box, SbVec3f
¢er)
virtual SbBool readInstance (SoInput *in, unsigned short flags)
virtual void notify (SoNotList *list)
int getReadStatus (void)
void setReadStatus (SbBool flag)
Detailed Description
The SoImage class draws a 2D image on the viewport.
An image can be specified either by using the image field, or by
specifying a filename. If width and or height is specified, the image
will be resized to match those values before it is displayed.
The current modelview matrix will be used to find the viewport
position, and the image is rendered in that position, with z-buffer
testing activated.
Here’s a simple, stand-alone example on how to set up and show an
SoImage:
#include <stdlib.h>
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoCamera.h>
#include <Inventor/nodes/SoCube.h>
#include <Inventor/nodes/SoImage.h>
static void
mandel(double sr, double si, double width, double height,
int bwidth, int bheight, int mult, unsigned char * bmp, int n)
{
double zr, zr_old, zi, cr, ci;
int w;
for (int y=0; y<bheight; y++)
for (int x=0; x<bwidth; x++) {
cr = ((double)(x)/(double)(bwidth))*width+sr;
ci = ((double)(y)/(double)(bheight))*height+si;
zr = zi = 0.0;
for (w = 0; (w < n) && (zr*zr + zi*zi)<n; w++) {
zr_old = zr;
zr = zr*zr - zi*zi + cr;
zi = 2*zr_old*zi + ci;
}
bmp[y*bwidth+x] = w*mult;
}
}
int
main(int argc, char ** argv)
{
QWidget * mainwin = SoQt::init(argv[0]);
SoSeparator * root = new SoSeparator;
root->ref();
const int IMGWIDTH = 256;
const int IMGHEIGHT = 256;
unsigned char * img = new unsigned char[IMGWIDTH * IMGHEIGHT];
mandel(-0.5, 0.6, 0.025, 0.025, IMGWIDTH, IMGHEIGHT, 1, img, 256);
SoImage * nimage = new SoImage;
nimage->vertAlignment = SoImage::HALF;
nimage->horAlignment = SoImage::CENTER;
nimage->image.setValue(SbVec2s(IMGWIDTH, IMGHEIGHT), 1, img);
SoCube * cube = new SoCube;
root->addChild(cube);
root->addChild(nimage);
SoQtExaminerViewer * viewer = new SoQtExaminerViewer(mainwin);
viewer->setSceneGraph(root);
viewer->setTitle(’SoImage use’);
viewer->show();
SoCamera * cam = viewer->getCamera();
cam->position = SbVec3f(0, 0, 50);
cam->focalDistance = 50;
SoQt::show(mainwin);
SoQt::mainLoop();
delete viewer;
root->unref();
delete img;
return 0;
}
Note that an SoImage node in the scene graph will have it’s positioning
/ rendering influenced by the current viewport and camera. This has
important implications for how to layout your scene graph for the best
possible rendering performance. See the note about this issue in the
SoText2 class documentation.
SoScale nodes can not be used to influence the dimensions of the
rendering output of SoImage nodes.
FILE FORMAT/DEFAULTS:
Image {
width -1
height -1
vertAlignment BOTTOM
horAlignment LEFT
image 0 0 0
filename ’’
}
Since:
TGS Inventor 2.5
Coin 1.0
Member Enumeration Documentation
enum SoImage::VertAlignment Vertical alignment for image.
Enumerator:
BOTTOM Vertical alignment at bottom of image.
HALF Vertical alignment at center of image.
TOP Vertical alignment at top of image.
enum SoImage::HorAlignment Horizontal alignment for image.
Enumerator:
LEFT Horizontal alignment at left border.
CENTER Horizontal alignment at center of image.
RIGHT Horizontal alignment ar right border.
Constructor & Destructor Documentation
SoImage::SoImage (void) Constructor.
SoImage::~SoImage () [protected, virtual] Destructor.
Member Function Documentation
void SoImage::initClass (void) [static] Sets up initialization for data
common to all instances of this class, like submitting necessary
information to the Coin type system.
Reimplemented from SoShape.
void SoImage::GLRender (SoGLRenderAction * action) [virtual] Action method
for the SoGLRenderAction.
This is called during rendering traversals. Nodes influencing the
rendering state in any way or who wants to throw geometry primitives at
OpenGL overrides this method.
Reimplemented from SoShape.
void SoImage::rayPick (SoRayPickAction * action) [virtual] Calculates
picked point based on primitives generated by subclasses.
Reimplemented from SoShape.
void SoImage::getPrimitiveCount (SoGetPrimitiveCountAction * action)
[virtual] Action method for the SoGetPrimitiveCountAction.
Calculates the number of triangle, line segment and point primitives
for the node and adds these to the counters of the action.
Nodes influencing how geometry nodes calculates their primitive count
also overrides this method to change the relevant state variables.
Reimplemented from SoShape.
void SoImage::generatePrimitives (SoAction * action) [protected, virtual]
Will generate a textured quad, representing the image in 3D.
Implements SoShape.
void SoImage::computeBBox (SoAction * action, SbBox3f & box, SbVec3f &
center) [protected, virtual] Implemented by SoShape subclasses to let
the SoShape superclass know the exact size and weighted center point of
the shape’s bounding box.
The bounding box and center point should be calculated and returned in
the local coordinate system.
The method implements action behavior for shape nodes for
SoGetBoundingBoxAction. It is invoked from SoShape::getBoundingBox().
(Subclasses should not override SoNode::getBoundingBox().)
The box parameter sent in is guaranteed to be an empty box, while
center is undefined upon function entry.
Implements SoShape.
SbBool SoImage::readInstance (SoInput * in, unsigned short flags)
[protected, virtual] This method is mainly intended for internal use
during file import operations.
It reads a definition of an instance from the input stream in. The
input stream state points to the start of a serialized / persistant
representation of an instance of this class type.
TRUE or FALSE is returned, depending on if the instantiation and
configuration of the new object of this class type went ok or not. The
import process should be robust and handle corrupted input streams by
returning FALSE.
flags is used internally during binary import when reading user
extension nodes, group nodes or engines.
Reimplemented from SoNode.
void SoImage::notify (SoNotList * l) [protected, virtual] Notifies all
auditors for this instance when changes are made.
Reimplemented from SoShape.
int SoImage::getReadStatus (void) [protected] Returns TRUE if node was read
ok.
void SoImage::setReadStatus (SbBool flag) [protected] Set read status for
this node.
Member Data Documentation
SoSFInt32 SoImage::width If bigger than 0, resize image to this width
before rendering. Default value is -1 (ie ’don’t resize’).
SoSFInt32 SoImage::height If bigger than 0, resize image to this height
before rendering. Default value is -1 (ie ’don’t resize’).
SoSFEnum SoImage::vertAlignment Vertical alignment. Default value is
SoImage::BOTTOM.
SoSFEnum SoImage::horAlignment Horizontal alignment. Default value is
SoImage::LEFT.
SoSFImage SoImage::image Inline image data. Default empty.
SoSFString SoImage::filename Image filename. Default empty.
Author
Generated automatically by Doxygen for Coin from the source code.