Exporter.h
Go to the documentation of this file.
1 /*
2  This file is part of the VRender library.
3  Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr)
4  Version 1.0.0, released on June 27, 2005.
5 
6  http://artis.imag.fr/Members/Cyril.Soler/VRender
7 
8  VRender is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  VRender is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with VRender; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
23 /****************************************************************************
24 
25  Copyright (C) 2002-2014 Gilles Debunne. All rights reserved.
26 
27  This file is part of the QGLViewer library version 2.6.3.
28 
29  http://www.libqglviewer.com - contact@libqglviewer.com
30 
31  This file may be used under the terms of the GNU General Public License
32  versions 2.0 or 3.0 as published by the Free Software Foundation and
33  appearing in the LICENSE file included in the packaging of this file.
34  In addition, as a special exception, Gilles Debunne gives you certain
35  additional rights, described in the file GPL_EXCEPTION in this package.
36 
37  libQGLViewer uses dual licensing. Commercial/proprietary software must
38  purchase a libQGLViewer Commercial License.
39 
40  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
41  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
42 
43 *****************************************************************************/
44 
45 #ifndef _VRENDER_EXPORTER_H
46 #define _VRENDER_EXPORTER_H
47 
48 // Set of classes for exporting in various formats, like EPS, XFig3.2, SVG.
49 
50 #include "Primitive.h"
51 
52 #include "../config.h"
53 #include <QTextStream>
54 #include <QString>
55 
56 namespace vrender
57 {
58  class VRenderParams ;
59  class Exporter
60  {
61  public:
62  Exporter() ;
63  virtual ~Exporter() {}
64 
65  virtual void exportToFile(const QString& filename,const std::vector<PtrPrimitive>&,VRenderParams&) ;
66 
67  void setBoundingBox(float xmin,float ymin,float xmax,float ymax) ;
68  void setClearColor(float r,float g,float b) ;
69  void setClearBackground(bool b) ;
70  void setBlackAndWhite(bool b) ;
71 
72  protected:
73  virtual void spewPoint(const Point *, QTextStream& out) = 0 ;
74  virtual void spewSegment(const Segment *, QTextStream& out) = 0 ;
75  virtual void spewPolygone(const Polygone *, QTextStream& out) = 0 ;
76 
77  virtual void writeHeader(QTextStream& out) const = 0 ;
78  virtual void writeFooter(QTextStream& out) const = 0 ;
79 
80  float _clearR,_clearG,_clearB ;
81  float _pointSize ;
82  float _lineWidth ;
83 
84  GLfloat _xmin,_xmax,_ymin,_ymax,_zmin,_zmax ;
85 
87  };
88 
89  // Exports to encapsulated postscript.
90 
91  class EPSExporter: public Exporter
92  {
93  public:
94  EPSExporter() ;
95  virtual ~EPSExporter() {}
96 
97  protected:
98  virtual void spewPoint(const Point *, QTextStream& out) ;
99  virtual void spewSegment(const Segment *, QTextStream& out) ;
100  virtual void spewPolygone(const Polygone *, QTextStream& out) ;
101 
102  virtual void writeHeader(QTextStream& out) const ;
103  virtual void writeFooter(QTextStream& out) const ;
104 
105  private:
106  void setColor(QTextStream& out,float,float,float) ;
107 
108  static const double EPS_GOURAUD_THRESHOLD ;
109  static const char *GOURAUD_TRIANGLE_EPS[] ;
110  static const char *CREATOR ;
111 
112  static float last_r ;
113  static float last_g ;
114  static float last_b ;
115  };
116 
117  // Exports to postscript. The only difference is the filename extension and
118  // the showpage at the end.
119 
120  class PSExporter: public EPSExporter
121  {
122  public:
123  virtual ~PSExporter() {}
124  protected:
125  virtual void writeFooter(QTextStream& out) const ;
126  };
127 
128  class FIGExporter: public Exporter
129  {
130  public:
131  FIGExporter() ;
132  virtual ~FIGExporter() {}
133 
134  protected:
135  virtual void spewPoint(const Point *, QTextStream& out) ;
136  virtual void spewSegment(const Segment *, QTextStream& out) ;
137  virtual void spewPolygone(const Polygone *, QTextStream& out) ;
138 
139  virtual void writeHeader(QTextStream& out) const ;
140  virtual void writeFooter(QTextStream& out) const ;
141 
142  private:
143  mutable int _sizeX ;
144  mutable int _sizeY ;
145  mutable int _depth ;
146 
147  int FigCoordX(double) const ;
148  int FigCoordY(double) const ;
149  int FigGrayScaleIndex(float red, float green, float blue) const ;
150  };
151 #ifdef A_FAIRE
152  class SVGExporter: public Exporter
153  {
154  protected:
155  virtual void spewPoint(const Point *, QTextStream& out) ;
156  virtual void spewSegment(const Segment *, QTextStream& out) ;
157  virtual void spewPolygone(const Polygone *, QTextStream& out) ;
158 
159  virtual void writeHeader(QTextStream& out) const ;
160  virtual void writeFooter(QTextStream& out) const ;
161  };
162 #endif
163 }
164 
165 #endif
vrender::Exporter::setClearBackground
void setClearBackground(bool b)
Definition: Exporter.cpp:106
vrender::Exporter::_clearB
float _clearB
Definition: Exporter.h:100
vrender::Exporter::_ymin
GLfloat _ymin
Definition: Exporter.h:104
vrender::Exporter::_zmax
GLfloat _zmax
Definition: Exporter.h:104
vrender::EPSExporter::EPSExporter
EPSExporter()
Definition: EPSExporter.cpp:60
vrender::FIGExporter::FIGExporter
FIGExporter()
Definition: FIGExporter.cpp:86
vrender::Polygone
Definition: Primitive.h:204
vrender::FIGExporter::FigGrayScaleIndex
int FigGrayScaleIndex(float red, float green, float blue) const
Definition: FIGExporter.cpp:79
vrender::Exporter::setClearColor
void setClearColor(float r, float g, float b)
Definition: Exporter.cpp:105
vrender::Exporter::writeHeader
virtual void writeHeader(QTextStream &out) const =0
vrender::Exporter::spewPoint
virtual void spewPoint(const Point *, QTextStream &out)=0
vrender::FIGExporter::FigCoordX
int FigCoordX(double) const
Definition: FIGExporter.cpp:51
vrender::Exporter::_xmax
GLfloat _xmax
Definition: Exporter.h:104
vrender::Exporter::_pointSize
float _pointSize
Definition: Exporter.h:101
vrender::Exporter::setBoundingBox
void setBoundingBox(float xmin, float ymin, float xmax, float ymax)
Definition: Exporter.cpp:97
vrender::Exporter::_clearR
float _clearR
Definition: Exporter.h:100
vrender::PSExporter::writeFooter
virtual void writeFooter(QTextStream &out) const
Definition: EPSExporter.cpp:115
vrender::Exporter::_zmin
GLfloat _zmin
Definition: Exporter.h:104
vrender::EPSExporter::last_b
static float last_b
Definition: Exporter.h:134
vrender::EPSExporter::last_g
static float last_g
Definition: Exporter.h:133
vrender::FIGExporter::_depth
int _depth
Definition: Exporter.h:165
vrender::Exporter::~Exporter
virtual ~Exporter()
Definition: Exporter.h:83
vrender::Exporter::_clearG
float _clearG
Definition: Exporter.h:100
vrender::FIGExporter::_sizeY
int _sizeY
Definition: Exporter.h:164
Primitive.h
vrender::FIGExporter
Definition: Exporter.h:148
vrender::Exporter::_clearBG
bool _clearBG
Definition: Exporter.h:106
vrender::EPSExporter::GOURAUD_TRIANGLE_EPS
static const char * GOURAUD_TRIANGLE_EPS[]
Definition: Exporter.h:129
vrender::Exporter::setBlackAndWhite
void setBlackAndWhite(bool b)
Definition: Exporter.cpp:107
vrender::Exporter::Exporter
Exporter()
Definition: Exporter.cpp:55
vrender::Exporter::_blackAndWhite
bool _blackAndWhite
Definition: Exporter.h:106
vrender::FIGExporter::spewPoint
virtual void spewPoint(const Point *, QTextStream &out)
Definition: FIGExporter.cpp:103
vrender::EPSExporter::CREATOR
static const char * CREATOR
Definition: Exporter.h:130
vrender::Exporter::_ymax
GLfloat _ymax
Definition: Exporter.h:104
vrender::EPSExporter::spewPolygone
virtual void spewPolygone(const Polygone *, QTextStream &out)
Definition: EPSExporter.cpp:152
vrender::EPSExporter::~EPSExporter
virtual ~EPSExporter()
Definition: Exporter.h:115
vrender::EPSExporter::EPS_GOURAUD_THRESHOLD
static const double EPS_GOURAUD_THRESHOLD
Definition: Exporter.h:128
vrender::Exporter
Definition: Exporter.h:79
vrender::PSExporter
Definition: Exporter.h:140
vrender::PSExporter::~PSExporter
virtual ~PSExporter()
Definition: Exporter.h:143
vrender::FIGExporter::FigCoordY
int FigCoordY(double) const
Definition: FIGExporter.cpp:65
vrender::EPSExporter
Definition: Exporter.h:111
vrender::EPSExporter::writeFooter
virtual void writeFooter(QTextStream &out) const
Definition: EPSExporter.cpp:107
vrender::FIGExporter::spewSegment
virtual void spewSegment(const Segment *, QTextStream &out)
Definition: FIGExporter.cpp:111
vrender::Exporter::spewSegment
virtual void spewSegment(const Segment *, QTextStream &out)=0
vrender::Exporter::spewPolygone
virtual void spewPolygone(const Polygone *, QTextStream &out)=0
vrender::FIGExporter::writeHeader
virtual void writeHeader(QTextStream &out) const
Definition: FIGExporter.cpp:90
vrender::EPSExporter::setColor
void setColor(QTextStream &out, float, float, float)
Definition: EPSExporter.cpp:308
vrender
Definition: AxisAlignedBox.h:48
vrender::EPSExporter::writeHeader
virtual void writeHeader(QTextStream &out) const
Definition: EPSExporter.cpp:67
vrender::EPSExporter::last_r
static float last_r
Definition: Exporter.h:132
vrender::FIGExporter::writeFooter
virtual void writeFooter(QTextStream &out) const
Definition: FIGExporter.cpp:98
vrender::Point
Definition: Primitive.h:170
vrender::Exporter::_lineWidth
float _lineWidth
Definition: Exporter.h:102
vrender::EPSExporter::spewPoint
virtual void spewPoint(const Point *, QTextStream &out)
Definition: EPSExporter.cpp:296
vrender::Exporter::writeFooter
virtual void writeFooter(QTextStream &out) const =0
vrender::EPSExporter::spewSegment
virtual void spewSegment(const Segment *, QTextStream &out)
Definition: EPSExporter.cpp:214
vrender::FIGExporter::_sizeX
int _sizeX
Definition: Exporter.h:163
vrender::FIGExporter::spewPolygone
virtual void spewPolygone(const Polygone *, QTextStream &out)
Definition: FIGExporter.cpp:179
vrender::Segment
Definition: Primitive.h:185
vrender::Exporter::exportToFile
virtual void exportToFile(const QString &filename, const std::vector< PtrPrimitive > &, VRenderParams &)
Definition: Exporter.cpp:61
vrender::FIGExporter::~FIGExporter
virtual ~FIGExporter()
Definition: Exporter.h:152
vrender::Exporter::_xmin
GLfloat _xmin
Definition: Exporter.h:104


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Apr 3 2025 02:40:44