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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.1)


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