# SoImage.h

    00001 #ifndef COIN_SOIMAGE_H
    00002 #define COIN_SOIMAGE_H
    00003
    00004 /**************************************************************************\
    00005  *
    00006  *  This file is part of the Coin 3D visualization library.
    00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU General Public License
    00011  *  ("GPL") version 2 as published by the Free Software Foundation.
    00012  *  See the file LICENSE.GPL at the root directory of this source
    00013  *  distribution for additional information about the GNU GPL.
    00014  *
    00015  *  For using Coin with software that can not be combined with the GNU
    00016  *  GPL, and for taking advantage of the additional benefits of our
    00017  *  support services, please contact Systems in Motion about acquiring
    00018  *  a Coin Professional Edition License.
    00019  *
    00020  *  See <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    00024  *
    00025 \**************************************************************************/
    00026
    00027 #include <Inventor/nodes/SoSubNode.h>
    00028 #include <Inventor/nodes/SoShape.h>
    00029 #include <Inventor/fields/SoSFInt32.h>
    00030 #include <Inventor/fields/SoSFEnum.h>
    00031 #include <Inventor/fields/SoSFImage.h>
    00032 #include <Inventor/fields/SoSFString.h>
    00033
    00034 class SoSensor;
    00035 class SoFieldSensor;
    00036 class SbImage;
    00037
    00038 class COIN_DLL_API SoImage : public SoShape {
    00039   typedef SoShape inherited;
    00040
    00041   SO_NODE_HEADER(SoImage);
    00042
    00043 public:
    00044   static void initClass(void);
    00045   SoImage(void);
    00046
    00047   enum VertAlignment {
    00048     BOTTOM,
    00049     HALF,
    00050     TOP
    00051   };
    00052
    00053   enum HorAlignment {
    00054     LEFT,
    00055     CENTER,
    00056     RIGHT
    00057   };
    00058
    00059   SoSFInt32 width;
    00060   SoSFInt32 height;
    00061   SoSFEnum vertAlignment;
    00062   SoSFEnum horAlignment;
    00063   SoSFImage image;
    00064   SoSFString filename;
    00065
    00066   virtual void GLRender(SoGLRenderAction * action);
    00067   virtual void rayPick(SoRayPickAction * action);
    00068   virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
    00069
    00070 protected:
    00071   virtual ~SoImage();
    00072
    00073   virtual void generatePrimitives(SoAction * action);
    00074   virtual void computeBBox(SoAction * action, SbBox3f & box, SbVec3f & center);
    00075
    00076   virtual SbBool readInstance(SoInput * in, unsigned short flags);
    00077   virtual void notify(SoNotList * list);
    00078   int getReadStatus(void);
    00079   void setReadStatus(SbBool flag);
    00080
    00081 private:
    00082   SbVec2s getSize(void) const;
    00083   static SbVec3f getNilpoint(SoState *state);
    00084   void getQuad(SoState *state, SbVec3f &v0, SbVec3f &v1,
    00085                SbVec3f &v2, SbVec3f &v3);
    00086
    00087   const unsigned char * getImage(SbVec2s & size, int & nc);
    00088   SbBool loadFilename(void);
    00089   SbBool readstatus;
    00090   SbImage * resizedimage;
    00091   SbBool resizedimagevalid;
    00092   class SoFieldSensor * filenamesensor;
    00093   SbBool transparency;
    00094   SbBool testtransparency;
    00095   void testTransparency(void);
    00096   static void filenameSensorCB(void *, SoSensor *);
    00097 };
    00098
    00099 #endif // !COIN_SOIMAGE_H