GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
graphics-init.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2019-2023 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 (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <QApplication>
31 #include <QMetaType>
32 #include <QThread>
33 
34 #include "graphics-init.h"
35 #include "octave-qobject.h"
36 #include "qt-graphics-toolkit.h"
37 #include "QtHandlesUtils.h"
38 
39 #include "graphics.h"
40 #include "gtk-manager.h"
41 #include "interpreter.h"
42 
44 
45 void graphics_init (interpreter& interp, base_qobject& oct_qobj)
46 {
47 #if defined (HAVE_QT_GRAPHICS)
48 
49  gh_manager& gh_mgr = interp.get_gh_manager ();
50 
51  autolock guard (gh_mgr.graphics_lock ());
52 
53  qRegisterMetaType<graphics_object> ("graphics_object");
54 
55  gh_mgr.enable_event_processing (true);
56 
57  qt_graphics_toolkit *qt_gtk = new qt_graphics_toolkit (interp, oct_qobj);
58 
59  if (QThread::currentThread ()
60  != QApplication::instance ()->thread ())
61  qt_gtk->moveToThread (QApplication::instance ()->thread ());
62 
63  graphics_toolkit tk (qt_gtk);
64 
65  gtk_manager& gtk_mgr = interp.get_gtk_manager ();
66 
67  gtk_mgr.register_toolkit ("qt");
68 
69  gtk_mgr.load_toolkit (tk);
70 
71 #else
72 
73  octave_unused_parameter (interp);
74  octave_unused_parameter (oct_qobj);
75 
76 #endif
77 }
78 
OCTAVE_END_NAMESPACE(octave)
Base class for Octave interfaces that use Qt.
void register_toolkit(const std::string &name)
Definition: gtk-manager.cc:74
void load_toolkit(const graphics_toolkit &tk)
Definition: gtk-manager.h:57
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void graphics_init(interpreter &interp, base_qobject &oct_qobj)