from AbstractGraph.hpp:40
class AbstractGraph : public CanvasWidget
{
public:
class GraphPoint
{
public:
GraphPoint()
{
}
int x;
int y;
CWRUtil::Q5 dx, dy;
};
AbstractGraph();
virtual ~AbstractGraph();
CWRUtil::Q5 widgetX(int x) const;
CWRUtil::Q5 widgetY(int y) const;
CWRUtil::Q5 widgetXindex(int index) const;
CWRUtil::Q5 widgetYindex(int index) const;
void setBuffer(GraphPoint* pointsBuffer, int numPointsInBuffer);
void setLinkedGraph(AbstractGraph& other);
void setRange(int newLleft, int newRight, int newTop, int newBottom);
virtual void setX(int16_t x);
virtual void setY(int16_t y);
virtual void setWidth(int16_t width);
virtual void setHeight(int16_t height);
template <class T>
void setLineWidth(T width)
{
CWRUtil::Q5 newLineWidth = CWRUtil::toQ5(width);
if (lineWidth == newLineWidth)
{
return;
}
lineWidth = newLineWidth;
if (numPoints > 0)
{
updateAndInvalidateCacheForLinesBetweenIndeces(0, numPoints - 1);
}
}
template <class T>
T getLineWidth() const
{
return int(lineWidth) / T(Rasterizer::POLY_BASE_SIZE);
}
virtual void clearGraph();
virtual bool addValue(int x, int y);
virtual bool deleteValue(int x);
virtual bool drawCanvasWidget(const Rect& invalidatedArea) const;
protected:
virtual Rect getMinimalRectContainingIndices(int firstIndex, int lastIndex) const = 0;
virtual void invalidateRectContainingIndices(int firstIndex, int lastIndex) const;
virtual void updateAndInvalidateCacheForLinesBetweenIndeces(int firstIndex, int lastIndex);
virtual Rect getMinimalRect() const;
AbstractGraph* linkedGraph;
int left, right, top, bottom;
GraphPoint* points;
int maxPoints;
int numPoints;
CWRUtil::Q5 lineWidth;
CWRUtil::Q5 widgetWidth;
CWRUtil::Q5 widgetHeight;
CWRUtil::Q5 graphWidth;
CWRUtil::Q5 graphHeight;
virtual void setNumPoints(int numPointsUsed);
virtual void invalidateLineFromIndex(int index);
virtual void insertPointAtIndex(int index);
virtual void deletePointAtIndex(int index);
virtual int findX(int x);
CWRUtil::Q5 xAboveOutgoing(int index) const
{
return widgetXindex(index) + points[index].dy;
}
CWRUtil::Q5 yAboveOutgoing(int index) const
{
return widgetYindex(index) - points[index].dx;
}
CWRUtil::Q5 xBelowOutgoing(int index) const
{
return widgetXindex(index) - points[index].dy;
}
CWRUtil::Q5 yBelowOutgoing(int index) const
{
return widgetYindex(index) + points[index].dx;
}
CWRUtil::Q5 xAboveIncoming(int index) const
{
return widgetXindex(index) + points[index - 1].dy;
}
CWRUtil::Q5 yAboveIncoming(int index) const
{
return widgetYindex(index) - points[index - 1].dx;
}
CWRUtil::Q5 xBelowIncoming(int index) const
{
return widgetXindex(index) - points[index - 1].dy;
}
CWRUtil::Q5 yBelowIncoming(int index) const
{
return widgetYindex(index) + points[index - 1].dx;
}
private:
void assignRange(int newLeft, int newRight, int newTop, int newBottom);
virtual void assignWidth(int16_t width);
virtual void assignHeight(int16_t height);
};