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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 ]

Diff markup

Differences between /externals/g4tools/include/toolx/Qt/zb_viewer (Version 11.3.0) and /externals/g4tools/include/toolx/Qt/zb_viewer (Version 11.2.2)


  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_Qt_zb_viewer                          4 #ifndef toolx_Qt_zb_viewer
  5 #define toolx_Qt_zb_viewer                          5 #define toolx_Qt_zb_viewer
  6                                                     6 
  7 #include "pixwin"                                   7 #include "pixwin"
  8 #include <tools/sg/zb_viewer>                       8 #include <tools/sg/zb_viewer>
  9                                                     9 
 10 #include "session"                                 10 #include "session"
 11                                                    11 
 12 #include <QtCore/qglobal.h> //For QT_VERSION.      12 #include <QtCore/qglobal.h> //For QT_VERSION.
 13                                                    13 
 14 #if QT_VERSION < 0x050000                          14 #if QT_VERSION < 0x050000
 15 #include <QtGui/qboxlayout.h>                      15 #include <QtGui/qboxlayout.h>
 16 #else                                              16 #else
 17 #include <QtWidgets/qboxlayout.h>                  17 #include <QtWidgets/qboxlayout.h>
 18 #endif                                             18 #endif
 19                                                    19 
 20 namespace toolx {                                  20 namespace toolx {
 21 namespace Qt {                                     21 namespace Qt {
 22                                                    22 
 23 class zb_viewer: public tools::sg::zb_viewer {     23 class zb_viewer: public tools::sg::zb_viewer {
 24   typedef tools::sg::zb_viewer parent;             24   typedef tools::sg::zb_viewer parent;
 25   typedef pixwin render_area_t;                    25   typedef pixwin render_area_t;
 26 public:                                            26 public:
 27   zb_viewer(session& a_session,                    27   zb_viewer(session& a_session,
 28             int a_x = 0,int a_y = 0,               28             int a_x = 0,int a_y = 0,
 29             unsigned int a_width = 500,unsigne     29             unsigned int a_width = 500,unsigned int a_height = 500,
 30             const std::string& a_win_title = "     30             const std::string& a_win_title = "")
 31   :parent(a_session.out(),a_width,a_height)        31   :parent(a_session.out(),a_width,a_height)
 32   ,m_session(a_session)                            32   ,m_session(a_session)
 33   ,m_shell(0)                                      33   ,m_shell(0)
 34   ,m_own_shell(false)                              34   ,m_own_shell(false)
 35   ,m_render_area(0)                                35   ,m_render_area(0)
 36   {                                                36   {
 37     if(!m_session.is_valid()) return; //throw      37     if(!m_session.is_valid()) return; //throw
 38     m_shell = m_session.create_window(a_win_ti     38     m_shell = m_session.create_window(a_win_title.c_str(),a_x,a_y,a_width,a_height);
 39     if(!m_shell) return; //throw                   39     if(!m_shell) return; //throw
 40     m_own_shell = true;                            40     m_own_shell = true;
 41                                                    41 
 42     m_render_area = new render_area_t(0,*this)     42     m_render_area = new render_area_t(0,*this);
 43                                                    43 
 44     QVBoxLayout* layout = new QVBoxLayout;         44     QVBoxLayout* layout = new QVBoxLayout;
 45     layout->setContentsMargins(0,0,0,0);           45     layout->setContentsMargins(0,0,0,0);
 46     layout->addWidget(m_render_area);              46     layout->addWidget(m_render_area);
 47     m_shell->setLayout(layout);                    47     m_shell->setLayout(layout);
 48   }                                                48   }
 49   virtual ~zb_viewer() {                           49   virtual ~zb_viewer() {
 50     if(m_render_area) m_render_area->set_devic     50     if(m_render_area) m_render_area->set_device_interactor(0);
 51     if(m_shell && m_own_shell) {                   51     if(m_shell && m_own_shell) {
 52       m_session.delete_window(m_shell);            52       m_session.delete_window(m_shell);
 53       //m_session.sync();                          53       //m_session.sync();
 54     }                                              54     }
 55   }                                                55   }
 56 protected:                                         56 protected:
 57   zb_viewer(const zb_viewer& a_from)               57   zb_viewer(const zb_viewer& a_from)
 58   :parent(a_from)                                  58   :parent(a_from)
 59   ,m_session(a_from.m_session)                     59   ,m_session(a_from.m_session)
 60   ,m_shell(0)                                      60   ,m_shell(0)
 61   ,m_own_shell(false)                              61   ,m_own_shell(false)
 62   ,m_render_area(0)                                62   ,m_render_area(0)
 63   {}                                               63   {}
 64   zb_viewer& operator=(const zb_viewer& a_from     64   zb_viewer& operator=(const zb_viewer& a_from){
 65     parent::operator=(a_from);                     65     parent::operator=(a_from);
 66     return *this;                                  66     return *this;
 67   }                                                67   }
 68 public:                                            68 public:
 69   bool has_window() const {return m_shell?true     69   bool has_window() const {return m_shell?true:false;} //for SWIG
 70                                                    70 
 71   bool show() {                                    71   bool show() {
 72     if(!m_shell) return false;                     72     if(!m_shell) return false;
 73     m_shell->show();                               73     m_shell->show();
 74     return true;                                   74     return true;
 75   }                                                75   }
 76                                                    76 
 77   void win_render() {                              77   void win_render() {
 78     if(!m_render_area) return;                     78     if(!m_render_area) return;
 79   //m_render_area->update();  //delayed.           79   //m_render_area->update();  //delayed.
 80     m_render_area->repaint(); //immediate.         80     m_render_area->repaint(); //immediate.
 81   }                                                81   }
 82                                                    82 
 83   void set_device_interactor(tools::sg::device     83   void set_device_interactor(tools::sg::device_interactor* a_interactor) {  //we do not have ownership.
 84     if(!m_render_area) return;                     84     if(!m_render_area) return;
 85     m_render_area->set_device_interactor(a_int     85     m_render_area->set_device_interactor(a_interactor);
 86   }                                                86   }
 87 public:                                            87 public:
 88   QWidget* shell() {return m_shell;}               88   QWidget* shell() {return m_shell;}
 89   void set_own_shell(bool a_value) {m_own_shel     89   void set_own_shell(bool a_value) {m_own_shell = a_value;}
 90   render_area_t* render_area() {return m_rende     90   render_area_t* render_area() {return m_render_area;}
 91   void enable_keyboard_focus() {                   91   void enable_keyboard_focus() {
 92     if(!m_render_area) return;                     92     if(!m_render_area) return;
 93     m_render_area->setFocusPolicy(::Qt::Strong     93     m_render_area->setFocusPolicy(::Qt::StrongFocus);
 94   }                                                94   }
 95 protected:                                         95 protected:
 96   session& m_session;                              96   session& m_session;
 97   QWidget* m_shell;                                97   QWidget* m_shell;
 98   bool m_own_shell;                                98   bool m_own_shell;
 99   render_area_t* m_render_area;                    99   render_area_t* m_render_area;
100 };                                                100 };
101                                                   101 
102 }}                                                102 }}
103                                                   103 
104                                                   104 
105 #endif                                            105 #endif
106                                                   106