Exporter.cpp
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 #include "VRender.h"
46 #include "Exporter.h"
47 #include "../qglviewer.h"
48 
49 #if QT_VERSION >= 0x040000
50 # include <QFile>
51 # include <QMessageBox>
52 #else
53 # include <qfile.h>
54 # include <qmessagebox.h>
55 #endif
56 
57 using namespace vrender ;
58 using namespace std ;
59 
61 {
62  _xmin=_xmax=_ymin=_ymax=_zmin=_zmax = 0.0 ;
63  _pointSize=1 ;
64 }
65 
66 void Exporter::exportToFile(const QString& filename,
67  const vector<PtrPrimitive>& primitive_tab,
68  VRenderParams& vparams)
69 {
70  QFile file(filename);
71 
72 #if QT_VERSION >= 0x040000
73  if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
74 #else
75  if (!file.open(IO_WriteOnly | IO_Translate)) {
76 #endif
77  QMessageBox::warning(NULL, QGLViewer::tr("Exporter error", "Message box window title"), QGLViewer::tr("Unable to open file %1.").arg(filename));
78  return;
79  }
80 
81  QTextStream out(&file);
82 
83  writeHeader(out) ;
84 
85  unsigned int N = primitive_tab.size()/200 + 1 ;
86 
87  for(unsigned int i=0;i<primitive_tab.size();++i)
88  {
89  Point *p = dynamic_cast<Point *>(primitive_tab[i]) ;
90  Segment *s = dynamic_cast<Segment *>(primitive_tab[i]) ;
91  Polygone *P = dynamic_cast<Polygone *>(primitive_tab[i]) ;
92 
93  if(p != NULL) spewPoint(p,out) ;
94  if(s != NULL) spewSegment(s,out) ;
95  if(P != NULL) spewPolygone(P,out) ;
96 
97  if(i%N == 0)
98  vparams.progress(i/(float)primitive_tab.size(),QGLViewer::tr("Exporting to file %1").arg(filename)) ;
99  }
100 
101  writeFooter(out) ;
102 
103  file.close();
104 }
105 
106 void Exporter::setBoundingBox(float xmin,float ymin,float xmax,float ymax)
107 {
108  _xmin = xmin ;
109  _ymin = ymin ;
110  _xmax = xmax ;
111  _ymax = ymax ;
112 }
113 
114 void Exporter::setClearColor(float r, float g, float b) { _clearR=r; _clearG=g; _clearB=b; }
115 void Exporter::setClearBackground(bool b) { _clearBG=b; }
116 void Exporter::setBlackAndWhite(bool b) { _blackAndWhite = b; }
117 
void setClearColor(float r, float g, float b)
Definition: Exporter.cpp:114
void setClearBackground(bool b)
Definition: Exporter.cpp:115
void setBoundingBox(float xmin, float ymin, float xmax, float ymax)
Definition: Exporter.cpp:106
void setBlackAndWhite(bool b)
Definition: Exporter.cpp:116
void progress(float, const QString &)
Definition: VRender.cpp:255
virtual void exportToFile(const QString &filename, const std::vector< PtrPrimitive > &, VRenderParams &)
Definition: Exporter.cpp:66


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