g4tools  5.4.0
ortho
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_sg_ortho
5 #define tools_sg_ortho
6 
7 #include "base_camera"
8 
9 namespace tools {
10 namespace sg {
11 
12 class ortho : public base_camera {
14 public:
15  virtual float near_height() const {return height.value();}
16  virtual void zoom(float a_fac) {
17  //for exa :
18  // a_fac = 0.99f is a zoom in
19  // a_fac = 1.01f is a zoom out
20  height.value(height.value()*a_fac);
21  }
22  virtual camera_type type() const {return camera_ortho;}
23 public:
25 public:
26  virtual const desc_fields& node_desc_fields() const {
28  static const desc_fields s_v(parent::node_desc_fields(),1, //WARNING : take care of count.
30  );
31  return s_v;
32  }
33 private:
34  void add_fields(){
35  add_field(&height);
36  }
37 public:
39  :parent()
40  ,height(2)
41  {
42 #ifdef TOOLS_MEM
43  mem::increment(s_class().c_str());
44 #endif
45  add_fields();
46  }
47  virtual ~ortho(){
48 #ifdef TOOLS_MEM
49  mem::decrement(s_class().c_str());
50 #endif
51  }
52 public:
53  ortho(const ortho& a_from)
54  :parent(a_from)
55  ,height(a_from.height)
56  {
57 #ifdef TOOLS_MEM
58  mem::increment(s_class().c_str());
59 #endif
60  add_fields();
61  }
62  ortho& operator=(const ortho& a_from){
63  parent::operator=(a_from);
64  height = a_from.height;
65  return *this;
66  }
67 public: //operators:
68  bool operator==(const ortho& a_from) const{
69  if(!parent::operator==(a_from)) return false;
70  if(height!=a_from.height) return false;
71  return true;
72  }
73  bool operator!=(const ortho& a_from) const {
74  return !operator==(a_from);
75  }
76 public:
77  void dump(std::ostream& a_out) {
78  parent::dump(a_out);
79  a_out << " height " << height.value() << std::endl;
80  }
81 protected:
82  virtual void get_lrbt(unsigned int a_ww,unsigned int a_wh,
83  float& a_l,float& a_r,float& a_b,float& a_t) {
84  float aspect = float(a_ww)/float(a_wh);
85  //landscape : float aspect = float(a_action.wh())/float(a_action.ww());
86  float hh = height.value()*0.5f;
87  a_l = -aspect*hh;
88  a_r = aspect*hh;
89  a_b = -hh;
90  a_t = hh;
91  }
92 };
93 
94 inline ortho* cast_ortho(base_camera& a_bcam) {return safe_cast<base_camera,ortho>(a_bcam);}
95 
96 }}
97 
98 #endif
tools::sg::ortho::ortho
ortho(const ortho &a_from)
Definition: ortho:53
tools::sg::ortho::near_height
virtual float near_height() const
Definition: ortho:15
tools::sg::camera_type
camera_type
Definition: enums:167
tools::sg::ortho::height
sf< float > height
Definition: ortho:24
TOOLS_NODE
#define TOOLS_NODE(a__class, a__sclass, a__parent)
Definition: node:324
tools::sg::ortho::operator!=
bool operator!=(const ortho &a_from) const
Definition: ortho:73
tools::sg::desc_fields
Definition: field_desc:148
tools::dump
void dump(std::ostream &a_out, const tools::array< T > &a_array, const std::string &a_title)
Definition: array:519
tools::sg::ortho
Definition: ortho:12
tools::sg::cast_ortho
ortho * cast_ortho(base_camera &a_bcam)
Definition: ortho:94
tools::sg::ortho::operator==
bool operator==(const ortho &a_from) const
Definition: ortho:68
tools::sg::ortho::zoom
virtual void zoom(float a_fac)
Definition: ortho:16
tools::sg::ortho::ortho
ortho()
Definition: ortho:38
tools::sg::ortho::dump
void dump(std::ostream &a_out)
Definition: ortho:77
tools::sg::camera_ortho
@ camera_ortho
Definition: enums:168
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::sg::node::add_field
void add_field(field *a_field)
Definition: node:128
TOOLS_FIELD_DESC_NODE_CLASS
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
Definition: field:68
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::sg::base_camera
Definition: base_camera:24
tools::sg::ortho::~ortho
virtual ~ortho()
Definition: ortho:47
tools::sg::ortho::node_desc_fields
virtual const desc_fields & node_desc_fields() const
Definition: ortho:26
tools::sg::sf< float >
tools::sg::ortho::operator=
ortho & operator=(const ortho &a_from)
Definition: ortho:62
base_camera
TOOLS_ARG_FIELD_DESC
#define TOOLS_ARG_FIELD_DESC(a__field)
Definition: field:71
tools::sg::ortho::get_lrbt
virtual void get_lrbt(unsigned int a_ww, unsigned int a_wh, float &a_l, float &a_r, float &a_b, float &a_t)
Definition: ortho:82
tools::sg::ortho::type
virtual camera_type type() const
Definition: ortho:22