changeset 20111:82b4fb8b8a28

maint: Merge away accidental head.
author Rik <rik@octave.org>
date Mon, 20 Apr 2015 20:49:22 -0700
parents 5a4717862648 (current diff) 248f2f2e7d48 (diff)
children 043dcb4da5fc
files
diffstat 4 files changed, 88 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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<axes> (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",
--- 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);
 
--- 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<figure> ().map_from_boundingbox (qp.x (),
-                                                               qp.y ());
+          return tkFig->properties<figure> ().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<figure> ().map_from_boundingbox (qp.x (),
+                                                                    qp.y ());
         }
     }
 
--- 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 <class T>
   inline typename T::properties&