Mercurial > octave
annotate libgui/graphics/GLCanvas.cc @ 31752:345a3f5890e7
assume QOpenGLWidget is available
QOpenGLWidget was introduced in Qt 5.4.
* acinclude.m4 (OCTAVE_CHECK_QT_OPENGL_OK): Delete.
(OCTAVE_CHECK_QT_VERSION): Delete use. Don't define separate macros
and compiler flag variables for QtOpenGL module. Include them with
the other Qt compiler flags.
* subst-config-vals.in.sh, subst-cross-config-vals.in.sh,
configure.ac, GLCanvas.cc, GLCanvas.h, module.mk, build-env.h,
build-env.in.cc, toplev.cc: Eliminate checks for Qt QOpenGLWidget.
Assume it is always available. Eliminate QtOpenGL configuration
variables.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 17 Jan 2023 13:43:26 -0500 |
parents | e863066429f1 |
children | d94ceed56929 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31648
diff
changeset
|
3 // Copyright (C) 2011-2023 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21692
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
27 # include "config.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
27417
f844b1f03dcc
update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27393
diff
changeset
|
30 #include "GLCanvas.h" |
f844b1f03dcc
update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27393
diff
changeset
|
31 #include "gl-select.h" |
f844b1f03dcc
update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27393
diff
changeset
|
32 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "gl-render.h" |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
34 #include "gl2ps-print.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "graphics.h" |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
36 #include "interpreter.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
38 OCTAVE_BEGIN_NAMESPACE(octave) |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
39 |
31639
ca7d58406f82
eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
40 GLCanvas::GLCanvas (octave::interpreter& interp, |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27481
diff
changeset
|
41 const graphics_handle& gh, QWidget *xparent) |
31752
345a3f5890e7
assume QOpenGLWidget is available
John W. Eaton <jwe@octave.org>
parents:
31751
diff
changeset
|
42 : QOpenGLWidget (xparent), Canvas (interp, gh), m_glfcns (), |
345a3f5890e7
assume QOpenGLWidget is available
John W. Eaton <jwe@octave.org>
parents:
31751
diff
changeset
|
43 m_renderer (m_glfcns) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
44 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
45 setFocusPolicy (Qt::ClickFocus); |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
46 setFocus (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
47 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
49 GLCanvas::~GLCanvas (void) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22413
diff
changeset
|
50 { } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
52 void |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
53 GLCanvas::initializeGL (void) |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
54 { |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
55 m_glfcns.init (); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
56 } |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
57 |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
58 void |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
59 GLCanvas::draw (const graphics_handle& gh) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
60 { |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
61 gh_manager& gh_mgr = m_interpreter.get_gh_manager (); |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
62 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
63 octave::autolock guard (gh_mgr.graphics_lock ()); |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
64 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
65 graphics_object go = gh_mgr.get_object (gh); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
67 if (go) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
68 { |
25884
4e108574385c
Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents:
25863
diff
changeset
|
69 graphics_object fig = go.get_ancestor ("figure"); |
4e108574385c
Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents:
25863
diff
changeset
|
70 double dpr = fig.get ("__device_pixel_ratio__").double_value (); |
4e108574385c
Improve OpenGL rendering on high resolution screens with Qt 5 (bug #49053)
John Swensen <jpswensen@gmail.com>
parents:
25863
diff
changeset
|
71 m_renderer.set_viewport (dpr * width (), dpr * height ()); |
25889
2da65009cc7f
Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25884
diff
changeset
|
72 m_renderer.set_device_pixel_ratio (dpr); |
25863
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
73 m_renderer.draw (go); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
74 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
75 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
77 uint8NDArray |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
78 GLCanvas::do_getPixels (const graphics_handle& gh) |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
79 { |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
80 uint8NDArray retval; |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
81 |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
82 gh_manager& gh_mgr = m_interpreter.get_gh_manager (); |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
83 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
84 graphics_object go = gh_mgr.get_object (gh); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25081
diff
changeset
|
85 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
86 if (go && go.isa ("figure")) |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
87 { |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
88 Matrix pos = go.get ("position").matrix_value (); |
25998
8d2b3e3ff182
print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25889
diff
changeset
|
89 double dpr = go.get ("__device_pixel_ratio__").double_value (); |
8d2b3e3ff182
print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25889
diff
changeset
|
90 pos(2) *= dpr; |
8d2b3e3ff182
print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25889
diff
changeset
|
91 pos(3) *= dpr; |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
92 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
93 // Make sure we have a valid current context |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
94 if (! begin_rendering ()) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
95 return retval; |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
96 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
97 // When the figure is not visible or its size is frozen for printing, |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
98 // we use a framebuffer object to make sure we are rendering on a |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
99 // suitably large frame. |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
100 if (go.get ("visible").string_value () == "off" |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
101 || go.get ("__printing__").string_value () == "on") |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
102 { |
31752
345a3f5890e7
assume QOpenGLWidget is available
John W. Eaton <jwe@octave.org>
parents:
31751
diff
changeset
|
103 QOpenGLFramebufferObject |
345a3f5890e7
assume QOpenGLWidget is available
John W. Eaton <jwe@octave.org>
parents:
31751
diff
changeset
|
104 fbo (pos(2), pos(3), |
345a3f5890e7
assume QOpenGLWidget is available
John W. Eaton <jwe@octave.org>
parents:
31751
diff
changeset
|
105 QOpenGLFramebufferObject::Attachment::Depth); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25081
diff
changeset
|
106 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
107 fbo.bind (); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25081
diff
changeset
|
108 |
25863
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
109 m_renderer.set_viewport (pos(2), pos(3)); |
25998
8d2b3e3ff182
print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25889
diff
changeset
|
110 m_renderer.set_device_pixel_ratio (dpr); |
25863
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
111 m_renderer.draw (go); |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
112 retval = m_renderer.get_pixels (pos(2), pos(3)); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25081
diff
changeset
|
113 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
114 fbo.release (); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
115 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
116 else |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
117 { |
25863
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
118 m_renderer.set_viewport (pos(2), pos(3)); |
25998
8d2b3e3ff182
print.m: Implement "-opengl", "-painters" and "-RGBImage" options (bug #52866)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25889
diff
changeset
|
119 m_renderer.set_device_pixel_ratio (dpr); |
25863
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
120 m_renderer.draw (go); |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
121 retval = m_renderer.get_pixels (pos(2), pos(3)); |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
122 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
123 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
124 end_rendering (); |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
125 } |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
126 |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
127 return retval; |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
128 } |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25081
diff
changeset
|
129 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
130 void |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
131 GLCanvas::do_print (const QString& file_cmd, const QString& term, |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
132 const graphics_handle& handle) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
133 { |
27647
2a506bc4a7af
eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27645
diff
changeset
|
134 gh_manager& gh_mgr = m_interpreter.get_gh_manager (); |
27335
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
135 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
136 octave::autolock guard (gh_mgr.graphics_lock ()); |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
137 |
50216d7a2f6b
eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents:
27303
diff
changeset
|
138 graphics_object go = gh_mgr.get_object (handle); |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
139 |
27168
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
140 if (go.valid_object ()) |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
141 { |
27168
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
142 graphics_object fig (go.get_ancestor ("figure")); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
143 |
26277
e92a44730a6e
Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25998
diff
changeset
|
144 // Make sure we have a valid current context |
e92a44730a6e
Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25998
diff
changeset
|
145 if (! begin_rendering ()) |
e92a44730a6e
Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25998
diff
changeset
|
146 error ("print: no valid OpenGL offscreen context"); |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
147 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
148 try |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
149 { |
27168
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
150 if (fig.get ("visible").string_value () == "on") |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
151 octave::gl2ps_print (m_glfcns, fig, file_cmd.toStdString (), |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
152 term.toStdString ()); |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
153 else |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
154 { |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
155 // When the figure is not visible, we use a framebuffer object |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
156 // to make sure we are rendering on a suitably large frame. |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
157 Matrix pos = fig.get ("position").matrix_value (); |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
158 double dpr = fig.get ("__device_pixel_ratio__").double_value (); |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
159 pos(2) *= dpr; |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
160 pos(3) *= dpr; |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
161 |
31752
345a3f5890e7
assume QOpenGLWidget is available
John W. Eaton <jwe@octave.org>
parents:
31751
diff
changeset
|
162 QOpenGLFramebufferObject |
27168
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
163 fbo (pos(2), pos(3), |
31752
345a3f5890e7
assume QOpenGLWidget is available
John W. Eaton <jwe@octave.org>
parents:
31751
diff
changeset
|
164 QOpenGLFramebufferObject::Attachment::Depth); |
27168
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
165 |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
166 fbo.bind (); |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
167 |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
168 octave::gl2ps_print (m_glfcns, fig, file_cmd.toStdString (), |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
169 term.toStdString ()); |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
170 |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
171 fbo.release (); |
e6bc258df691
Use framebuffer object for printing invisible Qt figures on mac (bug #55268)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26617
diff
changeset
|
172 } |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
173 } |
27481
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27417
diff
changeset
|
174 catch (octave::execution_exception& ee) |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
175 { |
27303
07b330708e3c
use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents:
27302
diff
changeset
|
176 emit interpreter_event |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
177 ([=] (void) |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
178 { |
27393
efe72866b483
mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents:
27335
diff
changeset
|
179 // INTERPRETER THREAD |
27481
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27417
diff
changeset
|
180 throw ee; |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
181 }); |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
182 } |
26617
98afb8bbd1f6
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
183 |
26277
e92a44730a6e
Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25998
diff
changeset
|
184 end_rendering (); |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
185 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
186 } |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
187 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
188 graphics_object |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
189 GLCanvas::selectFromAxes (const graphics_object& ax, const QPoint& pt) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
190 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
191 makeCurrent (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
193 if (ax) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
194 { |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
195 octave::opengl_selector s (m_glfcns); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 |
25889
2da65009cc7f
Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25884
diff
changeset
|
197 s.set_viewport (width (), height ()); |
24691
b658e0fa0cb3
maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents:
24636
diff
changeset
|
198 return s.select (ax, pt.x (), height () - pt.y (), |
24636
9d01ce02d5cb
Make selection and "HitTest" compatible with Matlab (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24534
diff
changeset
|
199 octave::select_ignore_hittest); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
200 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
202 return graphics_object (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
203 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
205 void |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
206 GLCanvas::drawZoomBox (const QPoint& p1, const QPoint& p2) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
207 { |
25863
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
208 Matrix overlaycolor (3, 1); |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
209 overlaycolor(0) = 0.45; |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
210 overlaycolor(1) = 0.62; |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
211 overlaycolor(2) = 0.81; |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
212 double overlayalpha = 0.1; |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
213 Matrix bordercolor = overlaycolor; |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
214 double borderalpha = 0.9; |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
215 double borderwidth = 1.5; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
25863
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
217 m_renderer.draw_zoom_box (width (), height (), |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
218 p1.x (), p1.y (), p2.x (), p2.y (), |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
219 overlaycolor, overlayalpha, |
8a6bf76abf31
eliminate some duplicate OpenGL drawing code
John W. Eaton <jwe@octave.org>
parents:
25862
diff
changeset
|
220 bordercolor, borderalpha, borderwidth); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
221 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
223 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
224 GLCanvas::paintGL (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
225 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
226 canvasPaintEvent (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
227 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
229 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
230 GLCanvas::mouseDoubleClickEvent (QMouseEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
231 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
232 canvasMouseDoubleClickEvent (xevent); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
233 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19642
diff
changeset
|
234 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
235 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
236 GLCanvas::mouseMoveEvent (QMouseEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
237 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
238 canvasMouseMoveEvent (xevent); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
239 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
241 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
242 GLCanvas::mousePressEvent (QMouseEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
243 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
244 canvasMousePressEvent (xevent); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
245 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
247 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
248 GLCanvas::mouseReleaseEvent (QMouseEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
249 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
250 canvasMouseReleaseEvent (xevent); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
251 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
253 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
254 GLCanvas::wheelEvent (QWheelEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
255 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
256 canvasWheelEvent (xevent); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
257 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19642
diff
changeset
|
258 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
259 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
260 GLCanvas::keyPressEvent (QKeyEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
261 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
262 if (! canvasKeyPressEvent (xevent)) |
31752
345a3f5890e7
assume QOpenGLWidget is available
John W. Eaton <jwe@octave.org>
parents:
31751
diff
changeset
|
263 QOpenGLWidget::keyPressEvent (xevent); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
264 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
266 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
267 GLCanvas::keyReleaseEvent (QKeyEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
268 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
269 if (! canvasKeyReleaseEvent (xevent)) |
31752
345a3f5890e7
assume QOpenGLWidget is available
John W. Eaton <jwe@octave.org>
parents:
31751
diff
changeset
|
270 QOpenGLWidget::keyReleaseEvent (xevent); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
271 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
272 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
273 bool |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
274 GLCanvas::begin_rendering (void) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
275 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
276 bool retval = true; |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25081
diff
changeset
|
277 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
278 if (! isValid ()) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
279 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
280 static bool os_ctx_ok = true; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
281 if (os_ctx_ok && ! m_os_context.isValid ()) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
282 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
283 // Try to initialize offscreen context |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
284 m_os_surface.create (); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
285 if (! m_os_context.create ()) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
286 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
287 os_ctx_ok = false; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
288 return false; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
289 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
290 } |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25081
diff
changeset
|
291 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
292 retval = m_os_context.makeCurrent (&m_os_surface); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
293 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
294 else |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
295 makeCurrent (); |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25081
diff
changeset
|
296 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
297 return retval; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
298 } |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25081
diff
changeset
|
299 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
300 void |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
301 GLCanvas::end_rendering (void) |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25081
diff
changeset
|
302 { |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
303 doneCurrent (); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
304 } |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
305 |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
306 OCTAVE_END_NAMESPACE(octave) |