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-2013 Gilles Debunne. All rights reserved.
26 
27  This file is part of the QGLViewer library version 2.4.0.
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 #if QT_VERSION >= 0x040000
54 # include <QTextStream>
55 # include <QString>
56 #else
57 # include <qtextstream.h>
58 # include <qstring.h>
59 #endif
60 
61 namespace vrender
62 {
63  class VRenderParams ;
64  class Exporter
65  {
66  public:
67  Exporter() ;
68  virtual ~Exporter() {};
69 
70  virtual void exportToFile(const QString& filename,const std::vector<PtrPrimitive>&,VRenderParams&) ;
71 
72  void setBoundingBox(float xmin,float ymin,float xmax,float ymax) ;
73  void setClearColor(float r,float g,float b) ;
74  void setClearBackground(bool b) ;
75  void setBlackAndWhite(bool b) ;
76 
77  protected:
78  virtual void spewPoint(const Point *, QTextStream& out) = 0 ;
79  virtual void spewSegment(const Segment *, QTextStream& out) = 0 ;
80  virtual void spewPolygone(const Polygone *, QTextStream& out) = 0 ;
81 
82  virtual void writeHeader(QTextStream& out) const = 0 ;
83  virtual void writeFooter(QTextStream& out) const = 0 ;
84 
86  float _pointSize ;
87  float _lineWidth ;
88 
90 
92  };
93 
94  // Exports to encapsulated postscript.
95 
96  class EPSExporter: public Exporter
97  {
98  public:
99  EPSExporter() ;
100  virtual ~EPSExporter() {};
101 
102  protected:
103  virtual void spewPoint(const Point *, QTextStream& out) ;
104  virtual void spewSegment(const Segment *, QTextStream& out) ;
105  virtual void spewPolygone(const Polygone *, QTextStream& out) ;
106 
107  virtual void writeHeader(QTextStream& out) const ;
108  virtual void writeFooter(QTextStream& out) const ;
109 
110  private:
111  void setColor(QTextStream& out,float,float,float) ;
112 
113  static const double EPS_GOURAUD_THRESHOLD ;
114  static const char *GOURAUD_TRIANGLE_EPS[] ;
115  static const char *CREATOR ;
116 
117  static float last_r ;
118  static float last_g ;
119  static float last_b ;
120  };
121 
122  // Exports to postscript. The only difference is the filename extension and
123  // the showpage at the end.
124 
125  class PSExporter: public EPSExporter
126  {
127  public:
128  virtual ~PSExporter() {};
129  protected:
130  virtual void writeFooter(QTextStream& out) const ;
131  };
132 
133  class FIGExporter: public Exporter
134  {
135  public:
136  FIGExporter() ;
137  virtual ~FIGExporter() {};
138 
139  protected:
140  virtual void spewPoint(const Point *, QTextStream& out) ;
141  virtual void spewSegment(const Segment *, QTextStream& out) ;
142  virtual void spewPolygone(const Polygone *, QTextStream& out) ;
143 
144  virtual void writeHeader(QTextStream& out) const ;
145  virtual void writeFooter(QTextStream& out) const ;
146 
147  private:
148  mutable int _sizeX ;
149  mutable int _sizeY ;
150  mutable int _depth ;
151 
152  int FigCoordX(double) const ;
153  int FigCoordY(double) const ;
154  int FigGrayScaleIndex(float red, float green, float blue) const ;
155  };
156 #ifdef A_FAIRE
157  class SVGExporter: public Exporter
158  {
159  protected:
160  virtual void spewPoint(const Point *, QTextStream& out) ;
161  virtual void spewSegment(const Segment *, QTextStream& out) ;
162  virtual void spewPolygone(const Polygone *, QTextStream& out) ;
163 
164  virtual void writeHeader(QTextStream& out) const ;
165  virtual void writeFooter(QTextStream& out) const ;
166  };
167 #endif
168 }
169 
170 #endif
GLfloat _zmax
Definition: Exporter.h:89
static float last_r
Definition: Exporter.h:117
static float last_g
Definition: Exporter.h:118
void setClearColor(float r, float g, float b)
Definition: Exporter.cpp:114
virtual ~Exporter()
Definition: Exporter.h:68
void setClearBackground(bool b)
Definition: Exporter.cpp:115
virtual void spewPoint(const Point *, QTextStream &out)=0
virtual void writeHeader(QTextStream &out) const =0
static const char * CREATOR
Definition: Exporter.h:115
void setBoundingBox(float xmin, float ymin, float xmax, float ymax)
Definition: Exporter.cpp:106
bool _blackAndWhite
Definition: Exporter.h:91
virtual ~EPSExporter()
Definition: Exporter.h:100
virtual ~FIGExporter()
Definition: Exporter.h:137
void setBlackAndWhite(bool b)
Definition: Exporter.cpp:116
GLfloat _xmax
Definition: Exporter.h:89
float _pointSize
Definition: Exporter.h:86
GLfloat _zmin
Definition: Exporter.h:89
virtual void spewSegment(const Segment *, QTextStream &out)=0
GLfloat _ymax
Definition: Exporter.h:89
virtual void spewPolygone(const Polygone *, QTextStream &out)=0
static const double EPS_GOURAUD_THRESHOLD
Definition: Exporter.h:113
virtual void exportToFile(const QString &filename, const std::vector< PtrPrimitive > &, VRenderParams &)
Definition: Exporter.cpp:66
float _lineWidth
Definition: Exporter.h:87
GLfloat _xmin
Definition: Exporter.h:89
virtual ~PSExporter()
Definition: Exporter.h:128
virtual void writeFooter(QTextStream &out) const =0
GLfloat _ymin
Definition: Exporter.h:89
static float last_b
Definition: Exporter.h:119


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Mon Jun 10 2019 14:00:24