annotate libgui/graphics/qt-graphics-toolkit.h @ 31644:9089bd969b37 stable

merge adjacent octave namespace blocks in libgui/graphics header files * BaseControl.h, ButtonControl.h, ButtonGroup.h, Canvas.h, CheckBoxControl.h, ContextMenu.h, EditControl.h, Figure.h, GLCanvas.h, ListBoxControl.h, Menu.h, Object.h, Panel.h, PopupMenuControl.h, PushButtonControl.h, PushTool.h, RadioButtonControl.h, SliderControl.h, Table.h, TextControl.h, ToggleButtonControl.h, ToggleTool.h, ToolBar.h, ToolBarButton.h, qt-graphics-toolkit.h: Merge adjacent octave namespace blocks.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Dec 2022 14:23:21 -0500
parents 796f54d4ddbf
children bd9da634f00d c6d54dd31a7e
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: 29992
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
27317
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
26 #if ! defined (octave_qt_graphics_toolkit_h)
718116e9c7d3 rename Backend to qt_graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 27316
diff changeset
27 #define octave_qt_graphics_toolkit_h 1
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <QObject>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
31 #include "event-manager.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "graphics.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
34 namespace octave
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
35 {
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
36 class interpreter;
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
37 class base_qobject;
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
38
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
39 class Object;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
40 class ObjectProxy;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41
28954
e4f767de937a Avoid warning about deprecated base_graphics_toolkit.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
42 class qt_graphics_toolkit
e4f767de937a Avoid warning about deprecated base_graphics_toolkit.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
43 : public QObject, public octave::base_graphics_toolkit
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
44 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
45 Q_OBJECT
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
47 public:
27316
22265a75be74 eliminate static instance of Qt graphics ObjectFactory class
John W. Eaton <jwe@octave.org>
parents: 27303
diff changeset
48
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
49 qt_graphics_toolkit (octave::interpreter& interp,
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
50 octave::base_qobject& oct_qobj);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
52 ~qt_graphics_toolkit (void) = default;
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
53
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
54 // The interpreter may call graphics toolkit functions that we
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
55 // implement here. The Qt GUI that manages these actions runs in a
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
56 // separate thread. So in order to correctly cross from the
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
57 // interpreter thread to the GUI thread, these functions should emit
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
58 // signals (in the interpreter thread) that are handled by slots
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
59 // that will run in the GUI thread. This design is similar to the
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
60 // event_manager, interpreter_events, and qt_interpreter_events
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
61 // classes work to pass messages from the interpreter to the GUI.
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
62 //
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
63 // FIXME: currently most of these functions do not emit signals.
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
64 // They may work because they use locking and the gh_manager class,
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
65 // but it might be better to use Qt signals and slots. In any case,
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
66 // we should ensure that they are correctly handling the connection
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
67 // between the interpreter and GUI threads.
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: 22323
diff changeset
69 bool is_valid (void) const { return true; }
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: 22323
diff changeset
71 void redraw_figure (const graphics_object& h) const;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
25799
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
73 void show_figure (const graphics_object& h) const;
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
74
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
75 void update (const graphics_object& obj, int pId);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
77 bool initialize (const graphics_object& obj);
18498
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: 22323
diff changeset
79 void finalize (const graphics_object& obj);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
81 void print_figure (const graphics_object& go,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
82 const std::string& term,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
83 const std::string& file_cmd,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
84 const std::string& /*debug_file*/) const;
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 19595
diff changeset
85
23535
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
86 uint8NDArray get_pixels (const graphics_object& go) const;
2aab625b502c Add getframe function for opengl based toolkits (bug #48195)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 23449
diff changeset
87
27254
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
88 Matrix get_text_extent (const graphics_object& go) const;
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
89
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
90 static Object * toolkitObject (const graphics_object& go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
92 static ObjectProxy * toolkitObjectProxy (const graphics_object& go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
94 signals:
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
95
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
96 void create_object_signal (double handle);
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
97
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
98 public slots:
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
99
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
100 void interpreter_event (const octave::fcn_callback& fcn);
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
101 void interpreter_event (const octave::meth_callback& meth);
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
102
27318
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
103 void create_object (double handle);
ae53e56e16f2 eliminate separate ObjectFactory class in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27317
diff changeset
104
27319
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
105 void gh_callback_event (const graphics_handle& h, const std::string& name);
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
106
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
107 void gh_callback_event (const graphics_handle& h, const std::string& name,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
108 const octave_value& data);
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
109
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
110 void gh_set_event (const graphics_handle& h, const std::string& name,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
111 const octave_value& value);
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
112
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
113 void gh_set_event (const graphics_handle& h, const std::string& name,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
114 const octave_value& value, bool notify_toolkit);
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
115
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
116 void gh_set_event (const graphics_handle& h, const std::string& name,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
117 const octave_value& value, bool notify_toolkit,
6b2d20317b26 use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27318
diff changeset
118 bool redraw_figure);
27303
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
119 private:
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
120
07b330708e3c use Qt signals for interpreter callbacks in Qt graphics toolkit
John W. Eaton <jwe@octave.org>
parents: 27254
diff changeset
121 octave::interpreter& m_interpreter;
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
122
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27319
diff changeset
123 octave::base_qobject& m_octave_qobj;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
124 };
22413
8758addcf265 maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents: 22411
diff changeset
125 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126
19595
be7ac98fab43 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18501
diff changeset
127 #endif