g4tools  5.4.0
Public Member Functions | Protected Attributes | List of all members
tools::sg::viewer Class Reference
Inheritance diagram for tools::sg::viewer:
Inheritance graph
[legend]
Collaboration diagram for tools::sg::viewer:
Collaboration graph
[legend]

Public Member Functions

virtual void * cast (const std::string &a_class) const
 
virtual void set_size (unsigned int a_w, unsigned int a_h)
 
virtual bool set_cursor_shape (cursor_shape)
 
 viewer (std::ostream &a_out, unsigned int a_width, unsigned int a_height)
 
virtual ~viewer ()
 
 viewer (const viewer &a_from)
 
vieweroperator= (const viewer &a_from)
 
bool set_default_cursor_shape ()
 
groupsg ()
 
const groupsg () const
 
unsigned int width () const
 
unsigned int height () const
 
bool screen2aspect (int a_x, int a_y, float &a_wx, float &a_wy) const
 
void set_clear_color (float a_r, float a_g, float a_b, float a_a=1)
 
void set_clear_color (const colorf &a_color)
 
void get_clear_color (float &a_r, float &a_g, float &a_b, float &a_a)
 
const colorfbackground () const
 
std::ostream & out () const
 
const std::string & out_dir () const
 
void set_produce_out_jpeg (bool a_value)
 
bool produce_out_jpeg () const
 
void set_produce_out_png (bool a_value)
 
bool produce_out_png () const
 
void set_produce_out_file (const std::string &a_file)
 
const std::string & produce_out_file () const
 
void set_produce_out_bpp (unsigned int a_bpp)
 
unsigned int produce_out_bpp () const
 

Protected Attributes

std::ostream & m_out
 
colorf m_clear_color
 
unsigned int m_ww
 
unsigned int m_wh
 
group m_sg
 
std::string m_out_dir
 
bool m_use_gsto
 
bool m_produce_out_jpeg
 
bool m_produce_out_png
 
std::string m_produce_out_file
 
unsigned int m_produce_out_bpp
 

Detailed Description

Definition at line 18 of file viewer.

Constructor & Destructor Documentation

◆ viewer() [1/2]

tools::sg::viewer::viewer ( std::ostream &  a_out,
unsigned int  a_width,
unsigned int  a_height 
)
inline

Definition at line 41 of file viewer.

42  :m_out(a_out)
43  ,m_clear_color(1,1,1)
44  ,m_ww(a_width)
45  ,m_wh(a_height)
46  ,m_use_gsto(false)
47  ,m_produce_out_jpeg(false)
48  ,m_produce_out_png(false)
51  {
52 #ifdef TOOLS_MEM
53  mem::increment(s_class().c_str());
54 #endif
55  }

◆ ~viewer()

virtual tools::sg::viewer::~viewer ( )
inlinevirtual

Definition at line 56 of file viewer.

56  {
57  m_sg.clear(); //we must delete node before m_zb_mgr (and any render_manager).
58 #ifdef TOOLS_MEM
59  mem::decrement(s_class().c_str());
60 #endif
61  }

◆ viewer() [2/2]

tools::sg::viewer::viewer ( const viewer a_from)
inline

Definition at line 63 of file viewer.

64  :m_out(a_from.m_out)
65  ,m_clear_color(a_from.m_clear_color)
66  ,m_ww(a_from.m_ww)
67  ,m_wh(a_from.m_wh)
68  ,m_sg(a_from.m_sg)
69  ,m_use_gsto(a_from.m_use_gsto)
70  ,m_produce_out_jpeg(a_from.m_produce_out_jpeg)
71  ,m_produce_out_png(a_from.m_produce_out_png)
72  ,m_produce_out_file(a_from.m_produce_out_file)
73  ,m_produce_out_bpp(a_from.m_produce_out_bpp)
74  {
75 #ifdef TOOLS_MEM
76  mem::increment(s_class().c_str());
77 #endif
78  }

Member Function Documentation

◆ background()

const colorf& tools::sg::viewer::background ( ) const
inline

Definition at line 125 of file viewer.

125 {return m_clear_color;}

◆ cast()

virtual void* tools::sg::viewer::cast ( const std::string &  a_class) const
inlinevirtual

Definition at line 21 of file viewer.

21  {
22  if(void* p = cmp_cast<viewer>(this,a_class)) {return p;}
23  else return 0;
24  }

◆ get_clear_color()

