VAPoR  3.0.0
viewpoint.h
Go to the documentation of this file.
1 #ifndef VIEWPOINT_H
2 #define VIEWPOINT_H
3 /*
4 * This class describes a viewpoint
5 */
6 #include <vapor/ExpatParseMgr.h>
7 #include "datastatus.h"
8 namespace VAPoR {
9 class XmlNode;
10 class ParamNode;
21 
23 
24 public:
26  Viewpoint() : ParamsBase(0, Viewpoint::_viewpointTag) {//set to default
27  previousClass = 0;
28  vector<double> campos(3,0.);
29  vector<double> vdir(3,0.);
30  vector<double> upvec(3,0.);
31  vector<double> rotctr(3,0.);
32  campos[2] = 0.5;
33  vdir[2]= -1;
34  upvec[1] = 1;
35  setUpVec(upvec,0);
36  setViewDir(vdir,0);
37  setCameraPosLocal(campos,0);
38  setRotationCenterLocal(rotctr,0);
39 
40  }
41 
43  virtual ~Viewpoint(){}
44 
48 
51  static ParamsBase* CreateDefaultInstance() {return new Viewpoint();}
54  const vector<double> getCameraPosLocal() {
55 
56  return ( GetValueDoubleVec(_camPosTag));
57  }
61  double getCameraPosLocal(int i) {return getCameraPosLocal()[i];}
67  int setCameraPosLocal(int coord, double val, Params* p) {
68  vector<double> campos= vector<double>(getCameraPosLocal());
69  campos[coord] = val;
70  return SetValueDouble(_camPosTag, "Set camera position",campos,p);
71  }
76  int setCameraPosLocal(const vector<double>&val, Params* p) {
77  return SetValueDouble(_camPosTag, "Set camera position", val,p);
78  }
81  const vector<double> getViewDir() {
82  return ( GetValueDoubleVec(_viewDirTag));
83  }
87  double getViewDir(int i) {return getViewDir()[i];}
93  int setViewDir(int coord, double val, Params* p) {
94  vector<double> vdir = vector<double>(getViewDir());
95  (vdir)[coord] = val;
96  return SetValueDouble(_viewDirTag,"Set view direction", vdir,p);
97  }
102  int setViewDir(const vector<double>&val, Params*p) {
103  return SetValueDouble(_viewDirTag, "Set view direction", val,p);
104  }
107  const vector<double> getUpVec() {
108  return ( GetValueDoubleVec(_upVecTag));
109  }
113  double getUpVec(int i) {return getUpVec()[i];}
119  int setUpVec(int coord, double val, Params* p) {
120 
121  vector<double> vdir = vector<double>(getUpVec());
122  vdir[coord] = val;
123  return SetValueDouble(_upVecTag, "Set up vector", vdir,p);
124  }
130  int setUpVec(const vector<double>&val, Params*p) {
131  return SetValueDouble(_upVecTag, "Set up vector", val,p);
132  }
135  const vector<double> getRotationCenterLocal() {
136  return ( GetValueDoubleVec(_rotCenterTag));
137  }
141  double getRotationCenterLocal(int i) {return getRotationCenterLocal()[i];}
147  int setRotationCenterLocal(int coord, double val, Params* p) {
148  vector<double> vdir(getRotationCenterLocal());
149  vdir[coord] = val;
150  return SetValueDouble(_rotCenterTag, "Set rotation center", vdir,p);
151  }
156  int setRotationCenterLocal(const vector<double>&val, Params* p) {
157  return SetValueDouble(_rotCenterTag, "Set rotation center", val, p);
158  }
161  void alignCenter(Params* p);
162 
163  //Routines that deal with stretched coordinates:
166  void getStretchedRotCtrLocal(double* vec){
167  vector<double> stretch = DataStatus::getStretchFactors();
168  const vector<double> rvec = getRotationCenterLocal();
169  for (int i = 0; i<3; i++) vec[i] = stretch[i]*rvec[i];
170  }
175  int setStretchedRotCtrLocal(const double* vec, Params* p){
176  vector<double> stretch = DataStatus::getStretchFactors();
177  vector<double> rotCtr;
178  for (int i = 0; i<3; i++) rotCtr.push_back(vec[i]/stretch[i]);
179  return setRotationCenterLocal(rotCtr, p);
180  }
183  void getStretchedCamPosLocal(double* vec){
184  vector<double> stretch = DataStatus::getStretchFactors();
185  const vector<double> cpos = getCameraPosLocal();
186  for (int i = 0; i<3; i++) vec[i] = stretch[i]*cpos[i];
187  }
192  int setStretchedCamPosLocal(const double* vec, Params* p){
193  vector<double> stretch = DataStatus::getStretchFactors();
194  vector<double> cpos;
195  for (int i = 0; i<3; i++) cpos.push_back(vec[i]/stretch[i]);
196  return setCameraPosLocal(cpos, p);
197  }
198 
200 #ifndef DOXYGEN_SKIP_THIS
201 
202  static const string _viewpointTag;
203 private:
204 
205  static const string _camPosTag;
206  static const string _viewDirTag;
207  static const string _upVecTag;
208  static const string _rotCenterTag;
209 
210 #endif //DOXYGEN_SKIP_THIS
211 };
212 };
213 
214 #endif //VIEWPOINT_H
215 
const vector< double > getViewDir()
Definition: viewpoint.h:81
int setViewDir(int coord, double val, Params *p)
Definition: viewpoint.h:93
static ParamsBase * CreateDefaultInstance()
Definition: viewpoint.h:51
int setCameraPosLocal(int coord, double val, Params *p)
Definition: viewpoint.h:67
double getViewDir(int i)
Definition: viewpoint.h:87
A pure virtual class for managing parameters used in visualization.
Definition: params.h:129
const vector< double > getRotationCenterLocal()
Definition: viewpoint.h:135
int setViewDir(const vector< double > &val, Params *p)
Definition: viewpoint.h:102
int setRotationCenterLocal(const vector< double > &val, Params *p)
Definition: viewpoint.h:156
void getStretchedRotCtrLocal(double *vec)
Definition: viewpoint.h:166
int setStretchedCamPosLocal(const double *vec, Params *p)
Definition: viewpoint.h:192
int setUpVec(int coord, double val, Params *p)
Definition: viewpoint.h:119
virtual ~Viewpoint()
Destructor.
Definition: viewpoint.h:43
Nodes with state in Xml tree representation.
Definition: ParamsBase.h:90
double getUpVec(int i)
Definition: viewpoint.h:113
const vector< double > getUpVec()
Definition: viewpoint.h:107
void getStretchedCamPosLocal(double *vec)
Definition: viewpoint.h:183
class that indicates location and direction of view
Definition: viewpoint.h:22
int setCameraPosLocal(const vector< double > &val, Params *p)
Definition: viewpoint.h:76
int setUpVec(const vector< double > &val, Params *p)
Definition: viewpoint.h:130
#define PARAMS_API
const vector< double > getCameraPosLocal()
Definition: viewpoint.h:54
Viewpoint()
Constructor, set everything to default view.
Definition: viewpoint.h:26
Definition: DC.h:10
int setRotationCenterLocal(int coord, double val, Params *p)
Definition: viewpoint.h:147
int setStretchedRotCtrLocal(const double *vec, Params *p)
Definition: viewpoint.h:175
double getRotationCenterLocal(int i)
Definition: viewpoint.h:141
static const vector< double > getStretchFactors()
Definition: datastatus.h:241
double getCameraPosLocal(int i)
Definition: viewpoint.h:61