Points&Forces (survey)
Software tools facilitating the task of surveying architecture
a_screen.h
Go to the documentation of this file.
1 /*
2  Copyright 2010-2022 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_SCREEN_H_
17 #define _A_SCREEN_H_
18 
19 // .NAME a_screen
20 // .PORTABILITY : ansi C++
21 // .SECTION Author
22 // Pierre Smars
23 
24 #include "vtkPolyData.h"
25 #include "vtkRenderer.h"
26 #include "vtkRenderWindow.h"
27 #include "vtkRenderWindowInteractor.h"
28 
29 #include "a_screenlayer.h"
30 #include "a_text.h"
31 #include "a_point.h"
32 
33 #include <string>
34 #include <vector>
35 
37 class a_screen
38 {
39  public:
40  // a_screen(const std::string& id);
41  a_screen();
42  ~a_screen();
43  virtual std::string type() const {return "a_screen";}
44  inline void logfile(a_text& text) {log_ << "setlogfile" << std::endl; log_ = text;}
45  inline void outputfile(a_text& text) {log_ << "setoutputfile" << std::endl; output_ = text;}
46  // inline void logfile(a_text& text) {this->logfile() << "setlogfile" << std::endl; log_ = text;}
47  // inline a_text& logfile() const {return &log_;}
48  inline void printout(const std::string text) {output_ << text << std::endl;}
49  inline void printout(const bool val) {output_ << val << std::endl;}
50  static const std::string help();
51  //layers management
52  bool existlayer(const std::string& s) const;
53  bool existlayer(const std::string& s, a_screenlayer *&) const;
54  virtual void newlayer(const std::string& s);
55  void newlayer(const a_screenlayer& l);
56  virtual void setlayer(const std::string& s);
57  virtual void eraselayer(const std::string& s);
58  void setofflayer(const std::string& s);
59  void setonlayer(const std::string& s);
60  const std::string getlayer() const;
61  std::string listlayers();
62  void color(float r, float g, float b);
63  void R(double v) {active_layer_->R(v);}
64  void G(double v) {active_layer_->G(v);}
65  void B(double v) {active_layer_->B(v);}
66  inline double R() const {return active_layer_->R();}
67  inline double G() const {return active_layer_->G();}
68  inline double B() const {return active_layer_->B();}
69  void thickness(const int);
70  inline int thickness() const {return active_layer_->thickness();}
71  void spotlight();
72  void sunlight();
73  void parallel_view();
74  void perspectia_view();
75 
76  //bounds utilities
77  inline bool empty() const {return empty_;}
78  inline void empty(bool code) {empty_ = code;}
79  //
80  virtual void interact();
81  void getinteract() {std::cout << *iren_ << std::endl;};
82  void point(const a_point& p);
83  void point(double x, double y, double z);
84  void line(const a_point& p1, const a_point& p2);
85  void line(double x1, double y1, double z1,
86  double x2, double y2, double z2);
87  void vertex(const a_point& p);
88  void vertex(double x, double y, double z);
89  void endpolyline();
90  void closepolyline();
91  void vertex0(double x, double y, double z);
92  void endpolyline0();
93  void closepolyline0();
94  void surfacepoint(const a_point& p);
95  void surfacepoint(double x, double y, double z);
96  void eraselastpoint();
97  void eraselastline();
98  void eraselastpolyline();
99 
100  //viewing member functions
101  void viewpoint(const a_point& pt);
102  void focalpoint(const a_point& pt);
103  void viewpoint(const double * pt);
104  void focalpoint(const double * pt);
105  a_point viewpoint() const;
106  a_point focalpoint() const;
107  void pan(const double * pt);
108  void azimuth(double x);
109  void elevation(double y);
110  void roll(double z);
111  void pitch(double u);
112  void yaw(double v);
113  void distance(double d);
114  void distance0(double d);
115  double azimuth() const {return x0_;}
116  double elevation() const {return y0_;}
117  double roll() const {return z0_;}
118  double distance() const;
119 
120  void background(double R, double G, double B);
121  inline void fullscreenon() {renWin_->SetSize(1280,1024);}
122  inline void fullscreenoff() {renWin_->SetSize(640,480);}
123  inline void cursor_show() {renWin_->ShowCursor();}
124  inline void cursor_hide() {renWin_->HideCursor();}
125 
126  //import/export
127  void output_position();
128  void dxfin(const std::string& file);
129  void dxfout(const std::string& file);
130  void ptin(const std::string& file);
131  void ptout(const std::string& file);
132  void tifout(const std::string& file);
133  void jpgout(const std::string& file);
134  void pngout(const std::string& file);
135  void vrmlout(const std::string& file);
136  void vtkout(const std::string& file);
137  void ribout(const std::string& file);
138 
139  inline void render() {renWin_->Render();}
140  void render_clip();
141  void reset();
142 
143  //: input/output
144  friend std::istream& operator>> (std::istream& i, a_screen& w);
145  friend std::ostream& operator<< (std::ostream& o, a_screen& w);
146  void open(const std::string& file);
147  void save(const std::string& file);
148 
152  class file_error {};
158  class no_layer_error {};
159 
160  protected:
161  vtkPolyData * data_;
162  std::vector<a_screenlayer *> layers_;
164  vtkRenderer * ren_;
165  vtkRenderWindow * renWin_;
166  vtkRenderWindowInteractor * iren_;
167  //orientation references
169  double x0_;
171  double y0_;
173  double z0_;
175  float clip_[2];
178  a_text output_;
180  a_text log_;
181  /*if there's already one graphic element*/
182  bool empty_;
183  bool one_point_;
184 
185  void point0(double x, double y, double z);
186  void line0(double x1, double y1, double z1,
187  double x2, double y2, double z2);
189  void unroll();
190 
191 };
192 
193 #endif
a_mat_sq x2(3)
a vtk screen
Definition: a_screen.h:38
virtual void eraselayer(const std::string &s)
Definition: a_screen.cxx:315
void reset()
Definition: a_screen.cxx:1024
double roll() const
Definition: a_screen.h:117
double B() const
Definition: a_screen.h:68
void closepolyline()
Definition: a_screen.cxx:522
void point(const a_point &p)
Definition: a_screen.cxx:453
static const std::string help()
Definition: a_screen.cxx:49
friend std::istream & operator>>(std::istream &i, a_screen &w)
Definition: a_screen.cxx:1059
void cursor_hide()
Definition: a_screen.h:124
double z0_
Definition: a_screen.h:173
void endpolyline0()
Definition: a_screen.cxx:551
void output_position()
Definition: a_screen.cxx:696
void printout(const std::string text)
Definition: a_screen.h:48
std::vector< a_screenlayer * > layers_
Definition: a_screen.h:162
void empty(bool code)
Definition: a_screen.h:78
void printout(const bool val)
Definition: a_screen.h:49
float clip_[2]
Definition: a_screen.h:175
void vertex0(double x, double y, double z)
Definition: a_screen.cxx:546
void eraselastline()
Definition: a_screen.cxx:594
void distance0(double d)
Definition: a_screen.cxx:676
void vrmlout(const std::string &file)
Definition: a_screen.cxx:964
double x0_
Definition: a_screen.h:169
void render_clip()
Definition: a_screen.cxx:1018
a_point viewpoint() const
Definition: a_screen.cxx:720
void pitch(double u)
Definition: a_screen.cxx:633
void endpolyline()
Definition: a_screen.cxx:508
void jpgout(const std::string &file)
Definition: a_screen.cxx:933
void setofflayer(const std::string &s)
Definition: a_screen.cxx:340
void point0(double x, double y, double z)
Definition: a_screen.cxx:536
const std::string getlayer() const
Definition: a_screen.cxx:358
double R() const
Definition: a_screen.h:66
void pan(const double *pt)
Definition: a_screen.cxx:706
void setonlayer(const std::string &s)
Definition: a_screen.cxx:349
void fullscreenon()
Definition: a_screen.h:121
void B(double v)
Definition: a_screen.h:65
void line(const a_point &p1, const a_point &p2)
Definition: a_screen.cxx:477
void line0(double x1, double y1, double z1, double x2, double y2, double z2)
Definition: a_screen.cxx:541
void color(float r, float g, float b)
Definition: a_screen.cxx:363
void getinteract()
Definition: a_screen.h:81
void tifout(const std::string &file)
Definition: a_screen.cxx:1003
a_text output_
Definition: a_screen.h:178
void eraselastpoint()
Definition: a_screen.cxx:587
virtual void newlayer(const std::string &s)
Definition: a_screen.cxx:245
friend std::ostream & operator<<(std::ostream &o, a_screen &w)
Definition: a_screen.cxx:1080
void cursor_show()
Definition: a_screen.h:123
void closepolyline0()
Definition: a_screen.cxx:556
void ptout(const std::string &file)
Definition: a_screen.cxx:920
void render()
Definition: a_screen.h:139
void fullscreenoff()
Definition: a_screen.h:122
double G() const
Definition: a_screen.h:67
virtual std::string type() const
Definition: a_screen.h:43
double y0_
Definition: a_screen.h:171
double azimuth() const
Definition: a_screen.h:115
void R(double v)
Definition: a_screen.h:63
void save(const std::string &file)
Definition: a_screen.cxx:1100
bool empty_
Definition: a_screen.h:182
vtkRenderWindowInteractor * iren_
Definition: a_screen.h:166
double distance() const
Definition: a_screen.cxx:669
a_point focalpoint() const
Definition: a_screen.cxx:728
void setlightoncameraposition()
Definition: a_screen.cxx:1044
virtual void interact()
Definition: a_screen.cxx:417
bool one_point_
Definition: a_screen.h:183
void vertex(const a_point &p)
Definition: a_screen.cxx:497
bool existlayer(const std::string &s) const
Definition: a_screen.cxx:222
void outputfile(a_text &text)
Definition: a_screen.h:45
void ribout(const std::string &file)
Definition: a_screen.cxx:991
virtual void setlayer(const std::string &s)
Definition: a_screen.cxx:306
void sunlight()
Definition: a_screen.cxx:391
a_text log_
Definition: a_screen.h:180
void open(const std::string &file)
Definition: a_screen.cxx:1088
a_screenlayer * active_layer_
Definition: a_screen.h:163
vtkRenderer * ren_
Definition: a_screen.h:164
void dxfin(const std::string &file)
Definition: a_screen.cxx:808
void pngout(const std::string &file)
Definition: a_screen.cxx:949
void yaw(double v)
Definition: a_screen.cxx:642
void dxfout(const std::string &file)
Definition: a_screen.cxx:879
void spotlight()
Definition: a_screen.cxx:380
void background(double R, double G, double B)
Definition: a_screen.cxx:687
void unroll()
Definition: a_screen.cxx:651
void ptin(const std::string &file)
Definition: a_screen.cxx:903
void logfile(a_text &text)
Definition: a_screen.h:44
void vtkout(const std::string &file)
Definition: a_screen.cxx:974
void surfacepoint(const a_point &p)
Definition: a_screen.cxx:561
bool empty() const
Definition: a_screen.h:77
void eraselastpolyline()
Definition: a_screen.cxx:601
void G(double v)
Definition: a_screen.h:64
vtkRenderWindow * renWin_
Definition: a_screen.h:165
std::string listlayers()
Definition: a_screen.cxx:295
void perspectia_view()
Definition: a_screen.cxx:410
bool spotlight_
Definition: a_screen.h:176
int thickness() const
Definition: a_screen.h:70
double elevation() const
Definition: a_screen.h:116
void parallel_view()
Definition: a_screen.cxx:403
vtkPolyData * data_
Definition: a_screen.h:161
layer used by screen to draw vector graphics
Definition: a_screenlayer.h:31
void B(float v)
void G(float v)
void thickness(const int)
void R(float v)
double v(const uint32_t step, const uint32_t n)
Definition: generate.cxx:42
Definition: stlb2stla.cxx:21