mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[curve_view] Fixed variable names
Change-Id: I8aad13c6bce719ba8f3a30cd86f06f7c89ec041e
This commit is contained in:
committed by
LeaNumworks
parent
fe8e490ac0
commit
26fdfcd25c
@@ -602,7 +602,7 @@ const uint8_t thickStampMask[(thickStampSize+1)*(thickStampSize+1)] = {
|
||||
|
||||
constexpr static int k_maxNumberOfIterations = 10;
|
||||
|
||||
void CurveView::drawCurve(KDContext * ctx, KDRect rect, float tStart, float tEnd, float tStep, EvaluateXYForParameter xyEvaluation, void * model, void * context, bool drawStraightLinesEarly, KDColor color, bool thick, bool colorUnderCurve, float colorLowerBound, float colorUpperBound, EvaluateXYForParameterDouble xyEvaluationDouble) const {
|
||||
void CurveView::drawCurve(KDContext * ctx, KDRect rect, float tStart, float tEnd, float tStep, EvaluateXYForFloatParameter xyFloatEvaluation, void * model, void * context, bool drawStraightLinesEarly, KDColor color, bool thick, bool colorUnderCurve, float colorLowerBound, float colorUpperBound, EvaluateXYForDoubleParameter xyDoubleEvaluation) const {
|
||||
float previousT = NAN;
|
||||
float t = NAN;
|
||||
float previousX = NAN;
|
||||
@@ -624,17 +624,17 @@ void CurveView::drawCurve(KDContext * ctx, KDRect rect, float tStart, float tEnd
|
||||
}
|
||||
previousX = x;
|
||||
previousY = y;
|
||||
Coordinate2D<float> xy = xyEvaluation(t, model, context);
|
||||
Coordinate2D<float> xy = xyFloatEvaluation(t, model, context);
|
||||
x = xy.x1();
|
||||
y = xy.x2();
|
||||
if (colorUnderCurve && !std::isnan(x) && colorLowerBound < x && x < colorUpperBound && !(std::isnan(y) || std::isinf(y))) {
|
||||
drawHorizontalOrVerticalSegment(ctx, rect, Axis::Vertical, x, std::min(0.0f, y), std::max(0.0f, y), color, 1);
|
||||
}
|
||||
joinDots(ctx, rect, xyEvaluation, model, context, drawStraightLinesEarly, previousT, previousX, previousY, t, x, y, color, thick, k_maxNumberOfIterations, xyEvaluationDouble);
|
||||
joinDots(ctx, rect, xyFloatEvaluation, model, context, drawStraightLinesEarly, previousT, previousX, previousY, t, x, y, color, thick, k_maxNumberOfIterations, xyDoubleEvaluation);
|
||||
} while (true);
|
||||
}
|
||||
|
||||
void CurveView::drawCartesianCurve(KDContext * ctx, KDRect rect, float xMin, float xMax, EvaluateXYForParameter xyEvaluation, void * model, void * context, KDColor color, bool thick, bool colorUnderCurve, float colorLowerBound, float colorUpperBound, EvaluateXYForParameterDouble xyEvaluationDouble) const {
|
||||
void CurveView::drawCartesianCurve(KDContext * ctx, KDRect rect, float xMin, float xMax, EvaluateXYForFloatParameter xyFloatEvaluation, void * model, void * context, KDColor color, bool thick, bool colorUnderCurve, float colorLowerBound, float colorUpperBound, EvaluateXYForDoubleParameter xyDoubleEvaluation) const {
|
||||
float rectLeft = pixelToFloat(Axis::Horizontal, rect.left() - k_externRectMargin);
|
||||
float rectRight = pixelToFloat(Axis::Horizontal, rect.right() + k_externRectMargin);
|
||||
float tStart = std::isnan(rectLeft) ? xMin : std::max(xMin, rectLeft);
|
||||
@@ -644,7 +644,7 @@ void CurveView::drawCartesianCurve(KDContext * ctx, KDRect rect, float xMin, flo
|
||||
return;
|
||||
}
|
||||
float tStep = pixelWidth();
|
||||
drawCurve(ctx, rect, tStart, tEnd, tStep, xyEvaluation, model, context, true, color, thick, colorUnderCurve, colorLowerBound, colorUpperBound, xyEvaluationDouble);
|
||||
drawCurve(ctx, rect, tStart, tEnd, tStep, xyFloatEvaluation, model, context, true, color, thick, colorUnderCurve, colorLowerBound, colorUpperBound, xyDoubleEvaluation);
|
||||
}
|
||||
|
||||
void CurveView::drawHistogram(KDContext * ctx, KDRect rect, EvaluateYForX yEvaluation, void * model, void * context, float firstBarAbscissa, float barWidth,
|
||||
@@ -685,7 +685,7 @@ void CurveView::drawHistogram(KDContext * ctx, KDRect rect, EvaluateYForX yEvalu
|
||||
}
|
||||
}
|
||||
|
||||
void CurveView::joinDots(KDContext * ctx, KDRect rect, EvaluateXYForParameter xyEvaluation , void * model, void * context, bool drawStraightLinesEarly, float t, float x, float y, float s, float u, float v, KDColor color, bool thick, int maxNumberOfRecursion, EvaluateXYForParameterDouble xyEvaluationDouble) const {
|
||||
void CurveView::joinDots(KDContext * ctx, KDRect rect, EvaluateXYForFloatParameter xyFloatEvaluation , void * model, void * context, bool drawStraightLinesEarly, float t, float x, float y, float s, float u, float v, KDColor color, bool thick, int maxNumberOfRecursion, EvaluateXYForDoubleParameter xyDoubleEvaluation) const {
|
||||
const bool isFirstDot = std::isnan(t);
|
||||
const bool isLeftDotValid = !(
|
||||
std::isnan(x) || std::isinf(x) ||
|
||||
@@ -709,19 +709,15 @@ void CurveView::joinDots(KDContext * ctx, KDRect rect, EvaluateXYForParameter xy
|
||||
|| (isLeftDotValid && deltaX*deltaX + deltaY*deltaY < circleDiameter * circleDiameter / 4.0f)) { // the dots are already close enough
|
||||
// the dots are already joined
|
||||
/* We need to be sure that the point is not an artifact caused by error
|
||||
* in float approximation. The value of pixelTolerance matters little,
|
||||
* as wrong points will be off by a large margin. */
|
||||
constexpr float pixelTolerance = 1.f;
|
||||
float pvD = xyEvaluationDouble ? floatToPixel(Axis::Vertical, static_cast<float>(xyEvaluationDouble(u, model, context).x2())) : pvf;
|
||||
if (std::fabs(pvf - pvD) < pixelTolerance) {
|
||||
stampAtLocation(ctx, rect, puf, pvf, color, thick);
|
||||
}
|
||||
* in float approximation. */
|
||||
float pvd = xyDoubleEvaluation ? floatToPixel(Axis::Vertical, static_cast<float>(xyDoubleEvaluation(u, model, context).x2())) : pvf;
|
||||
stampAtLocation(ctx, rect, puf, pvd, color, thick);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Middle point
|
||||
float ct = (t + s)/2.0f;
|
||||
Coordinate2D<float> cxy = xyEvaluation(ct, model, context);
|
||||
Coordinate2D<float> cxy = xyFloatEvaluation(ct, model, context);
|
||||
float cx = cxy.x1();
|
||||
float cy = cxy.x2();
|
||||
if ((drawStraightLinesEarly || maxNumberOfRecursion == 0) && isRightDotValid && isLeftDotValid &&
|
||||
@@ -730,12 +726,12 @@ void CurveView::joinDots(KDContext * ctx, KDRect rect, EvaluateXYForParameter xy
|
||||
* can draw a 'straight' line between the two */
|
||||
|
||||
constexpr float dangerousSlope = 1e6f;
|
||||
if (xyEvaluationDouble && std::fabs((v-y) / (u-x)) > dangerousSlope) {
|
||||
if (xyDoubleEvaluation && std::fabs((v-y) / (u-x)) > dangerousSlope) {
|
||||
/* We need to make sure we're not drawing a vertical asymptote because of
|
||||
* rounding errors. */
|
||||
Coordinate2D<double> xyD = xyEvaluationDouble(static_cast<double>(t), model, context);
|
||||
Coordinate2D<double> uvD = xyEvaluationDouble(static_cast<double>(s), model, context);
|
||||
Coordinate2D<double> cxyD = xyEvaluationDouble(static_cast<double>(ct), model, context);
|
||||
Coordinate2D<double> xyD = xyDoubleEvaluation(static_cast<double>(t), model, context);
|
||||
Coordinate2D<double> uvD = xyDoubleEvaluation(static_cast<double>(s), model, context);
|
||||
Coordinate2D<double> cxyD = xyDoubleEvaluation(static_cast<double>(ct), model, context);
|
||||
if (((xyD.x1() <= cxyD.x1() && cxyD.x1() <= uvD.x1()) || (uvD.x1() <= cxyD.x1() && cxyD.x1() <= xyD.x1()))
|
||||
&& ((xyD.x2() <= cxyD.x2() && cxyD.x2() <= uvD.x2()) || (uvD.x2() <= cxyD.x2() && cxyD.x2() <= xyD.x2())))
|
||||
{
|
||||
@@ -748,8 +744,8 @@ void CurveView::joinDots(KDContext * ctx, KDRect rect, EvaluateXYForParameter xy
|
||||
}
|
||||
}
|
||||
if (maxNumberOfRecursion > 0) {
|
||||
joinDots(ctx, rect, xyEvaluation, model, context, drawStraightLinesEarly, t, x, y, ct, cx, cy, color, thick, maxNumberOfRecursion-1, xyEvaluationDouble);
|
||||
joinDots(ctx, rect, xyEvaluation, model, context, drawStraightLinesEarly, ct, cx, cy, s, u, v, color, thick, maxNumberOfRecursion-1, xyEvaluationDouble);
|
||||
joinDots(ctx, rect, xyFloatEvaluation, model, context, drawStraightLinesEarly, t, x, y, ct, cx, cy, color, thick, maxNumberOfRecursion-1, xyDoubleEvaluation);
|
||||
joinDots(ctx, rect, xyFloatEvaluation, model, context, drawStraightLinesEarly, ct, cx, cy, s, u, v, color, thick, maxNumberOfRecursion-1, xyDoubleEvaluation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user