Mercurial > jwe > octave
changeset 27323:6b2d20317b26
use Qt signals to manage calls to gh_manager functions in Qt graphics toolkit
Limit access to the gh_manager object to the qt_graphics_toolkit class
by using Qt signals to pass gh_manager events from individual graphics
objects up to the qt_graphics_toolkit object. From there, we can make
calls to the gh_manager object.
* qt-graphics-toolkit.h, qt-graphics-toolkit.cc
(qt_graphics_toolkit::gh_callback_event,
qt_graphics_toolkit::gh_set_event): New slots.
(qt_graphics_toolkit::create_object): Connect
Object::gh_callback_event and Object::gh_set_event signals to
qt_graphics_toolkit::gh_callback_event and
qt_graphics_toolkit::gh_set_event slots.
* BaseControl.cc, ButtonControl.cc, ButtonGroup.cc, Canvas.cc,
ContextMenu.cc, EditControl.cc, Figure.cc, ListBoxControl.cc, Menu.cc,
PopupMenuControl.cc, PushTool.cc, SliderControl.cc, Table.cc,
ToggleTool.cc: Emit gh_callback_event and gh_set_event signals instead
of calling gh_manager functions directly.
* Object.h (Object::gh_callback_event, Object::gh_set_event):
New signals.
* Canvas.h (Canvas::gh_callback_event, Canvas::gh_set_event):
New signals.
* Container.h (Container::gh_callback_event, Container::gh_set_event):
New signals.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 02 Aug 2019 15:19:43 -0500 |
parents | ae53e56e16f2 |
children | 1dfd6ae74fbf |
files | libgui/graphics/BaseControl.cc libgui/graphics/ButtonControl.cc libgui/graphics/ButtonGroup.cc libgui/graphics/Canvas.cc libgui/graphics/Canvas.h libgui/graphics/Container.cc libgui/graphics/Container.h libgui/graphics/ContextMenu.cc libgui/graphics/EditControl.cc libgui/graphics/Figure.cc libgui/graphics/ListBoxControl.cc libgui/graphics/Menu.cc libgui/graphics/Object.h libgui/graphics/PopupMenuControl.cc libgui/graphics/PushTool.cc libgui/graphics/SliderControl.cc libgui/graphics/Table.cc libgui/graphics/ToggleTool.cc libgui/graphics/qt-graphics-toolkit.cc libgui/graphics/qt-graphics-toolkit.h |
diffstat | 20 files changed, 320 insertions(+), 146 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/BaseControl.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/BaseControl.cc Fri Aug 02 15:19:43 2019 -0500 @@ -217,19 +217,19 @@ graphics_object fig = go.get_ancestor ("figure"); if (fig) { - gh_manager::post_set (fig.get_handle (), "currentobject", - m_handle.value (), false); + emit gh_set_event (fig.get_handle (), "currentobject", + m_handle.value (), false); if (m->button () != Qt::LeftButton || ! up.enable_is ("on")) { - gh_manager::post_set (fig.get_handle (), "selectiontype", - Utils::figureSelectionType (m), false); - gh_manager::post_set (fig.get_handle (), "currentpoint", - Utils::figureCurrentPoint (fig, m), - false); - gh_manager::post_callback (fig.get_handle (), - "windowbuttondownfcn"); - gh_manager::post_callback (m_handle, "buttondownfcn"); + emit gh_set_event (fig.get_handle (), "selectiontype", + Utils::figureSelectionType (m), false); + emit gh_set_event (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig, m), + false); + emit gh_callback_event (fig.get_handle (), + "windowbuttondownfcn"); + emit gh_callback_event (m_handle, "buttondownfcn"); if (m->button () == Qt::RightButton) ContextMenu::executeAt (up, m->globalPos ()); @@ -237,12 +237,12 @@ else { if (up.style_is ("listbox")) - gh_manager::post_set (fig.get_handle (), "selectiontype", - Utils::figureSelectionType (m), - false); + emit gh_set_event (fig.get_handle (), "selectiontype", + Utils::figureSelectionType (m), + false); else - gh_manager::post_set (fig.get_handle (), "selectiontype", - octave_value ("normal"), false); + emit gh_set_event (fig.get_handle (), "selectiontype", + octave_value ("normal"), false); } } } @@ -259,10 +259,10 @@ if (fig) { - gh_manager::post_set (fig.get_handle (), "currentpoint", - Utils::figureCurrentPoint (fig, m), false); - gh_manager::post_callback (fig.get_handle (), - "windowbuttonmotionfcn"); + emit gh_set_event (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig, m), false); + emit gh_callback_event (fig.get_handle (), + "windowbuttonmotionfcn"); } } break; @@ -276,18 +276,18 @@ Utils::makeKeyEventStruct (dynamic_cast<QKeyEvent *> (xevent)); graphics_object fig = object ().get_ancestor ("figure"); - gh_manager::post_set (fig.get_handle (), "currentcharacter", - keyData.getfield ("Character"), false); - gh_manager::post_callback (m_handle, "keypressfcn", keyData); + emit gh_set_event (fig.get_handle (), "currentcharacter", + keyData.getfield ("Character"), false); + emit gh_callback_event (m_handle, "keypressfcn", keyData); } break; case QEvent::FocusIn: - gh_manager::post_set (m_handle, "__focus__", "on", false); + emit gh_set_event (m_handle, "__focus__", "on", false); break; case QEvent::FocusOut: - gh_manager::post_set (m_handle, "__focus__", "off", false); + emit gh_set_event (m_handle, "__focus__", "off", false); break; default:
--- a/libgui/graphics/ButtonControl.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/ButtonControl.cc Fri Aug 02 15:19:43 2019 -0500 @@ -126,8 +126,8 @@ double newValue = (checked ? up.get_max () : up.get_min ()); if (oldValue.numel () != 1 || (newValue != oldValue(0))) - gh_manager::post_set (m_handle, "value", newValue, false); - gh_manager::post_callback (m_handle, "callback"); + emit gh_set_event (m_handle, "value", newValue, false); + emit gh_callback_event (m_handle, "callback"); } } @@ -137,7 +137,7 @@ QAbstractButton *btn = qWidget<QAbstractButton> (); if (! btn->isCheckable ()) - gh_manager::post_callback (m_handle, "callback"); + emit gh_callback_event (m_handle, "callback"); } };
--- a/libgui/graphics/ButtonGroup.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/ButtonGroup.cc Fri Aug 02 15:19:43 2019 -0500 @@ -469,8 +469,8 @@ } if (oldValue != newValue) - gh_manager::post_set (m_handle, "selectedobject", newValue.as_octave_value (), - false); + emit gh_set_event (m_handle, "selectedobject", + newValue.as_octave_value (), false); } } @@ -496,8 +496,8 @@ eventData.setfield ("Source", bp.get___myhandle__ ().as_octave_value ()); eventData.setfield ("EventName", "SelectionChanged"); octave_value selectionChangedEventObject (new octave_struct (eventData)); - gh_manager::post_callback (m_handle, "selectionchangedfcn", - selectionChangedEventObject); + emit gh_callback_event (m_handle, "selectionchangedfcn", + selectionChangedEventObject); } }
--- a/libgui/graphics/Canvas.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/Canvas.cc Fri Aug 02 15:19:43 2019 -0500 @@ -194,8 +194,8 @@ { gh_manager::auto_lock lock; - gh_manager::post_set (fig.get_handle (), "currentpoint", - Utils::figureCurrentPoint (fig, event), false); + emit gh_set_event (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig, event), false); Matrix children = obj.get_properties ().get_children (); octave_idx_type num_children = children.numel (); @@ -220,8 +220,8 @@ cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2); cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2); - gh_manager::post_set (childObj.get_handle (), "currentpoint", cp, - false); + emit gh_set_event (childObj.get_handle (), "currentpoint", cp, + false); } } } @@ -232,8 +232,8 @@ { gh_manager::auto_lock lock; - gh_manager::post_set (fig.get_handle (), "currentpoint", - Utils::figureCurrentPoint (fig), false); + emit gh_set_event (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig), false); Matrix children = obj.get_properties ().get_children (); octave_idx_type num_children = children.numel (); @@ -260,8 +260,8 @@ cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2); cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2); - gh_manager::post_set (childObj.get_handle (), "currentpoint", cp, - false); + emit gh_set_event (childObj.get_handle (), "currentpoint", cp, + false); } } } @@ -512,8 +512,8 @@ && ! figObj.get ("windowbuttonmotionfcn").isempty ()) { updateCurrentPoint (figObj, obj, event); - gh_manager::post_callback (figObj.get_handle (), - "windowbuttonmotionfcn"); + emit gh_callback_event (figObj.get_handle (), + "windowbuttonmotionfcn"); } } } @@ -653,27 +653,24 @@ fprop.set_currentobject (Matrix ()); // Update figure "selectiontype" and "currentpoint" - gh_manager::post_set (figObj.get_handle (), "selectiontype", - Utils::figureSelectionType (event, - isdblclick), - false); + emit gh_set_event (figObj.get_handle (), "selectiontype", + Utils::figureSelectionType (event, isdblclick), + false); updateCurrentPoint (figObj, obj, event); - gh_manager::post_callback (figObj.get_handle (), - "windowbuttondownfcn", - button_number (event)); + emit gh_callback_event (figObj.get_handle (), + "windowbuttondownfcn", + button_number (event)); // Execute the "buttondownfcn" of the selected object. If the // latter is empty then execute the figure "buttondownfcn" if (currentObj && ! currentObj.get ("buttondownfcn").isempty ()) - gh_manager::post_callback (currentObj.get_handle (), - "buttondownfcn", - button_number (event)); + emit gh_callback_event (currentObj.get_handle (), + "buttondownfcn", button_number (event)); else if (figObj && ! figObj.get ("buttondownfcn").isempty ()) - gh_manager::post_callback (figObj.get_handle (), - "buttondownfcn", - button_number (event)); + emit gh_callback_event (figObj.get_handle (), + "buttondownfcn", button_number (event)); // Show context menu of the selected object if (currentObj && event->button () == Qt::RightButton) @@ -845,8 +842,7 @@ graphics_object figObj (obj.get_ancestor ("figure")); updateCurrentPoint (figObj, obj, event); - gh_manager::post_callback (figObj.get_handle (), - "windowbuttonupfcn"); + emit gh_callback_event (figObj.get_handle (), "windowbuttonupfcn"); } } else if (m_mouseMode == TextMode) @@ -1005,8 +1001,8 @@ if (! figObj.get ("windowscrollwheelfcn").isempty ()) { octave_scalar_map eventData = Utils::makeScrollEventStruct (event); - gh_manager::post_callback (m_handle, "windowscrollwheelfcn", - eventData); + emit gh_callback_event (m_handle, "windowscrollwheelfcn", + eventData); } } } @@ -1027,10 +1023,10 @@ octave_scalar_map eventData = Utils::makeKeyEventStruct (event); - gh_manager::post_set (figObj.get_handle (), "currentcharacter", - eventData.getfield ("Character"), false); - gh_manager::post_callback (figObj.get_handle (), "keypressfcn", - eventData); + emit gh_set_event (figObj.get_handle (), "currentcharacter", + eventData.getfield ("Character"), false); + emit gh_callback_event (figObj.get_handle (), "keypressfcn", + eventData); } return true; @@ -1050,8 +1046,8 @@ if (obj.valid_object ()) { graphics_object figObj (obj.get_ancestor ("figure")); - gh_manager::post_callback (figObj.get_handle (), "keyreleasefcn", - Utils::makeKeyEventStruct (event)); + emit gh_callback_event (figObj.get_handle (), "keyreleasefcn", + Utils::makeKeyEventStruct (event)); } return true;
--- a/libgui/graphics/Canvas.h Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/Canvas.h Fri Aug 02 15:19:43 2019 -0500 @@ -82,6 +82,20 @@ void interpreter_event (const octave::fcn_callback& fcn); void interpreter_event (const octave::meth_callback& meth); + void gh_callback_event (const graphics_handle& h, const std::string& name); + + void gh_callback_event (const graphics_handle& h, const std::string& name, + const octave_value& data); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value, bool notify_toolkit); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value, bool notify_toolkit, + bool redraw_figure); protected: virtual void draw (const graphics_handle& handle) = 0; virtual void drawZoomBox (const QPoint& p1, const QPoint& p2) = 0;
--- a/libgui/graphics/Container.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/Container.cc Fri Aug 02 15:19:43 2019 -0500 @@ -67,6 +67,49 @@ connect (m_canvas, SIGNAL (interpeter_event (const meth_callback&)), this, SIGNAL (interpeter_event (const meth_callback&))); + connect (m_canvas, + SIGNAL (gh_callback_event (const graphics_handle&, + const std::string&)), + this, + SIGNAL (gh_callback_event (const graphics_handle&, + const std::string&))); + + connect (m_canvas, + SIGNAL (gh_callback_event (const graphics_handle&, + const std::string&, + const octave_value&)), + this, + SIGNAL (gh_callback_event (const graphics_handle&, + const std::string&, + const octave_value&))); + + connect (m_canvas, + SIGNAL (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&)), + this, + SIGNAL (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&))); + + connect (m_canvas, + SIGNAL (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&, bool)), + this, + SIGNAL (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&, bool))); + + connect (m_canvas, + SIGNAL (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&, bool, bool)), + this, + SIGNAL (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&, bool, bool))); + QWidget *canvasWidget = m_canvas->qWidget (); canvasWidget->lower ();
--- a/libgui/graphics/Container.h Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/Container.h Fri Aug 02 15:19:43 2019 -0500 @@ -52,6 +52,21 @@ void interpreter_event (const octave::fcn_callback& fcn); void interpreter_event (const octave::meth_callback& meth); + void gh_callback_event (const graphics_handle& h, const std::string& name); + + void gh_callback_event (const graphics_handle& h, const std::string& name, + const octave_value& data); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value, bool notify_toolkit); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value, bool notify_toolkit, + bool redraw_figure); + protected: void childEvent (QChildEvent *event); void resizeEvent (QResizeEvent *event);
--- a/libgui/graphics/ContextMenu.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/ContextMenu.cc Fri Aug 02 15:19:43 2019 -0500 @@ -93,14 +93,14 @@ void ContextMenu::aboutToShow (void) { - gh_manager::post_callback (m_handle, "callback"); - gh_manager::post_set (m_handle, "visible", "on", false); + emit gh_callback_event (m_handle, "callback"); + emit gh_set_event (m_handle, "visible", "on", false); } void ContextMenu::aboutToHide (void) { - gh_manager::post_set (m_handle, "visible", "off", false); + emit gh_set_event (m_handle, "visible", "off", false); } QWidget*
--- a/libgui/graphics/EditControl.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/EditControl.cc Fri Aug 02 15:19:43 2019 -0500 @@ -228,17 +228,17 @@ if (m_textChanged) { if (m_multiLine) - gh_manager::post_set (m_handle, "string", - Utils::toCellString (txt.split ("\n")), false); + emit gh_set_event (m_handle, "string", + Utils::toCellString (txt.split ("\n")), false); else - gh_manager::post_set (m_handle, "string", - Utils::toStdString (txt), false); + emit gh_set_event (m_handle, "string", + Utils::toStdString (txt), false); m_textChanged = false; } if (txt.length () > 0) - gh_manager::post_callback (m_handle, "callback"); + emit gh_callback_event (m_handle, "callback"); } void @@ -250,12 +250,12 @@ ? qWidget<TextEdit> ()->toPlainText () : qWidget<QLineEdit> ()->text ()); if (m_multiLine) - gh_manager::post_set (m_handle, "string", - Utils::toCellString (txt.split ("\n")), false); + emit gh_set_event (m_handle, "string", + Utils::toCellString (txt.split ("\n")), false); else - gh_manager::post_set (m_handle, "string", - Utils::toStdString (txt), false); - gh_manager::post_callback (m_handle, "callback"); + emit gh_set_event (m_handle, "string", Utils::toStdString (txt), + false); + emit gh_callback_event (m_handle, "callback"); m_textChanged = false; }
--- a/libgui/graphics/Figure.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/Figure.cc Fri Aug 02 15:19:43 2019 -0500 @@ -634,8 +634,8 @@ figure::properties& fp = properties<figure> (); - gh_manager::post_set (m_handle, prop, fp.bbox2position (bb), false, - prop == "position"); + emit gh_set_event (m_handle, prop, fp.bbox2position (bb), false, + prop == "position"); } bool @@ -676,7 +676,7 @@ { case QEvent::Close: xevent->ignore (); - gh_manager::post_callback (m_handle, "closerequestfcn"); + emit gh_callback_event (m_handle, "closerequestfcn"); return true; default:
--- a/libgui/graphics/ListBoxControl.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/ListBoxControl.cc Fri Aug 02 15:19:43 2019 -0500 @@ -175,8 +175,8 @@ foreach (const QModelIndex& idx, l) value(i++) = idx.row () + 1; - gh_manager::post_set (m_handle, "value", octave_value (value), false); - gh_manager::post_callback (m_handle, "callback"); + emit gh_set_event (m_handle, "value", octave_value (value), false); + emit gh_callback_event (m_handle, "callback"); } m_selectionChanged = false;
--- a/libgui/graphics/Menu.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/Menu.cc Fri Aug 02 15:19:43 2019 -0500 @@ -286,13 +286,13 @@ if (action->isCheckable ()) action->setChecked (! action->isChecked ()); - gh_manager::post_callback (m_handle, "callback"); + emit gh_callback_event (m_handle, "callback"); } void Menu::actionHovered (void) { - gh_manager::post_callback (m_handle, "callback"); + emit gh_callback_event (m_handle, "callback"); } void
--- a/libgui/graphics/Object.h Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/Object.h Fri Aug 02 15:19:43 2019 -0500 @@ -83,6 +83,21 @@ void interpreter_event (const octave::fcn_callback& fcn); void interpreter_event (const octave::meth_callback& meth); + void gh_callback_event (const graphics_handle& h, const std::string& name); + + void gh_callback_event (const graphics_handle& h, const std::string& name, + const octave_value& data); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value, bool notify_toolkit); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value, bool notify_toolkit, + bool redraw_figure); + public slots: void slotUpdate (int pId); void slotFinalize (void);
--- a/libgui/graphics/PopupMenuControl.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/PopupMenuControl.cc Fri Aug 02 15:19:43 2019 -0500 @@ -88,10 +88,9 @@ } else { - gh_manager::post_set (m_handle, "value", - octave_value (box->count () > 0 - ? 1.0 : 0.0), - false); + emit gh_set_event (m_handle, "value", + octave_value (box->count () > 0 ? 1.0 : 0.0), + false); } } m_blockUpdate = false; @@ -134,10 +133,9 @@ { if (! m_blockUpdate) { - gh_manager::post_set (m_handle, "value", - octave_value (double (index + 1)), - false); - gh_manager::post_callback (m_handle, "callback"); + emit gh_set_event (m_handle, "value", octave_value (double (index + 1)), + false); + emit gh_callback_event (m_handle, "callback"); } }
--- a/libgui/graphics/PushTool.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/PushTool.cc Fri Aug 02 15:19:43 2019 -0500 @@ -70,7 +70,7 @@ void PushTool::clicked (void) { - gh_manager::post_callback (m_handle, "clickedcallback"); + emit gh_callback_event (m_handle, "clickedcallback"); } };
--- a/libgui/graphics/SliderControl.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/SliderControl.cc Fri Aug 02 15:19:43 2019 -0500 @@ -147,8 +147,8 @@ { double dval = dmin + (ival * (dmax - dmin) / RANGE_INT_MAX); - gh_manager::post_set (m_handle, "value", octave_value (dval)); - gh_manager::post_callback (m_handle, "callback"); + emit gh_set_event (m_handle, "value", octave_value (dval)); + emit gh_callback_event (m_handle, "callback"); } } }
--- a/libgui/graphics/Table.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/Table.cc Fri Aug 02 15:19:43 2019 -0500 @@ -497,9 +497,8 @@ eventData.setfield ("Indices", indices); octave_value cellSelectionCallbackEventObject = octave_value (new octave_struct (eventData)); - gh_manager::post_callback (m_handle, - "cellselectioncallback", - cellSelectionCallbackEventObject); + emit gh_callback_event (m_handle, "cellselectioncallback", + cellSelectionCallbackEventObject); } } @@ -547,9 +546,8 @@ octave_value cellEditCallbackEventObject = octave_value (new octave_struct (eventData)); - gh_manager::post_callback (m_handle, - "celleditcallback", - cellEditCallbackEventObject); + emit gh_callback_event (m_handle, "celleditcallback", + cellEditCallbackEventObject); } else if (error.string_value ().length () > 0) warning ("%s", error.string_value ().c_str ()); @@ -584,10 +582,8 @@ if (edit_data.string_value () != old_data.string_value ()) { m_curData = octave_value (cell); - gh_manager::post_set (m_handle, - "data", - octave_value (cell), - false); + emit gh_set_event (m_handle, "data", octave_value (cell), + false); } octave_value error = octave_value (""); @@ -607,7 +603,8 @@ columnformat (col), columneditable (col)); m_curData = octave_value (cell); - gh_manager::post_set (m_handle, "data", octave_value (cell), false); + emit gh_set_event (m_handle, "data", octave_value (cell), + false); octave_value error = octave_value (""); sendCellEditCallback (row, @@ -635,7 +632,7 @@ columneditable (col)); m_curData = octave_value (data); - gh_manager::post_set (m_handle, "data", data, false); + emit gh_set_event (m_handle, "data", data, false); octave_value error = octave_value (""); sendCellEditCallback (row, @@ -696,8 +693,8 @@ if (new_value != old_value) { m_curData = octave_value (matrix); - gh_manager::post_set (m_handle, "data", - octave_value (matrix), false); + emit gh_set_event (m_handle, "data", octave_value (matrix), + false); } sendCellEditCallback (row, col, @@ -730,7 +727,8 @@ if (new_value != old_value) { m_curData = octave_value (cell); - gh_manager::post_set (m_handle, "data", octave_value (cell), false); + emit gh_set_event (m_handle, "data", octave_value (cell), + false); } sendCellEditCallback (row, @@ -836,7 +834,7 @@ new_data = data; } m_curData = octave_value (new_data); - gh_manager::post_set (m_handle, "data", new_data, false); + emit gh_set_event (m_handle, "data", new_data, false); sendCellEditCallback (row, col, @@ -1361,7 +1359,7 @@ extent(0, 2) = s.width (); extent(0, 3) = s.height () ; graphics_object go = object (); - gh_manager::post_set (go.get_handle (), "extent", extent, false); + emit gh_set_event (go.get_handle (), "extent", extent, false); } void @@ -1529,22 +1527,22 @@ if (m->button () != Qt::LeftButton || ! tp.is_enable ()) { - gh_manager::post_set (fig.get_handle (), "selectiontype", - Utils::figureSelectionType (m), false); - gh_manager::post_set (fig.get_handle (), "currentpoint", - Utils::figureCurrentPoint (fig, m), - false); - gh_manager::post_callback (fig.get_handle (), - "windowbuttondownfcn"); - gh_manager::post_callback (m_handle, "buttondownfcn"); + emit gh_set_event (fig.get_handle (), "selectiontype", + Utils::figureSelectionType (m), false); + emit gh_set_event (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig, m), + false); + emit gh_callback_event (fig.get_handle (), + "windowbuttondownfcn"); + emit gh_callback_event (m_handle, "buttondownfcn"); if (m->button () == Qt::RightButton) ContextMenu::executeAt (properties (), m->globalPos ()); } else { - gh_manager::post_set (fig.get_handle (), "selectiontype", - octave_value ("normal"), false); + emit gh_set_event (fig.get_handle (), "selectiontype", + octave_value ("normal"), false); } } break; @@ -1559,9 +1557,9 @@ octave_scalar_map keyData = Utils::makeKeyEventStruct (k); graphics_object fig = object ().get_ancestor ("figure"); - gh_manager::post_set (fig.get_handle (), "currentcharacter", - keyData.getfield ("Character"), false); - gh_manager::post_callback (m_handle, "keypressfcn", keyData); + emit gh_set_event (fig.get_handle (), "currentcharacter", + keyData.getfield ("Character"), false); + emit gh_callback_event (m_handle, "keypressfcn", keyData); } int row = m_tableWidget->currentRow (); int col = m_tableWidget->currentColumn (); @@ -1644,10 +1642,9 @@ octave_scalar_map keyData = Utils::makeKeyEventStruct (k); graphics_object fig = object ().get_ancestor ("figure"); - gh_manager::post_set (fig.get_handle (), "currentcharacter", - keyData.getfield ("Character"), false); - gh_manager::post_callback (m_handle, "keyreleasefcn", - keyData); + emit gh_set_event (fig.get_handle (), "currentcharacter", + keyData.getfield ("Character"), false); + emit gh_callback_event (m_handle, "keyreleasefcn", keyData); } } break; @@ -1670,22 +1667,22 @@ if (m->button () != Qt::LeftButton || ! tp.is_enable ()) { - gh_manager::post_set (fig.get_handle (), "selectiontype", - Utils::figureSelectionType (m), false); - gh_manager::post_set (fig.get_handle (), "currentpoint", - Utils::figureCurrentPoint (fig, m), - false); - gh_manager::post_callback (fig.get_handle (), - "windowbuttondownfcn"); - gh_manager::post_callback (m_handle, "buttondownfcn"); + emit gh_set_event (fig.get_handle (), "selectiontype", + Utils::figureSelectionType (m), false); + emit gh_set_event (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig, m), + false); + emit gh_callback_event (fig.get_handle (), + "windowbuttondownfcn"); + emit gh_callback_event (m_handle, "buttondownfcn"); if (m->button () == Qt::RightButton) ContextMenu::executeAt (tp, m->globalPos ()); } else { - gh_manager::post_set (fig.get_handle (), "selectiontype", - Utils::figureSelectionType (m), false); + emit gh_set_event (fig.get_handle (), "selectiontype", + Utils::figureSelectionType (m), false); QComboBox *comboBox_0 = qobject_cast<QComboBox *> (watched); for (int row = 0; row < m_tableWidget->rowCount (); row++)
--- a/libgui/graphics/ToggleTool.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/ToggleTool.cc Fri Aug 02 15:19:43 2019 -0500 @@ -83,12 +83,9 @@ void ToggleTool::triggered (bool checked) { - gh_manager::post_set (m_handle, "state", checked, false); - gh_manager::post_callback (m_handle, - checked - ? "oncallback" - : "offcallback"); - gh_manager::post_callback (m_handle, "clickedcallback"); + emit gh_set_event (m_handle, "state", checked, false); + emit gh_callback_event (m_handle, checked ? "oncallback" : "offcallback"); + emit gh_callback_event (m_handle, "clickedcallback"); } };
--- a/libgui/graphics/qt-graphics-toolkit.cc Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/qt-graphics-toolkit.cc Fri Aug 02 15:19:43 2019 -0500 @@ -433,6 +433,56 @@ SIGNAL (interpreter_event (const octave::meth_callback&)), this, SLOT (interpreter_event (const octave::meth_callback&))); + + connect (obj, + SIGNAL (interpreter_event (const octave::meth_callback&)), + this, + SLOT (interpreter_event (const octave::meth_callback&))); + + connect (obj, + SIGNAL (gh_callback_event (const graphics_handle&, + const std::string&)), + this, + SLOT (gh_callback_event (const graphics_handle&, + const std::string&))); + + connect (obj, + SIGNAL (gh_callback_event (const graphics_handle&, + const std::string&, + const octave_value&)), + this, + SLOT (gh_callback_event (const graphics_handle&, + const std::string&, + const octave_value&))); + + connect (obj, + SIGNAL (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&)), + this, + SLOT (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&))); + + connect (obj, + SIGNAL (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&, bool)), + this, + SLOT (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&, bool))); + + connect (obj, + SIGNAL (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&, + bool, bool)), + this, + SLOT (gh_set_event (const graphics_handle&, + const std::string&, + const octave_value&, + bool, bool))); } } else @@ -445,4 +495,40 @@ handle); } + void qt_graphics_toolkit::gh_callback_event (const graphics_handle& h, + const std::string& nm) + { + gh_manager::post_callback (h, nm); + } + + void qt_graphics_toolkit::gh_callback_event (const graphics_handle& h, + const std::string& nm, + const octave_value& data) + { + gh_manager::post_callback (h, nm, data); + } + + void qt_graphics_toolkit::gh_set_event (const graphics_handle& h, + const std::string& nm, + const octave_value& value) + { + gh_manager::post_set (h, nm, value); + } + + void qt_graphics_toolkit::gh_set_event (const graphics_handle& h, + const std::string& nm, + const octave_value& value, + bool notify_toolkit) + { + gh_manager::post_set (h, nm, value, notify_toolkit); + } + + void qt_graphics_toolkit::gh_set_event (const graphics_handle& h, + const std::string& nm, + const octave_value& value, + bool notify_toolkit, + bool redraw_figure) + { + gh_manager::post_set (h, nm, value, notify_toolkit, redraw_figure); + } };
--- a/libgui/graphics/qt-graphics-toolkit.h Fri Aug 02 14:28:48 2019 -0500 +++ b/libgui/graphics/qt-graphics-toolkit.h Fri Aug 02 15:19:43 2019 -0500 @@ -99,11 +99,24 @@ void create_object (double handle); + void gh_callback_event (const graphics_handle& h, const std::string& name); + + void gh_callback_event (const graphics_handle& h, const std::string& name, + const octave_value& data); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value, bool notify_toolkit); + + void gh_set_event (const graphics_handle& h, const std::string& name, + const octave_value& value, bool notify_toolkit, + bool redraw_figure); private: octave::interpreter& m_interpreter; }; - } #endif