00001 #ifndef COIN_SOIMAGE_H
00002 #define COIN_SOIMAGE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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