Mercurial > octave
annotate libgui/graphics/GLCanvas.cc @ 24798:45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
* NEWS: Announce support for printing invisible qt figures without osmesa.
* __opengl_print__.m: Allow invisible figures to be printed with qt if
QOFFSCREENSURFACE is present.
* getframe.m: Allow using __get_frame__ on invisible qt figures if
QOFFSCREENSURFACE is present.
* Backenc.cc (Backend::get_pixels): Don't restrict to visible figures.
* Canvas.h/cc (Canvas::do_print): New pure virtual function
(Canvas::print): Call do_print.
* GLCanvas.h/cc (GLCanvas::begin_rendering): New methods to make sure a valid
OpenGL context is made current before rendering.
(GLCanvas::end_rendering): Call doneCurrent.
(GLCanvas::getPixels): Make use of begin/end_rendering. If the figure is not
visible or its size is frozen, draw on a framebuffer object of suitable size.
(GLCanvas::do_print): Move code for OpenGL printing here. Make use of
begin/end_rendering.
* acinclude.m4: Add test for presence and usability of QOffscreenSurface.
* configure.ac: Allow building the manual with qt if QOffscreenSurface is OK.
* geometryimages.m, interpimages.m, plotimages.m, sparseimages.m,
splineimages.m: Allow using qt toolkit to generate images for the manual when
QOFFSCREENSURFACE is present.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Fri, 23 Feb 2018 14:33:55 +0100 |
parents | b658e0fa0cb3 |
children | ae6679369a80 |
rev | line source |
---|---|
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23215
diff
changeset
|
3 Copyright (C) 2011-2017 Michael Goffioul |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
5 This file is part of Octave. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24142
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22490
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24142
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22490
diff
changeset
|
10 (at your option) any later version. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22490
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22490
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22490
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22490
diff
changeset
|
15 GNU General Public License for more details. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24142
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21692
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
24 # include "config.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #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
|
28 #include "gl2ps-print.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include "graphics.h" |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
30 #include "octave-link.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include "GLCanvas.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "gl-select.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 { |
24142
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
37 #if defined (HAVE_QOPENGLWIDGET) |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
38 # define OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
39 #else |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
40 # if defined (Q_OS_WIN32) |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
41 # define OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS \ |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
42 QGLFormat (QGL::SampleBuffers | QGL::AlphaChannel \ |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
43 | QGL::IndirectRendering), |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
44 # else |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
45 # define OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS \ |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
46 QGLFormat (QGL::SampleBuffers | QGL::AlphaChannel), |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
47 # endif |
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
48 #endif |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
50 GLCanvas::GLCanvas (QWidget *xparent, const graphics_handle& gh) |
24142
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
51 : OCTAVE_QT_OPENGL_WIDGET (OCTAVE_QT_OPENGL_WIDGET_FORMAT_ARGS xparent), |
22490 | 52 Canvas (gh) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
53 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
54 setFocusPolicy (Qt::ClickFocus); |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
55 setFocus (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
56 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
58 GLCanvas::~GLCanvas (void) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22413
diff
changeset
|
59 { } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
61 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
62 GLCanvas::draw (const graphics_handle& gh) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
63 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
64 gh_manager::auto_lock lock; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
65 graphics_object go = gh_manager::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 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
69 octave::opengl_renderer r; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
71 r.set_viewport (width (), height ()); |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
72 r.draw (go); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
73 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
74 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
76 uint8NDArray |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
77 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
|
78 { |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
79 uint8NDArray retval; |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
80 graphics_object go = gh_manager::get_object (gh); |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
81 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
82 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
|
83 { |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
84 Matrix pos = go.get ("position").matrix_value (); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
85 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
86 // 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
|
87 if (! begin_rendering ()) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
88 return retval; |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
89 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
90 // 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
|
91 // 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
|
92 // suitably large frame. |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
93 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
|
94 || 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
|
95 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
96 OCTAVE_QT_OPENGL_FBO |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
97 fbo (pos(2), pos(3),OCTAVE_QT_OPENGL_FBO::Attachment::Depth); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
98 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
99 fbo.bind (); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
100 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
101 octave::opengl_renderer r; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
102 r.set_viewport (pos(2), pos(3)); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
103 r.draw (go); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
104 retval = r.get_pixels (pos(2), pos(3)); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
105 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
106 fbo.release (); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
107 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
108 else |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
109 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
110 octave::opengl_renderer r; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
111 r.set_viewport (pos(2), pos(3)); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
112 r.draw (go); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
113 retval = r.get_pixels (pos(2), pos(3)); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
114 } |
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 end_rendering (); |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
117 } |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
118 |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
119 return retval; |
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
120 } |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
121 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
122 void |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
123 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
|
124 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
|
125 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
126 gh_manager::auto_lock lock; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
127 graphics_object obj = gh_manager::get_object (handle); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
128 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
129 if (obj.valid_object ()) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
130 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
131 graphics_object figObj (obj.get_ancestor ("figure")); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
132 try |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
133 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
134 // 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
|
135 if (! begin_rendering ()) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
136 error ("print: no valid OpenGL offscreen context"); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
137 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
138 octave::gl2ps_print (figObj, file_cmd.toStdString (), |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
139 term.toStdString ()); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
140 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
141 catch (octave::execution_exception e) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
142 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
143 octave_link::post_exception (std::current_exception ()); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
144 end_rendering (); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
145 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
146 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
147 } |
23535
2aab625b502c
Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23449
diff
changeset
|
148 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
149 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
150 GLCanvas::toggleAxes (const graphics_handle& gh) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
151 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
152 canvasToggleAxes (gh); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
153 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19642
diff
changeset
|
154 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
155 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
156 GLCanvas::toggleGrid (const graphics_handle& gh) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
157 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
158 canvasToggleGrid (gh); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
159 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19642
diff
changeset
|
160 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
161 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
162 GLCanvas::autoAxes (const graphics_handle& gh) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
163 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
164 canvasAutoAxes (gh); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
165 } |
19870
815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
John W. Eaton <jwe@octave.org>
parents:
19663
diff
changeset
|
166 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
167 graphics_object |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
168 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
|
169 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
170 makeCurrent (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
172 if (ax) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
173 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
174 octave::opengl_selector s; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
176 s.set_viewport (width (), height ()); |
24691
b658e0fa0cb3
maint: Remove trailing whitespace from files.
Rik <rik@octave.org>
parents:
24636
diff
changeset
|
177 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
|
178 octave::select_ignore_hittest); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
179 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
181 return graphics_object (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
182 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
184 inline void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
185 glDrawZoomBox (const QPoint& p1, const QPoint& p2) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
186 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
187 glVertex2d (p1.x (), p1.y ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
188 glVertex2d (p2.x (), p1.y ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
189 glVertex2d (p2.x (), p2.y ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
190 glVertex2d (p1.x (), p2.y ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
191 glVertex2d (p1.x (), p1.y ()); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
192 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
194 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
195 GLCanvas::drawZoomBox (const QPoint& p1, const QPoint& p2) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
196 { |
23215
0842b119dc1b
Fix opengl "invalid operation" when zooming (bug #50317)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23083
diff
changeset
|
197 glMatrixMode (GL_MODELVIEW); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
198 glPushMatrix (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
199 glLoadIdentity (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
201 glMatrixMode (GL_PROJECTION); |
23215
0842b119dc1b
Fix opengl "invalid operation" when zooming (bug #50317)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23083
diff
changeset
|
202 glPushMatrix (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
203 glLoadIdentity (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
204 glOrtho (0, width (), height (), 0, 1, -1); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
206 glPushAttrib (GL_DEPTH_BUFFER_BIT | GL_CURRENT_BIT); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
207 glDisable (GL_DEPTH_TEST); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
209 glBegin (GL_POLYGON); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
210 glColor4f (0.45, 0.62, 0.81, 0.1); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
211 glDrawZoomBox (p1, p2); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
212 glEnd (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 |
23215
0842b119dc1b
Fix opengl "invalid operation" when zooming (bug #50317)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23083
diff
changeset
|
214 glLineWidth (1.5); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
215 glBegin (GL_LINE_STRIP); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
216 glColor4f (0.45, 0.62, 0.81, 0.9); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
217 glDrawZoomBox (p1, p2); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
218 glEnd (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
220 glPopAttrib (); |
23215
0842b119dc1b
Fix opengl "invalid operation" when zooming (bug #50317)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23083
diff
changeset
|
221 |
0842b119dc1b
Fix opengl "invalid operation" when zooming (bug #50317)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23083
diff
changeset
|
222 glMatrixMode (GL_MODELVIEW); |
0842b119dc1b
Fix opengl "invalid operation" when zooming (bug #50317)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23083
diff
changeset
|
223 glPopMatrix (); |
0842b119dc1b
Fix opengl "invalid operation" when zooming (bug #50317)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23083
diff
changeset
|
224 |
0842b119dc1b
Fix opengl "invalid operation" when zooming (bug #50317)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23083
diff
changeset
|
225 glMatrixMode (GL_PROJECTION); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
226 glPopMatrix (); |
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 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
230 GLCanvas::paintGL (void) |
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 canvasPaintEvent (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
233 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
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::mouseDoubleClickEvent (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 canvasMouseDoubleClickEvent (xevent); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
239 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19642
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::mouseMoveEvent (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 canvasMouseMoveEvent (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::mousePressEvent (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 canvasMousePressEvent (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::mouseReleaseEvent (QMouseEvent *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 canvasMouseReleaseEvent (xevent); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
257 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
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::wheelEvent (QWheelEvent *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 canvasWheelEvent (xevent); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
263 } |
19663
dfea01b3425f
more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents:
19642
diff
changeset
|
264 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
265 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
266 GLCanvas::keyPressEvent (QKeyEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
267 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
268 if (! canvasKeyPressEvent (xevent)) |
24142
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
269 OCTAVE_QT_OPENGL_WIDGET::keyPressEvent (xevent); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
270 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
272 void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
273 GLCanvas::keyReleaseEvent (QKeyEvent *xevent) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
274 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
275 if (! canvasKeyReleaseEvent (xevent)) |
24142
59cdf06c940e
use QOpenGLWidget if it is available
John W. Eaton <jwe@octave.org>
parents:
23535
diff
changeset
|
276 OCTAVE_QT_OPENGL_WIDGET::keyReleaseEvent (xevent); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
277 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 |
24798
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
279 bool |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
280 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
|
281 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
282 bool retval = true; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
283 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
284 if (! isValid ()) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
285 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
286 # if defined (HAVE_QOFFSCREENSURFACE) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
287 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
|
288 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
|
289 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
290 // 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
|
291 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
|
292 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
|
293 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
294 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
|
295 return false; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
296 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
297 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
298 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
299 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
|
300 # else |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
301 retval = false; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
302 # endif |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
303 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
304 else |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
305 makeCurrent (); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
306 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
307 return retval; |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
308 } |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
309 |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
310 void |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
311 GLCanvas::end_rendering (void) |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
312 { |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
313 doneCurrent (); |
45470049a43f
Allow getframe and print to work without osmesa (bug #53186).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
24691
diff
changeset
|
314 } |
22413
8758addcf265
maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
315 } |