mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
statistics: convert bar series to QSGNodes
To this end, two new ChartItems were added: A "bar" (a rectangle with a border) and a "text" (multiple lines of text). It turns out that the text on the bars now looks atrocious. The reason appears to be that the antialiasing of the font-rendering does not blend into the alpha channel, but into a supposed background color? This will have to be investigated. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2008857660
commit
b42e19e36b
4 changed files with 200 additions and 70 deletions
|
@ -11,6 +11,7 @@ class QSGGeometry;
|
|||
class QSGGeometryNode;
|
||||
class QSGFlatColorMaterial;
|
||||
class QSGImageNode;
|
||||
class QSGRectangleNode;
|
||||
class QSGTexture;
|
||||
class StatsView;
|
||||
enum class ChartZValue : int;
|
||||
|
@ -20,7 +21,6 @@ public:
|
|||
ChartItem(StatsView &v, ChartZValue z);
|
||||
virtual ~ChartItem();
|
||||
virtual void render() = 0; // Only call on render thread!
|
||||
QRectF getRect() const;
|
||||
bool dirty; // If true, call render() when rebuilding the scene
|
||||
ChartItem *dirtyPrev, *dirtyNext; // Double linked list of dirty items
|
||||
const ChartZValue zValue;
|
||||
|
@ -64,6 +64,22 @@ private:
|
|||
double radius;
|
||||
};
|
||||
|
||||
// Attention: text is only drawn after calling setColor()!
|
||||
class ChartTextItem : public ChartPixmapItem {
|
||||
public:
|
||||
ChartTextItem(StatsView &v, ChartZValue z, const QFont &f, const std::vector<QString> &text, bool center);
|
||||
void setColor(const QColor &color);
|
||||
private:
|
||||
QFont f;
|
||||
double fontHeight;
|
||||
bool center;
|
||||
struct Item {
|
||||
QString s;
|
||||
double width;
|
||||
};
|
||||
std::vector<Item> items;
|
||||
};
|
||||
|
||||
class ChartLineItem : public ChartItem {
|
||||
public:
|
||||
ChartLineItem(StatsView &v, ChartZValue z, QColor color, double width);
|
||||
|
@ -74,6 +90,7 @@ private:
|
|||
QPointF from, to;
|
||||
QColor color;
|
||||
double width;
|
||||
bool horizontal;
|
||||
bool positionDirty;
|
||||
bool materialDirty;
|
||||
std::unique_ptr<QSGGeometryNode> node;
|
||||
|
@ -81,4 +98,26 @@ private:
|
|||
std::unique_ptr<QSGGeometry> geometry;
|
||||
};
|
||||
|
||||
// A bar in a bar chart: a rectangle bordered by lines.
|
||||
class ChartBarItem : public ChartItem {
|
||||
public:
|
||||
ChartBarItem(StatsView &v, ChartZValue z, double borderWidth, bool horizontal);
|
||||
~ChartBarItem();
|
||||
void setColor(QColor color, QColor borderColor);
|
||||
void setRect(const QRectF &rect);
|
||||
QRectF getRect() const;
|
||||
void render() override; // Only call on render thread!
|
||||
private:
|
||||
QColor color, borderColor;
|
||||
double borderWidth;
|
||||
QRectF rect;
|
||||
bool horizontal;
|
||||
bool positionDirty;
|
||||
bool colorDirty;
|
||||
std::unique_ptr<QSGRectangleNode> node;
|
||||
std::unique_ptr<QSGGeometryNode> borderNode;
|
||||
std::unique_ptr<QSGFlatColorMaterial> borderMaterial;
|
||||
std::unique_ptr<QSGGeometry> borderGeometry;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue