00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_TO_HTML_ACTION_
00025 #define _SO_TO_HTML_ACTION_
00026
00027 #include <Inventor/SoOffscreenRenderer.h>
00028
00029 #include <Inventor/actions/SoAction.h>
00030
00031 #include <Inventor/actions/SoSubAction.h>
00032
00033 #include <Inventor/SoLists.h>
00034 #include <Inventor/SbBox.h>
00035
00036 class SoNode ;
00037 class SoAction ;
00038 class SoOffscreenRenderer ;
00039
00040
00041
00072 class SoToHTMLAction : public SoAction {
00073
00074 SO_ACTION_HEADER(SoToHTMLAction);
00075
00076 public:
00077 typedef void* SoToHTMLReallocCB(void *ptr, size_t newSize) ;
00078
00080 enum ShapeType {
00082 NONE,
00084 RECTANGLE,
00086 CIRCLE,
00088 POLYGON
00089 } ;
00090
00092 enum Components {
00094 LUMINANCE = 1,
00096 LUMINANCE_TRANSPARENCY = 2,
00098 RGB = 3,
00100 RGB_TRANSPARENCY = 4
00101 };
00102
00104 enum ImageFormat {
00106 BMP_FORMAT,
00108 JPEG_FORMAT
00109 };
00110
00114 SoToHTMLAction() ;
00115
00119 ~SoToHTMLAction() ;
00120
00128 SoNONUNICODE SbBool openHTMLFile(const char *filename) ;
00129
00130
00136 SbBool openHTMLFile( const SbString& filename );
00137
00141 void closeHTMLFile() ;
00142
00146 void setHTMLFilePointer(FILE *newFP) ;
00150 FILE* getHTMLFilePointer() const ;
00151
00158 void setHTMLBuffer(void *bufPointer, size_t initSize,
00159 SoToHTMLReallocCB *reallocFunc, int32_t offset=0) ;
00165 SbBool getHTMLBuffer(void *&bufPointer, size_t &nBytes) const ;
00170 void resetHTMLBuffer() ;
00171
00178 void setImageURLName(const char *name) ;
00182 const char *getImageURLName() const ;
00183
00191 void setImageFilePointer(FILE *newFP) ;
00195 FILE* getImageFilePointer() const ;
00196
00200 void setRegionShapeType(ShapeType type) ;
00204 ShapeType getRegionShapeType() const ;
00205
00209 void setImageBackgroundColor(const SbColor &c);
00213 const SbColor & getImageBackgroundColor() const ;
00214
00218 void setImageComponents( Components components );
00222 Components getImageComponents() const ;
00223
00227 void setImageFormat(ImageFormat format) ;
00231 ImageFormat getImageFormat() const ;
00232
00238 void setImageQuality(float quality) ;
00242 float getImageQuality() const ;
00243
00248 void setViewportRegion(const SbViewportRegion ®ion);
00252 const SbViewportRegion& getViewportRegion() const;
00253
00257 void setMapHighlight(SbBool onOff);
00261 SbBool isMapHighlight();
00262
00264 virtual void apply(SoNode *scene) ;
00266 virtual void apply(SoPath *path) ;
00268 virtual void apply(const SoPathList &pathList, SbBool flag = FALSE) ;
00269
00270 private:
00271
00272 static void initClass() ;
00273 static void exitClass() ;
00274
00275 private:
00276
00277 static void stencilCB(void *d, SoAction* action) ;
00278 static void stencilEndCB(void *d, SoAction* action) ;
00279 static void initStencilCB(void *d, SoAction* action) ;
00280
00281
00282
00283 void computeAnchorsBBoxList() ;
00284
00285
00286
00287 void addCallbackAtFirstForAnchors() ;
00288 void removeAnchorsCallbacks() ;
00289
00290
00291
00292 void addInitStencilCallback() ;
00293 void removeInitStencilCallback() ;
00294
00295
00296
00297 const char* retreiveAnchorURL(int index) ;
00298
00299
00300 void readStencilBuffer() ;
00301
00302
00303 void writelnHTMLTag(const char *tag) ;
00304 void writeHTMLTag(const char *tag) ;
00305 void writeHTMLMaps() ;
00306 void writeHTMLImage() ;
00307 void writeHTML(const char *str) ;
00308
00309
00310 void generateHTMLOutput() ;
00311
00312
00313
00314 void updateAnchorsList() ;
00315
00316
00317
00318
00319
00320 int* computeApproximatePolygon(const SbVec2s *polygon, int numPolyPoints,
00321 int &numApproxIndices) ;
00322
00323
00324
00325 void fillStencilBuffer(const SbBox2s &box, int valueToReplace, int replaceValue) ;
00326
00327
00328
00329 const char* getImageURLBaseName() const ;
00330
00331
00332 FILE* m_HTMLFP ;
00333 FILE* m_imageFP ;
00334
00335
00336
00337
00338 SbBool m_isStencilInit ;
00339
00340
00341 SbString m_imageURLName ;
00342
00343
00344 SoNodeList m_anchorList ;
00345
00346
00347 SbBox2s *m_boxAnchorList ;
00348
00349
00350 SoNode *m_scene ;
00351 SoOffscreenRenderer *m_offscreenRenderer ;
00352
00353
00354 unsigned char* m_stencilBuffer ;
00355
00356
00357 SbViewportRegion m_vpRegion ;
00358
00359
00360 Components m_imageComponents ;
00361
00362
00363 SbColor m_imageBackgroundColor ;
00364
00365
00366 ImageFormat m_imageFormat ;
00367
00368
00369 float m_imageQuality ;
00370
00371
00372 ShapeType m_regionShapeType ;
00373
00374
00375 static int m_mapNumber ;
00376
00377
00378
00379 SbBool m_isOpenHTMLFile ;
00380
00381
00382 SbBool m_isMapHighlight;
00383
00384
00385 SbBool m_isHTMLBuffer ;
00386 void* m_HTMLBuffer ;
00387 char* m_curHTMLBuffer ;
00388 size_t m_HTMLBufferSize ;
00389 SoToHTMLReallocCB *m_reallocHTMLFunc ;
00390
00391 SbBool makeRoomInBuf(size_t nBytes) ;
00392
00393 };
00394
00395 #endif // _SO_TO_HTML_ACTION_
00396
00397
00398
00399