Warning, /include/Geant4/toolx/Windows/sg_viewer 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 toolx_Windows_sg_viewer
0005 #define toolx_Windows_sg_viewer
0006
0007 #include "session"
0008 #include "window"
0009 #include "glarea"
0010
0011 #include "../sg/GL_viewer"
0012
0013 // disable the warning about the usage of "this" in the constructor.
0014 #pragma warning(disable:4355)
0015
0016 namespace toolx {
0017 namespace Windows {
0018
0019 class sg_viewer : public window, public sg::GL_viewer {
0020 typedef window parent_window;
0021 typedef sg::GL_viewer parent_viewer;
0022 public:
0023 virtual void close() {}
0024 public:
0025 sg_viewer(session& a_session,
0026 int a_x = 0,int a_y = 0,
0027 unsigned int a_width = 500,unsigned int a_height = 500,
0028 const std::string& a_title = "")
0029 :parent_window(a_title.c_str(),a_x,a_y,a_width,a_height)
0030 ,parent_viewer(a_session.out(),a_width,a_height)
0031 ,m_session(a_session)
0032 ,m_glarea(m_hwnd,*this)
0033 {
0034 parent_window::set_focus_hwnd(m_glarea.hwnd());
0035 }
0036 virtual ~sg_viewer() {}
0037 protected:
0038 sg_viewer(const sg_viewer& a_from)
0039 :parent_window(a_from)
0040 ,parent_viewer(a_from)
0041 ,m_session(a_from.m_session)
0042 ,m_glarea(a_from.m_glarea)
0043 {}
0044 sg_viewer& operator=(const sg_viewer& a_from){
0045 parent_window::operator=(a_from);
0046 return *this;
0047 }
0048 public:
0049 bool has_window() const {return m_hwnd?true:false;} //for SWIG
0050
0051 HWND window() const {return m_hwnd;}
0052
0053 bool show() {
0054 if(!m_hwnd) return false;
0055 m_session.show_window(m_hwnd);
0056 return true;
0057 }
0058
0059 void win_render() {m_glarea.wm_paint();}
0060
0061
0062 public:
0063 void set_device_interactor(tools::sg::device_interactor* a_interactor) { //we do not have ownership.
0064 m_glarea.set_device_interactor(a_interactor);
0065 }
0066 protected:
0067 class _glarea : public glarea {
0068 public:
0069 virtual void paint(unsigned int a_w,unsigned int a_h) {
0070 m_viewer.set_size(a_w,a_h);
0071 m_viewer.render();
0072 }
0073 public:
0074 _glarea(HWND a_parent,parent_viewer& a_viewer)
0075 :glarea(a_parent)
0076 ,m_viewer(a_viewer)
0077 {}
0078 protected:
0079 parent_viewer& m_viewer;
0080 };
0081
0082 protected:
0083 session& m_session;
0084 _glarea m_glarea;
0085 };
0086
0087 }}
0088
0089
0090 #endif