mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Use curve view window in the abstract class curve view
Change-Id: I2c54cb111944f294e00d45244f23cdda9984bf02
This commit is contained in:
@@ -7,15 +7,34 @@
|
||||
|
||||
constexpr KDColor CurveView::k_axisColor;
|
||||
|
||||
CurveView::CurveView() :
|
||||
View()
|
||||
CurveView::CurveView(CurveViewWindow * curveViewWindow) :
|
||||
View(),
|
||||
m_curveViewWindow(curveViewWindow)
|
||||
{
|
||||
}
|
||||
|
||||
void CurveView::setCurveViewWindow(CurveViewWindow * curveViewWindow) {
|
||||
m_curveViewWindow = curveViewWindow;
|
||||
}
|
||||
|
||||
void CurveView::reload() {
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
float CurveView::min(Axis axis) const {
|
||||
assert(axis == Axis::Horizontal || axis == Axis::Vertical);
|
||||
return (axis == Axis::Horizontal ? m_curveViewWindow->xMin() : m_curveViewWindow->yMin());
|
||||
}
|
||||
|
||||
float CurveView::max(Axis axis) const {
|
||||
assert(axis == Axis::Horizontal || axis == Axis::Vertical);
|
||||
return (axis == Axis::Horizontal ? m_curveViewWindow->xMax() : m_curveViewWindow->yMax());
|
||||
}
|
||||
|
||||
float CurveView::gridUnit(Axis axis) const {
|
||||
return (axis == Axis::Horizontal ? m_curveViewWindow->xGridUnit() : m_curveViewWindow->yGridUnit());
|
||||
}
|
||||
|
||||
KDCoordinate CurveView::pixelLength(Axis axis) const {
|
||||
assert(axis == Axis::Horizontal || axis == Axis::Vertical);
|
||||
return (axis == Axis::Horizontal ? m_frame.width() : m_frame.height());
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <escher.h>
|
||||
#include <poincare.h>
|
||||
#include "curve_view_window.h"
|
||||
|
||||
class CurveView : public View {
|
||||
public:
|
||||
@@ -10,16 +11,17 @@ public:
|
||||
Horizontal = 0,
|
||||
Vertical = 1
|
||||
};
|
||||
CurveView();
|
||||
CurveView(CurveViewWindow * curveViewWindow = nullptr);
|
||||
void reload();
|
||||
protected:
|
||||
constexpr static KDColor k_axisColor = KDColor::RGB24(0x000000);
|
||||
constexpr static KDCoordinate k_labelMargin = 4;
|
||||
constexpr static int k_maxNumberOfXLabels = 18;
|
||||
constexpr static int k_maxNumberOfYLabels = 13;
|
||||
virtual float min(Axis axis) const = 0;
|
||||
virtual float max(Axis axis) const = 0;
|
||||
virtual float gridUnit(Axis axis) const = 0;
|
||||
void setCurveViewWindow(CurveViewWindow * curveViewWindow);
|
||||
float min(Axis axis) const;
|
||||
float max(Axis axis) const;
|
||||
float gridUnit(Axis axis) const;
|
||||
virtual char * label(Axis axis, int index) const = 0;
|
||||
KDCoordinate pixelLength(Axis axis) const;
|
||||
float pixelToFloat(Axis axis, KDCoordinate p) const;
|
||||
@@ -43,6 +45,7 @@ private:
|
||||
* function shifts the stamp (by blending adjacent pixel colors) to draw with
|
||||
* anti alising. */
|
||||
void stampAtLocation(float pxf, float pyf, KDColor color, KDContext * ctx, KDRect rect) const;
|
||||
CurveViewWindow * m_curveViewWindow;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Graph {
|
||||
constexpr KDColor GraphView::k_gridColor;
|
||||
|
||||
GraphView::GraphView(FunctionStore * functionStore, GraphWindow * graphWindow) :
|
||||
CurveView(),
|
||||
CurveView(graphWindow),
|
||||
m_cursorView(CursorView()),
|
||||
m_xCursorPosition(-1.0f),
|
||||
m_yCursorPosition(-1.0f),
|
||||
@@ -60,10 +60,6 @@ void GraphView::reloadCursor() {
|
||||
layoutSubviews();
|
||||
}
|
||||
|
||||
float GraphView::gridUnit(Axis axis) const {
|
||||
return (axis == Axis::Horizontal ? m_graphWindow->xGridUnit() : m_graphWindow->yGridUnit());
|
||||
}
|
||||
|
||||
char * GraphView::label(Axis axis, int index) const {
|
||||
return (axis == Axis::Horizontal ? (char *)m_xLabels[index] : (char *)m_yLabels[index]);
|
||||
}
|
||||
@@ -199,16 +195,6 @@ void GraphView::drawGrid(KDContext * ctx, KDRect rect) const {
|
||||
drawGridLines(ctx, rect, Axis::Vertical, m_graphWindow->yGridUnit(), k_gridColor);
|
||||
}
|
||||
|
||||
float GraphView::min(Axis axis) const {
|
||||
assert(axis == Axis::Horizontal || axis == Axis::Vertical);
|
||||
return (axis == Axis::Horizontal ? m_graphWindow->xMin() : m_graphWindow->yMin());
|
||||
}
|
||||
|
||||
float GraphView::max(Axis axis) const {
|
||||
assert(axis == Axis::Horizontal || axis == Axis::Vertical);
|
||||
return (axis == Axis::Horizontal ? m_graphWindow->xMax() : m_graphWindow->yMax());
|
||||
}
|
||||
|
||||
float GraphView::evaluateCurveAtAbscissa(void * curve, float abscissa) const {
|
||||
Function * f = (Function *)curve;
|
||||
return f->evaluateAtAbscissa(abscissa, m_context);
|
||||
|
||||
@@ -40,9 +40,6 @@ private:
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews() override;
|
||||
|
||||
float min(Axis axis) const override;
|
||||
float max(Axis axis) const override;
|
||||
float gridUnit(Axis axis) const override;
|
||||
char * label(Axis axis, int index) const override;
|
||||
float evaluateCurveAtAbscissa(void * expression, float abscissa) const override;
|
||||
void drawGrid(KDContext * ctx, KDRect rect) const;
|
||||
|
||||
@@ -12,6 +12,7 @@ LawCurveView::LawCurveView() :
|
||||
}
|
||||
|
||||
void LawCurveView::setLaw(Law * law) {
|
||||
setCurveViewWindow(law);
|
||||
m_law = law;
|
||||
}
|
||||
|
||||
@@ -45,21 +46,6 @@ void LawCurveView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
}
|
||||
}
|
||||
|
||||
float LawCurveView::min(Axis axis) const {
|
||||
assert(axis == Axis::Horizontal || axis == Axis::Vertical);
|
||||
return (axis == Axis::Horizontal ? m_law->xMin() : m_law->yMin());
|
||||
}
|
||||
|
||||
float LawCurveView::max(Axis axis) const {
|
||||
assert(axis == Axis::Horizontal || axis == Axis::Vertical);
|
||||
return (axis == Axis::Horizontal ? m_law->xMax() : m_law->yMax());
|
||||
}
|
||||
|
||||
float LawCurveView::gridUnit(Axis axis) const {
|
||||
assert(axis == Axis::Horizontal);
|
||||
return m_law->xGridUnit();
|
||||
}
|
||||
|
||||
char * LawCurveView::label(Axis axis, int index) const {
|
||||
assert(axis == Axis::Horizontal);
|
||||
return (char *)m_labels[index];
|
||||
|
||||
@@ -18,9 +18,6 @@ public:
|
||||
void reload();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
protected:
|
||||
float min(Axis axis) const override;
|
||||
float max(Axis axis) const override;
|
||||
float gridUnit(Axis axis) const override;
|
||||
char * label(Axis axis, int index) const override;
|
||||
private:
|
||||
char m_labels[k_maxNumberOfXLabels][Constant::FloatBufferSizeInScientificMode];
|
||||
|
||||
Reference in New Issue
Block a user