Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef toolx_Windows_sg_viewer 4 #ifndef toolx_Windows_sg_viewer 5 #define toolx_Windows_sg_viewer 5 #define toolx_Windows_sg_viewer 6 6 7 #include "session" 7 #include "session" 8 #include "window" 8 #include "window" 9 #include "glarea" 9 #include "glarea" 10 10 11 #include "../sg/GL_viewer" 11 #include "../sg/GL_viewer" 12 12 13 // disable the warning about the usage of "thi 13 // disable the warning about the usage of "this" in the constructor. 14 #pragma warning(disable:4355) 14 #pragma warning(disable:4355) 15 15 16 namespace toolx { 16 namespace toolx { 17 namespace Windows { 17 namespace Windows { 18 18 19 class sg_viewer : public window, public sg::GL 19 class sg_viewer : public window, public sg::GL_viewer { 20 typedef window parent_window; 20 typedef window parent_window; 21 typedef sg::GL_viewer parent_viewer; 21 typedef sg::GL_viewer parent_viewer; 22 public: 22 public: 23 virtual void close() {} 23 virtual void close() {} 24 public: 24 public: 25 sg_viewer(session& a_session, 25 sg_viewer(session& a_session, 26 int a_x = 0,int a_y = 0, 26 int a_x = 0,int a_y = 0, 27 unsigned int a_width = 500,unsigne 27 unsigned int a_width = 500,unsigned int a_height = 500, 28 const std::string& a_title = "") 28 const std::string& a_title = "") 29 :parent_window(a_title.c_str(),a_x,a_y,a_wid 29 :parent_window(a_title.c_str(),a_x,a_y,a_width,a_height) 30 ,parent_viewer(a_session.out(),a_width,a_hei 30 ,parent_viewer(a_session.out(),a_width,a_height) 31 ,m_session(a_session) 31 ,m_session(a_session) 32 ,m_glarea(m_hwnd,*this) 32 ,m_glarea(m_hwnd,*this) 33 { 33 { 34 parent_window::set_focus_hwnd(m_glarea.hwn 34 parent_window::set_focus_hwnd(m_glarea.hwnd()); 35 } 35 } 36 virtual ~sg_viewer() {} 36 virtual ~sg_viewer() {} 37 protected: 37 protected: 38 sg_viewer(const sg_viewer& a_from) 38 sg_viewer(const sg_viewer& a_from) 39 :parent_window(a_from) 39 :parent_window(a_from) 40 ,parent_viewer(a_from) 40 ,parent_viewer(a_from) 41 ,m_session(a_from.m_session) 41 ,m_session(a_from.m_session) 42 ,m_glarea(a_from.m_glarea) 42 ,m_glarea(a_from.m_glarea) 43 {} 43 {} 44 sg_viewer& operator=(const sg_viewer& a_from 44 sg_viewer& operator=(const sg_viewer& a_from){ 45 parent_window::operator=(a_from); 45 parent_window::operator=(a_from); 46 return *this; 46 return *this; 47 } 47 } 48 public: 48 public: 49 bool has_window() const {return m_hwnd?true: 49 bool has_window() const {return m_hwnd?true:false;} //for SWIG 50 50 51 HWND window() const {return m_hwnd;} 51 HWND window() const {return m_hwnd;} 52 52 53 bool show() { 53 bool show() { 54 if(!m_hwnd) return false; 54 if(!m_hwnd) return false; 55 m_session.show_window(m_hwnd); 55 m_session.show_window(m_hwnd); 56 return true; 56 return true; 57 } 57 } 58 58 59 void win_render() {m_glarea.wm_paint();} 59 void win_render() {m_glarea.wm_paint();} 60 60 61 61 62 public: 62 public: 63 void set_device_interactor(tools::sg::device 63 void set_device_interactor(tools::sg::device_interactor* a_interactor) { //we do not have ownership. 64 m_glarea.set_device_interactor(a_interacto 64 m_glarea.set_device_interactor(a_interactor); 65 } 65 } 66 protected: 66 protected: 67 class _glarea : public glarea { 67 class _glarea : public glarea { 68 public: 68 public: 69 virtual void paint(unsigned int a_w,unsign 69 virtual void paint(unsigned int a_w,unsigned int a_h) { 70 m_viewer.set_size(a_w,a_h); 70 m_viewer.set_size(a_w,a_h); 71 m_viewer.render(); 71 m_viewer.render(); 72 } 72 } 73 public: 73 public: 74 _glarea(HWND a_parent,parent_viewer& a_vie 74 _glarea(HWND a_parent,parent_viewer& a_viewer) 75 :glarea(a_parent) 75 :glarea(a_parent) 76 ,m_viewer(a_viewer) 76 ,m_viewer(a_viewer) 77 {} 77 {} 78 protected: 78 protected: 79 parent_viewer& m_viewer; 79 parent_viewer& m_viewer; 80 }; 80 }; 81 81 82 protected: 82 protected: 83 session& m_session; 83 session& m_session; 84 _glarea m_glarea; 84 _glarea m_glarea; 85 }; 85 }; 86 86 87 }} 87 }} 88 88 89 89 90 #endif 90 #endif