Geom Software - C++ Programming and Geometry Libraries
Fade2D Documentation pages v1.55
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 
51 {
52 public:
53 
54 
59  CLASS_DECLSPEC
60  explicit Visualizer2(const std::string& filename_);
61 
62  CLASS_DECLSPEC
63  ~Visualizer2();
64 
65 
68  CLASS_DECLSPEC
69  void addObject(const Segment2& seg,const Color& c);
72  CLASS_DECLSPEC
73  void addObject(const std::vector<Point2>& vPoints,const Color& c);
74 
77  CLASS_DECLSPEC
78  void addObject(const std::vector<Point2*>& vPoints,const Color& c);
79 
80 
83  CLASS_DECLSPEC
84  void addObject(const std::vector<Segment2>& vSegments,const Color& c);
85 
88  CLASS_DECLSPEC
89  void addObject(const std::vector<Triangle2>& vT,const Color& c);
90 
93  CLASS_DECLSPEC
94  void addObject(const Circle2& circ,const Color& c);
97  CLASS_DECLSPEC
98  void addObject(const Point2& pnt,const Color& c);
101  CLASS_DECLSPEC
102  void addObject(const Triangle2& tri,const Color& c);
103 
106  CLASS_DECLSPEC
107  void addObject(const std::vector<Triangle2*>& vT,const Color& c);
108 
111  CLASS_DECLSPEC
112  void addObject(const Label& lab,const Color& c);
113 
116  CLASS_DECLSPEC
117  void addHeaderLine(const std::string& s);
118 
119 
124  CLASS_DECLSPEC
125  void writeFile();
126 
127 protected:
128  std::ofstream outFile;
129  std::vector<std::pair<Segment2,Color> > vSegments;
130  std::vector<std::pair<Circle2,Color> > vCircles;
131  std::vector<std::pair<Point2,Color> > vPoints;
132  std::vector<std::pair<Triangle2,Color> > vTriangles;
133  std::vector<std::pair<Label,Color> > vLabels;
134  void writeHeaderLines();
135 
136  int updateCtr;
137  Bbox2 bbox;
138  bool bFill;
139 
140  Point2 scaledPoint(const Point2 &p);
141  double scaledDouble(const double &d);
142  void changeColor(float r,float g,float b,float linewidth,bool bFill);
143  void changeColor(const Color& c);
144  void writeHeader(const std::string& title);
145  void writeFooter();
146  void writeLabel(Label l);
147  void writeLine(const Point2& pSource,const Point2& pTarget);
148  void writeTriangle(const Triangle2* pT,bool bFill_,double width);
149  void writePoint(Point2& p1_,float size);
150  void writeCircle(const Point2& p1_,double radius,bool bFill);
151  void periodicStroke();
152  void setRange();
153  Color lastColor;
154  std::string filename;
155  std::vector<std::string> vHeaderLines;
156  bool bFileClosed;
157 };
158 
159 
160 } // (namespace)
Point.
Definition: Point2.h:39
Circle.
Definition: Circle2.h:36
Visualizer2 is a general Postscript writer. It draws the objects Point2, Segment2, Triangle2, Circle2 and Label.
Definition: Visualizer2.h:50
Color.
Definition: Color.h:58
Segment.
Definition: Segment2.h:38
Text-Label.
Definition: Label.h:36
Bbox2 is an axis aligned bounding box.
Definition: Bbox2.h:36
Triangle.
Definition: Triangle2.h:48
Definition: Bbox2.h:25