Mercurial > octave
annotate libgui/graphics/gl-select.cc @ 29358:0a5b15007766 stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 09:52:15 -0500 |
parents | bd51beb6205e |
children | 796f54d4ddbf |
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 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 // Copyright (C) 2011-2021 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:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21209
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 |
21196
bd96c2efd4fe
move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents:
20519
diff
changeset
|
30 #include "gl-select.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 |
22326
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
32 namespace octave |
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
33 { |
71dd9d5a5ecd
move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
34 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
35 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
36 opengl_selector::apply_pick_matrix (void) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
37 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
38 GLdouble p_matrix[16]; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
40 m_glfcns.glGetDoublev (GL_PROJECTION_MATRIX, p_matrix); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
41 m_glfcns.glMatrixMode (GL_PROJECTION); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
42 m_glfcns.glLoadIdentity (); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
43 |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
44 // The following block is equivalent to gluPickMatrix, but we avoid |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
45 // using glu functions so that we can call OpenGL functions through |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
46 // the QOpenGLFunctions class so that the OpenGL implementation may |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
47 // be selected dynamically. |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
48 |
25889
2da65009cc7f
Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25862
diff
changeset
|
49 Matrix viewport = get_viewport_scaled (); |
2da65009cc7f
Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25862
diff
changeset
|
50 |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
51 if (size > 0) |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
52 { |
25889
2da65009cc7f
Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25862
diff
changeset
|
53 m_glfcns.glTranslatef ((viewport(2) - 2 * (xp - viewport(0))) / size, |
2da65009cc7f
Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25862
diff
changeset
|
54 (viewport(3) - 2 * (yp - viewport(1))) / size, 0); |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
55 |
25889
2da65009cc7f
Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25862
diff
changeset
|
56 m_glfcns.glScalef (viewport(2) / size, viewport(3) / size, 1.0); |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
57 } |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
58 |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
59 m_glfcns.glMultMatrixd (p_matrix); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
60 m_glfcns.glMatrixMode (GL_MODELVIEW); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
61 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
63 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
64 opengl_selector::setup_opengl_transformation (const axes::properties& props) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
65 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
66 opengl_renderer::setup_opengl_transformation (props); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
67 apply_pick_matrix (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
68 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
70 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
71 opengl_selector::init_marker (const std::string& m, double sz, float width) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
72 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
73 opengl_renderer::init_marker (m, sz, width); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
74 apply_pick_matrix (); |
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 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 # define BUFFER_SIZE 128 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
79 graphics_object |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
80 opengl_selector::select (const graphics_object& ax, int x, int y, int flags) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
81 { |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
82 m_glfcns.glEnable (GL_DEPTH_TEST); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
83 m_glfcns.glDepthFunc (GL_LEQUAL); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
84 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
85 xp = x; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
86 yp = y; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
88 GLuint select_buffer[BUFFER_SIZE]; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
89 |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
90 m_glfcns.glSelectBuffer (BUFFER_SIZE, select_buffer); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
91 m_glfcns.glRenderMode (GL_SELECT); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
92 m_glfcns.glInitNames (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
93 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
94 object_map.clear (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
95 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
96 draw (ax); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
98 int hits = m_glfcns.glRenderMode (GL_RENDER); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
99 graphics_object obj; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
100 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
101 if (hits > 0) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
102 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
103 GLuint current_minZ = 0xffffffff; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
104 GLuint current_name = 0xffffffff; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
106 for (int i = 0, j = 0; i < hits && j < BUFFER_SIZE-3; i++) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
107 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
108 GLuint n = select_buffer[j++], |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
109 minZ = select_buffer[j++]; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
111 j++; // skip maxZ |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
112 if (((flags & select_last) == 0 && (minZ <= current_minZ)) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
113 || ((flags & select_last) != 0 && (minZ >= current_minZ))) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
114 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
115 bool candidate = true; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
116 GLuint name = |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
117 select_buffer[std::min (j + n, GLuint (BUFFER_SIZE)) - 1]; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
119 if ((flags & select_ignore_hittest) == 0) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
120 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
121 graphics_object go = object_map[name]; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
122 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
123 if (! go.get_properties ().is_hittest ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
124 candidate = false; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
125 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
127 if (candidate) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
128 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
129 current_minZ = minZ; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
130 current_name = name; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
131 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
132 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
133 j += n; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
134 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
135 else |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
136 j += n; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
137 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
139 if (current_name != 0xffffffff) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
140 obj = object_map[current_name]; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
141 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
142 else if (hits < 0) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
143 warning ("opengl_selector::select: selection buffer overflow"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
144 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
145 object_map.clear (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
146 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
147 return obj; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
148 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
150 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
151 opengl_selector::draw (const graphics_object& go, bool toplevel) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
152 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
153 GLuint name = object_map.size (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
154 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
155 object_map[name] = go; |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
156 m_glfcns.glPushName (name); |
24523
501986e12b8b
Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23577
diff
changeset
|
157 set_selecting (true); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
158 opengl_renderer::draw (go, toplevel); |
24523
501986e12b8b
Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23577
diff
changeset
|
159 set_selecting (false); |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
160 m_glfcns.glPopName (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
161 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
163 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
164 opengl_selector::fake_text (double x, double y, double z, const Matrix& bbox, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
165 bool use_scale) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
166 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
167 ColumnVector xpos, xp1, xp2; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
168 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
169 xpos = get_transform ().transform (x, y, z, use_scale); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
171 xp1 = xp2 = xpos; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
172 xp1(0) += bbox(0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
173 xp1(1) -= bbox(1); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
174 xp2(0) += (bbox(0) + bbox(2)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
175 xp2(1) -= (bbox(1) + bbox(3)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
176 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
177 ColumnVector p1, p2, p3, p4; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
179 p1 = get_transform ().untransform (xp1(0), xp1(1), xp1(2), false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
180 p2 = get_transform ().untransform (xp2(0), xp1(1), xp1(2), false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
181 p3 = get_transform ().untransform (xp2(0), xp2(1), xp1(2), false); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
182 p4 = get_transform ().untransform (xp1(0), xp2(1), xp1(2), false); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
184 m_glfcns.glBegin (GL_QUADS); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
185 m_glfcns.glVertex3dv (p1.data ()); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
186 m_glfcns.glVertex3dv (p2.data ()); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
187 m_glfcns.glVertex3dv (p3.data ()); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
188 m_glfcns.glVertex3dv (p4.data ()); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
189 m_glfcns.glEnd (); |
22411
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 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
192 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
193 opengl_selector::draw_text (const text::properties& props) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
194 { |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
195 if (props.get_string ().isempty ()) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
196 return; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
197 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
198 Matrix pos = props.get_data_position (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
199 const Matrix bbox = props.get_extent_matrix (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
200 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
201 fake_text (pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0, bbox); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
202 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
204 Matrix |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
205 opengl_selector::render_text (const std::string& txt, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
206 double x, double y, double z, |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
207 int halign, int valign, double rotation) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
208 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
209 uint8NDArray pixels; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
210 Matrix bbox (1, 4, 0.0); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
212 // FIXME: probably more efficient to only compute bbox instead |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
213 // of doing full text rendering... |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
214 text_to_pixels (txt, pixels, bbox, halign, valign, rotation); |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
215 fake_text (x, y, z, bbox, false); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
216 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
217 return bbox; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
218 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
219 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
220 void |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
221 opengl_selector::draw_image (const image::properties& props) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
222 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
223 Matrix xd = props.get_xdata ().matrix_value (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
224 octave_idx_type nc = props.get_cdata ().columns (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
225 double x_pix_size = (nc == 1 ? 1 : (xd(1) - xd(0)) / (nc - 1)); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
227 Matrix yd = props.get_ydata ().matrix_value (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
228 octave_idx_type nr = props.get_cdata ().rows (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
229 double y_pix_size = (nr == 1 ? 1 : (yd(1) - yd(0)) / (nr - 1)); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
230 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
231 ColumnVector p1(3, 0.0), p2(3, 0.0), p3(3, 0.0), p4(3, 0.0); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
232 p1(0) = xd(0) - x_pix_size/2; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
233 p1(1) = yd(0) - y_pix_size/2; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
234 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
235 p2(0) = xd(1) + x_pix_size/2; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
236 p2(1) = yd(0) - y_pix_size/2; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
238 p3(0) = xd(1) + x_pix_size/2; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
239 p3(1) = yd(1) + y_pix_size/2; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
240 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
241 p4(0) = xd(0) - x_pix_size/2; |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
242 p4(1) = yd(1) + y_pix_size/2; |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 |
25862
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
244 m_glfcns.glBegin (GL_QUADS); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
245 m_glfcns.glVertex3dv (p1.data ()); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
246 m_glfcns.glVertex3dv (p2.data ()); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
247 m_glfcns.glVertex3dv (p3.data ()); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
248 m_glfcns.glVertex3dv (p4.data ()); |
e5a73a8c116c
use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
249 m_glfcns.glEnd (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22326
diff
changeset
|
250 } |
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 } |