statistics: convert scatter series to use QSG

The original plan to reuse the ChartPixmapItem for the
scatteritems was dumped, because it is unclear if the
textures are shared if generated for each item.

Instead, a new ChartScatterItem was created, where all
items share the same textures (one for highlighted,
one for non-highlighted). This means that the rendering
of the scatter items is now done in the chartitem.cpp
file, which feels like a layering violation. Not good,
but the easiest for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-17 22:03:27 +01:00 committed by bstoeger
parent 409f159e1d
commit b07a7fe5f1
4 changed files with 123 additions and 69 deletions

View file

@ -150,6 +150,26 @@ private:
std::unique_ptr<QSGGeometry> whiskersGeometry;
};
// An item in a scatter chart. This is not simply a normal pixmap item,
// because we want that all items share the *same* texture for memory
// efficiency. It is somewhat questionable to define the form of the
// scatter item here, but so it is for now.
class ChartScatterItem : public HideableChartProxyItem<QSGImageNode> {
public:
ChartScatterItem(StatsView &v, ChartZValue z);
~ChartScatterItem();
void setPos(QPointF pos); // Specifies the *center* of the item.
void setHighlight(bool highlight); // In the future, support different kinds of scatter items.
void render() override; // Only call on render thread!
QRectF getRect() const;
bool contains(QPointF point) const;
private:
QRectF rect;
QSizeF textureSize;
bool positionDirty, textureDirty;
bool highlighted;
};
// Implementation detail of templates - move to serparate header file
template <typename Node>