mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
statistics: draw legend as a QSGNode
In order not to waste CPU by constantly rerendering the chart, we must use these weird OpenGL QSGNode things. The interface is appallingly low-level and unfriendly. As a first test, try to convert the legend. Create a wrapper class that represents a rectangular item with a texture and that will certainly need some (lots of) optimization. Make sure that all low-level QSG-objects are only accessed in the rendering thread. This means that the wrapper has to maintain a notion of "dirtiness" of the state. I.e. which part of the QSG-objects have to be modified. From the low-level wrapper derive a class that draws a rounded rectangle for every resize. The child class of that must then paint on the rectangle after every resize. That looks all not very fortunate, but it displays a legend and will make it possible to move the legend without and drawing operations, only shifting around an OpenGL surface. The render thread goes through all chart-items and rerenders them if dirty. Currently, on deletion of these items, this list is not reset. I.e. currently it is not supported to remove individual items. Only the full scene can be cleared! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9be23b5f3f
commit
2b961414d7
8 changed files with 284 additions and 91 deletions
|
|
@ -19,8 +19,10 @@ struct StatsVariable;
|
|||
|
||||
class QGraphicsLineItem;
|
||||
class QGraphicsSimpleTextItem;
|
||||
class QSGImageNode;
|
||||
class StatsSeries;
|
||||
class CategoryAxis;
|
||||
class ChartItem;
|
||||
class CountAxis;
|
||||
class HistogramAxis;
|
||||
class StatsAxis;
|
||||
|
|
@ -46,6 +48,10 @@ public:
|
|||
~StatsView();
|
||||
|
||||
void plot(const StatsState &state);
|
||||
QQuickWindow *w() const; // Make window available to items
|
||||
QSizeF size() const;
|
||||
void addQSGNode(QSGNode *node, int z); // Must only be called in render thread!
|
||||
void unregisterChartItem(const ChartItem *item);
|
||||
private slots:
|
||||
void replotIfVisible();
|
||||
private:
|
||||
|
|
@ -103,6 +109,9 @@ private:
|
|||
template <typename T, class... Args>
|
||||
T *createAxis(const QString &title, Args&&... args);
|
||||
|
||||
template <typename T, class... Args>
|
||||
std::unique_ptr<T> createChartItem(Args&&... args);
|
||||
|
||||
template<typename T>
|
||||
CategoryAxis *createCategoryAxis(const QString &title, const StatsBinner &binner,
|
||||
const std::vector<T> &bins, bool isHorizontal);
|
||||
|
|
@ -156,11 +165,14 @@ private:
|
|||
std::vector<RegressionLine> regressionLines;
|
||||
std::vector<HistogramMarker> histogramMarkers;
|
||||
std::unique_ptr<QGraphicsSimpleTextItem> title;
|
||||
std::vector<ChartItem *> items; // Attention: currently, items are not automatically removed on destruction!
|
||||
StatsSeries *highlightedSeries;
|
||||
StatsAxis *xAxis, *yAxis;
|
||||
|
||||
void hoverEnterEvent(QHoverEvent *event) override;
|
||||
void hoverMoveEvent(QHoverEvent *event) override;
|
||||
|
||||
QSGImageNode *rootNode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue