Exporter.h
Go to the documentation of this file.
00001 /*
00002  This file is part of the VRender library.
00003  Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr)
00004  Version 1.0.0, released on June 27, 2005.
00005 
00006  http://artis.imag.fr/Members/Cyril.Soler/VRender
00007 
00008  VRender is free software; you can redistribute it and/or modify
00009  it under the terms of the GNU General Public License as published by
00010  the Free Software Foundation; either version 2 of the License, or
00011  (at your option) any later version.
00012 
00013  VRender is distributed in the hope that it will be useful,
00014  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  GNU General Public License for more details.
00017 
00018  You should have received a copy of the GNU General Public License
00019  along with VRender; if not, write to the Free Software Foundation, Inc.,
00020  51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
00021 */
00022 
00023 /****************************************************************************
00024 
00025  Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
00026 
00027  This file is part of the QGLViewer library version 2.4.0.
00028 
00029  http://www.libqglviewer.com - contact@libqglviewer.com
00030 
00031  This file may be used under the terms of the GNU General Public License 
00032  versions 2.0 or 3.0 as published by the Free Software Foundation and
00033  appearing in the LICENSE file included in the packaging of this file.
00034  In addition, as a special exception, Gilles Debunne gives you certain 
00035  additional rights, described in the file GPL_EXCEPTION in this package.
00036 
00037  libQGLViewer uses dual licensing. Commercial/proprietary software must
00038  purchase a libQGLViewer Commercial License.
00039 
00040  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00041  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00042 
00043 *****************************************************************************/
00044 
00045 #ifndef _VRENDER_EXPORTER_H
00046 #define _VRENDER_EXPORTER_H
00047 
00048 // Set of classes for exporting in various formats, like EPS, XFig3.2, SVG.
00049 
00050 #include "Primitive.h"
00051 
00052 #include "../config.h"
00053 #if QT_VERSION >= 0x040000
00054 # include <QTextStream>
00055 # include <QString>
00056 #else
00057 # include <qtextstream.h>
00058 # include <qstring.h>
00059 #endif
00060 
00061 namespace vrender
00062 {
00063         class VRenderParams ;
00064         class Exporter
00065         {
00066                 public:
00067                         Exporter() ;
00068                         virtual ~Exporter() {};
00069 
00070                         virtual void exportToFile(const QString& filename,const std::vector<PtrPrimitive>&,VRenderParams&) ;
00071 
00072                         void setBoundingBox(float xmin,float ymin,float xmax,float ymax) ;
00073                         void setClearColor(float r,float g,float b) ;
00074                         void setClearBackground(bool b) ;
00075                         void setBlackAndWhite(bool b) ;
00076 
00077                 protected:
00078                         virtual void spewPoint(const Point *, QTextStream& out) = 0 ;
00079                         virtual void spewSegment(const Segment *, QTextStream& out) = 0 ;
00080                         virtual void spewPolygone(const Polygone *, QTextStream& out) = 0 ;
00081 
00082                         virtual void writeHeader(QTextStream& out) const = 0 ;
00083                         virtual void writeFooter(QTextStream& out) const = 0 ;
00084 
00085                         float _clearR,_clearG,_clearB ;
00086                         float _pointSize ;
00087                         float _lineWidth ;
00088 
00089                         GLfloat _xmin,_xmax,_ymin,_ymax,_zmin,_zmax ;
00090 
00091                         bool _clearBG,_blackAndWhite ;
00092         };
00093 
00094         // Exports to encapsulated postscript.
00095 
00096         class EPSExporter: public Exporter
00097         {
00098                 public:
00099                         EPSExporter() ;
00100                         virtual ~EPSExporter() {};
00101 
00102                 protected:
00103                         virtual void spewPoint(const Point *, QTextStream& out) ;
00104                         virtual void spewSegment(const Segment *, QTextStream& out) ;
00105                         virtual void spewPolygone(const Polygone *, QTextStream& out) ;
00106 
00107                         virtual void writeHeader(QTextStream& out) const ;
00108                         virtual void writeFooter(QTextStream& out) const ;
00109 
00110                 private:
00111                         void setColor(QTextStream& out,float,float,float) ;
00112 
00113                         static const double EPS_GOURAUD_THRESHOLD ;
00114                         static const char *GOURAUD_TRIANGLE_EPS[] ;
00115                         static const char *CREATOR ;
00116 
00117                         static float last_r ;
00118                         static float last_g ;
00119                         static float last_b ;
00120         };
00121 
00122         //  Exports to postscript. The only difference is the filename extension and
00123         // the showpage at the end.
00124 
00125         class PSExporter: public EPSExporter
00126         {
00127                 public:
00128                         virtual ~PSExporter() {};
00129                 protected:
00130                         virtual void writeFooter(QTextStream& out) const ;
00131         };
00132 
00133         class FIGExporter: public Exporter
00134         {
00135                 public:
00136                         FIGExporter() ;
00137                         virtual ~FIGExporter() {};
00138 
00139                 protected:
00140                         virtual void spewPoint(const Point *, QTextStream& out) ;
00141                         virtual void spewSegment(const Segment *, QTextStream& out) ;
00142                         virtual void spewPolygone(const Polygone *, QTextStream& out) ;
00143 
00144                         virtual void writeHeader(QTextStream& out) const ;
00145                         virtual void writeFooter(QTextStream& out) const ;
00146 
00147                 private:
00148                         mutable int _sizeX ;
00149                         mutable int _sizeY ;
00150                         mutable int _depth ;
00151 
00152                         int FigCoordX(double) const ;
00153                         int FigCoordY(double) const ;
00154                         int FigGrayScaleIndex(float red, float green, float blue) const ;
00155         };
00156 #ifdef A_FAIRE
00157         class SVGExporter: public Exporter
00158         {
00159                 protected:
00160                         virtual void spewPoint(const Point *, QTextStream& out) ;
00161                         virtual void spewSegment(const Segment *, QTextStream& out) ;
00162                         virtual void spewPolygone(const Polygone *, QTextStream& out) ;
00163 
00164                         virtual void writeHeader(QTextStream& out) const ;
00165                         virtual void writeFooter(QTextStream& out) const ;
00166         };
00167 #endif
00168 }
00169 
00170 #endif


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Aug 27 2015 14:13:26