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