mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-27 01:29:58 +01:00
[apps/sequence] Clip default range initialisation to 0 on X range for
sequences Change-Id: I501a397ce3016ba605bd9aca950b87a2ca295000
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#include "curve_view_range.h"
|
||||
#include <math.h>
|
||||
#include <ion.h>
|
||||
#include <poincare.h>
|
||||
|
||||
using namespace Shared;
|
||||
using namespace Poincare;
|
||||
|
||||
namespace Sequence {
|
||||
|
||||
@@ -10,6 +14,53 @@ CurveViewRange::CurveViewRange(CurveViewCursor * cursor, InteractiveCurveViewRan
|
||||
m_xMin = -k_displayLeftMarginRatio*m_xMax;
|
||||
}
|
||||
|
||||
void CurveViewRange::roundAbscissa() {
|
||||
float xMin = m_xMin;
|
||||
float xMax = m_xMax;
|
||||
m_xMin = roundf((xMin+xMax)/2) - (float)Ion::Display::Width/2.0f;
|
||||
m_xMax = roundf((xMin+xMax)/2) + (float)Ion::Display::Width/2.0f-1.0f;
|
||||
if (m_xMin < 0.0f) {
|
||||
m_xMin = -k_displayLeftMarginRatio*(float)Ion::Display::Width;
|
||||
m_xMax = m_xMin+(float)Ion::Display::Width;
|
||||
}
|
||||
m_xGridUnit = computeGridUnit(Axis::X, m_xMin, m_xMax);
|
||||
if (m_delegate) {
|
||||
m_delegate->didChangeRange(this);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveViewRange::normalize() {
|
||||
float xMin = m_xMin;
|
||||
float xMax = m_xMax;
|
||||
float yMin = m_yMin;
|
||||
float yMax = m_yMax;
|
||||
m_xMin = (xMin+xMax)/2 - 5.3f;
|
||||
m_xMax = (xMin+xMax)/2 + 5.3f;
|
||||
if (m_xMin < 0.0f) {
|
||||
m_xMin = -k_displayLeftMarginRatio*2.0f*5.3f;
|
||||
m_xMax = m_xMin + 2.0f*5.3f;
|
||||
}
|
||||
m_xGridUnit = computeGridUnit(Axis::X, m_xMin, m_xMax);
|
||||
m_yAuto = false;
|
||||
m_yMin = (yMin+yMax)/2 - 3.1f;
|
||||
m_yMax = (yMin+yMax)/2 + 3.1f;
|
||||
m_yGridUnit = computeGridUnit(Axis::Y, m_yMin, m_yMax);
|
||||
}
|
||||
|
||||
void CurveViewRange::setTrigonometric() {
|
||||
m_xMin = -k_displayLeftMarginRatio*21.0f;
|
||||
m_xMax = 21.0f;
|
||||
if (Preferences::sharedPreferences()->angleUnit() == Expression::AngleUnit::Degree) {
|
||||
m_xMin = -k_displayLeftMarginRatio*1200;
|
||||
m_xMax = 1200;
|
||||
}
|
||||
m_xGridUnit = computeGridUnit(Axis::X, m_xMin, m_xMax);
|
||||
m_yAuto = false;
|
||||
m_yMin = -1.6f;
|
||||
m_yMax = 1.6f;
|
||||
m_yGridUnit = computeGridUnit(Axis::Y, m_yMin, m_yMax);
|
||||
}
|
||||
|
||||
void CurveViewRange::setDefault() {
|
||||
m_xMax = 10.0f;
|
||||
m_xMin = -k_displayLeftMarginRatio*m_xMax;
|
||||
|
||||
@@ -8,6 +8,9 @@ namespace Sequence {
|
||||
class CurveViewRange : public Shared::InteractiveCurveViewRange {
|
||||
public:
|
||||
CurveViewRange(Shared::CurveViewCursor * cursor, Shared::InteractiveCurveViewRangeDelegate * delegate);
|
||||
void roundAbscissa() override;
|
||||
void normalize() override;
|
||||
void setTrigonometric() override;
|
||||
void setDefault() override;
|
||||
private:
|
||||
constexpr static float k_displayLeftMarginRatio = 0.05f;
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace Shared {
|
||||
InteractiveCurveViewRange::InteractiveCurveViewRange(CurveViewCursor * cursor, InteractiveCurveViewRangeDelegate * delegate) :
|
||||
MemoizedCurveViewRange(),
|
||||
m_yAuto(true),
|
||||
m_cursor(cursor),
|
||||
m_delegate(delegate)
|
||||
m_delegate(delegate),
|
||||
m_cursor(cursor)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,18 @@ public:
|
||||
// Window
|
||||
void zoom(float ratio);
|
||||
void panWithVector(float x, float y);
|
||||
void roundAbscissa();
|
||||
void normalize();
|
||||
void setTrigonometric();
|
||||
virtual void roundAbscissa();
|
||||
virtual void normalize();
|
||||
virtual void setTrigonometric();
|
||||
virtual void setDefault();
|
||||
void centerAxisAround(Axis axis, float position);
|
||||
void panToMakePointVisible(float x, float y, float topMarginRatio, float rightMarginRatio, float bottomMarginRation, float leftMarginRation);
|
||||
protected:
|
||||
bool m_yAuto;
|
||||
InteractiveCurveViewRangeDelegate * m_delegate;
|
||||
private:
|
||||
constexpr static float k_minFloat = 1E-8f;
|
||||
CurveViewCursor * m_cursor;
|
||||
InteractiveCurveViewRangeDelegate * m_delegate;
|
||||
};
|
||||
|
||||
typedef void (InteractiveCurveViewRange::*ParameterSetterPointer)(float);
|
||||
|
||||
Reference in New Issue
Block a user