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 (
"QtHandles::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")
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 %08x",
143 go.
type ().c_str (), QThread::currentThreadId ());
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 %08x",
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 %08x",
209 go.
type ().c_str (), QThread::currentThreadId ());
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"))
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 ();
383 qWarning (
"qt_graphics_toolkit::create_object: invalid object for handle %g",
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 %08x",
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)
471 const std::string& nm,
480 const std::string& nm,
489 const std::string& nm,
495 gh_mgr.
post_set (h, nm, value, notify_toolkit);
499 const std::string& nm,
charNDArray max(char d, const charNDArray &m)
static CheckBoxControl * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
static ContextMenu * 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,...)
static Menu * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
uint8NDArray get_pixels(void)
void setObject(Object *obj)
void print(const QString &file_cmd, const QString &term)
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 PopupMenuControl * 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)
virtual void set(const caseless_str &, const octave_value &)
void post_set(const graphics_handle &h, const std::string &name, const octave_value &value, bool notify_toolkit=true, bool redraw_figure=false)
graphics_object get_object(double val) const
void post_callback(const graphics_handle &h, const std::string &name, const octave_value &data=Matrix())
octave::mutex graphics_lock(void)
octave_value get(bool all=false) const
bool isa(const std::string &go_name) const
base_properties & get_properties(void)
std::string type(void) const
graphics_handle get_handle(void) const
bool valid_object(void) const
Base class for Octave interfaces that use Qt.
Provides threadsafe access to octave.
void post_event(const fcn_callback &fcn)
gh_manager & get_gh_manager(void)
event_manager & get_event_manager(void)
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
Matrix get_boundingbox(bool internal=false, const Matrix &parent_pix_size=Matrix()) const
template QFont computeFont< uicontrol >(const uicontrol::properties &props, int height)
QString fromStdString(const std::string &s)
static std::string toolkitObjectProperty(const graphics_object &go)
std::function< void(octave::interpreter &)> meth_callback
std::function< void(void)> fcn_callback
octave_value::octave_value(const Array< char > &chm, char type) return retval