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

Public Member Functions

 sg_viewer (session &a_session, int a_x=0, int a_y=0, unsigned int a_width=500, unsigned int a_height=500, const std::string &a_win_title="")
 
virtual ~sg_viewer ()
 
 sg_viewer (const sg_viewer &a_from)
 
sg_vieweroperator= (const sg_viewer &a_from)
 
bool has_window () const
 
Window window () const
 
bool show ()
 
void win_render ()
 
void set_device_interactor (tools::sg::device_interactor *)
 
- Public Member Functions inherited from tools::sg::GL_viewer
void render ()
 
 GL_viewer (std::ostream &a_out, unsigned int a_width, unsigned int a_height)
 
virtual ~GL_viewer ()
 
 GL_viewer (const GL_viewer &a_from)
 
GL_vieweroperator= (const GL_viewer &a_from)
 
- Public Member Functions inherited from tools::sg::viewer
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

sessionm_session
 
Window m_win
 
- Protected Attributes inherited from tools::sg::GL_viewer
GL_manager m_gl_mgr
 
- Protected Attributes inherited from tools::sg::viewer
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 20 of file sg_viewer.

Constructor & Destructor Documentation

◆ sg_viewer() [1/2]

tools::X11::sg_viewer::sg_viewer ( session a_session,
int  a_x = 0,
int  a_y = 0,
unsigned int  a_width = 500,
unsigned int  a_height = 500,
const std::string &  a_win_title = "" 
)
inline

Definition at line 48 of file sg_viewer.

52  :parent(a_session.out(),a_width,a_height)
53  ,m_session(a_session)
54  ,m_win(0)
55  {
56  if(!m_session.display()) return; //throw
57  m_win = m_session.create_window(a_win_title.c_str(),a_x,a_y,a_width,a_height);
58  if(!m_win) return; //throw
59  m_session.add_dispatcher(new dispatcher(*this));
60  }

◆ ~sg_viewer()

virtual tools::X11::sg_viewer::~sg_viewer ( )
inlinevirtual

Definition at line 61 of file sg_viewer.

61  {
62  if(m_win) {
65  m_session.sync();
66  }
67  }

◆ sg_viewer() [2/2]

tools::X11::sg_viewer::sg_viewer ( const sg_viewer a_from)
inline

Definition at line 69 of file sg_viewer.

70  :parent(a_from)
71  ,m_session(a_from.m_session)
72  ,m_win(a_from.m_win)
73  {}

Member Function Documentation

◆ has_window()

bool tools::X11::sg_viewer::has_window ( ) const
inline

Definition at line 80 of file sg_viewer.

80 {return m_win?true:false;} //for SWIG

◆ operator=()

sg_viewer& tools::X11::sg_viewer::operator= ( const sg_viewer a_from)
inline

Definition at line 74 of file sg_viewer.

74  {
75  parent::operator=(a_from);
76  m_win = a_from.m_win;
77  return *this;
78  }

◆ set_device_interactor()

void tools::X11::sg_viewer::set_device_interactor ( tools::sg::device_interactor )
inline

Definition at line 104 of file sg_viewer.

104 {}

◆ show()

bool tools::X11::sg_viewer::show ( )
inline

Definition at line 84 of file sg_viewer.

84  {
85  if(!m_win) return false;
87  return true;
88  }

◆ win_render()

void tools::X11::sg_viewer::win_render ( )
inline

Definition at line 90 of file sg_viewer.

90  {
91  if(!m_win) return;
92  if(::glXMakeCurrent(m_session.display(),m_win,m_session.context())==False){
93  m_session.out() << "tools::X11::sg_viewer::win_render : glXMakeCurrent failed." << std::endl;
94  return;
95  }
96  render(); //viewer::render()
97  ::glXSwapBuffers(m_session.display(),m_win);
98  if(::glXMakeCurrent(m_session.display(),None,NULL)==False){
99  m_session.out() << "tools::X11::sg_viewer::win_render : glXMakeCurrent(None,NULL) failed." << std::endl;
100  }
101  }

◆ window()

Window tools::X11::sg_viewer::window ( ) const
inline

Definition at line 82 of file sg_viewer.

82 {return m_win;}

Member Data Documentation

◆ m_session

session& tools::X11::sg_viewer::m_session
protected

Definition at line 106 of file sg_viewer.

◆ m_win

Window tools::X11::sg_viewer::m_win
protected

Definition at line 107 of file sg_viewer.


The documentation for this class was generated from the following file:
tools::X11::session::create_window
Window create_window(const char *a_title, int a_x, int a_y, unsigned int a_width, unsigned int a_height)
Definition: session:160
tools::X11::base_session::out
std::ostream & out() const
Definition: base_session:92
tools::X11::base_session::delete_window
void delete_window(Window a_window) const
Definition: base_session:242
tools::X11::session::context
GLXContext context() const
Definition: session:158
tools::sg::GL_viewer::operator=
GL_viewer & operator=(const GL_viewer &a_from)
Definition: GL_viewer:58
tools::X11::sg_viewer::m_win
Window m_win
Definition: sg_viewer:107
tools::X11::base_session::remove_dispatchers_with_window
void remove_dispatchers_with_window(Window a_win)
Definition: base_session:323
tools::X11::base_session::show_window
void show_window(Window a_window) const
Definition: base_session:207
tools::X11::base_session::sync
bool sync()
Definition: base_session:116
tools::X11::base_session::display
Display * display() const
Definition: base_session:99
tools::X11::base_session::add_dispatcher
void add_dispatcher(dispatcher *a_dispatcher)
Definition: base_session:313
tools::sg::GL_viewer::render
void render()
Definition: GL_viewer:18
tools::X11::sg_viewer::m_session
session & m_session
Definition: sg_viewer:106