[python] Matplotlib: plot_controller inherits from

ZoomAndPanCurveViewController to be able to pan
This commit is contained in:
Émilie Feral
2020-03-23 13:53:26 +01:00
parent d504564334
commit 4022cdfa60

View File

@@ -1,37 +1,25 @@
#ifndef PYTHON_MATPLOTLIB_PLOT_CONTROLLER_H
#define PYTHON_MATPLOTLIB_PLOT_CONTROLLER_H
#include <apps/shared/simple_interactive_curve_view_controller.h>
#include <apps/shared/curve_view_cursor.h>
#include <apps/shared/zoom_and_pan_curve_view_controller.h>
#include <python/port/port.h>
#include "plot_view.h"
#include "plot_store.h"
namespace Matplotlib {
class PlotController : public Shared::SimpleInteractiveCurveViewController, public MicroPython::ExecutionViewControllerHelper {
class PlotController : public Shared::ZoomAndPanCurveViewController, public MicroPython::ExecutionViewControllerHelper {
public:
PlotController(PlotStore * store, MicroPython::ExecutionEnvironment * executiveEnvironment) : Shared::SimpleInteractiveCurveViewController(nullptr, &m_cursor), ExecutionViewControllerHelper(executiveEnvironment), m_store(store), m_view(m_store) {}
PlotController(PlotStore * store, MicroPython::ExecutionEnvironment * executiveEnvironment) : Shared::ZoomAndPanCurveViewController(nullptr), ExecutionViewControllerHelper(executiveEnvironment), m_store(store), m_view(m_store) {}
void viewWillAppear() override { MicroPython::ExecutionViewControllerHelper::viewWillAppear(this); }
void viewDidDisappear() override { MicroPython::ExecutionViewControllerHelper::viewDidDisappear(this); }
float cursorBottomMarginRatio() override {
return 0.0f;
}
virtual void reloadBannerView() override {
}
virtual bool handleEnter() override {
return false;
}
protected:
Shared::CurveView * curveView() override { return &m_view; }
Shared::InteractiveCurveViewRange * interactiveCurveViewRange() override { return m_store; }
private:
PlotStore * m_store;
Shared::CurveViewCursor m_cursor;
PlotView m_view;
};