Warning, /include/Geant4/tools/sg/zb_manager 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_zb_manager
0005 #define tools_sg_zb_manager
0006
0007 #include "render_manager"
0008
0009 #include <map>
0010
0011 namespace tools {
0012 namespace sg {
0013
0014 class zb_manager : public virtual render_manager {
0015 typedef render_manager parent;
0016 public:
0017 TOOLS_SCLASS(tools::sg::zb_manager)
0018 virtual void* cast(const std::string& a_class) const {
0019 if(void* p = cmp_cast<zb_manager>(this,a_class)) {return p;}
0020 else return 0;
0021 }
0022 public:
0023 virtual bool begin_render(int,int,unsigned int,unsigned int,float,float,float,float,bool = true) {return true;}
0024 virtual void end_render() {}
0025
0026 virtual unsigned int create_texture(const img_byte& a_img,bool /*a_NEAREST*/) {
0027 m_gen_id++; //never return 0.
0028 m_gstos[m_gen_id] = a_img;
0029 return m_gen_id;
0030 }
0031
0032 virtual unsigned int create_gsto_from_data(size_t,const float*) {return 0;}
0033
0034 virtual bool is_gsto_id_valid(unsigned int a_id) const {
0035 gstos_t::const_iterator it = m_gstos.find(a_id);
0036 if(it==m_gstos.end()) return false;
0037 return true;
0038 }
0039 virtual void delete_gsto(unsigned int a_id) {
0040 gstos_t::iterator it = m_gstos.find(a_id);
0041 if(it!=m_gstos.end()) m_gstos.erase(it);
0042 }
0043
0044 //
0045 virtual gsto_mode get_gsto_mode() const {return gsto_memory;}
0046 virtual void set_gsto_mode(gsto_mode) {}
0047 virtual void available_gsto_modes(std::vector<std::string>& a_v) {a_v.clear();}
0048 virtual void available_not_memory_gsto_mode(std::string& a_s) const {a_s.clear();}
0049 virtual size_t used_texture_memory() const {return 0;}
0050 virtual size_t gstos_size() const {return 0;}
0051 public:
0052 zb_manager():m_gen_id(0){
0053 }
0054 virtual ~zb_manager(){
0055 m_gstos.clear();
0056 }
0057 public:
0058 zb_manager(const zb_manager& a_from)
0059 :parent(a_from)
0060 ,m_gen_id(0)
0061 ,m_gstos()
0062 {
0063 }
0064 zb_manager& operator=(const zb_manager& a_from){
0065 if(&a_from==this) return *this;
0066 m_gen_id = 0;
0067 m_gstos.clear();
0068 return *this;
0069 }
0070 public:
0071 bool find(unsigned int a_id,img_byte& a_img) {
0072 gstos_t::iterator it = m_gstos.find(a_id);
0073 if(it==m_gstos.end()) return false;
0074 a_img = (*it).second;
0075 return true;
0076 }
0077 void delete_gstos() {m_gstos.clear();}
0078 protected:
0079 unsigned int m_gen_id;
0080 typedef std::map<unsigned int,img_byte> gstos_t;
0081 gstos_t m_gstos; //only textures for the moment.
0082 };
0083
0084 }}
0085
0086 #endif