Mercurial > octave-libtiff
changeset 19870:815db217f6f4
provide autoscale option for Qt plotting (bug #44307)
* Canvas.h, Canvas.cc (Canvas::autoAxes): New pure virtual function.
(Canvas::canvasAutoAxes): New function.
(autoscale_axes): New static function.
(Canvas::canvasMouseDoubleClickEvent, Canvas::canvasMousePressEvent):
Use it.
* Figure.h, Figure.cc (Figure::createFigureToolBarAndMenuBar):
Add autoscale button to window.
(Figure::autoAxes): New function.
* GLCanvas.h, GLCanvas.cc (GLCanvas::autoAxes): New function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 27 Feb 2015 11:24:12 -0500 |
parents | 60fe3ef12bb0 |
children | ed5ee3f610db |
files | libgui/graphics/Canvas.cc libgui/graphics/Canvas.h libgui/graphics/Figure.cc libgui/graphics/Figure.h libgui/graphics/GLCanvas.cc libgui/graphics/GLCanvas.h |
diffstat | 6 files changed, 61 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/Canvas.cc Thu Feb 26 18:57:58 2015 -0600 +++ b/libgui/graphics/Canvas.cc Fri Feb 27 11:24:12 2015 -0500 @@ -199,6 +199,44 @@ } } +static void +autoscale_axes (axes::properties& ap) +{ + ap.clear_zoom_stack (); + + ap.set_xlimmode ("auto"); + ap.set_ylimmode ("auto"); + ap.set_zlimmode ("auto"); +} + +void Canvas::canvasAutoAxes (const graphics_handle& handle) +{ + gh_manager::auto_lock lock; + + graphics_object go = gh_manager::get_object (handle); + + if (go.valid_object ()) + { + figure::properties& fp = Utils::properties<figure> (go); + + graphics_handle ah = fp.get_currentaxes (); + + graphics_object ax = gh_manager::get_object (ah); + + if (ax.valid_object ()) + { + axes::properties& ap = Utils::properties<axes> (ax); + + if (ap.handlevisibility_is ("on") && ap.is_visible ()) + { + autoscale_axes (ap); + + redraw (true); + } + } + } +} + void Canvas::canvasPaintEvent (void) { if (! m_redrawBlocked) @@ -397,10 +435,7 @@ axes::properties& ap = Utils::properties<axes> (axesObj); - ap.clear_zoom_stack (); - ap.set_xlimmode ("auto"); - ap.set_ylimmode ("auto"); - ap.set_zlimmode ("auto"); + autoscale_axes (ap); } } @@ -573,10 +608,7 @@ axes::properties& ap = Utils::properties<axes> (axesObj); - ap.clear_zoom_stack (); - ap.set_xlimmode ("auto"); - ap.set_ylimmode ("auto"); - ap.set_zlimmode ("auto"); + autoscale_axes (ap); } break;
--- a/libgui/graphics/Canvas.h Thu Feb 26 18:57:58 2015 -0600 +++ b/libgui/graphics/Canvas.h Fri Feb 27 11:24:12 2015 -0500 @@ -67,6 +67,7 @@ virtual void toggleAxes (const graphics_handle& handle) = 0; virtual void toggleGrid (const graphics_handle& handle) = 0; + virtual void autoAxes (const graphics_handle& handle) = 0; protected: virtual void draw (const graphics_handle& handle) = 0; @@ -85,6 +86,7 @@ void canvasToggleAxes (const graphics_handle& handle); void canvasToggleGrid (const graphics_handle& handle); + void canvasAutoAxes (const graphics_handle& handle); void canvasPaintEvent (void); void canvasMouseDoubleClickEvent (QMouseEvent* event); void canvasMouseMoveEvent (QMouseEvent* event);
--- a/libgui/graphics/Figure.cc Thu Feb 26 18:57:58 2015 -0600 +++ b/libgui/graphics/Figure.cc Fri Feb 27 11:24:12 2015 -0500 @@ -282,6 +282,10 @@ connect (toggle_grid, SIGNAL (triggered (void)), this, SLOT (toggleGrid (void))); + QAction *auto_axes = m_figureToolBar->addAction ("Autoscale"); + connect (auto_axes, SIGNAL (triggered (void)), + this, SLOT (autoAxes (void))); + m_menuBar = new MenuBar (win); win->setMenuBar (m_menuBar); @@ -860,4 +864,12 @@ canvas->toggleGrid (m_handle); } +void Figure::autoAxes (void) +{ + Canvas* canvas = m_container->canvas (m_handle); + + if (canvas) + canvas->autoAxes (m_handle); +} + }; // namespace QtHandles
--- a/libgui/graphics/Figure.h Thu Feb 26 18:57:58 2015 -0600 +++ b/libgui/graphics/Figure.h Fri Feb 27 11:24:12 2015 -0500 @@ -123,6 +123,7 @@ void updateContainer (void); void toggleAxes (void); void toggleGrid (void); + void autoAxes (void); signals: void asyncUpdate (void);
--- a/libgui/graphics/GLCanvas.cc Thu Feb 26 18:57:58 2015 -0600 +++ b/libgui/graphics/GLCanvas.cc Fri Feb 27 11:24:12 2015 -0500 @@ -70,6 +70,11 @@ canvasToggleGrid (gh); } +void GLCanvas::autoAxes (const graphics_handle& gh) +{ + canvasAutoAxes (gh); +} + graphics_object GLCanvas::selectFromAxes (const graphics_object& ax, const QPoint& pt) {
--- a/libgui/graphics/GLCanvas.h Thu Feb 26 18:57:58 2015 -0600 +++ b/libgui/graphics/GLCanvas.h Fri Feb 27 11:24:12 2015 -0500 @@ -39,6 +39,7 @@ void draw (const graphics_handle& handle); void toggleAxes (const graphics_handle& handle); void toggleGrid (const graphics_handle& handle); + void autoAxes (const graphics_handle& handle); void drawZoomBox (const QPoint& p1, const QPoint& p2); void resize (int /* x */, int /* y */, int /* width */, int /* height */) { }