mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps] Graph: when setting default range of a function, take
into account the potential periodicity
This commit is contained in:
committed by
EmilieNumworks
parent
660775903f
commit
05055c387f
@@ -39,6 +39,19 @@ void GraphController::setDisplayDerivativeInBanner(bool displayDerivative) {
|
||||
m_displayDerivativeInBanner = displayDerivative;
|
||||
}
|
||||
|
||||
float GraphController::interestingXRange() {
|
||||
float characteristicRange = 0.0f;
|
||||
TextFieldDelegateApp * myApp = (TextFieldDelegateApp *)app();
|
||||
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
|
||||
Function * f = functionStore()->activeFunctionAtIndex(i);
|
||||
float fRange = f->expression(myApp->localContext())->characteristicXRange(*(myApp->localContext()));
|
||||
if (!std::isnan(fRange)) {
|
||||
characteristicRange = fRange > characteristicRange ? fRange : characteristicRange;
|
||||
}
|
||||
}
|
||||
return (characteristicRange > 0.0f ? 1.6f*characteristicRange : 10.0f);
|
||||
}
|
||||
|
||||
void GraphController::selectFunctionWithCursor(int functionIndex) {
|
||||
FunctionGraphController::selectFunctionWithCursor(functionIndex);
|
||||
CartesianFunction * f = m_functionStore->activeFunctionAtIndex(indexFunctionSelectedByCursor());
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
void viewWillAppear() override;
|
||||
bool displayDerivativeInBanner() const;
|
||||
void setDisplayDerivativeInBanner(bool displayDerivative);
|
||||
float interestingXRange() override;
|
||||
private:
|
||||
void selectFunctionWithCursor(int functionIndex) override;
|
||||
BannerView * bannerView() override;
|
||||
|
||||
@@ -75,7 +75,8 @@ void CurveViewRange::setTrigonometric() {
|
||||
}
|
||||
|
||||
void CurveViewRange::setDefault() {
|
||||
m_xMax = 10.0f;
|
||||
assert(m_delegate);
|
||||
m_xMax = m_delegate->interestingXRange();
|
||||
m_xMin = -k_displayLeftMarginRatio*m_xMax;
|
||||
m_xGridUnit = computeGridUnit(Axis::X, m_xMin, m_xMax);
|
||||
setYAuto(true);
|
||||
|
||||
@@ -167,8 +167,9 @@ void InteractiveCurveViewRange::setTrigonometric() {
|
||||
}
|
||||
|
||||
void InteractiveCurveViewRange::setDefault() {
|
||||
m_xMax = 10.0f;
|
||||
MemoizedCurveViewRange::setXMin(-10.0f);
|
||||
assert(m_delegate);
|
||||
m_xMax = m_delegate->interestingXRange();
|
||||
MemoizedCurveViewRange::setXMin(-m_xMax);
|
||||
setYAuto(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,4 +48,8 @@ bool InteractiveCurveViewRangeDelegate::didChangeRange(InteractiveCurveViewRange
|
||||
return true;
|
||||
}
|
||||
|
||||
float InteractiveCurveViewRangeDelegate::interestingXRange() {
|
||||
return 10.0f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ class InteractiveCurveViewRange;
|
||||
class InteractiveCurveViewRangeDelegate {
|
||||
public:
|
||||
bool didChangeRange(InteractiveCurveViewRange * interactiveCurveViewRange);
|
||||
virtual float interestingXRange();
|
||||
protected:
|
||||
struct Range {
|
||||
float min;
|
||||
|
||||
Reference in New Issue
Block a user