Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoToHTMLAction.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : R. ALBOU (Sep 1998)
22**=======================================================================*/
23
24#ifndef _SO_TO_HTML_ACTION_
25#define _SO_TO_HTML_ACTION_
26
27#include <Inventor/SbColor.h>
31
33
34#include <Inventor/SoLists.h>
35#include <Inventor/SbBox.h>
36
37class SoNode ;
38class SoAction ;
39
40/*----------------------------------------------------------------------------*/
41
71class SoToHTMLAction : public SoAction {
72
74
75 public:
76 typedef void* SoToHTMLReallocCB(void *ptr, size_t newSize) ;
77
89
101
109
114
119
127 SoNONUNICODE SbBool openHTMLFile(const char *filename) ;
128
129
135 SbBool openHTMLFile( const SbString& filename );
136
141
145 void setHTMLFilePointer(FILE *newFP) ;
149 FILE* getHTMLFilePointer() const ;
150
157 void setHTMLBuffer(void *bufPointer, size_t initSize,
158 SoToHTMLReallocCB *reallocFunc, int32_t offset=0) ;
164 SbBool getHTMLBuffer(void *&bufPointer, size_t &nBytes) const ;
170
177 void setImageURLName(const char *name) ;
181 const char *getImageURLName() const ;
182
190 void setImageFilePointer(FILE *newFP) ;
194 FILE* getImageFilePointer() const ;
195
204
213
217 void setImageComponents( Components components );
222
231
237 void setImageQuality(float quality) ;
241 float getImageQuality() const ;
242
252
261
263 virtual void apply(SoNode *scene) ;
265 virtual void apply(SoPath *path) ;
267 virtual void apply(const SoPathList &pathList, SbBool flag = FALSE) ;
268
269 private:
270 // Internally used to initialize the class.
271 static void initClass() ;
272 static void exitClass() ;
273
274 private:
275 // Callbacks
276 static void stencilCB(void *d, SoAction* action) ;
277 static void stencilEndCB(void *d, SoAction* action) ;
278 static void initStencilCB(void *d, SoAction* action) ;
279
280 // Compute bounding for each anchor from the stencil
281 // buffer
282 void computeAnchorsBBoxList() ;
283
284 // Adds/removes a callback node as first child of
285 // each anchor group node
286 void addCallbackAtFirstForAnchors() ;
287 void removeAnchorsCallbacks() ;
288
289 // Adds/removes a callback as first child of
290 // the root scene graph
291 void addInitStencilCallback() ;
292 void removeInitStencilCallback() ;
293
294 // Retreives anchor URL at a specific index
295 // From the scene graph
296 const char* retreiveAnchorURL(int index) ;
297
298 // Read the stencil buffer
299 void readStencilBuffer() ;
300
301 // HTML Instructions
302 void writelnHTMLTag(const char *tag) ;
303 void writeHTMLTag(const char *tag) ;
304 void writeHTMLMaps() ;
305 void writeHTMLImage() ;
306 void writeHTML(const char *str) ;
307
308 // Generate the HTML output
309 void generateHTMLOutput() ;
310
311 // Seachs all SoWWWAnchor
312 // and updates the anchor list.
313 void updateAnchorsList() ;
314
315 // Compute an approximation from a polygon with angle of two consecutive
316 // segments inferior to the chordal deviation.
317 // The indices and their number corresponding to approximation of the original
318 // polygon are returned.
319 int* computeApproximatePolygon(const SbVec2s *polygon, int numPolyPoints,
320 int &numApproxIndices) ;
321
322 // Fill a bounding box of the stencil buffer with all values == valueToReplace
323 // by replaceValue.
324 void fillStencilBuffer(const SbBox2s &box, int valueToReplace, int replaceValue) ;
325
326 // Return the base name of an URL
327 // ex : https://www.openinventor.com//file.jpg return file.jpg
328 const char* getImageURLBaseName() const ;
329
330 // File descriptor for the image and the HTML file
331 FILE* m_HTMLFP ;
332 FILE* m_imageFP ;
333
334 // Indicates if the stencil has been initialize
335 // in order to prevent from several initializations
336 // (SoAnnotation node could cause this problem)
337 SbBool m_isStencilInit ;
338
339 // Image URL name
340 SbString m_imageURLName ;
341
342 // Nodelist for SoWWWAnchor
343 SoNodeList m_anchorList ;
344
345 // Array of bounding box for each anchors
346 SbBox2s *m_boxAnchorList ;
347
348 // Current scene graph
349 SoNode *m_scene ;
350
351 SoRef<SoOffscreenRenderArea> m_osRenderArea;
352
353 // Current stencil buffer
354 unsigned char* m_stencilBuffer ;
355
356 // Viewport region for image
357 SbViewportRegion m_vpRegion ;
358
359 // Image components
360 Components m_imageComponents ;
361
362 // Image background color
363 SbColor m_imageBackgroundColor ;
364
365 // Image format
366 ImageFormat m_imageFormat ;
367
368 // Image quality
369 float m_imageQuality ;
370
371 // Region shape type
372 ShapeType m_regionShapeType ;
373
374 // Map number
375 static int m_mapNumber ;
376
377 // Indicate whether an HTML file has been
378 // opened with openHTMLFile().
379 SbBool m_isOpenHTMLFile ;
380
381 // Map highlighting
382 SbBool m_isMapHighlight;
383
384 /* Management of a buffer for HTML file */
385 SbBool m_isHTMLBuffer ;
386 void* m_HTMLBuffer ;
387 char* m_curHTMLBuffer ;
388 size_t m_HTMLBufferSize ;
389 SoToHTMLReallocCB *m_reallocHTMLFunc ;
390
391 SbBool makeRoomInBuf(size_t nBytes) ;
392
393};
394
395#endif // _SO_TO_HTML_ACTION_
396
397
398
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
#define SO_ACTION_HEADER(className)
Definition SoSubAction.h:69
2D box class.
Definition SbBox.h:2194
Color vector class.
Definition SbColor.h:82
Class for smart character strings.
Definition SbString.h:202
2D vector class.
Definition SbVec.h:700
Class for representing a viewport.
Abstract base class for all actions.
Definition SoAction.h:132
Abstract base class for all database nodes.
Definition SoNode.h:145
Maintains a list of pointers to nodes.
Definition SoNodeList.h:74
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Maintains a list of pointers to paths.
Definition SoPathList.h:81
Smart pointer for any class inheriting SoRefCounter.
Definition SoRef.h:90
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Generates an HTM...
SoNONUNICODE SbBool openHTMLFile(const char *filename)
Opens named file (sets file pointer to result) .
void setImageFilePointer(FILE *newFP)
Sets the file pointer to use for the generated image file.
FILE * getImageFilePointer() const
Returns the file pointer for the generated image file.
void resetHTMLBuffer()
Resets buffer of the HTML output for output again.
float getImageQuality() const
Returns the image quality.
virtual void apply(SoNode *scene)
Generate HTML output for the specified root node.
void setHTMLBuffer(void *bufPointer, size_t initSize, SoToHTMLReallocCB *reallocFunc, int32_t offset=0)
Sets up memory buffer for writing HTML output, its initial size, a reallocation function (which is ca...
const char * getImageURLName() const
Returns the URL name of image in the HTML file.
const SbColor & getImageBackgroundColor() const
Returns the image background color.
void setHTMLFilePointer(FILE *newFP)
Sets file pointer to write to.
void setImageComponents(Components components)
Sets the components of image.
ImageFormat getImageFormat() const
Returns the image format.
SbBool isMapHighlight()
Returns anchor highlighting.
void setRegionShapeType(ShapeType type)
Sets the region shape type.
SoToHTMLAction()
Constructor.
void setImageFormat(ImageFormat format)
Sets the image format.
void setImageURLName(const char *name)
Sets the URL name of image in the HTML file, ("image.jpg" by default).
ShapeType getRegionShapeType() const
Returns the region shape type.
virtual void apply(SoPath *path)
Generate HTML output for the specified path.
Components getImageComponents() const
Returns the components of image.
ImageFormat
Defines the format of the image
@ BMP_FORMAT
BMP_FORMAT.
@ JPEG_FORMAT
JPEG_FORMAT.
FILE * getHTMLFilePointer() const
Returns the file pointer in use, or NULL if using a buffer.
Components
Components used to generate the image
@ RGB
RGB(Default)
@ RGB_TRANSPARENCY
RGB_TRANSPARENCY.
@ LUMINANCE_TRANSPARENCY
LUMINANCE_TRANSPARENCY.
@ LUMINANCE
LUMINANCE.
void * SoToHTMLReallocCB(void *ptr, size_t newSize)
void setViewportRegion(const SbViewportRegion &region)
Specifies viewport region for the image.
SbBool openHTMLFile(const SbString &filename)
Opens named file (sets file pointer to result) .
void closeHTMLFile()
Closes the HTML output file.
ShapeType
Defines the different shape type for maps.
@ POLYGON
POLYGON(default)
@ RECTANGLE
RECTANGLE.
virtual void apply(const SoPathList &pathList, SbBool flag=FALSE)
Generate HTML output for the specified list of path.
~SoToHTMLAction()
Destructor.
void setImageQuality(float quality)
Sets the image quality.
void setImageBackgroundColor(const SbColor &c)
Sets the image background color.
SbBool getHTMLBuffer(void *&bufPointer, size_t &nBytes) const
Returns pointer to memory buffer of the HTML output being written to and the new size of the buffer.
const SbViewportRegion & getViewportRegion() const
Returns viewport region for the image.
void setMapHighlight(SbBool onOff)
Sets anchor highlighting.
int SbBool
Boolean type.
Definition SbBase.h:87