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 #ifdef TOOLS_MEM
0043 mem::increment(s_class().c_str());
0044 #endif
0045 add_fields();
0046 }
0047 virtual ~ortho(){
0048 #ifdef TOOLS_MEM
0049 mem::decrement(s_class().c_str());
0050 #endif
0051 }
0052 public:
0053 ortho(const ortho& a_from)
0054 :parent(a_from)
0055 ,height(a_from.height)
0056 {
0057 #ifdef TOOLS_MEM
0058 mem::increment(s_class().c_str());
0059 #endif
0060 add_fields();
0061 }
0062 ortho& operator=(const ortho& a_from){
0063 parent::operator=(a_from);
0064 height = a_from.height;
0065 return *this;
0066 }
0067 public: //operators:
0068 bool operator==(const ortho& a_from) const{
0069 if(!parent::operator==(a_from)) return false;
0070 if(height!=a_from.height) return false;
0071 return true;
0072 }
0073 bool operator!=(const ortho& a_from) const {
0074 return !operator==(a_from);
0075 }
0076 public:
0077 void dump(std::ostream& a_out) {
0078 parent::dump(a_out);
0079 a_out << " height " << height.value() << std::endl;
0080 }
0081 protected:
0082 virtual void get_lrbt(unsigned int a_ww,unsigned int a_wh,
0083 float& a_l,float& a_r,float& a_b,float& a_t) {
0084 float aspect = float(a_ww)/float(a_wh);
0085 //landscape : float aspect = float(a_action.wh())/float(a_action.ww());
0086 float hh = height.value()*0.5f;
0087 a_l = -aspect*hh;
0088 a_r = aspect*hh;
0089 a_b = -hh;
0090 a_t = hh;
0091 }
0092 };
0093
0094 inline ortho* cast_ortho(base_camera& a_bcam) {return safe_cast<base_camera,ortho>(a_bcam);}
0095
0096 }}
0097
0098 #endif