[apps/*curve_view] Substitute resolution by pixelWidth

This commit is contained in:
Ruben Dashyan
2019-07-11 12:22:56 +02:00
committed by EmilieNumworks
parent c80baae1e9
commit 292493ba36
5 changed files with 11 additions and 17 deletions

View File

@@ -86,11 +86,8 @@ bool GraphController::moveCursorHorizontally(int direction) {
if (direction < 0 && xCursorPosition <= 0) {
return false;
}
/* The cursor moves by step of at minimum 1. If the windowRange is to large
* compared to the resolution, the cursor takes bigger round step to cross
* the window in approximatively resolution steps. */
double step = std::ceil((interactiveCurveViewRange()->xMax()-interactiveCurveViewRange()->xMin())/m_view.resolution());
step = step < 1.0 ? 1.0 : step;
// The cursor moves by step that is larger than 1 and than a pixel's width.
const int step = std::ceil(m_view.pixelWidth());
double x = direction > 0 ? xCursorPosition + step:
xCursorPosition - step;
if (x < 0.0) {

View File

@@ -14,16 +14,15 @@ GraphView::GraphView(SequenceStore * sequenceStore, InteractiveCurveViewRange *
void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
FunctionGraphView::drawRect(ctx, rect);
/* A dot is drawn at every step where step is larger than 1
* and than a pixel's width. */
const int step = std::ceil(pixelWidth());
for (int i = 0; i < m_sequenceStore->numberOfActiveFunctions(); i++) {
Ion::Storage::Record record = m_sequenceStore->activeRecordAtIndex(i);
Sequence * s = m_sequenceStore->modelForRecord(record);;
float rectXMin = pixelToFloat(Axis::Horizontal, rect.left() - k_externRectMargin);
rectXMin = rectXMin < 0 ? 0 : rectXMin;
float rectXMax = pixelToFloat(Axis::Horizontal, rect.right() + k_externRectMargin);
/* We draw a dot at every integer if WindowRange/Resolution < 1. Otherwise,
* we draw a dot at every step where step is an integer wider than 1. */
float windowRange = curveViewRange()->xMax() - curveViewRange()->xMin();
int step = std::ceil(windowRange/resolution());
for (int x = rectXMin; x < rectXMax; x += step) {
float y = s->evaluateAtAbscissa((float)x, context());
if (std::isnan(y)) {

View File

@@ -87,8 +87,8 @@ void CurveView::setOkView(View * okView) {
layoutSubviews();
}
float CurveView::resolution() const {
return bounds().width();
const float CurveView::pixelWidth() const {
return (m_curveViewRange->xMax() - m_curveViewRange->xMin()) / m_frame.width();
}
void CurveView::drawGridLines(KDContext * ctx, KDRect rect, Axis axis, float step, KDColor boldColor, KDColor lightColor) const {
@@ -498,9 +498,7 @@ const uint8_t stampMask[stampSize+1][stampSize+1] = {
constexpr static int k_maxNumberOfIterations = 10;
void CurveView::drawCurve(KDContext * ctx, KDRect rect, EvaluateModelWithParameter evaluation, void * model, void * context, KDColor color, bool colorUnderCurve, float colorLowerBound, float colorUpperBound, bool continuously) const {
float xMin = min(Axis::Horizontal);
float xMax = max(Axis::Horizontal);
float xStep = (xMax-xMin)/resolution();
const float xStep = pixelWidth();
float rectMin = pixelToFloat(Axis::Horizontal, rect.left() - k_externRectMargin);
float rectMax = pixelToFloat(Axis::Horizontal, rect.right() + k_externRectMargin);
@@ -543,7 +541,7 @@ void CurveView::drawHistogram(KDContext * ctx, KDRect rect, EvaluateModelWithPar
float rectMaxUpperBound = firstBarAbscissa + (rectMaxBinNumber+1)*barWidth + barWidth;
float pHighlightLowerBound = floatToPixel(Axis::Horizontal, highlightLowerBound);
float pHighlightUpperBound = floatToPixel(Axis::Horizontal, highlightUpperBound);
float step = std::fmax(barWidth, (curveViewRange()->xMax() - curveViewRange()->xMin())/resolution());
const float step = std::fmax(barWidth, pixelWidth());
for (float x = rectMinLowerBound; x < rectMaxUpperBound; x += step) {
/* When |rectMinLowerBound| >> step, rectMinLowerBound + step = rectMinLowerBound.
* In that case, quit the infinite loop. */

View File

@@ -36,7 +36,7 @@ public:
void setBannerView(View * bannerView);
void setOkView(View * okView);
void setForceOkDisplay(bool force) { m_forceOkDisplay = force; }
float resolution() const;
const float pixelWidth() const;
protected:
CurveViewRange * curveViewRange() const { return m_curveViewRange; }
void setCurveViewRange(CurveViewRange * curveViewRange);

View File

@@ -84,7 +84,7 @@ InteractiveCurveViewRangeDelegate::Range FunctionGraphController::computeYRange(
range.max = xMax;
return range;
}
float step = (xMax - xMin) / curveView()->resolution() / 2;
const float step = curveView()->pixelWidth() / 2;
for (int i=0; i<functionStore()->numberOfActiveFunctions(); i++) {
ExpiringPointer<Function> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
/* Scan x-range from the middle to the extrema in order to get balanced