Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 #ifndef _VRENDER_EXPORTER_H
00046 #define _VRENDER_EXPORTER_H
00047 
00048 
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         
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         
00123         
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