summaryrefslogtreecommitdiffstats
path: root/stats/chartitem.cpp
AgeCommit message (Collapse)Author
2021-01-20statistics: replace PieSeries by QSG nodesGravatar Berthold Stoeger
Since there are no disk-segment QSG primitives (one could draw a triangle fan, but that doesn't seem optimal), this draws into a pixmap and blits that as a QSG node. Since this is the only series without axis, it needs a function that returns the size of the plot area. This didn't exist, so add it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20statistics: convert scatter series to use QSGGravatar Berthold Stoeger
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>
2021-01-20statistics: convert box-and-whiskers plot to QSGGravatar Berthold Stoeger
This is lazy: Derive from the bar chart item and add whiskers in the subclassed render() function. The code is ugly, because the base class function clears the dirty flags and therefore the derived class has to remember them. Oh well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20statistics: implement showing / hiding of items in QSGGravatar Berthold Stoeger
To replace the QGraphicsScene, we need the possibility of showing and hiding items. Turns out, the QSG API is completely insane. Whether an item should be shown is queried by the virtual function isSubtreeBlocked(), which is supposed to be overriden by the derived classes. However, the common nodes for rectangles and pixmaps are supposed to be created by QQuickWindow, for hardware optimization. This gives nodes that cannot be derived from and therefore whether the item is shown or not cannot be controlled. There are therefore two distinct cases to consider: The node is allocated by the code directly or indirectly by QQuickWindow. In the latter case, we use a proxy node with the only purpose of having a "visible" flag and add the obtained node as a child. This madness is performed with template trickery to get unified code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20statistics: convert bar series to QSGNodesGravatar Berthold Stoeger
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>
2021-01-20statistics: keep track of dirty items in double-linked listGravatar Berthold Stoeger
So far the items to be recalculated in the drawing thread had a "dirty" flag and were kept in one array par z-level. Once the series are implemented in terms of QSGNodes, there may lots of these items. To make this more efficient when only one or two of these items change (e.g. highlighting due to mouseover), keep the dirty items in a linked list. Of course, this makes the draw first version of the chart less efficient. There are more fancy ways of implementing the double-linked list, but the few ns gained in the render thread are hardly worth it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20statistics: convert QuartileMarkers to QSGNodesGravatar Berthold Stoeger
Slowly converting the QGraphicsScene items to QSGNodes to avoid full replot of the scene. This adds a new abstraction for line-nodes. Since the render() function here is fundamentally different from the pixmap-nodes we had so far, this has to be made virtual. Also, move the quartile markers to their own source file, since the StatsView source file is quite huge already. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20statistics: add notion of Z-value to chart itemsGravatar Berthold Stoeger
The chart items were drawn in order of creation. To control this, add a notion of Z-value. In contrast to QGraphicsScene, make this a small integer value. To controll order of drawing, a plain QSGNode is created for every possible Z-Value and items are added to these nodes. Thus, items are rendered by Z-value and if the Z-value is equal by order of creation. Likewise split the list of chart-items into Z-values, so that items can be quickly unregistered: The items that will be removed individually will usuall be part of Z-levels with only few items (e.g. legend, infobox). Z-levels with many items (notably the series) will always be fully rebuilt. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20statistics: draw legend as a QSGNodeGravatar Berthold Stoeger
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>