Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/ortho is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_sg_ortho
0005 #define tools_sg_ortho
0006 
0007 #include "base_camera"
0008 
0009 namespace tools {
0010 namespace sg {
0011 
0012 class ortho : public base_camera {
0013   TOOLS_NODE(ortho,tools::sg::ortho,base_camera)
0014 public:
0015   virtual float near_height() const {return height.value();}
0016   virtual void zoom(float a_fac) {
0017     //for exa :
0018     //  a_fac = 0.99f is a zoom in
0019     //  a_fac = 1.01f is a zoom out
0020     height.value(height.value()*a_fac);
0021   }
0022   virtual camera_type type() const {return camera_ortho;}
0023 public:
0024   sf<float> height;
0025 public:
0026   virtual const desc_fields& node_desc_fields() const {
0027     TOOLS_FIELD_DESC_NODE_CLASS(tools::sg::ortho)
0028     static const desc_fields s_v(parent::node_desc_fields(),1, //WARNING : take care of count.
0029       TOOLS_ARG_FIELD_DESC(height)
0030     );
0031     return s_v;
0032   }
0033 private:
0034   void add_fields(){
0035     add_field(&height);
0036   }
0037 public:
0038   ortho()
0039   :parent()
0040   ,height(2)
0041   {
0042     add_fields();
0043   }
0044   virtual ~ortho(){
0045   }
0046 public:
0047   ortho(const ortho& a_from)
0048   :parent(a_from)
0049   ,height(a_from.height)
0050   {
0051     add_fields();
0052   }
0053   ortho& operator=(const ortho& a_from){
0054     parent::operator=(a_from);
0055     height = a_from.height;
0056     return *this;
0057   }
0058 public: //operators:
0059   bool operator==(const ortho& a_from) const{
0060     if(!parent::operator==(a_from)) return false;
0061     if(height!=a_from.height) return false;
0062     return true;
0063   }
0064   bool operator!=(const ortho& a_from) const {
0065     return !operator==(a_from);
0066   }
0067 public:
0068   void dump(std::ostream& a_out) {
0069     parent::dump(a_out);
0070     a_out << " height " << height.value() << std::endl;
0071   }
0072 protected:
0073   virtual void get_lrbt(unsigned int a_ww,unsigned int a_wh,
0074                         float& a_l,float& a_r,float& a_b,float& a_t) {
0075     float aspect = float(a_ww)/float(a_wh);
0076     float hh = height.value()*0.5f;
0077     a_l = -aspect*hh;
0078     a_r = aspect*hh;
0079     a_b = -hh;
0080     a_t = hh;
0081   }
0082 };
0083 
0084 inline ortho* cast_ortho(base_camera& a_bcam) {return safe_cast<base_camera,ortho>(a_bcam);}
0085 
0086 }}
0087 
0088 #endif