mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/shared] computeYRange clips tMin..tMax to xMin..xMax if possible
This commit is contained in:
@@ -42,6 +42,7 @@ public:
|
||||
int derivativeNameWithArgument(char * buffer, size_t bufferSize);
|
||||
double approximateDerivative(double x, Poincare::Context * context) const;
|
||||
// tMin and tMax
|
||||
bool shouldClipTRangeToXRange() const override { return plotType() == PlotType::Cartesian; }
|
||||
double tMin() const override;
|
||||
double tMax() const override;
|
||||
void setTMin(double tMin);
|
||||
|
||||
@@ -531,6 +531,7 @@ void CurveView::drawCurve(KDContext * ctx, KDRect rect, float tStart, float tEnd
|
||||
void CurveView::drawCartesianCurve(KDContext * ctx, KDRect rect, float xMin, float xMax, EvaluateXYForParameter xyEvaluation, void * model, void * context, KDColor color, bool colorUnderCurve, float colorLowerBound, float colorUpperBound) const {
|
||||
float tStart = maxFloat(xMin, pixelToFloat(Axis::Horizontal, rect.left() - k_externRectMargin));
|
||||
float tEnd = minFloat(xMax, pixelToFloat(Axis::Horizontal, rect.right() + k_externRectMargin));
|
||||
assert(!std::isinf(tStart) && !std::isnan(tStart) && !std::isinf(tEnd) && !std::isnan(tEnd) );
|
||||
if (tStart > tEnd) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
void setActive(bool active);
|
||||
|
||||
// Definition Interval
|
||||
virtual bool shouldClipTRangeToXRange() const { return true; } // Returns true if the function will not be displayed if t is outside x range.
|
||||
virtual double tMin() const { return NAN; }
|
||||
virtual double tMax() const { return NAN; }
|
||||
|
||||
|
||||
@@ -92,10 +92,14 @@ InteractiveCurveViewRangeDelegate::Range FunctionGraphController::computeYRange(
|
||||
double tMin = f->tMin();
|
||||
if (std::isnan(tMin)) {
|
||||
tMin = xMin;
|
||||
} else if (f->shouldClipTRangeToXRange()) {
|
||||
tMin = maxFloat(tMin, xMin);
|
||||
}
|
||||
double tMax = f->tMax();
|
||||
if (std::isnan(tMax)) {
|
||||
tMax = xMax;
|
||||
} else if (f->shouldClipTRangeToXRange()) {
|
||||
tMax = minFloat(tMax, xMax);
|
||||
}
|
||||
const int balancedBound = std::floor((tMax-tMin)/2/step);
|
||||
for (int j = -balancedBound; j <= balancedBound ; j++) {
|
||||
|
||||
Reference in New Issue
Block a user