Merge changes I83daefa6,Iee820055

* changes:
  [apps/graph] draw only active functions
  [apps/graph] add a method in function expression view to mark a cell as dirty
This commit is contained in:
Romain Goyet
2016-10-04 15:20:19 +02:00
committed by Gerrit
4 changed files with 14 additions and 7 deletions

View File

@@ -162,13 +162,15 @@ void GraphView::drawFunction(KDContext * ctx, KDRect rect) const {
for (KDCoordinate px = rect.x()-stampSize; px<rect.right(); px++) {
float x = pixelToFloat(Axis::Horizontal, px);
for (int i=0; i<m_functionStore->numberOfFunctions(); i++) {
Float xExp = Float(x);
plotContext.setExpressionForSymbolName(&xExp, "x");
Graph::Function * f = m_functionStore->functionAtIndex(i);
float y = f->expression()->approximate(plotContext);
KDCoordinate py = floatToPixel(Axis::Vertical, y);
KDRect stampRect(px, py, stampSize, stampSize);
ctx->fillRectWithMask(stampRect, f->color(), mask, workingBuffer);
if (f->isActive()) {
Float xExp = Float(x);
plotContext.setExpressionForSymbolName(&xExp, "x");
float y = f->expression()->approximate(plotContext);
KDCoordinate py = floatToPixel(Axis::Vertical, y);
KDRect stampRect(px, py, stampSize, stampSize);
ctx->fillRectWithMask(stampRect, f->color(), mask, workingBuffer);
}
}
}
}

View File

@@ -31,3 +31,8 @@ void FunctionCell::setHighlighted(bool highlight) {
Graph::Function * FunctionCell::function() {
return m_function;
}
void FunctionCell::reloadCell() {
//TODO: optimize for function_name_view (make it virtual)
markRectAsDirty(bounds());
}

View File

@@ -11,6 +11,7 @@ public:
void setEven(bool even);
void setHighlighted(bool highlight);
Graph::Function * function();
void reloadCell();
static constexpr KDColor k_evenLineBackgroundColor = KDColor(0xF9F9F9);
static constexpr KDColor k_oddLineBackgroundColor = KDColor(0xEEEEF2);

View File

@@ -9,7 +9,6 @@ class FunctionCell;
class FunctionExpressionView : public FunctionCell {
public:
FunctionExpressionView();
void drawRect(KDContext * ctx, KDRect rect) const override;
};