00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _SO_IMAGE_
00026 #define _SO_IMAGE_
00027
00028 #include <Inventor/nodes/SoShape.h>
00029
00030 #include <Inventor/fields/SoSFFilePathString.h>
00031 #include <Inventor/fields/SoSFImage.h>
00032 #include <Inventor/fields/SoSFEnum.h>
00033 #include <Inventor/fields/SoSFInt32.h>
00034 #include <Inventor/nodes/SoNode.h>
00035 #include <Inventor/nodes/SoTexture.h>
00036 #include <Inventor/image/SbRasterImage.h>
00037
00038 #include <Inventor/sys/SoGLType.h>
00039
00040
00041
00042 class SoGetPrimitiveCountAction;
00043 class SoGLRenderAction;
00044 class SoSensor;
00045 class SoFieldSensor;
00046
00123 class SoImage : public SoShape {
00124
00125 SO_NODE_HEADER(SoImage);
00126
00127 public:
00128
00130 enum HorAlignment {
00134 LEFT,
00138 CENTER,
00142 RIGHT
00143 };
00144
00146 enum VertAlignment {
00150 BOTTOM,
00154 HALF,
00158 TOP
00159 };
00160
00162 enum FileType {
00166 UNKNOWN = SoTexture::UNKNOWN,
00170 RGB = SoTexture::RGB,
00174 SGI = SoTexture::SGI,
00178 TIFF = SoTexture::TIFF,
00182 GIF = SoTexture::GIF,
00186 JPEG = SoTexture::JPEG,
00190 BMP = SoTexture::BMP,
00194 PNG = SoTexture::PNG,
00198 JPEG2000 = SoTexture::JPEG2000,
00202 PGX = SoTexture::PGX,
00206 PNM = SoTexture::PNM,
00210 RAS = SoTexture::RAS,
00214 DDS = SoTexture::DDS,
00218 HDRI = SoTexture::HDRI,
00220 NUM_FILETYPES
00221 };
00222
00223
00224
00236 SoSFFilePathString filename;
00237
00244 SoSFImage image;
00252 SoSFEnum horAlignment;
00259 SoSFEnum vertAlignment;
00260
00268 SoSFInt32 width;
00269
00277 SoSFInt32 height;
00278
00282 SoImage();
00283
00284
00285
00286 private:
00287 virtual void GLRender(SoGLRenderAction *action);
00288 virtual void rayPick(SoRayPickAction *action);
00289 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
00290
00291 virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er);
00292
00293 private:
00294 static void initClass();
00295 static void exitClass();
00296
00297 static void computeRasterLimits( SoAction *action, int width, int height,
00298 const SbVec3f &leftBottomPointPix, const SbMatrix &screenToObj,
00299 SbVec3f &llp0, SbVec3f &lrp1,
00300 SbVec3f &ulp2, SbVec3f &urp3 );
00301
00302
00303
00304 static SbVec3f getRasterLeftBottomPoint( const SbVec3f &origPixels, HorAlignment halign, VertAlignment valign,
00305 int widthPixels, int heightPixels );
00306
00307 static void computeRasterLimitsPoints( SoAction *action,
00308 HorAlignment halign, VertAlignment valign,
00309 int width, int height,
00310 const SbVec3f &screenOrigin,
00311 SbVec3f &p0, SbVec3f &p1, SbVec3f &p2, SbVec3f &p3, bool toObj = true );
00312
00313 private:
00314 virtual void generatePrimitives(SoAction *action);
00315
00316
00317
00318
00319 virtual SbBool shouldGLRender(SoGLRenderAction *action,
00320 SbBool isPointsOrLines = FALSE);
00321
00322
00323 virtual SbBool readInstance(SoInput *in, unsigned short flags);
00324
00325 int getReadStatus() { return m_readStatus; }
00326 void setReadStatus(SbBool flag) { m_readStatus = flag; }
00327
00328
00329 virtual ~SoImage();
00330
00331 private:
00332 SbBool m_readStatus;
00333
00334
00335 SoFieldSensor *m_imageSensor;
00336 SoFieldSensor *m_filenameSensor;
00337
00338 static void imageChangedCB(void *, SoSensor *);
00339 static void filenameChangedCB(void *, SoSensor *);
00340
00341
00342 void computeImageLimits(SoAction *action, SbBox3f &box);
00343
00344
00345 void computeImageLimitsPoints(SoAction *action,SbVec3f &p0,
00346 SbVec3f &p1, SbVec3f &p2, SbVec3f &p3);
00347
00348
00349
00350
00351 void drawImage(SoState *state, int widthPixels, int heightPixels);
00352
00353
00354 SbVec3f getLeftBottomPoint(SbVec3f &origPixels,
00355 int widthPixels, int heightPixels);
00356
00357
00358 int getWidth();
00359 int getHeight();
00360
00361 FileType m_filetype;
00362
00363 };
00364
00365
00366 #endif
00367
00368