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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  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 "this" in the constructor.
 14 #pragma warning(disable:4355)
 15 
 16 namespace toolx {
 17 namespace Windows {
 18 
 19 class sg_viewer : public window, public sg::GL_viewer  {
 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,unsigned int a_height = 500,
 28             const std::string& a_title = "")
 29   :parent_window(a_title.c_str(),a_x,a_y,a_width,a_height)
 30   ,parent_viewer(a_session.out(),a_width,a_height)
 31   ,m_session(a_session)
 32   ,m_glarea(m_hwnd,*this)
 33   {
 34     parent_window::set_focus_hwnd(m_glarea.hwnd());
 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:false;} //for SWIG
 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_interactor* a_interactor) {  //we do not have ownership.
 64     m_glarea.set_device_interactor(a_interactor);
 65   }
 66 protected:
 67   class _glarea : public glarea {
 68   public:
 69     virtual void paint(unsigned int a_w,unsigned int a_h) {
 70       m_viewer.set_size(a_w,a_h);
 71       m_viewer.render();
 72     }
 73   public:
 74     _glarea(HWND a_parent,parent_viewer& a_viewer)
 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