GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
GLCanvas.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2018 Michael Goffioul
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_GLCanvas_h)
24 #define octave_GLCanvas_h 1
25 
26 #if defined (HAVE_QOPENGLWIDGET)
27 # include <QOpenGLWidget>
28 # define OCTAVE_QT_OPENGL_WIDGET QOpenGLWidget
29 # include <QOpenGLFramebufferObject>
30 # define OCTAVE_QT_OPENGL_FBO QOpenGLFramebufferObject
31 # if defined (HAVE_QT_OFFSCREEN)
32 # include <QOpenGLContext>
33 # include <QOffscreenSurface>
34 # endif
35 #elif defined (HAVE_QGLWIDGET)
36 # include <QGLWidget>
37 # define OCTAVE_QT_OPENGL_WIDGET QGLWidget
38 # include <QGLFramebufferObject>
39 # define OCTAVE_QT_OPENGL_FBO QGLFramebufferObject
40 #else
41 # error "configuration error: must have <QOpenGLWidget> or <QGLWidget>."
42 #endif
43 
44 #include "Canvas.h"
45 
46 namespace QtHandles
47 {
48  class GLCanvas : public OCTAVE_QT_OPENGL_WIDGET, public Canvas
49  {
50  public:
51  GLCanvas (QWidget *parent, const graphics_handle& handle);
52  ~GLCanvas (void);
53 
54  void draw (const graphics_handle& handle);
56  void do_print (const QString& file_cmd, const QString& term,
57  const graphics_handle& handle);
58  void toggleAxes (const graphics_handle& handle);
59  void toggleGrid (const graphics_handle& handle);
60  void autoAxes (const graphics_handle& handle);
61  void drawZoomBox (const QPoint& p1, const QPoint& p2);
62  void resize (int /* x */, int /* y */,
63  int /* width */, int /* height */) { }
65  const QPoint& pt);
66  QWidget * qWidget (void) { return this; }
67 
68  protected:
69  void paintGL (void);
70  void mouseDoubleClickEvent (QMouseEvent *event);
71  void mouseMoveEvent (QMouseEvent *event);
72  void mousePressEvent (QMouseEvent *event);
73  void mouseReleaseEvent (QMouseEvent *event);
74  void wheelEvent (QWheelEvent *event);
75  void keyPressEvent (QKeyEvent *event);
76  void keyReleaseEvent (QKeyEvent *event);
77 
78  private:
79 
80  bool begin_rendering (void);
81  void end_rendering (void);
82 
83 # if defined (HAVE_QT_OFFSCREEN)
84  QOpenGLContext m_os_context;
85  QOffscreenSurface m_os_surface;
86 # endif
87  };
88 
89 }
90 
91 #endif
void autoAxes(const graphics_handle &handle)
Definition: GLCanvas.cc:162
void end_rendering(void)
Definition: GLCanvas.cc:311
void mouseDoubleClickEvent(QMouseEvent *event)
Definition: GLCanvas.cc:236
graphics_object selectFromAxes(const graphics_object &ax, const QPoint &pt)
Definition: GLCanvas.cc:168
GLCanvas(QWidget *parent, const graphics_handle &handle)
Definition: GLCanvas.cc:50
void wheelEvent(QWheelEvent *event)
Definition: GLCanvas.cc:260
void mouseMoveEvent(QMouseEvent *event)
Definition: GLCanvas.cc:242
bool begin_rendering(void)
Definition: GLCanvas.cc:280
void draw(const graphics_handle &handle)
Definition: GLCanvas.cc:62
void keyReleaseEvent(QKeyEvent *event)
Definition: GLCanvas.cc:273
void toggleAxes(const graphics_handle &handle)
Definition: GLCanvas.cc:150
QWidget * qWidget(void)
Definition: GLCanvas.h:66
uint8NDArray do_getPixels(const graphics_handle &handle)
Definition: GLCanvas.cc:77
void paintGL(void)
Definition: GLCanvas.cc:230
void toggleGrid(const graphics_handle &handle)
Definition: GLCanvas.cc:156
void mousePressEvent(QMouseEvent *event)
Definition: GLCanvas.cc:248
void drawZoomBox(const QPoint &p1, const QPoint &p2)
Definition: GLCanvas.cc:195
void resize(int, int, int, int)
Definition: GLCanvas.h:62
void mouseReleaseEvent(QMouseEvent *event)
Definition: GLCanvas.cc:254
is a function handle
Definition: bsxfun.cc:337
void keyPressEvent(QKeyEvent *event)
Definition: GLCanvas.cc:266
void do_print(const QString &file_cmd, const QString &term, const graphics_handle &handle)
Definition: GLCanvas.cc:123