annotate libgui/graphics/gl-select.cc @ 31646:c6d54dd31a7e stable

maint: Use macros to begin/end C++ namespaces. * BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, KeyMap.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, Object.cc, Object.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, Table.cc, Table.h, TextControl.cc, TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, annotation-dialog.cc, annotation-dialog.h, gl-select.cc, gl-select.h, qopengl-functions.h, qt-graphics-toolkit.cc, qt-graphics-toolkit.h, QTerminal.h, color-picker.cc, color-picker.h, command-widget.cc, command-widget.h, community-news.cc, community-news.h, dialog.cc, dialog.h, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.cc, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.cc, dw-main-window.h, external-editor-interface.cc, external-editor-interface.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h, find-files-model.cc, find-files-model.h, graphics-init.cc, graphics-init.h, gui-settings.cc, gui-settings.h, gui-utils.cc, gui-utils.h, history-dock-widget.cc, history-dock-widget.h, interpreter-qobject.cc, interpreter-qobject.h, led-indicator.cc, led-indicator.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc, main-window.h, news-reader.cc, news-reader.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, qt-application.cc, qt-application.h, qt-interpreter-events.cc, qt-interpreter-events.h, qt-utils.h, release-notes.cc, release-notes.h, resource-manager.cc, resource-manager.h, set-path-dialog.cc, set-path-dialog.h, set-path-model.cc, set-path-model.h, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, tab-bar.cc, tab-bar.h, terminal-dock-widget.cc, terminal-dock-widget.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h: Use new macros to begin/end C++ namespaces.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Dec 2022 14:37:51 -0500
parents 796f54d4ddbf
children 29d734430e5f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3 // Copyright (C) 2011-2022 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
31646
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
32 OCTAVE_BEGIN_NAMESPACE(octave)
22326
71dd9d5a5ecd move more new classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
33
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
34 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
35 opengl_selector::apply_pick_matrix (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
36 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
37 GLdouble p_matrix[16];
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38
25862
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
39 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
40 m_glfcns.glMatrixMode (GL_PROJECTION);
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
41 m_glfcns.glLoadIdentity ();
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
42
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
43 // 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
44 // 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
45 // 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
46 // be selected dynamically.
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
47
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25862
diff changeset
48 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
49
25862
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
50 if (size > 0)
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
51 {
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25862
diff changeset
52 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
53 (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
54
25889
2da65009cc7f Fix graphics object selection on high resolution screens (bug #49053)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25862
diff changeset
55 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
56 }
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 m_glfcns.glMultMatrixd (p_matrix);
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
59 m_glfcns.glMatrixMode (GL_MODELVIEW);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
60 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
62 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
63 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
64 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
65 opengl_renderer::setup_opengl_transformation (props);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
66 apply_pick_matrix ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
67 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
69 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
70 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
71 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
72 opengl_renderer::init_marker (m, sz, width);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
73 apply_pick_matrix ();
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
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 # define BUFFER_SIZE 128
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
78 graphics_object
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
79 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
80 {
25862
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
81 m_glfcns.glEnable (GL_DEPTH_TEST);
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
82 m_glfcns.glDepthFunc (GL_LEQUAL);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
83
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
84 xp = x;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
85 yp = y;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
87 GLuint select_buffer[BUFFER_SIZE];
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
88
25862
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
89 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
90 m_glfcns.glRenderMode (GL_SELECT);
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
91 m_glfcns.glInitNames ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
92
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
93 object_map.clear ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
94
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
95 draw (ax);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
25862
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
97 int hits = m_glfcns.glRenderMode (GL_RENDER);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
98 graphics_object obj;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
99
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
100 if (hits > 0)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
101 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
102 GLuint current_minZ = 0xffffffff;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
103 GLuint current_name = 0xffffffff;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
105 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
106 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
107 GLuint n = select_buffer[j++],
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
108 minZ = select_buffer[j++];
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
110 j++; // skip maxZ
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
111 if (((flags & select_last) == 0 && (minZ <= current_minZ))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
112 || ((flags & select_last) != 0 && (minZ >= current_minZ)))
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
113 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
114 bool candidate = true;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
115 GLuint name =
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
116 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
117
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
118 if ((flags & select_ignore_hittest) == 0)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
119 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
120 graphics_object go = object_map[name];
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
121
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
122 if (! go.get_properties ().is_hittest ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
123 candidate = false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
124 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
126 if (candidate)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
127 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
128 current_minZ = minZ;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
129 current_name = name;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
130 }
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 j += n;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
133 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
134 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
135 j += n;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
136 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
138 if (current_name != 0xffffffff)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
139 obj = object_map[current_name];
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
140 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
141 else if (hits < 0)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
142 warning ("opengl_selector::select: selection buffer overflow");
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
143
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
144 object_map.clear ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
145
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
146 return obj;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
147 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
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 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
151 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
152 GLuint name = object_map.size ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
153
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
154 object_map[name] = go;
25862
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
155 m_glfcns.glPushName (name);
24523
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23577
diff changeset
156 set_selecting (true);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
157 opengl_renderer::draw (go, toplevel);
24523
501986e12b8b Implement "pickableparts" property (bug #52795).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23577
diff changeset
158 set_selecting (false);
25862
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
159 m_glfcns.glPopName ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
160 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
162 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
163 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
164 bool use_scale)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
165 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
166 ColumnVector xpos, xp1, xp2;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
167
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
168 xpos = get_transform ().transform (x, y, z, use_scale);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
169
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
170 xp1 = xp2 = xpos;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
171 xp1(0) += bbox(0);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
172 xp1(1) -= bbox(1);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
173 xp2(0) += (bbox(0) + bbox(2));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
174 xp2(1) -= (bbox(1) + bbox(3));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
175
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
176 ColumnVector p1, p2, p3, p4;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
178 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
179 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
180 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
181 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
182
25862
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
183 m_glfcns.glBegin (GL_QUADS);
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
184 m_glfcns.glVertex3dv (p1.data ());
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
185 m_glfcns.glVertex3dv (p2.data ());
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
186 m_glfcns.glVertex3dv (p3.data ());
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
187 m_glfcns.glVertex3dv (p4.data ());
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
188 m_glfcns.glEnd ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
189 }
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 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
192 opengl_selector::draw_text (const text::properties& props)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
193 {
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23220
diff changeset
194 if (props.get_string ().isempty ())
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
195 return;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
196
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
197 Matrix pos = props.get_data_position ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
198 const Matrix bbox = props.get_extent_matrix ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
199
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
200 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
201 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
203 Matrix
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
204 opengl_selector::render_text (const std::string& txt,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
205 double x, double y, double z,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
206 int halign, int valign, double rotation)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
207 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
208 uint8NDArray pixels;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
209 Matrix bbox (1, 4, 0.0);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
210
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
211 // 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
212 // of doing full text rendering...
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
213 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
214 fake_text (x, y, z, bbox, false);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
215
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
216 return bbox;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
217 }
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 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
220 opengl_selector::draw_image (const image::properties& props)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
221 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
222 Matrix xd = props.get_xdata ().matrix_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
223 octave_idx_type nc = props.get_cdata ().columns ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
224 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
225
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
226 Matrix yd = props.get_ydata ().matrix_value ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
227 octave_idx_type nr = props.get_cdata ().rows ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
228 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
229
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
230 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
231 p1(0) = xd(0) - x_pix_size/2;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
232 p1(1) = yd(0) - y_pix_size/2;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
233
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
234 p2(0) = xd(1) + x_pix_size/2;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
235 p2(1) = yd(0) - y_pix_size/2;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
236
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
237 p3(0) = xd(1) + x_pix_size/2;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
238 p3(1) = yd(1) + y_pix_size/2;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
239
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
240 p4(0) = xd(0) - x_pix_size/2;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22326
diff changeset
241 p4(1) = yd(1) + y_pix_size/2;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
242
25862
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
243 m_glfcns.glBegin (GL_QUADS);
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
244 m_glfcns.glVertex3dv (p1.data ());
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
245 m_glfcns.glVertex3dv (p2.data ());
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
246 m_glfcns.glVertex3dv (p3.data ());
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
247 m_glfcns.glVertex3dv (p4.data ());
e5a73a8c116c use wrapper class to call OpenGL functions
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
248 m_glfcns.glEnd ();
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
31646
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
251 OCTAVE_END_NAMESPACE(octave)