Mercurial > octave
changeset 20472:2d415c68213f
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.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Sat, 25 Jul 2015 13:20:21 +0200 |
parents | 25caa0deaabb |
children | 4c2e76cbdc7d |
files | libgui/graphics/Canvas.cc libgui/graphics/Canvas.h |
diffstat | 2 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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<graphics_object> axesList; Matrix children = obj.get_properties ().get_all_children (); @@ -399,7 +400,30 @@ } } - if (! currentObj) + if (axes_only) + { + QPoint pt = event->pos (); + + for (QList<graphics_object>::ConstIterator it = axesList.begin (); + it != axesList.end (); ++it) + { + const axes::properties& ap = + dynamic_cast<const axes::properties&> ((*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<graphics_object>::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 ()) {
--- 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;