mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-23 07:40:42 +01:00
[apps] Graph: In graphview, replace the type by a boolean to decide
wether to draw tangent
This commit is contained in:
committed by
EmilieNumworks
parent
cdfbc02499
commit
53b90034da
@@ -26,7 +26,7 @@ I18n::Message GraphController::emptyMessage() {
|
||||
}
|
||||
|
||||
void GraphController::viewWillAppear() {
|
||||
m_view.setType(GraphView::Type::Default);
|
||||
m_view.drawTangent(false);
|
||||
FunctionGraphController::viewWillAppear();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ public:
|
||||
bool displayDerivativeInBanner() const;
|
||||
void setDisplayDerivativeInBanner(bool displayDerivative);
|
||||
private:
|
||||
GraphView::Type type() const;
|
||||
BannerView * bannerView() override;
|
||||
void reloadBannerView() override;
|
||||
bool moveCursorHorizontally(int direction) override;
|
||||
|
||||
@@ -8,12 +8,12 @@ GraphView::GraphView(CartesianFunctionStore * functionStore, InteractiveCurveVie
|
||||
CurveViewCursor * cursor, BannerView * bannerView, View * cursorView) :
|
||||
FunctionGraphView(graphRange, cursor, bannerView, cursorView),
|
||||
m_functionStore(functionStore),
|
||||
m_type(Type::Default)
|
||||
m_tangent(false)
|
||||
{
|
||||
}
|
||||
|
||||
void GraphView::reload() {
|
||||
if (m_type == Type::Tangent) {
|
||||
if (m_tangent) {
|
||||
KDRect dirtyZone(KDRect(0, 0, bounds().width(), bounds().height()-m_bannerView->bounds().height()));
|
||||
markRectAsDirty(dirtyZone);
|
||||
}
|
||||
@@ -29,7 +29,7 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
Poincare::Context * c = (Poincare::Context *)context;
|
||||
return f->evaluateAtAbscissa(t, c);
|
||||
}, f, context(), f->color());
|
||||
if (m_type == Type::Tangent && f == m_selectedFunction) {
|
||||
if (m_tangent && f == m_selectedFunction) {
|
||||
float tangentParameter[2];
|
||||
tangentParameter[0] = f->approximateDerivative(m_curveViewCursor->x(), context());
|
||||
tangentParameter[1] = -tangentParameter[0]*m_curveViewCursor->x()+f->evaluateAtAbscissa(m_curveViewCursor->x(), context());
|
||||
|
||||
@@ -8,20 +8,15 @@ namespace Graph {
|
||||
|
||||
class GraphView : public Shared::FunctionGraphView {
|
||||
public:
|
||||
enum class Type {
|
||||
Default,
|
||||
Tangent,
|
||||
Integral
|
||||
};
|
||||
|
||||
GraphView(CartesianFunctionStore * functionStore, Shared::InteractiveCurveViewRange * graphRange,
|
||||
Shared::CurveViewCursor * cursor, Shared::BannerView * bannerView, View * cursorView);
|
||||
void reload() override;
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
Type type() const { return m_type; }
|
||||
void setType(Type type) { m_type = type; }
|
||||
void drawTangent(bool tangent) { m_tangent = tangent; }
|
||||
private:
|
||||
CartesianFunctionStore * m_functionStore;
|
||||
Type m_type;
|
||||
bool m_tangent;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ const char * TangentGraphController::title() {
|
||||
|
||||
void TangentGraphController::viewWillAppear() {
|
||||
m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
m_graphView->setType(GraphView::Type::Tangent);
|
||||
m_graphView->drawTangent(true);
|
||||
m_graphView->setOkView(nullptr);
|
||||
m_graphView->selectMainView(true);
|
||||
reloadBannerView();
|
||||
|
||||
Reference in New Issue
Block a user