26#if defined (HAVE_CONFIG_H)
32#include <QApplication>
33#include <QFontMetrics>
71# define OCTAVE_PTR_TYPE octave_uint64
72# define OCTAVE_INTPTR_TYPE uint64_t
73# define OCTAVE_PTR_SCALAR uint64_scalar_value
82 if (go.isa (
"figure"))
83 return "__plot_stream__";
84 else if (go.isa (
"uicontrol")
86 || go.isa (
"uibuttongroup")
88 || go.isa (
"uicontextmenu")
90 || go.isa (
"uitoolbar")
91 || go.isa (
"uipushtool")
92 || go.isa (
"uitoggletool"))
95 qCritical (
"octave::qt_graphics_toolkit: no __object__ property known for object "
96 "of type %s", go.type ().c_str ());
104 m_octave_qobj (oct_qobj)
117 Qt::BlockingQueuedConnection);
123 if (go.isa (
"figure")
124 || (go.isa (
"uicontrol") && go.get (
"style").string_value () !=
"frame")
125 || go.isa (
"uipanel")
126 || go.isa (
"uibuttongroup")
128 || go.isa (
"uicontextmenu")
129 || go.isa (
"uitable")
130 || go.isa (
"uitoolbar")
131 || go.isa (
"uipushtool")
132 || go.isa (
"uitoggletool"))
142 Logger::debug (
"qt_graphics_toolkit::initialize %s from thread %p",
143 go.type ().c_str (), QThread::currentThreadId ());
146 graphics_object gObj (go);
163 if (pId == figure::properties::ID___PLOT_STREAM__
164 || pId == uicontrol::properties::ID___OBJECT__
165 || pId == uipanel::properties::ID___OBJECT__
166 || pId == uibuttongroup::properties::ID___OBJECT__
167 || pId == uimenu::properties::ID___OBJECT__
168 || pId == uicontextmenu::properties::ID___OBJECT__
169 || pId == uitable::properties::ID___OBJECT__
170 || pId == uitoolbar::properties::ID___OBJECT__
171 || pId == uipushtool::properties::ID___OBJECT__
172 || pId == uitoggletool::properties::ID___OBJECT__
173 || pId == base_properties::ID___MODIFIED__)
176 Logger::debug (
"qt_graphics_toolkit::update %s(%d) from thread %p",
177 go.type ().c_str (), pId, QThread::currentThreadId ());
183 if (go.isa (
"uicontrol")
184 && pId == uicontrol::properties::ID_STYLE)
208 Logger::debug (
"qt_graphics_toolkit::finalize %s from thread %p",
209 go.type ().c_str (), QThread::currentThreadId ());
218 graphics_object gObj (go);
227 if (go.get_properties ().is_visible ())
239 if (go.get_properties ().is_visible ())
250 const std::string& term,
251 const std::string& file_cmd,
252 const std::string& )
const
266 if (go.isa (
"figure"))
282 if (go.isa (
"uicontrol"))
289 Matrix bb = up.get_boundingbox (
false);
291 QFontMetrics fm (font);
299 sz = fm.size (Qt::TextSingleLine, s);
300 ext(2) = sz.width ();
301 ext(3) = sz.height ();
311 sz = fm.size (Qt::TextSingleLine, s);
312 wd =
std::max (wd,
static_cast<double> (sz.width ()));
313 hg =
std::max (hg,
static_cast<double> (sz.height ()));
319 ext(3) = hg * sv.
numel ();
359 octave::event_manager& evmgr =
m_interpreter.get_event_manager ();
361 evmgr.post_event (fcn);
367 octave::event_manager& evmgr =
m_interpreter.get_event_manager ();
369 evmgr.post_event (meth);
381 if (! go.valid_object ())
383 qWarning (
"qt_graphics_toolkit::create_object: invalid object for handle %g",
388 if (go.get_properties ().is_beingdeleted ())
390 qWarning (
"qt_graphics_toolkit::create_object: object is being deleted");
398 qWarning (
"qt_graphics_toolkit::create_object: no proxy for handle %g",
404 "create %s from thread %p",
405 go.type ().c_str (), QThread::currentThreadId ());
409 if (go.isa (
"figure"))
411 else if (go.isa (
"uicontrol"))
414 Utils::properties<uicontrol> (go);
416 if (up.style_is (
"pushbutton"))
418 else if (up.style_is (
"edit"))
420 else if (up.style_is (
"checkbox"))
422 else if (up.style_is (
"radiobutton"))
424 else if (up.style_is (
"togglebutton"))
426 else if (up.style_is (
"text"))
428 else if (up.style_is (
"popupmenu"))
430 else if (up.style_is (
"slider"))
432 else if (up.style_is (
"listbox"))
435 else if (go.isa (
"uibuttongroup"))
437 else if (go.isa (
"uipanel"))
439 else if (go.isa (
"uimenu"))
441 else if (go.isa (
"uicontextmenu"))
443 else if (go.isa (
"uitable"))
445 else if (go.isa (
"uitoolbar"))
447 else if (go.isa (
"uipushtool"))
449 else if (go.isa (
"uitoggletool"))
452 qWarning (
"qt_graphics_toolkit::create_object: unsupported type '%s'",
453 go.type ().c_str ());
463 const std::string& nm)
467 gh_mgr.post_callback (h, nm);
471 const std::string& nm,
476 gh_mgr.post_callback (h, nm, data);
480 const std::string& nm,
485 gh_mgr.post_set (h, nm, value);
489 const std::string& nm,
495 gh_mgr.post_set (h, nm, value, notify_toolkit);
499 const std::string& nm,
506 gh_mgr.post_set (h, nm, value, notify_toolkit,
redraw_figure);
charNDArray max(char d, const charNDArray &m)
static CheckBoxControl * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
static EditControl * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
static ListBoxControl * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
static void debug(const char *fmt,...)
void print(const QString &file_cmd, const QString &term)
void setObject(Object *obj)
uint8NDArray get_pixels(void)
virtual void do_connections(const QObject *receiver, const QObject *emitter=nullptr)
static Panel * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
static SliderControl * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
static Table * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
static TextControl * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
Base class for Octave interfaces that use Qt.
bool iscellstr(void) const
bool is_string(void) const
bool is_defined(void) const
std::string string_value(bool force=false) const
string_vector string_vector_value(bool pad=false) const
octave_idx_type numel(void) const
OCTAVE_NAMESPACE_BEGIN typedef std::function< void(void)> fcn_callback
std::function< void(interpreter &)> meth_callback
QString fromStdString(const std::string &s)
T::properties & properties(graphics_object obj)
template QFont computeFont< uicontrol >(const uicontrol::properties &props, int height)
static std::string toolkitObjectProperty(const graphics_object &go)