Geom Software - C++ Programming and Geometry Libraries
Fade2D Documentation pages v1.52
Visualizer2.h
1 // Copyright (C) Geom Software e.U, Bernhard Kornberger, Graz/Austria
2 //
3 // This file is part of the Fade2D library. The student license is free
4 // of charge and covers personal non-commercial research. Licensees
5 // holding a commercial license may use this file in accordance with
6 // the Commercial License Agreement.
7 //
8 // This software is provided AS IS with NO WARRANTY OF ANY KIND,
9 // INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
10 // FOR A PARTICULAR PURPOSE.
11 //
12 // Please contact the author if any conditions of this licensing are
13 // not clear to you.
14 //
15 // Author: Bernhard Kornberger, bkorn (at) geom.at
16 // http://www.geom.at
17 
18 
19 #pragma once
20 
21 
22 #include "Point2.h"
23 #include "Circle2.h"
24 #include "Segment2.h"
25 #include "Color.h"
26 #include "Label.h"
27 #include "Bbox2.h"
28 
29 
30 #include "common.h"
31 #if GEOM_PSEUDO3D==GEOM_TRUE
32  namespace GEOM_FADE25D {
33 #elif GEOM_PSEUDO3D==GEOM_FALSE
34  namespace GEOM_FADE2D {
35 #else
36  #error GEOM_PSEUDO3D is not defined
37 #endif
38 
39 
48 {
49 public:
50 
51 
56  CLASS_DECLSPEC
57  explicit Visualizer2(const std::string& filename_);
58 
59  CLASS_DECLSPEC
60  ~Visualizer2();
61 
62 
65  CLASS_DECLSPEC
66  void addObject(const Segment2& seg,const Color& c);
69  CLASS_DECLSPEC
70  void addObject(const std::vector<Point2>& vPoints,const Color& c);
71 
74  CLASS_DECLSPEC
75  void addObject(const std::vector<Point2*>& vPoints,const Color& c);
76 
77 
80  CLASS_DECLSPEC
81  void addObject(const std::vector<Segment2>& vSegments,const Color& c);
82 
85  CLASS_DECLSPEC
86  void addObject(const std::vector<Triangle2>& vT,const Color& c);
87 
90  CLASS_DECLSPEC
91  void addObject(const Circle2& circ,const Color& c);
94  CLASS_DECLSPEC
95  void addObject(const Point2& pnt,const Color& c);
98  CLASS_DECLSPEC
99  void addObject(const Triangle2& tri,const Color& c);
100 
103  CLASS_DECLSPEC
104  void addObject(const std::vector<Triangle2*>& vT,const Color& c);
105 
108  CLASS_DECLSPEC
109  void addObject(const Label& lab,const Color& c);
110 
113  CLASS_DECLSPEC
114  void addHeaderLine(const std::string& s);
115 
116 
121  CLASS_DECLSPEC
122  void writeFile();
123 
124 protected:
125  std::ofstream outFile;
126  std::vector<std::pair<Segment2,Color> > vSegments;
127  std::vector<std::pair<Circle2,Color> > vCircles;
128  std::vector<std::pair<Point2,Color> > vPoints;
129  std::vector<std::pair<Triangle2,Color> > vTriangles;
130  std::vector<std::pair<Label,Color> > vLabels;
131  void writeHeaderLines();
132 
133  int updateCtr;
134  Bbox2 bbox;
135  bool bFill;
136 
137  Point2 scaledPoint(const Point2 &p);
138  double scaledDouble(const double &d);
139  void changeColor(float r,float g,float b,float linewidth,bool bFill);
140  void changeColor(const Color& c);
141  void writeHeader(const std::string& title);
142  void writeFooter();
143  void writeLabel(Label l);
144  void writeLine(const Point2& pSource,const Point2& pTarget);
145  void writeTriangle(const Triangle2* pT,bool bFill_,double width);
146  void writePoint(Point2& p1_,float size);
147  void writeCircle(const Point2& p1_,double radius);
148  void periodicStroke();
149  void setRange();
150  Color lastColor;
151  std::string filename;
152  std::vector<std::string> vHeaderLines;
153  bool bFileClosed;
154 };
155 
156 
157 } // (namespace)
Point.
Definition: Point2.h:39
Circle.
Definition: Circle2.h:36
Postscript writer.
Definition: Visualizer2.h:47
Color
Definition: Color.h:51
Segment.
Definition: Segment2.h:38
Text-Label.
Definition: Label.h:36
Boundingbox.
Definition: Bbox2.h:34
Triangle.
Definition: Triangle2.h:48
Definition: Bbox2.h:25