# HG changeset patch # User Pantxo Diribarne # Date 1437823221 -7200 # Node ID 2d415c68213f1da2449a131e584b3b3309d3e950 # Parent 25caa0deaabbc33dc4756ce749cb8440fa5eee5c Don't use GL_SELECT to find axes objects in Qt figures (bug #45540) * Canvas.h (Canvas::select_object): add a boolean argument that defaults to false. Indicate the method should only look for axes abjects * Canvas.cc (Canvas::select_object): avoid using GL_SELECT mechanism to find axes only. Compare mouse coordinates with all axes limits. diff -r 25caa0deaabb -r 2d415c68213f libgui/graphics/Canvas.cc --- a/libgui/graphics/Canvas.cc Sun Aug 23 14:55:01 2015 +0200 +++ b/libgui/graphics/Canvas.cc Sat Jul 25 13:20:21 2015 +0200 @@ -373,7 +373,8 @@ void Canvas::select_object (graphics_object obj, QMouseEvent* event, - graphics_object ¤tObj, graphics_object &axesObj) + graphics_object ¤tObj, graphics_object &axesObj, + bool axes_only) { QList axesList; Matrix children = obj.get_properties ().get_all_children (); @@ -399,7 +400,30 @@ } } - if (! currentObj) + if (axes_only) + { + QPoint pt = event->pos (); + + for (QList::ConstIterator it = axesList.begin (); + it != axesList.end (); ++it) + { + const axes::properties& ap = + dynamic_cast ((*it).get_properties ()); + + ColumnVector p0 = ap.pixel2coord (pt.x (), pt.y ()); + Matrix xlim = ap.get_xlim ().matrix_value (); + Matrix ylim = ap.get_ylim ().matrix_value (); + + if (xlim(0) < p0(0) && xlim(1) > p0(0) + && ylim(0) < p0(1) && ylim(1) > p0(1)) + { + axesObj = *it; + return; + } + } + + } + else if (! currentObj) { for (QList::ConstIterator it = axesList.begin (); it != axesList.end (); ++it) @@ -505,7 +529,7 @@ if (obj.valid_object ()) { graphics_object currentObj, axesObj; - select_object (obj, event, currentObj, axesObj); + select_object (obj, event, currentObj, axesObj, true); if (axesObj.valid_object ()) { diff -r 25caa0deaabb -r 2d415c68213f libgui/graphics/Canvas.h --- a/libgui/graphics/Canvas.h Sun Aug 23 14:55:01 2015 +0200 +++ b/libgui/graphics/Canvas.h Sat Jul 25 13:20:21 2015 +0200 @@ -109,7 +109,8 @@ void annotation_callback (const octave_value_list& args); void select_object (graphics_object obj, QMouseEvent* event, - graphics_object ¤tObj, graphics_object &axesObj); + graphics_object ¤tObj, graphics_object &axesObj, + bool axes_only = false); private: graphics_handle m_handle;