Mercurial > octave-nkf
comparison libgui/graphics/Canvas.cc @ 20507: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 | 64f6d0543626 |
children | 79eb0746b21f |
comparison
equal
deleted
inserted
replaced
20506:25caa0deaabb | 20507:2d415c68213f |
---|---|
371 return zm.contents ("Motion").string_value (); | 371 return zm.contents ("Motion").string_value (); |
372 } | 372 } |
373 | 373 |
374 void | 374 void |
375 Canvas::select_object (graphics_object obj, QMouseEvent* event, | 375 Canvas::select_object (graphics_object obj, QMouseEvent* event, |
376 graphics_object ¤tObj, graphics_object &axesObj) | 376 graphics_object ¤tObj, graphics_object &axesObj, |
377 bool axes_only) | |
377 { | 378 { |
378 QList<graphics_object> axesList; | 379 QList<graphics_object> axesList; |
379 Matrix children = obj.get_properties ().get_all_children (); | 380 Matrix children = obj.get_properties ().get_all_children (); |
380 octave_idx_type num_children = children.numel (); | 381 octave_idx_type num_children = children.numel (); |
381 | 382 |
397 break; | 398 break; |
398 } | 399 } |
399 } | 400 } |
400 } | 401 } |
401 | 402 |
402 if (! currentObj) | 403 if (axes_only) |
404 { | |
405 QPoint pt = event->pos (); | |
406 | |
407 for (QList<graphics_object>::ConstIterator it = axesList.begin (); | |
408 it != axesList.end (); ++it) | |
409 { | |
410 const axes::properties& ap = | |
411 dynamic_cast<const axes::properties&> ((*it).get_properties ()); | |
412 | |
413 ColumnVector p0 = ap.pixel2coord (pt.x (), pt.y ()); | |
414 Matrix xlim = ap.get_xlim ().matrix_value (); | |
415 Matrix ylim = ap.get_ylim ().matrix_value (); | |
416 | |
417 if (xlim(0) < p0(0) && xlim(1) > p0(0) | |
418 && ylim(0) < p0(1) && ylim(1) > p0(1)) | |
419 { | |
420 axesObj = *it; | |
421 return; | |
422 } | |
423 } | |
424 | |
425 } | |
426 else if (! currentObj) | |
403 { | 427 { |
404 for (QList<graphics_object>::ConstIterator it = axesList.begin (); | 428 for (QList<graphics_object>::ConstIterator it = axesList.begin (); |
405 it != axesList.end (); ++it) | 429 it != axesList.end (); ++it) |
406 { | 430 { |
407 graphics_object go = selectFromAxes (*it, event->pos ()); | 431 graphics_object go = selectFromAxes (*it, event->pos ()); |
503 graphics_object obj = gh_manager::get_object (m_handle); | 527 graphics_object obj = gh_manager::get_object (m_handle); |
504 | 528 |
505 if (obj.valid_object ()) | 529 if (obj.valid_object ()) |
506 { | 530 { |
507 graphics_object currentObj, axesObj; | 531 graphics_object currentObj, axesObj; |
508 select_object (obj, event, currentObj, axesObj); | 532 select_object (obj, event, currentObj, axesObj, true); |
509 | 533 |
510 if (axesObj.valid_object ()) | 534 if (axesObj.valid_object ()) |
511 { | 535 { |
512 Figure* fig = | 536 Figure* fig = |
513 dynamic_cast<Figure*> (Backend::toolkitObject (obj)); | 537 dynamic_cast<Figure*> (Backend::toolkitObject (obj)); |