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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/pixwin (Version 11.3.0) and /externals/g4tools/include/toolx/Qt/pixwin (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_pixwin                             4 #ifndef toolx_Qt_pixwin
  5 #define toolx_Qt_pixwin                             5 #define toolx_Qt_pixwin
  6                                                     6 
  7 #include <QtCore/qglobal.h> //For QT_VERSION.       7 #include <QtCore/qglobal.h> //For QT_VERSION.
  8                                                     8 
  9 #if QT_VERSION < 0x050000                           9 #if QT_VERSION < 0x050000
 10 #include <QtGui/qwidget.h>                         10 #include <QtGui/qwidget.h>
 11 #else                                              11 #else
 12 #include <QtWidgets/qwidget.h>                     12 #include <QtWidgets/qwidget.h>
 13 #endif                                             13 #endif
 14                                                    14 
 15 #include <QtGui/qevent.h>                          15 #include <QtGui/qevent.h>
 16 #include <QtGui/qpainter.h>                        16 #include <QtGui/qpainter.h>
 17                                                    17 
 18 #include <tools/sg/zb_viewer>                      18 #include <tools/sg/zb_viewer>
 19 #include <tools/sg/device_interactor>              19 #include <tools/sg/device_interactor>
 20                                                    20 
 21 #ifdef TOOLS_MEM                                   21 #ifdef TOOLS_MEM
 22 #include <tools/mem>                               22 #include <tools/mem>
 23 #endif                                             23 #endif
 24                                                    24 
 25 namespace toolx {                                  25 namespace toolx {
 26 namespace Qt {                                     26 namespace Qt {
 27                                                    27 
 28 class pixwin : public QWidget                      28 class pixwin : public QWidget
 29 {                                                  29 {
 30   typedef QWidget parent;                          30   typedef QWidget parent;
 31   TOOLS_SCLASS(toolx::Qt::pixwin)                  31   TOOLS_SCLASS(toolx::Qt::pixwin)
 32 public:                                            32 public:
 33   virtual void resizeEvent(QResizeEvent* a_eve     33   virtual void resizeEvent(QResizeEvent* a_event) {
 34   //::printf("debug : toolx::Qt::pixwin::resiz     34   //::printf("debug : toolx::Qt::pixwin::resizeEvent : %d, %d\n",a_event->size().width(),a_event->size().height());
 35     parent::resizeEvent(a_event);                  35     parent::resizeEvent(a_event);
 36     m_viewer.set_size(a_event->size().width(),     36     m_viewer.set_size(a_event->size().width(),a_event->size().height());
 37   }                                                37   }
 38   virtual void paintEvent(QPaintEvent* a_event     38   virtual void paintEvent(QPaintEvent* a_event) {
 39     parent::paintEvent(a_event);                   39     parent::paintEvent(a_event);
 40     if(!m_viewer.render(tools::sg::zb_viewer::     40     if(!m_viewer.render(tools::sg::zb_viewer::get_rgbas,false)) return;  //rgbas because Qt wants an image 32 bits aligned.
 41   //static size_t s_count = 0;::printf("debug      41   //static size_t s_count = 0;::printf("debug : toolx::Qt::pixwin::paintEvent %d %d : %lu\n",parent::m_ww,parent::m_wh,s_count);s_count++;
 42     QImage image(tools::vec_data(m_viewer.out_     42     QImage image(tools::vec_data(m_viewer.out_buffer()),m_viewer.width(),m_viewer.height(),QImage::Format_RGBA8888);
 43     QPixmap pixmap = QPixmap::fromImage(image)     43     QPixmap pixmap = QPixmap::fromImage(image);
 44     QPainter painter(this);                        44     QPainter painter(this);
 45     painter.drawPixmap(0,0,pixmap);                45     painter.drawPixmap(0,0,pixmap);
 46   //parent::after_render();                        46   //parent::after_render();
 47     m_viewer.out_buffer_clear();                   47     m_viewer.out_buffer_clear();
 48   }                                                48   }
 49                                                    49 
 50   virtual void keyPressEvent(QKeyEvent* a_even     50   virtual void keyPressEvent(QKeyEvent* a_event) {
 51     if(!m_interactor) return;                      51     if(!m_interactor) return;
 52     tools::sg::key_down_event _event(convert_k     52     tools::sg::key_down_event _event(convert_key(a_event->key()));
 53     m_interactor->key_press(_event);               53     m_interactor->key_press(_event);
 54   }                                                54   }
 55   virtual void keyReleaseEvent(QKeyEvent* a_ev     55   virtual void keyReleaseEvent(QKeyEvent* a_event) {
 56     if(!m_interactor) return;                      56     if(!m_interactor) return;
 57     tools::sg::key_up_event _event(convert_key     57     tools::sg::key_up_event _event(convert_key(a_event->key()));
 58     m_interactor->key_release(_event);             58     m_interactor->key_release(_event);
 59   }                                                59   }
 60   virtual void mousePressEvent(QMouseEvent* a_     60   virtual void mousePressEvent(QMouseEvent* a_event) {
 61     if(!m_interactor) return;                      61     if(!m_interactor) return;
 62 #if QT_VERSION < 0x060000                          62 #if QT_VERSION < 0x060000
 63     tools::sg::mouse_down_event _event(a_event     63     tools::sg::mouse_down_event _event(a_event->x(),a_event->y());
 64 #else                                              64 #else
 65     tools::sg::mouse_down_event _event(a_event     65     tools::sg::mouse_down_event _event(a_event->position().x(),a_event->position().y());
 66 #endif                                             66 #endif
 67     m_interactor->mouse_press(_event);             67     m_interactor->mouse_press(_event);
 68   }                                                68   }
 69   virtual void mouseReleaseEvent(QMouseEvent*      69   virtual void mouseReleaseEvent(QMouseEvent* a_event) {
 70     if(!m_interactor) return;                      70     if(!m_interactor) return;
 71 #if QT_VERSION < 0x060000                          71 #if QT_VERSION < 0x060000
 72     tools::sg::mouse_up_event _event(a_event->     72     tools::sg::mouse_up_event _event(a_event->x(),a_event->y());
 73 #else                                              73 #else
 74     tools::sg::mouse_up_event _event(a_event->     74     tools::sg::mouse_up_event _event(a_event->position().x(),a_event->position().y());
 75 #endif                                             75 #endif
 76     m_interactor->mouse_release(_event);           76     m_interactor->mouse_release(_event);
 77   }                                                77   }
 78   virtual void mouseMoveEvent(QMouseEvent* a_e     78   virtual void mouseMoveEvent(QMouseEvent* a_event) {
 79     if(!m_interactor) return;                      79     if(!m_interactor) return;
 80 #if QT_VERSION < 0x060000                          80 #if QT_VERSION < 0x060000
 81     tools::sg::mouse_move_event _event(a_event     81     tools::sg::mouse_move_event _event(a_event->x(),a_event->y(),0,0,false);
 82 #else                                              82 #else
 83     tools::sg::mouse_move_event _event(a_event     83     tools::sg::mouse_move_event _event(a_event->position().x(),a_event->position().y(),0,0,false);
 84 #endif                                             84 #endif
 85     m_interactor->mouse_move(_event);              85     m_interactor->mouse_move(_event);
 86   }                                                86   }
 87 //virtual void mouseDoubleClickEvent(QMouseEve     87 //virtual void mouseDoubleClickEvent(QMouseEvent* a_event) {
 88 //  if(!m_interactor) return;                      88 //  if(!m_interactor) return;
 89 //  tools::sg::mouse_double_click_event _event     89 //  tools::sg::mouse_double_click_event _event(a_event->x(),a_event->y());
 90 //  m_interactor->mouse_double_click(_event);      90 //  m_interactor->mouse_double_click(_event);
 91 //}                                                91 //}
 92   virtual void wheelEvent(QWheelEvent* a_event     92   virtual void wheelEvent(QWheelEvent* a_event) {
 93     if(!m_interactor) return;                      93     if(!m_interactor) return;
 94     tools::sg::wheel_rotate_event _event(a_eve     94     tools::sg::wheel_rotate_event _event(a_event->angleDelta().y());
 95     m_interactor->wheel_rotate(_event);            95     m_interactor->wheel_rotate(_event);
 96   }                                                96   }
 97                                                    97 
 98 public:                                            98 public:
 99   pixwin(QWidget* a_parent,tools::sg::zb_viewe     99   pixwin(QWidget* a_parent,tools::sg::zb_viewer& a_viewer):parent(a_parent),m_viewer(a_viewer),m_interactor(0){
100 #ifdef TOOLS_MEM                                  100 #ifdef TOOLS_MEM
101     tools::mem::increment(s_class().c_str());     101     tools::mem::increment(s_class().c_str());
102 #endif                                            102 #endif
103   }                                               103   }
104   virtual ~pixwin(){                              104   virtual ~pixwin(){
105 #ifdef TOOLS_MEM                                  105 #ifdef TOOLS_MEM
106     tools::mem::decrement(s_class().c_str());     106     tools::mem::decrement(s_class().c_str());
107 #endif                                            107 #endif
108   }                                               108   }
109 public:                                           109 public:
110   void set_device_interactor(tools::sg::device    110   void set_device_interactor(tools::sg::device_interactor* a_interactor) {m_interactor = a_interactor;} //we do not have ownership.
111 protected:                                        111 protected:
112   tools::key_code convert_key(/*Qt::Key*/int a    112   tools::key_code convert_key(/*Qt::Key*/int a_key) {return a_key;}
113 protected:                                        113 protected:
114   tools::sg::zb_viewer& m_viewer;                 114   tools::sg::zb_viewer& m_viewer;
115   tools::sg::device_interactor* m_interactor;     115   tools::sg::device_interactor* m_interactor;
116 };                                                116 };
117                                                   117 
118 }}                                                118 }}
119                                                   119 
120                                                   120 
121 #endif                                            121 #endif