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/SbColor.h>
00028 #include <Inventor/SbViewportRegion.h>
00029 #include <Inventor/actions/SoAction.h>
00030 #include <Inventor/SoOffscreenRenderArea.h>
00031
00032 #include <Inventor/actions/SoSubAction.h>
00033
00034 #include <Inventor/SoLists.h>
00035 #include <Inventor/SbBox.h>
00036
00037 class SoNode ;
00038 class SoAction ;
00039
00040
00041
00071 class SoToHTMLAction : public SoAction {
00072
00073 SO_ACTION_HEADER(SoToHTMLAction);
00074
00075 public:
00076 typedef void* SoToHTMLReallocCB(void *ptr, size_t newSize) ;
00077
00079 enum ShapeType {
00081 NONE,
00083 RECTANGLE,
00085 CIRCLE,
00087 POLYGON
00088 } ;
00089
00091 enum Components {
00093 LUMINANCE = 1,
00095 LUMINANCE_TRANSPARENCY = 2,
00097 RGB = 3,
00099 RGB_TRANSPARENCY = 4
00100 };
00101
00103 enum ImageFormat {
00105 BMP_FORMAT,
00107 JPEG_FORMAT
00108 };
00109
00113 SoToHTMLAction() ;
00114
00118 ~SoToHTMLAction() ;
00119
00127 SoNONUNICODE SbBool openHTMLFile(const char *filename) ;
00128
00129
00135 SbBool openHTMLFile( const SbString& filename );
00136
00140 void closeHTMLFile() ;
00141
00145 void setHTMLFilePointer(FILE *newFP) ;
00149 FILE* getHTMLFilePointer() const ;
00150
00157 void setHTMLBuffer(void *bufPointer, size_t initSize,
00158 SoToHTMLReallocCB *reallocFunc, int32_t offset=0) ;
00164 SbBool getHTMLBuffer(void *&bufPointer, size_t &nBytes) const ;
00169 void resetHTMLBuffer() ;
00170
00177 void setImageURLName(const char *name) ;
00181 const char *getImageURLName() const ;
00182
00190 void setImageFilePointer(FILE *newFP) ;
00194 FILE* getImageFilePointer() const ;
00195
00199 void setRegionShapeType(ShapeType type) ;
00203 ShapeType getRegionShapeType() const ;
00204
00208 void setImageBackgroundColor(const SbColor &c);
00212 const SbColor & getImageBackgroundColor() const ;
00213
00217 void setImageComponents( Components components );
00221 Components getImageComponents() const ;
00222
00226 void setImageFormat(ImageFormat format) ;
00230 ImageFormat getImageFormat() const ;
00231
00237 void setImageQuality(float quality) ;
00241 float getImageQuality() const ;
00242
00247 void setViewportRegion(const SbViewportRegion ®ion);
00251 const SbViewportRegion& getViewportRegion() const;
00252
00256 void setMapHighlight(SbBool onOff);
00260 SbBool isMapHighlight();
00261
00263 virtual void apply(SoNode *scene) ;
00265 virtual void apply(SoPath *path) ;
00267 virtual void apply(const SoPathList &pathList, SbBool flag = FALSE) ;
00268
00269 private:
00270
00271 static void initClass() ;
00272 static void exitClass() ;
00273
00274 private:
00275
00276 static void stencilCB(void *d, SoAction* action) ;
00277 static void stencilEndCB(void *d, SoAction* action) ;
00278 static void initStencilCB(void *d, SoAction* action) ;
00279
00280
00281
00282 void computeAnchorsBBoxList() ;
00283
00284
00285
00286 void addCallbackAtFirstForAnchors() ;
00287 void removeAnchorsCallbacks() ;
00288
00289
00290
00291 void addInitStencilCallback() ;
00292 void removeInitStencilCallback() ;
00293
00294
00295
00296 const char* retreiveAnchorURL(int index) ;
00297
00298
00299 void readStencilBuffer() ;
00300
00301
00302 void writelnHTMLTag(const char *tag) ;
00303 void writeHTMLTag(const char *tag) ;
00304 void writeHTMLMaps() ;
00305 void writeHTMLImage() ;
00306 void writeHTML(const char *str) ;
00307
00308
00309 void generateHTMLOutput() ;
00310
00311
00312
00313 void updateAnchorsList() ;
00314
00315
00316
00317
00318
00319 int* computeApproximatePolygon(const SbVec2s *polygon, int numPolyPoints,
00320 int &numApproxIndices) ;
00321
00322
00323
00324 void fillStencilBuffer(const SbBox2s &box, int valueToReplace, int replaceValue) ;
00325
00326
00327
00328 const char* getImageURLBaseName() const ;
00329
00330
00331 FILE* m_HTMLFP ;
00332 FILE* m_imageFP ;
00333
00334
00335
00336
00337 SbBool m_isStencilInit ;
00338
00339
00340 SbString m_imageURLName ;
00341
00342
00343 SoNodeList m_anchorList ;
00344
00345
00346 SbBox2s *m_boxAnchorList ;
00347
00348
00349 SoNode *m_scene ;
00350
00351 SoRef<SoOffscreenRenderArea> m_osRenderArea;
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