mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/statistics] Reload CurveView before drawing histogram labels
This commit is contained in:
committed by
LeaNumworks
parent
a42208f773
commit
83722342f7
@@ -193,8 +193,6 @@ int CurveView::numberOfLabels(Axis axis) const {
|
||||
float minLabel = std::ceil(min(axis)/labelStep);
|
||||
float maxLabel = std::floor(max(axis)/labelStep);
|
||||
int numberOfLabels = maxLabel - minLabel + 1;
|
||||
// Assert labels are up to date
|
||||
assert(m_drawnRangeVersion == m_curveViewRange->rangeChecksum());
|
||||
assert(numberOfLabels <= (axis == Axis::Horizontal ? k_maxNumberOfXLabels : k_maxNumberOfYLabels));
|
||||
return numberOfLabels;
|
||||
}
|
||||
@@ -378,6 +376,9 @@ void CurveView::drawLabelsAndGraduations(KDContext * ctx, KDRect rect, Axis axis
|
||||
return;
|
||||
}
|
||||
|
||||
// Labels will be pulled. They must be up to date with current curve view.
|
||||
assert(m_drawnRangeVersion == m_curveViewRange->rangeChecksum());
|
||||
|
||||
// Draw the labels
|
||||
for (int i = minDrawnLabel; i < maxDrawnLabel; i++) {
|
||||
KDCoordinate labelPosition = std::round(floatToPixel(axis, labelValueAtIndex(axis, i)));
|
||||
|
||||
@@ -27,6 +27,9 @@ HistogramController::HistogramController(Responder * parentResponder, InputEvent
|
||||
|
||||
void HistogramController::setCurrentDrawnSeries(int series) {
|
||||
initYRangeParameters(series);
|
||||
/* The range of it CurveView has changed, the CurveView must be reloaded.
|
||||
* See comment in HistogramView::drawRect. */
|
||||
m_view.dataViewAtIndex(series)->CurveView::reload();
|
||||
}
|
||||
|
||||
StackViewController * HistogramController::stackController() {
|
||||
|
||||
@@ -38,6 +38,14 @@ void HistogramView::reloadSelectedBar() {
|
||||
}
|
||||
|
||||
void HistogramView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
/* When setting the current drawn series, the histogram's CurveView range is
|
||||
* updated along the Vertical axis. To call drawLabelsAndGraduations,
|
||||
* CurveView must be reloaded (in setCurrentDrawnSeries method) so that labels
|
||||
* and their values match the new range.
|
||||
* In this situation, we update CurveView's Vertical axis, and draw horizontal
|
||||
* labels, which are independent. To avoid having to call CurveView::reload(),
|
||||
* axis could be taken into account when checking if labels are up to date,
|
||||
* instead of using rangeChecksum(), which mixes all axis. */
|
||||
m_controller->setCurrentDrawnSeries(m_series);
|
||||
ctx->fillRect(rect, KDColorWhite);
|
||||
drawAxis(ctx, rect, Axis::Horizontal);
|
||||
|
||||
Reference in New Issue
Block a user