Points&Forces (survey)
Software tools facilitating the task of surveying architecture
a_canvas.h
Go to the documentation of this file.
1 /*
2  Copyright 2010-2016 Pierre SMARS (smars@yuntech.edu.tw)
3  This program is free software: you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation, either version 2 of the License, or
6  (at your option) any later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 #ifndef _A_CANVAS_H_
17 #define _A_CANVAS_H_
18 
19 // .NAME a_canvas
20 // .PORTABILITY : ansi C++
21 // .SECTION Author
22 // Pierre Smars
23 
24 class a_element;
25 
26 #include "vtkPolyData.h"
27 #include "vtkRenderer.h"
28 #include "vtkRenderWindow.h"
29 #include "vtkRenderWindowInteractor.h"
30 
31 #include "a_element.h"
32 #include "a_text.h"
33 #include "a_point.h"
34 
35 #include <string>
36 #include <vector>
37 
39 class a_canvas
40 {
41  public:
42  a_canvas();
43  ~a_canvas();
44  void clear();
45  virtual std::string type() const {return "a_canvas";}
46  static const std::string help();
47  void name(const std::string& name);
48  inline std::string name() const {return name_;}
49 
50  void logfile(a_text& text);
51  void outputfile(a_text& text);
52  inline a_text& logfile() {return log_;}
53  inline void printout(const std::string text) {output_ << text << std::endl;}
54  inline void printout(const bool x) {output_ << x << std::endl;}
55 
56  //layers management
57  bool existelement(const std::string& s) const;
58  bool existelement(const std::string& s, a_element *&) const;
59  void addelement(a_element& l);
60  void setelement(const std::string& s);
61  void unlinkelement(const std::string& s);
62  void fitelements(const std::string& m, const std::string& p);
63  const std::string getelementname() const;
64  std::string listelements();
65  void spotlight();
66  void sunlight();
67  void parallel_view();
68  void perspectia_view();
69  double scale() const;
70  void scale(double val);
71  void magnification(unsigned short val);
72  //bounds utilities
73  inline bool empty() const {return empty_;}
74  inline void empty(bool code) {empty_ = code;}
75  //
76  virtual void interact();
77  virtual void straighten();
78  virtual void fit_interact();
79  virtual void fit_deform_interact();
80  virtual void cut_interact();
81  void getinteract() {std::cout << *iren_ << std::endl;};
82 
83  //viewing member functions
84  void viewpoint(const a_point& pt);
85  void focalpoint(const a_point& pt);
86  void up(const a_point& pt);
87  void viewpoint(const double * pt);
88  void focalpoint(const double * pt);
89  void up(const double * pt);
90  a_point viewpoint() const;
91  a_point focalpoint() const;
92  a_point up() const;
93  void pan(const double * pt);
94  void azimuth(double x);
95  void elevation(double y);
96  void roll(double z);
97  void pitch(double u);
98  void yaw(double v);
99  void distance(double d);
100  void distance0(double d);
101  double azimuth() const;
102  double elevation() const;
103  double roll() const;
104  double distance() const;
105  void x();
106  void X();
107  void y();
108  void Y();
109  void z();
110  void Z();
111 
112  void background(double R, double G, double B);
113  inline void size(const int w, const int h) {renWin_->SetSize(w,h);}
114  int width() const;
115  int height() const;
116  inline void fullscreenon() {renWin_->SetSize(1280,1024);}
117  inline void fullscreenoff() {renWin_->SetSize(640,480);}
118  inline void cursor_show() {renWin_->ShowCursor();}
119  inline void cursor_hide() {renWin_->HideCursor();}
120 
121  //import/export
122  void output_position();
123  void jpgout(const std::string& file);
124  void pngout(const std::string& file);
125  void vrmlout(const std::string& file);
126  void vtkout(const std::string& file);
127  void ribout(const std::string& file);
128  void tifout(const std::string& file);
129 
130  inline void render() {renWin_->Render();}
131  void render_clip();
132  void reset();
133 
134  //: input/output
135  friend std::istream& operator>> (std::istream& i, a_canvas& w);
136  friend std::ostream& operator<< (std::ostream& o, a_canvas& w);
137  void open(const std::string& file);
138  void save(const std::string& file);
139 
143  class file_error {};
150 
151  protected:
152  virtual void reset_interact();
153 
154  std::string name_;
155  std::vector<a_element *> elements_;
157  vtkRenderer * ren_;
158  vtkRenderWindow * renWin_;
159  vtkRenderWindowInteractor * iren_;
161  float clip_[2];
164  a_text output_;
166  a_text log_;
167  /*if there's already one graphic element*/
168  bool empty_;
169  bool one_point_;
173  void unroll();
174 };
175 
176 #endif
a vtk screen
Definition: a_canvas.h:40
bool spotlight_
Definition: a_canvas.h:162
void x()
Definition: a_canvas.cxx:829
double elevation() const
Definition: a_canvas.cxx:698
friend std::ostream & operator<<(std::ostream &o, a_canvas &w)
Definition: a_canvas.cxx:1174
double roll() const
Definition: a_canvas.cxx:728
void jpgout(const std::string &file)
Definition: a_canvas.cxx:1042
void clear()
Definition: a_canvas.cxx:230
void distance0(double d)
Definition: a_canvas.cxx:809
void Z()
Definition: a_canvas.cxx:909
vtkRenderWindowInteractor * iren_
Definition: a_canvas.h:159
void yaw(double v)
Definition: a_canvas.cxx:747
a_text output_
Definition: a_canvas.h:164
void vtkout(const std::string &file)
Definition: a_canvas.cxx:1085
std::string listelements()
Definition: a_canvas.cxx:366
bool empty_
Definition: a_canvas.h:168
std::vector< a_element * > elements_
Definition: a_canvas.h:155
void save(const std::string &file)
Definition: a_canvas.cxx:1193
double azimuth() const
Definition: a_canvas.cxx:656
void cursor_show()
Definition: a_canvas.h:118
void spotlight()
Definition: a_canvas.cxx:425
a_element * active_element_
Definition: a_canvas.h:156
void pitch(double u)
Definition: a_canvas.cxx:764
std::string name_
Definition: a_canvas.h:154
double scale() const
Definition: a_canvas.cxx:474
void magnification(unsigned short val)
Definition: a_canvas.cxx:466
void output_position()
Definition: a_canvas.cxx:936
void unroll()
Definition: a_canvas.cxx:784
void cursor_hide()
Definition: a_canvas.h:119
void y()
Definition: a_canvas.cxx:861
void X()
Definition: a_canvas.cxx:845
void outputfile(a_text &text)
Definition: a_canvas.cxx:251
virtual void fit_deform_interact()
Definition: a_canvas.cxx:537
void reset()
Definition: a_canvas.cxx:1132
void printout(const std::string text)
Definition: a_canvas.h:53
vtkRenderWindow * renWin_
Definition: a_canvas.h:158
void open(const std::string &file)
Definition: a_canvas.cxx:1182
void sunlight()
Definition: a_canvas.cxx:437
void fullscreenoff()
Definition: a_canvas.h:117
int width() const
Definition: a_canvas.cxx:925
float clip_[2]
Definition: a_canvas.h:161
void ribout(const std::string &file)
Definition: a_canvas.cxx:1099
void tifout(const std::string &file)
Definition: a_canvas.cxx:1111
void printout(const bool x)
Definition: a_canvas.h:54
static const std::string help()
Definition: a_canvas.cxx:68
bool existelement(const std::string &s) const
Definition: a_canvas.cxx:311
friend std::istream & operator>>(std::istream &i, a_canvas &w)
Definition: a_canvas.cxx:1169
void Y()
Definition: a_canvas.cxx:877
void pan(const double *pt)
Definition: a_canvas.cxx:946
bool one_point_
Definition: a_canvas.h:169
virtual std::string type() const
Definition: a_canvas.h:45
bool empty() const
Definition: a_canvas.h:73
a_point viewpoint() const
Definition: a_canvas.cxx:960
int height() const
Definition: a_canvas.cxx:931
void background(double R, double G, double B)
Definition: a_canvas.cxx:820
virtual void fit_interact()
Definition: a_canvas.cxx:517
a_text log_
Definition: a_canvas.h:166
const std::string getelementname() const
Definition: a_canvas.cxx:400
void addelement(a_element &l)
Definition: a_canvas.cxx:337
void empty(bool code)
Definition: a_canvas.h:74
void parallel_view()
Definition: a_canvas.cxx:450
void perspectia_view()
Definition: a_canvas.cxx:458
void size(const int w, const int h)
Definition: a_canvas.h:113
a_point up() const
Definition: a_canvas.cxx:976
void unlinkelement(const std::string &s)
Definition: a_canvas.cxx:386
double distance() const
Definition: a_canvas.cxx:802
std::string name() const
Definition: a_canvas.h:48
a_point focalpoint() const
Definition: a_canvas.cxx:968
void getinteract()
Definition: a_canvas.h:81
virtual void interact()
Definition: a_canvas.cxx:617
void render_clip()
Definition: a_canvas.cxx:1126
double magnification_
magnification value for exports
Definition: a_canvas.h:171
void z()
Definition: a_canvas.cxx:893
virtual void reset_interact()
Definition: a_canvas.cxx:504
void fullscreenon()
Definition: a_canvas.h:116
void pngout(const std::string &file)
Definition: a_canvas.cxx:1059
void setlightoncameraposition()
Definition: a_canvas.cxx:1154
void vrmlout(const std::string &file)
Definition: a_canvas.cxx:1075
vtkRenderer * ren_
Definition: a_canvas.h:157
void setelement(const std::string &s)
Definition: a_canvas.cxx:377
a_text & logfile()
Definition: a_canvas.h:52
virtual void straighten()
Definition: a_canvas.cxx:493
void render()
Definition: a_canvas.h:130
void fitelements(const std::string &m, const std::string &p)
Definition: a_canvas.cxx:405
virtual void cut_interact()
Definition: a_canvas.cxx:554
layer used by screen to draw vector graphics
Definition: a_element.h:39
double v(const uint32_t step, const uint32_t n)
Definition: generate.cxx:42
Definition: stlb2stla.cxx:21