Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 2 // See the file tools.license for terms. 3 4 #ifndef toolx_Windows_zb_viewer 5 #define toolx_Windows_zb_viewer 6 7 #include "session" 8 #include "window" 9 10 #include "pixwin" 11 #include <tools/sg/zb_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 zb_viewer : public window, protected pix 20 typedef window parent_window; 21 typedef pixwin parent_render_area; 22 typedef tools::sg::zb_viewer parent_viewer; 23 protected: 24 virtual void paint() { 25 //parent_viewer::m_out << "toolx::Windows: 26 if(!render(get_bgras,false)) return; 27 HDC hDC = ::GetDC(parent_render_area::m_hw 28 HDC bitmap_DC = ::CreateCompatibleDC(hDC); 29 HBITMAP bitmap = ::CreateBitmap(parent_vie 30 HBITMAP old_bitmap = (HBITMAP)::SelectObje 31 ::BitBlt(hDC,0,0,parent_viewer::m_ww,paren 32 ::SelectObject(bitmap_DC, old_bitmap); 33 ::DeleteObject(bitmap); 34 ::DeleteDC(bitmap_DC); 35 ::ReleaseDC(parent_render_area::m_hwnd,hDC 36 ::ValidateRect(parent_render_area::m_hwnd, 37 m_out_buffer.clear(); 38 } 39 virtual void resize(unsigned int a_w,unsigne 40 //parent_viewer::m_out << "toolx::Windows: 41 set_size(a_w,a_h); 42 } 43 public: 44 virtual void close() {} 45 public: 46 zb_viewer(session& a_session, 47 int a_x = 0,int a_y = 0, 48 unsigned int a_width = 500,unsigne 49 const std::string& a_title = "") 50 :parent_window(a_title.c_str(),a_x,a_y,a_wid 51 ,parent_render_area(parent_window::m_hwnd,a_ 52 ,parent_viewer(a_session.out(),a_width,a_hei 53 ,m_session(a_session) 54 { 55 parent_window::set_focus_hwnd(parent_rende 56 } 57 virtual ~zb_viewer() {} 58 protected: 59 zb_viewer(const zb_viewer& a_from) 60 :parent_window(a_from) 61 ,parent_render_area(a_from) 62 ,parent_viewer(a_from) 63 ,m_session(a_from.m_session) 64 {} 65 zb_viewer& operator=(const zb_viewer& a_from 66 parent_window::operator=(a_from); 67 return *this; 68 } 69 public: 70 bool has_window() const {return parent_windo 71 72 HWND window() const {return parent_window::m 73 74 bool show() { 75 if(!parent_window::m_hwnd) return false; 76 m_session.show_window(parent_window::m_hwn 77 return true; 78 } 79 80 void win_render() {parent_render_area::wm_pa 81 void set_device_interactor(tools::sg::device 82 parent_render_area::set_device_interactor( 83 } 84 protected: 85 session& m_session; 86 }; 87 88 }} 89 90 91 #endif