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


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