SYNOPSIS

#include <Inventor/nodes/SoImage.h>

Inherits SoShape.

Public Types

enum VertAlignment { BOTTOM, HALF, TOP }

enum HorAlignment { LEFT, CENTER, RIGHT }

Public Member Functions

virtual SoType getTypeId (void) const

Returns the type identification of an object derived from a class inheriting SoBase. This is used for run-time type checking and 'downward' casting. SoImage (void)

virtual void GLRender (SoGLRenderAction *action)

virtual void rayPick (SoRayPickAction *action)

virtual void getPrimitiveCount (SoGetPrimitiveCountAction *action)

Static Public Member Functions

static SoType getClassTypeId (void)

static void initClass (void)

Public Attributes

SoSFInt32 width

SoSFInt32 height

SoSFEnum vertAlignment

SoSFEnum horAlignment

SoSFImage image

SoSFString filename

Protected Member Functions

virtual const SoFieldData * getFieldData (void) const

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)

Static Protected Member Functions

static const SoFieldData ** getFieldDataPtr (void)

Additional Inherited Members

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 \fBSoImage::VertAlignment\fP

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 \fBSoImage::HorAlignment\fP

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 ()\fC [protected]\fP, \fC [virtual]\fP

Destructor.

Member Function Documentation

\fBSoType\fP SoImage::getTypeId (void) const\fC [virtual]\fP

Returns the type identification of an object derived from a class inheriting SoBase. This is used for run-time type checking and 'downward' casting. Usage example:

void foo(SoNode * node)
{
  if (node->getTypeId() == SoFile::getClassTypeId()) {
    SoFile * filenode = (SoFile *)node;  // safe downward cast, knows the type
  }
}

For application programmers wanting to extend the library with new nodes, engines, nodekits, draggers or others: this method needs to be overridden in all subclasses. This is typically done as part of setting up the full type system for extension classes, which is usually accomplished by using the pre-defined macros available through for instance Inventor/nodes/SoSubNode.h (SO_NODE_INIT_CLASS and SO_NODE_CONSTRUCTOR for node classes), Inventor/engines/SoSubEngine.h (for engine classes) and so on.

For more information on writing Coin extensions, see the class documentation of the toplevel superclasses for the various class groups.

Reimplemented from SoShape.

const \fBSoFieldData\fP * SoImage::getFieldData (void) const\fC [protected]\fP, \fC [virtual]\fP

Returns a pointer to the class-wide field data storage object for this instance. If no fields are present, returns NULL.

Reimplemented from SoShape.

void SoImage::GLRender (\fBSoGLRenderAction\fP *action)\fC [virtual]\fP

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 (\fBSoRayPickAction\fP *action)\fC [virtual]\fP

Calculates picked point based on primitives generated by subclasses.

Reimplemented from SoShape.

void SoImage::getPrimitiveCount (\fBSoGetPrimitiveCountAction\fP *action)\fC [virtual]\fP

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 (\fBSoAction\fP *action)\fC [protected]\fP, \fC [virtual]\fP

Will generate a textured quad, representing the image in 3D.

Implements SoShape.

void SoImage::computeBBox (\fBSoAction\fP *action, \fBSbBox3f\fP &box, \fBSbVec3f\fP ¢er)\fC [protected]\fP, \fC [virtual]\fP

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 (\fBSoInput\fP *in, unsigned shortflags)\fC [protected]\fP, \fC [virtual]\fP

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 (\fBSoNotList\fP *l)\fC [protected]\fP, \fC [virtual]\fP

Notifies all auditors for this instance when changes are made.

Reimplemented from SoShape.

int SoImage::getReadStatus (void)\fC [protected]\fP

Returns TRUE if node was read ok.

void SoImage::setReadStatus (SbBoolflag)\fC [protected]\fP

Set read status for this node.

Member Data Documentation

\fBSoSFInt32\fP SoImage::width

If bigger than 0, resize image to this width before rendering. Default value is -1 (ie 'don't resize').

\fBSoSFInt32\fP SoImage::height

If bigger than 0, resize image to this height before rendering. Default value is -1 (ie 'don't resize').

\fBSoSFEnum\fP SoImage::vertAlignment

Vertical alignment. Default value is SoImage::BOTTOM.

\fBSoSFEnum\fP SoImage::horAlignment

Horizontal alignment. Default value is SoImage::LEFT.

\fBSoSFImage\fP SoImage::image

Inline image data. Default empty.

\fBSoSFString\fP SoImage::filename

Image filename. Default empty.

Author

Generated automatically by Doxygen for Coin from the source code.