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