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
81 if (go.isa (
"figure"))
82 return "__plot_stream__";
83 else if (go.isa (
"uicontrol")
85 || go.isa (
"uibuttongroup")
87 || go.isa (
"uicontextmenu")
89 || go.isa (
"uitoolbar")
90 || go.isa (
"uipushtool")
91 || go.isa (
"uitoggletool"))
94 qCritical (
"octave::qt_graphics_toolkit: no __object__ property known for object "
95 "of type %s", go.type ().c_str ());
101 octave::base_qobject& oct_qobj)
103 m_octave_qobj (oct_qobj)
116 Qt::BlockingQueuedConnection);
122 if (go.isa (
"figure")
123 || (go.isa (
"uicontrol") && go.get (
"style").string_value () !=
"frame")
124 || go.isa (
"uipanel")
125 || go.isa (
"uibuttongroup")
127 || go.isa (
"uicontextmenu")
128 || go.isa (
"uitable")
129 || go.isa (
"uitoolbar")
130 || go.isa (
"uipushtool")
131 || go.isa (
"uitoggletool"))
141 Logger::debug (
"qt_graphics_toolkit::initialize %s from thread %p",
142 go.type ().c_str (), QThread::currentThreadId ());
145 graphics_object gObj (go);
162 if (pId == figure::properties::ID___PLOT_STREAM__
163 || pId == uicontrol::properties::ID___OBJECT__
164 || pId == uipanel::properties::ID___OBJECT__
165 || pId == uibuttongroup::properties::ID___OBJECT__
166 || pId == uimenu::properties::ID___OBJECT__
167 || pId == uicontextmenu::properties::ID___OBJECT__
168 || pId == uitable::properties::ID___OBJECT__
169 || pId == uitoolbar::properties::ID___OBJECT__
170 || pId == uipushtool::properties::ID___OBJECT__
171 || pId == uitoggletool::properties::ID___OBJECT__
172 || pId == base_properties::ID___MODIFIED__)
175 Logger::debug (
"qt_graphics_toolkit::update %s(%d) from thread %p",
176 go.type ().c_str (), pId, QThread::currentThreadId ());
182 if ((go.isa (
"uicontrol")
183 && pId == uicontrol::properties::ID_STYLE)
184 || (go.isa (
"uitable")
185 && pId == uitable::properties::ID_DATA))
212 Logger::debug (
"qt_graphics_toolkit::finalize %s from thread %p",
213 go.type ().c_str (), QThread::currentThreadId ());
222 graphics_object gObj (go);
231 if (go.get_properties ().is_visible ())
243 if (go.get_properties ().is_visible ())
254 const std::string& term,
255 const std::string& file_cmd,
256 const std::string& )
const
270 if (go.isa (
"figure"))
286 if (go.isa (
"uicontrol"))
293 Matrix bb = up.get_boundingbox (
false);
295 QFontMetrics fm (font);
303 sz = fm.size (Qt::TextSingleLine, s);
304 ext(2) = sz.width ();
305 ext(3) = sz.height ();
315 sz = fm.size (Qt::TextSingleLine, s);
316 wd =
std::max (wd,
static_cast<double> (sz.width ()));
317 hg =
std::max (hg,
static_cast<double> (sz.height ()));
323 ext(3) = hg * sv.
numel ();
363 octave::event_manager& evmgr =
m_interpreter.get_event_manager ();
365 evmgr.post_event (fcn);
371 octave::event_manager& evmgr =
m_interpreter.get_event_manager ();
373 evmgr.post_event (meth);
381 octave::autolock guard (gh_mgr.graphics_lock ());
385 if (! go.valid_object ())
387 qWarning (
"qt_graphics_toolkit::create_object: invalid object for handle %g",
392 if (go.get_properties ().is_beingdeleted ())
394 qWarning (
"qt_graphics_toolkit::create_object: object is being deleted");
402 qWarning (
"qt_graphics_toolkit::create_object: no proxy for handle %g",
408 "create %s from thread %p",
409 go.type ().c_str (), QThread::currentThreadId ());
413 if (go.isa (
"figure"))
415 else if (go.isa (
"uicontrol"))
418 Utils::properties<uicontrol> (go);
420 if (up.style_is (
"pushbutton"))
422 else if (up.style_is (
"edit"))
424 else if (up.style_is (
"checkbox"))
426 else if (up.style_is (
"radiobutton"))
428 else if (up.style_is (
"togglebutton"))
430 else if (up.style_is (
"text"))
432 else if (up.style_is (
"popupmenu"))
434 else if (up.style_is (
"slider"))
436 else if (up.style_is (
"listbox"))
439 else if (go.isa (
"uibuttongroup"))
441 else if (go.isa (
"uipanel"))
443 else if (go.isa (
"uimenu"))
445 else if (go.isa (
"uicontextmenu"))
447 else if (go.isa (
"uitable"))
449 else if (go.isa (
"uitoolbar"))
451 else if (go.isa (
"uipushtool"))
453 else if (go.isa (
"uitoggletool"))
456 qWarning (
"qt_graphics_toolkit::create_object: unsupported type '%s'",
457 go.type ().c_str ());
467 const std::string& nm)
471 gh_mgr.post_callback (h, nm);
475 const std::string& nm,
480 gh_mgr.post_callback (h, nm, data);
484 const std::string& nm,
489 gh_mgr.post_set (h, nm, value);
493 const std::string& nm,
499 gh_mgr.post_set (h, nm, value, notify_toolkit);
503 const std::string& nm,
510 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)
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_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::function< void(void)> fcn_callback
std::function< void(interpreter &)> meth_callback
QString fromStdString(const std::string &s)
template QFont computeFont< uicontrol >(const uicontrol::properties &props, int height)
T::properties & properties(graphics_object obj)