mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-23 07:40:42 +01:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -9,7 +9,6 @@ class FunctionCell;
|
||||
class FunctionExpressionView : public FunctionCell {
|
||||
public:
|
||||
FunctionExpressionView();
|
||||
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user