void tools::sg::viewer::get_clear_color ( float &  a_r,
float &  a_g,
float &  a_b,
float &  a_a 
)
inline

Definition at line 118 of file viewer.

118  {
119  a_r = m_clear_color.r();
120  a_g = m_clear_color.g();
121  a_b = m_clear_color.b();
122  a_a = m_clear_color.a();
123  }

◆ height()

unsigned int tools::sg::viewer::height ( ) const
inline

Definition at line 98 of file viewer.

98 {return m_wh;}

◆ operator=()

viewer& tools::sg::viewer::operator= ( const viewer a_from)
inline

Definition at line 79 of file viewer.

79  {
80  m_clear_color = a_from.m_clear_color;
81  m_ww = a_from.m_ww;
82  m_wh = a_from.m_wh;
83  m_sg = a_from.m_sg;
84  m_use_gsto = a_from.m_use_gsto;
85  m_produce_out_jpeg = a_from.m_produce_out_jpeg;
86  m_produce_out_png = a_from.m_produce_out_png;
87  m_produce_out_file = a_from.m_produce_out_file;
88  m_produce_out_bpp = a_from.m_produce_out_bpp;
89  return *this;
90  }

◆ out()

std::ostream& tools::sg::viewer::out ( ) const
inline

Definition at line 127 of file viewer.

127 {return m_out;}

◆ out_dir()

const std::string& tools::sg::viewer::out_dir ( ) const
inline

Definition at line 129 of file viewer.

129 {return m_out_dir;}

◆ produce_out_bpp()

unsigned int tools::sg::viewer::produce_out_bpp ( ) const
inline

Definition at line 142 of file viewer.

142 {return m_produce_out_bpp;}

◆ produce_out_file()

const std::string& tools::sg::viewer::produce_out_file ( ) const
inline

Definition at line 139 of file viewer.

139 {return m_produce_out_file;}

◆ produce_out_jpeg()

bool tools::sg::viewer::produce_out_jpeg ( ) const
inline

Definition at line 133 of file viewer.

133 {return m_produce_out_jpeg;}

◆ produce_out_png()

bool tools::sg::viewer::produce_out_png ( ) const
inline

Definition at line 136 of file viewer.

136 {return m_produce_out_png;}

◆ screen2aspect()

bool tools::sg::viewer::screen2aspect ( int  a_x,
int  a_y,
float &  a_wx,
float &  a_wy 
) const
inline

Definition at line 100 of file viewer.

100  {
101  // convert screen point in [aspect,1] coordinates.
102  //if(!m_ww) {a_wx = a_wy = 0;return false;}
103  //if(!m_wh) {a_wx = a_wy = 0;return false;}
104  float aspect = float(m_ww)/float(m_wh);
105  float wch = 1;
106  float wcw = wch*aspect;
107  a_wx = float(a_x) * wcw/float(m_ww);
108  a_wy = float(a_y) * wch/float(m_wh);
109  return true;
110  }

◆ set_clear_color() [1/2]

void tools::sg::viewer::set_clear_color ( const colorf a_color)
inline

Definition at line 115 of file viewer.

115  {
116  m_clear_color = a_color;
117  }

◆ set_clear_color() [2/2]

void tools::sg::viewer::set_clear_color ( float  a_r,
float  a_g,
float  a_b,
float  a_a = 1 
)
inline

Definition at line 112 of file viewer.

112  {
113  m_clear_color = colorf(a_r,a_g,a_b,a_a);
114  }

◆ set_cursor_shape()

virtual bool tools::sg::viewer::set_cursor_shape ( cursor_shape  )
inlinevirtual

Definition at line 39 of file viewer.

39 {return false;}

◆ set_default_cursor_shape()

bool tools::sg::viewer::set_default_cursor_shape ( )
inline

Definition at line 92 of file viewer.

◆ set_produce_out_bpp()

void tools::sg::viewer::set_produce_out_bpp ( unsigned int  a_bpp)
inline

Definition at line 141 of file viewer.

141 {m_produce_out_bpp = a_bpp;}

◆ set_produce_out_file()

void tools::sg::viewer::set_produce_out_file ( const std::string &  a_file)
inline

Definition at line 138 of file viewer.

138 {m_produce_out_file = a_file;}

◆ set_produce_out_jpeg()

void tools::sg::viewer::set_produce_out_jpeg ( bool  a_value)
inline

Definition at line 132 of file viewer.

132 {m_produce_out_jpeg = a_value;}

◆ set_produce_out_png()

