SoImage(3)

NAME
SoImage - The SoImage class draws a 2D image on the viewport.

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
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 &center)
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, standalone example on how to set up and show an SoImage:

#include <cstdlib>
#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 its 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 cannot 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 at right border.

Constructor & Destructor Documentation

  SoImage::SoImage (void)
Constructor.

  SoImage::~SoImage () [protected], [virtual]
Destructor.

Member Function Documentation

  SoType SoImage::getClassTypeId (void) [static]
This static method returns the SoType object associated with objects of this class.

  SoType SoImage::getTypeId (void) const [virtual]
Returns the type identification of an object derived from a class inheriting SoBase. This is used for runtime type checking and 'downward' casting.

Reimplemented from SoShape.

  const SoFieldData ** SoImage::getFieldDataPtr (void) [static], [protected]
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
 Returns the SoFieldData class which holds information about fields in this node.

  const SoFieldData * SoImage::getFieldData (void) const [protected], [virtual]
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::initClass (void) [static]

  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 want to throw geometry primitives at OpenGL override 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 calculate their primitive count also override 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 / persistent 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 (i.e. 'don't resize').

  SoSFInt32 SoImage::height
If bigger than 0, resize image to this height before rendering. Default value is -1 (i.e. '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.