GNU Octave 7.1.0
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-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_GLCanvas_h)
27#define octave_GLCanvas_h 1
28
29#if defined (HAVE_QOPENGLWIDGET)
30# include <QOpenGLWidget>
31# define OCTAVE_QT_OPENGL_WIDGET QOpenGLWidget
32# include <QOpenGLFramebufferObject>
33# define OCTAVE_QT_OPENGL_FBO QOpenGLFramebufferObject
34# if defined (HAVE_QT_OFFSCREEN)
35# include <QOpenGLContext>
36# include <QOffscreenSurface>
37# endif
38#elif defined (HAVE_QGLWIDGET)
39# include <QGLWidget>
40# define OCTAVE_QT_OPENGL_WIDGET QGLWidget
41# include <QGLFramebufferObject>
42# define OCTAVE_QT_OPENGL_FBO QGLFramebufferObject
43#else
44# error "configuration error: must have <QOpenGLWidget> or <QGLWidget>."
45#endif
46
47#include "Canvas.h"
48
49#include "gl-render.h"
50#include "qopengl-functions.h"
51
52namespace octave
53{
54 class base_qobject;
55}
56
57namespace octave
58{
60 {
61 public:
62 GLCanvas (octave::base_qobject& oct_qobj, octave::interpreter& interp,
63 const graphics_handle& handle, QWidget *parent);
64 ~GLCanvas (void);
65
66 void initializeGL (void);
67
68 void draw (const graphics_handle& handle);
70 void do_print (const QString& file_cmd, const QString& term,
71 const graphics_handle& handle);
72 void drawZoomBox (const QPoint& p1, const QPoint& p2);
73 void resize (int /* x */, int /* y */,
74 int /* width */, int /* height */) { }
75 graphics_object selectFromAxes (const graphics_object& ax,
76 const QPoint& pt);
77 QWidget * qWidget (void) { return this; }
78
79 protected:
80 void paintGL (void);
81 void mouseDoubleClickEvent (QMouseEvent *event);
82 void mouseMoveEvent (QMouseEvent *event);
83 void mousePressEvent (QMouseEvent *event);
84 void mouseReleaseEvent (QMouseEvent *event);
85 void wheelEvent (QWheelEvent *event);
86 void keyPressEvent (QKeyEvent *event);
87 void keyReleaseEvent (QKeyEvent *event);
88
89 private:
90
91 bool begin_rendering (void);
92 void end_rendering (void);
93
96
97# if defined (HAVE_QT_OFFSCREEN)
98 QOpenGLContext m_os_context;
99 QOffscreenSurface m_os_surface;
100# endif
101 };
102
103}
104
105#endif
octave::opengl_renderer m_renderer
Definition: GLCanvas.h:95
void mouseReleaseEvent(QMouseEvent *event)
Definition: GLCanvas.cc:262
void paintGL(void)
Definition: GLCanvas.cc:238
void resize(int, int, int, int)
Definition: GLCanvas.h:73
QWidget * qWidget(void)
Definition: GLCanvas.h:77
void draw(const graphics_handle &handle)
Definition: GLCanvas.cc:73
void wheelEvent(QWheelEvent *event)
Definition: GLCanvas.cc:268
GLCanvas(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_handle &handle, QWidget *parent)
Definition: GLCanvas.cc:53
void mousePressEvent(QMouseEvent *event)
Definition: GLCanvas.cc:256
void initializeGL(void)
Definition: GLCanvas.cc:67
uint8NDArray do_getPixels(const graphics_handle &handle)
Definition: GLCanvas.cc:92
void drawZoomBox(const QPoint &p1, const QPoint &p2)
Definition: GLCanvas.cc:220
void end_rendering(void)
Definition: GLCanvas.cc:319
void do_print(const QString &file_cmd, const QString &term, const graphics_handle &handle)
Definition: GLCanvas.cc:145
void keyReleaseEvent(QKeyEvent *event)
Definition: GLCanvas.cc:281
void keyPressEvent(QKeyEvent *event)
Definition: GLCanvas.cc:274
graphics_object selectFromAxes(const graphics_object &ax, const QPoint &pt)
Definition: GLCanvas.cc:203
octave::qopengl_functions m_glfcns
Definition: GLCanvas.h:94
void mouseMoveEvent(QMouseEvent *event)
Definition: GLCanvas.cc:250
void mouseDoubleClickEvent(QMouseEvent *event)
Definition: GLCanvas.cc:244
bool begin_rendering(void)
Definition: GLCanvas.cc:288
Base class for Octave interfaces that use Qt.