Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_sg_gl2ps_manager 4 #ifndef tools_sg_gl2ps_manager 5 #define tools_sg_gl2ps_manager 5 #define tools_sg_gl2ps_manager 6 6 7 #include "render_manager" 7 #include "render_manager" 8 8 9 #include <map> 9 #include <map> 10 10 11 namespace tools { 11 namespace tools { 12 namespace sg { 12 namespace sg { 13 13 14 class gl2ps_manager : public virtual render_ma 14 class gl2ps_manager : public virtual render_manager { 15 typedef render_manager parent; 15 typedef render_manager parent; 16 public: 16 public: 17 TOOLS_SCLASS(tools::sg::gl2ps_manager) 17 TOOLS_SCLASS(tools::sg::gl2ps_manager) 18 virtual void* cast(const std::string& a_clas 18 virtual void* cast(const std::string& a_class) const { 19 if(void* p = cmp_cast<gl2ps_manager>(this, 19 if(void* p = cmp_cast<gl2ps_manager>(this,a_class)) {return p;} 20 else return 0; 20 else return 0; 21 } 21 } 22 public: 22 public: 23 virtual bool begin_render(int,int,unsigned i 23 virtual bool begin_render(int,int,unsigned int,unsigned int,float,float,float,float,bool = true) {return true;} 24 virtual void end_render() {} 24 virtual void end_render() {} 25 25 26 virtual unsigned int create_texture(const im 26 virtual unsigned int create_texture(const img_byte& a_img,bool /*a_NEAREST*/) { 27 m_gen_id++; //never return 0. 27 m_gen_id++; //never return 0. 28 m_gstos[m_gen_id] = a_img; 28 m_gstos[m_gen_id] = a_img; 29 return m_gen_id; 29 return m_gen_id; 30 } 30 } 31 31 32 virtual unsigned int create_gsto_from_data(s 32 virtual unsigned int create_gsto_from_data(size_t,const float*) {return 0;} 33 33 34 virtual bool is_gsto_id_valid(unsigned int a 34 virtual bool is_gsto_id_valid(unsigned int a_id) const { 35 gstos_t::const_iterator it = m_gstos.find( 35 gstos_t::const_iterator it = m_gstos.find(a_id); 36 if(it==m_gstos.end()) return false; 36 if(it==m_gstos.end()) return false; 37 return true; 37 return true; 38 } 38 } 39 virtual void delete_gsto(unsigned int a_id) 39 virtual void delete_gsto(unsigned int a_id) { 40 gstos_t::iterator it = m_gstos.find(a_id); 40 gstos_t::iterator it = m_gstos.find(a_id); 41 if(it!=m_gstos.end()) m_gstos.erase(it); 41 if(it!=m_gstos.end()) m_gstos.erase(it); 42 } 42 } 43 43 44 virtual gsto_mode get_gsto_mode() const {ret 44 virtual gsto_mode get_gsto_mode() const {return gsto_memory;} 45 virtual void set_gsto_mode(gsto_mode) {} 45 virtual void set_gsto_mode(gsto_mode) {} 46 virtual void available_gsto_modes(std::vecto 46 virtual void available_gsto_modes(std::vector<std::string>& a_v) {a_v.clear();} 47 virtual void available_not_memory_gsto_mode( 47 virtual void available_not_memory_gsto_mode(std::string& a_s) const {a_s.clear();} 48 virtual size_t used_texture_memory() const { 48 virtual size_t used_texture_memory() const {return 0;} 49 virtual size_t gstos_size() const {return 0; 49 virtual size_t gstos_size() const {return 0;} 50 public: 50 public: 51 gl2ps_manager():m_gen_id(0){ 51 gl2ps_manager():m_gen_id(0){ 52 #ifdef TOOLS_MEM 52 #ifdef TOOLS_MEM 53 mem::increment(s_class().c_str()); 53 mem::increment(s_class().c_str()); 54 #endif 54 #endif 55 } 55 } 56 virtual ~gl2ps_manager(){ 56 virtual ~gl2ps_manager(){ 57 m_gstos.clear(); 57 m_gstos.clear(); 58 #ifdef TOOLS_MEM 58 #ifdef TOOLS_MEM 59 mem::decrement(s_class().c_str()); 59 mem::decrement(s_class().c_str()); 60 #endif 60 #endif 61 } 61 } 62 public: 62 public: 63 gl2ps_manager(const gl2ps_manager& a_from) 63 gl2ps_manager(const gl2ps_manager& a_from) 64 :parent(a_from) 64 :parent(a_from) 65 ,m_gen_id(0) 65 ,m_gen_id(0) 66 ,m_gstos() 66 ,m_gstos() 67 { 67 { 68 #ifdef TOOLS_MEM 68 #ifdef TOOLS_MEM 69 mem::increment(s_class().c_str()); 69 mem::increment(s_class().c_str()); 70 #endif 70 #endif 71 } 71 } 72 gl2ps_manager& operator=(const gl2ps_manager 72 gl2ps_manager& operator=(const gl2ps_manager& a_from){ 73 if(&a_from==this) return *this; 73 if(&a_from==this) return *this; 74 m_gen_id = 0; 74 m_gen_id = 0; 75 m_gstos.clear(); 75 m_gstos.clear(); 76 return *this; 76 return *this; 77 } 77 } 78 public: 78 public: 79 bool find(unsigned int a_id,img_byte& a_img) 79 bool find(unsigned int a_id,img_byte& a_img) { 80 gstos_t::iterator it = m_gstos.find(a_id); 80 gstos_t::iterator it = m_gstos.find(a_id); 81 if(it==m_gstos.end()) return false; 81 if(it==m_gstos.end()) return false; 82 a_img = (*it).second; 82 a_img = (*it).second; 83 return true; 83 return true; 84 } 84 } 85 //void cleanup() {} 85 //void cleanup() {} 86 void delete_gstos() {m_gstos.clear();} 86 void delete_gstos() {m_gstos.clear();} 87 protected: 87 protected: 88 unsigned int m_gen_id; 88 unsigned int m_gen_id; 89 typedef std::map<unsigned int,img_byte> gsto 89 typedef std::map<unsigned int,img_byte> gstos_t; 90 gstos_t m_gstos; //only textures for the mom 90 gstos_t m_gstos; //only textures for the moment. 91 }; 91 }; 92 92 93 }} 93 }} 94 94 95 #endif 95 #endif