void tools::sg::viewer::set_produce_out_png ( bool  a_value)
inline

Definition at line 135 of file viewer.

135 {m_produce_out_png = a_value;}

◆ set_size()

virtual void tools::sg::viewer::set_size ( unsigned int  a_w,
unsigned int  a_h 
)
inlinevirtual

Reimplemented in tools::sg::plots_viewer.

Definition at line 26 of file viewer.

26  {
27  //m_out << "debug : tools::sg::viewer::set_size :"
28  // << " ww " << a_w
29  // << " wh " << a_h
30  // << std::endl;
31  size_event e(m_ww,m_wh,a_w,a_h);
32  m_ww = a_w;
33  m_wh = a_h;
34  event_action action(m_out,m_ww,m_wh,e);
35  action.set_do_switch_children(true); //Android : rot device : GUI & scene.
36  m_sg.event(action); //used by m_plots in plots_viewer.
37  }

◆ sg() [1/2]

group& tools::sg::viewer::sg ( )
inline

Definition at line 94 of file viewer.

94 {return m_sg;}

◆ sg() [2/2]

const group& tools::sg::viewer::sg ( ) const
inline

Definition at line 95 of file viewer.

95 {return m_sg;}

◆ width()

unsigned int tools::sg::viewer::width ( ) const
inline

Definition at line 97 of file viewer.

97 {return m_ww;}

Member Data Documentation

◆ m_clear_color

colorf tools::sg::viewer::m_clear_color
protected

Definition at line 170 of file viewer.

◆ m_out

std::ostream& tools::sg::viewer::m_out
protected

Definition at line 169 of file viewer.

◆ m_out_dir

std::string tools::sg::viewer::m_out_dir
protected

Definition at line 174 of file viewer.

◆ m_produce_out_bpp

unsigned int tools::sg::viewer::m_produce_out_bpp
protected

Definition at line 179 of file viewer.

◆ m_produce_out_file

std::string tools::sg::viewer::m_produce_out_file
protected

Definition at line 178 of file viewer.

◆ m_produce_out_jpeg

bool tools::sg::viewer::m_produce_out_jpeg
protected

Definition at line 176 of file viewer.

◆ m_produce_out_png

bool tools::sg::viewer::m_produce_out_png
protected

Definition at line 177 of file viewer.

◆ m_sg

group tools::sg::viewer::m_sg
protected

Definition at line 173 of file viewer.

◆ m_use_gsto

bool tools::sg::viewer::m_use_gsto
protected

Definition at line 175 of file viewer.

◆ m_wh

unsigned int tools::sg::viewer::m_wh
protected

Definition at line 172 of file viewer.

◆ m_ww

unsigned int tools::sg::viewer::m_ww
protected

Definition at line 171 of file viewer.


The documentation for this class was generated from the following file:
tools::sg::viewer::m_wh
unsigned int m_wh
Definition: viewer:172
tools::sg::viewer::m_ww
unsigned int m_ww
Definition: viewer:171
tools::sg::viewer::m_produce_out_png
bool m_produce_out_png
Definition: viewer:177
tools::sg::group::event
virtual void event(event_action &a_action)
Definition: group:45
tools::sg::viewer::m_produce_out_bpp
unsigned int m_produce_out_bpp
Definition: viewer:179
tools::sg::viewer::m_out_dir
std::string m_out_dir
Definition: viewer:174
tools::sg::viewer::m_use_gsto
bool m_use_gsto
Definition: viewer:175
tools::sg::viewer::m_produce_out_file
std::string m_produce_out_file
Definition: viewer:178
tools::colorf::g
float g() const
Definition: colorf:33
tools::sg::viewer::m_sg
group m_sg
Definition: viewer:173
tools::colorf::a
float a() const
Definition: colorf:35
tools::sg::cursor_default
@ cursor_default
Definition: cursor_shape:11
tools::sg::viewer::m_out
std::ostream & m_out
Definition: viewer:169
tools::sg::viewer::m_produce_out_jpeg
bool m_produce_out_jpeg
Definition: viewer:176
tools::sg::viewer::set_cursor_shape
virtual bool set_cursor_shape(cursor_shape)
Definition: viewer:39
tools::sg::group::clear
void clear()
Definition: group:235
tools::colorf::r
float r() const
Definition: colorf:32
tools::sg::viewer::m_clear_color
colorf m_clear_color
Definition: viewer:170
tools::colorf::b
float b() const
Definition: colorf:34