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 
81  float _pointSize ;
82  float _lineWidth ;
83 
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
GLfloat _zmax
Definition: Exporter.h:84
static float last_r
Definition: Exporter.h:112
static float last_g
Definition: Exporter.h:113
void setClearColor(float r, float g, float b)
Definition: Exporter.cpp:105
virtual ~Exporter()
Definition: Exporter.h:63
void setClearBackground(bool b)
Definition: Exporter.cpp:106
virtual void spewPoint(const Point *, QTextStream &out)=0
virtual void writeHeader(QTextStream &out) const =0
static const char * CREATOR
Definition: Exporter.h:110
void setBoundingBox(float xmin, float ymin, float xmax, float ymax)
Definition: Exporter.cpp:97
bool _blackAndWhite
Definition: Exporter.h:86
virtual ~EPSExporter()
Definition: Exporter.h:95
virtual ~FIGExporter()
Definition: Exporter.h:132
void setBlackAndWhite(bool b)
Definition: Exporter.cpp:107
GLfloat _xmax
Definition: Exporter.h:84
float _pointSize
Definition: Exporter.h:81
GLfloat _zmin
Definition: Exporter.h:84
virtual void spewSegment(const Segment *, QTextStream &out)=0
GLfloat _ymax
Definition: Exporter.h:84
virtual void spewPolygone(const Polygone *, QTextStream &out)=0
static const double EPS_GOURAUD_THRESHOLD
Definition: Exporter.h:108
virtual void exportToFile(const QString &filename, const std::vector< PtrPrimitive > &, VRenderParams &)
Definition: Exporter.cpp:61
float _lineWidth
Definition: Exporter.h:82
GLfloat _xmin
Definition: Exporter.h:84
virtual ~PSExporter()
Definition: Exporter.h:123
virtual void writeFooter(QTextStream &out) const =0
GLfloat _ymin
Definition: Exporter.h:84
static float last_b
Definition: Exporter.h:114


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Wed Jun 5 2019 19:26:39