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] [ 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/glarea (Version 11.3.0) and /externals/g4tools/include/toolx/Qt/glarea (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_glarea                             4 #ifndef toolx_Qt_glarea
  5 #define toolx_Qt_glarea                             5 #define toolx_Qt_glarea
  6                                                     6 
  7 #include "../sg/GL_viewer"                          7 #include "../sg/GL_viewer"
  8                                                     8 
  9 #include <QtCore/qglobal.h> //For QT_VERSION.       9 #include <QtCore/qglobal.h> //For QT_VERSION.
 10                                                    10 
 11 #if QT_VERSION < 0x060000                          11 #if QT_VERSION < 0x060000
 12 #include <QtOpenGL/qgl.h>                          12 #include <QtOpenGL/qgl.h>
 13 #else                                              13 #else
 14 #include <QtOpenGLWidgets/qopenglwidget.h>         14 #include <QtOpenGLWidgets/qopenglwidget.h>
 15 #endif                                             15 #endif
 16                                                    16 
 17 #include <QtGui/qevent.h>                          17 #include <QtGui/qevent.h>
 18                                                    18 
 19 #include <tools/sg/device_interactor>              19 #include <tools/sg/device_interactor>
 20 #ifdef TOOLS_MEM                                   20 #ifdef TOOLS_MEM
 21 #include <tools/mem>                               21 #include <tools/mem>
 22 #endif                                             22 #endif
 23                                                    23 
 24 namespace toolx {                                  24 namespace toolx {
 25 namespace Qt {                                     25 namespace Qt {
 26                                                    26 
 27 class glarea                                       27 class glarea
 28 #if QT_VERSION < 0x060000                          28 #if QT_VERSION < 0x060000
 29 :public QGLWidget                                  29 :public QGLWidget
 30 #else                                              30 #else
 31 :public QOpenGLWidget                              31 :public QOpenGLWidget
 32 #endif                                             32 #endif
 33 {                                                  33 {
 34 #if QT_VERSION < 0x060000                          34 #if QT_VERSION < 0x060000
 35   typedef QGLWidget parent;                        35   typedef QGLWidget parent;
 36 #else                                              36 #else
 37   using parent = QOpenGLWidget;                    37   using parent = QOpenGLWidget;
 38 #endif                                             38 #endif
 39   TOOLS_SCLASS(toolx::Qt::glarea)                  39   TOOLS_SCLASS(toolx::Qt::glarea)
 40 public:                                            40 public:
 41   virtual void initializeGL() {}                   41   virtual void initializeGL() {}
 42   virtual void paintGL() {                         42   virtual void paintGL() {
 43 #if QT_VERSION < 0x050000                          43 #if QT_VERSION < 0x050000
 44     m_viewer.set_size(width(),height());           44     m_viewer.set_size(width(),height());
 45 #else                                              45 #else
 46     m_viewer.set_size(devicePixelRatio()*width     46     m_viewer.set_size(devicePixelRatio()*width(),devicePixelRatio()*height());
 47 #endif                                             47 #endif
 48     m_viewer.render();                             48     m_viewer.render();
 49   }                                                49   }
 50                                                    50 
 51   virtual void keyPressEvent(QKeyEvent* a_even     51   virtual void keyPressEvent(QKeyEvent* a_event) {
 52     if(!m_interactor) return;                      52     if(!m_interactor) return;
 53     tools::sg::key_down_event _event(convert_k     53     tools::sg::key_down_event _event(convert_key(a_event->key()));
 54     m_interactor->key_press(_event);               54     m_interactor->key_press(_event);
 55   }                                                55   }
 56   virtual void keyReleaseEvent(QKeyEvent* a_ev     56   virtual void keyReleaseEvent(QKeyEvent* a_event) {
 57     if(!m_interactor) return;                      57     if(!m_interactor) return;
 58     tools::sg::key_up_event _event(convert_key     58     tools::sg::key_up_event _event(convert_key(a_event->key()));
 59     m_interactor->key_release(_event);             59     m_interactor->key_release(_event);
 60   }                                                60   }
 61   virtual void mousePressEvent(QMouseEvent* a_     61   virtual void mousePressEvent(QMouseEvent* a_event) {
 62     if(!m_interactor) return;                      62     if(!m_interactor) return;
 63 #if QT_VERSION < 0x060000                          63 #if QT_VERSION < 0x060000
 64     tools::sg::mouse_down_event _event(a_event     64     tools::sg::mouse_down_event _event(a_event->x(),a_event->y());
 65 #else                                              65 #else
 66     tools::sg::mouse_down_event _event(a_event     66     tools::sg::mouse_down_event _event(a_event->position().x(),a_event->position().y());
 67 #endif                                             67 #endif
 68     m_interactor->mouse_press(_event);             68     m_interactor->mouse_press(_event);
 69   }                                                69   }
 70   virtual void mouseReleaseEvent(QMouseEvent*      70   virtual void mouseReleaseEvent(QMouseEvent* a_event) {
 71     if(!m_interactor) return;                      71     if(!m_interactor) return;
 72 #if QT_VERSION < 0x060000                          72 #if QT_VERSION < 0x060000
 73     tools::sg::mouse_up_event _event(a_event->     73     tools::sg::mouse_up_event _event(a_event->x(),a_event->y());
 74 #else                                              74 #else
 75     tools::sg::mouse_up_event _event(a_event->     75     tools::sg::mouse_up_event _event(a_event->position().x(),a_event->position().y());
 76 #endif                                             76 #endif
 77     m_interactor->mouse_release(_event);           77     m_interactor->mouse_release(_event);
 78   }                                                78   }
 79   virtual void mouseMoveEvent(QMouseEvent* a_e     79   virtual void mouseMoveEvent(QMouseEvent* a_event) {
 80     if(!m_interactor) return;                      80     if(!m_interactor) return;
 81 #if QT_VERSION < 0x060000                          81 #if QT_VERSION < 0x060000
 82     tools::sg::mouse_move_event _event(a_event     82     tools::sg::mouse_move_event _event(a_event->x(),a_event->y(),0,0,false);
 83 #else                                              83 #else
 84     tools::sg::mouse_move_event _event(a_event     84     tools::sg::mouse_move_event _event(a_event->position().x(),a_event->position().y(),0,0,false);
 85 #endif                                             85 #endif
 86     m_interactor->mouse_move(_event);              86     m_interactor->mouse_move(_event);
 87   }                                                87   }
 88   virtual void wheelEvent(QWheelEvent* a_event     88   virtual void wheelEvent(QWheelEvent* a_event) {
 89     if(!m_interactor) return;                      89     if(!m_interactor) return;
 90     tools::sg::wheel_rotate_event _event(a_eve     90     tools::sg::wheel_rotate_event _event(a_event->angleDelta().y());
 91     m_interactor->wheel_rotate(_event);            91     m_interactor->wheel_rotate(_event);
 92   }                                                92   }
 93                                                    93 
 94 public:                                            94 public:
 95   glarea(QWidget* a_parent,toolx::sg::GL_viewe     95   glarea(QWidget* a_parent,toolx::sg::GL_viewer& a_viewer):parent(a_parent),m_viewer(a_viewer),m_interactor(0){
 96 #ifdef TOOLS_MEM                                   96 #ifdef TOOLS_MEM
 97     tools::mem::increment(s_class().c_str());      97     tools::mem::increment(s_class().c_str());
 98 #endif                                             98 #endif
 99   }                                                99   }
100   virtual ~glarea(){                              100   virtual ~glarea(){
101 #ifdef TOOLS_MEM                                  101 #ifdef TOOLS_MEM
102     tools::mem::decrement(s_class().c_str());     102     tools::mem::decrement(s_class().c_str());
103 #endif                                            103 #endif
104   }                                               104   }
105 public:                                           105 public:
106   void set_device_interactor(tools::sg::device    106   void set_device_interactor(tools::sg::device_interactor* a_interactor) {m_interactor = a_interactor;} //we do not have ownership.
107 protected:                                        107 protected:
108   tools::key_code convert_key(/*Qt::Key*/int a    108   tools::key_code convert_key(/*Qt::Key*/int a_key) {return a_key;}
109 protected:                                        109 protected:
110   toolx::sg::GL_viewer& m_viewer;                 110   toolx::sg::GL_viewer& m_viewer;
111   tools::sg::device_interactor* m_interactor;     111   tools::sg::device_interactor* m_interactor;
112 };                                                112 };
113                                                   113 
114 }}                                                114 }}
115                                                   115 
116                                                   116 
117 #endif                                            117 #endif