# HG changeset patch # User Rik # Date 1429588162 25200 # Node ID 82b4fb8b8a2822ef2d2ae1e6e546f118bcbd20f7 # Parent 5a47178626482b882f2c56eca2c028f1d7721e37# Parent 248f2f2e7d4872466ee478b51debc63d56c8353d maint: Merge away accidental head. diff -r 5a4717862648 -r 82b4fb8b8a28 libgui/graphics/Canvas.cc --- a/libgui/graphics/Canvas.cc Mon Apr 20 22:48:11 2015 -0400 +++ b/libgui/graphics/Canvas.cc Mon Apr 20 20:49:22 2015 -0700 @@ -114,6 +114,11 @@ } } +/* + Two updateCurrentPoint() routines are required: + 1) Used for QMouseEvents where cursor position data is in callback from Qt. + 2) Used for QKeyEvents where cursor position must be determined. +*/ void Canvas::updateCurrentPoint(const graphics_object& fig, const graphics_object& obj, QMouseEvent* event) @@ -153,6 +158,46 @@ } void +Canvas::updateCurrentPoint(const graphics_object& fig, + const graphics_object& obj) +{ + gh_manager::auto_lock lock; + + gh_manager::post_set (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig), false); + + Matrix children = obj.get_properties ().get_children (); + octave_idx_type num_children = children.numel (); + + for (int i = 0; i < num_children; i++) + { + graphics_object childObj (gh_manager::get_object (children(i))); + + if (childObj.isa ("axes")) + { + // FIXME: QCursor::pos() may give inaccurate results with asynchronous + // window systems like X11 over ssh. + QWidget *w = qWidget (); + QPoint p = w->mapFromGlobal (QCursor::pos ()); + axes::properties& ap = Utils::properties (childObj); + Matrix x_zlim = ap.get_transform_zlim (); + graphics_xform x_form = ap.get_transform (); + + ColumnVector p1 = x_form.untransform (p.x (), p.y (), x_zlim(0)); + ColumnVector p2 = x_form.untransform (p.x (), p.y (), x_zlim(1)); + + Matrix cp (2, 3, 0.0); + + 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); + } + } +} + +void Canvas::annotation_callback (const octave_value_list& args) { Ffeval (ovl ("annotation").append (args)); @@ -886,6 +931,16 @@ { if (m_eventMask & KeyPress) { + gh_manager::auto_lock lock; + graphics_object obj = gh_manager::get_object (m_handle); + + if (obj.valid_object ()) + { + graphics_object figObj (obj.get_ancestor ("figure")); + + updateCurrentPoint (figObj, obj); + } + octave_scalar_map eventData = Utils::makeKeyEventStruct (event); gh_manager::post_set (m_handle, "currentcharacter", diff -r 5a4717862648 -r 82b4fb8b8a28 libgui/graphics/Canvas.h --- a/libgui/graphics/Canvas.h Mon Apr 20 22:48:11 2015 -0400 +++ b/libgui/graphics/Canvas.h Mon Apr 20 20:49:22 2015 -0700 @@ -102,6 +102,8 @@ void updateCurrentPoint (const graphics_object& fig, const graphics_object& obj, QMouseEvent *event); + void updateCurrentPoint (const graphics_object& fig, + const graphics_object& obj); void annotation_callback (const octave_value_list& args); diff -r 5a4717862648 -r 82b4fb8b8a28 libgui/graphics/QtHandlesUtils.cc --- a/libgui/graphics/QtHandlesUtils.cc Mon Apr 20 22:48:11 2015 -0400 +++ b/libgui/graphics/QtHandlesUtils.cc Mon Apr 20 20:49:22 2015 -0700 @@ -193,6 +193,11 @@ return std::string ("normal"); } +/* + Two figureCurrentPoint() routines are required: + 1) Used for QMouseEvents where cursor position data is in callback from Qt. + 2) Used for QKeyEvents where cursor position must be determined. +*/ Matrix figureCurrentPoint (const graphics_object& fig, QMouseEvent* event) { @@ -206,9 +211,31 @@ { QPoint qp = c->mapFromGlobal (event->globalPos ()); - return - tkFig->properties
().map_from_boundingbox (qp.x (), - qp.y ()); + return tkFig->properties
().map_from_boundingbox (qp.x (), + qp.y ()); + } + } + + return Matrix (1, 2, 0.0); +} + +Matrix +figureCurrentPoint (const graphics_object& fig) +{ + Object* tkFig = Backend::toolkitObject (fig); + + if (tkFig) + { + Container* c = tkFig->innerContainer (); + + if (c) + { + // FIXME: QCursor::pos() may give inaccurate results with asynchronous + // window systems like X11 over ssh. + QPoint qp = c->mapFromGlobal (QCursor::pos ()); + + return tkFig->properties
().map_from_boundingbox (qp.x (), + qp.y ()); } } diff -r 5a4717862648 -r 82b4fb8b8a28 libgui/graphics/QtHandlesUtils.h --- a/libgui/graphics/QtHandlesUtils.h Mon Apr 20 22:48:11 2015 -0400 +++ b/libgui/graphics/QtHandlesUtils.h Mon Apr 20 20:49:22 2015 -0700 @@ -62,6 +62,7 @@ bool isDoubleClick = false); Matrix figureCurrentPoint (const graphics_object& fig, QMouseEvent* event); + Matrix figureCurrentPoint (const graphics_object& fig); template inline typename T::properties&