GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
qt-graphics-toolkit.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2011-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_qt_graphics_toolkit_h)
27 #define octave_qt_graphics_toolkit_h 1
28 
29 #include <QObject>
30 
31 #include "event-manager.h"
32 #include "graphics.h"
33 
34 namespace octave
35 {
36  class interpreter;
37  class base_qobject;
38 }
39 
40 namespace QtHandles
41 {
42  class Object;
43  class ObjectProxy;
44 
46  : public QObject, public octave::base_graphics_toolkit
47  {
48  Q_OBJECT
49 
50  public:
51 
53  octave::base_qobject& oct_qobj);
54 
55  ~qt_graphics_toolkit (void) = default;
56 
57  // The interpreter may call graphics toolkit functions that we
58  // implement here. The Qt GUI that manages these actions runs in a
59  // separate thread. So in order to correctly cross from the
60  // interpreter thread to the GUI thread, these functions should emit
61  // signals (in the interpreter thread) that are handled by slots
62  // that will run in the GUI thread. This design is similar to the
63  // event_manager, interpreter_events, and qt_interpreter_events
64  // classes work to pass messages from the interpreter to the GUI.
65  //
66  // FIXME: currently most of these functions do not emit signals.
67  // They may work because they use locking and the gh_manager class,
68  // but it might be better to use Qt signals and slots. In any case,
69  // we should ensure that they are correctly handling the connection
70  // between the interpreter and GUI threads.
71 
72  bool is_valid (void) const { return true; }
73 
74  void redraw_figure (const graphics_object& h) const;
75 
76  void show_figure (const graphics_object& h) const;
77 
78  void update (const graphics_object& obj, int pId);
79 
80  bool initialize (const graphics_object& obj);
81 
82  void finalize (const graphics_object& obj);
83 
84  void print_figure (const graphics_object& go,
85  const std::string& term,
86  const std::string& file_cmd,
87  const std::string& /*debug_file*/) const;
88 
89  uint8NDArray get_pixels (const graphics_object& go) const;
90 
91  Matrix get_text_extent (const graphics_object& go) const;
92 
93  static Object * toolkitObject (const graphics_object& go);
94 
95  static ObjectProxy * toolkitObjectProxy (const graphics_object& go);
96 
97  signals:
98 
99  void create_object_signal (double handle);
100 
101  public slots:
102 
103  void interpreter_event (const octave::fcn_callback& fcn);
104  void interpreter_event (const octave::meth_callback& meth);
105 
106  void create_object (double handle);
107 
108  void gh_callback_event (const graphics_handle& h, const std::string& name);
109 
110  void gh_callback_event (const graphics_handle& h, const std::string& name,
111  const octave_value& data);
112 
113  void gh_set_event (const graphics_handle& h, const std::string& name,
114  const octave_value& value);
115 
116  void gh_set_event (const graphics_handle& h, const std::string& name,
117  const octave_value& value, bool notify_toolkit);
118 
119  void gh_set_event (const graphics_handle& h, const std::string& name,
120  const octave_value& value, bool notify_toolkit,
121  bool redraw_figure);
122  private:
123 
125 
127  };
128 }
129 
130 #endif
Definition: dMatrix.h:42
void print_figure(const graphics_object &go, const std::string &term, const std::string &file_cmd, const std::string &) const
void create_object_signal(double handle)
void gh_set_event(const graphics_handle &h, const std::string &name, const octave_value &value)
void show_figure(const graphics_object &h) const
static ObjectProxy * toolkitObjectProxy(const graphics_object &go)
octave::interpreter & m_interpreter
octave::base_qobject & m_octave_qobj
void gh_callback_event(const graphics_handle &h, const std::string &name)
static Object * toolkitObject(const graphics_object &go)
void finalize(const graphics_object &obj)
void update(const graphics_object &obj, int pId)
void redraw_figure(const graphics_object &h) const
void interpreter_event(const octave::fcn_callback &fcn)
Matrix get_text_extent(const graphics_object &go) const
uint8NDArray get_pixels(const graphics_object &go) const
bool initialize(const graphics_object &obj)
qt_graphics_toolkit(octave::interpreter &interp, octave::base_qobject &oct_qobj)
Base class for Octave interfaces that use Qt.
QString name
std::function< void(octave::interpreter &)> meth_callback
Definition: event-manager.h:47
std::function< void(void)> fcn_callback
Definition: event-manager.h:46