man SoImage (Fonctions bibliothèques) -

NAME

SoImage -

SYNOPSIS



#include <Inventor/nodes/SoImage.h>

Inherits SoShape.

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

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

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)

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

SoType SoImage::getClassTypeId (void) [static]

This static method returns the SoType object associated with objects of this class.

Reimplemented from SoShape.

SoType SoImage::getTypeId (void) const [virtual]

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
    }
    else if (node->getTypeId().isOfType(SoGroup::getClassTypeId())) {
      SoGroup * group = (SoGroup *)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 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.

Reimplemented from SoShape.

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]

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 * list) [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.