PlotCurveItem: implement OpenGL curve fill#3068
Conversation
|
Some quirks found while testing out this PR:
UPDATE: |
b1b95cf to
e7ba72f
Compare
|
This looks great, I wish I had more time to follow it in detail... I am not so excited about PlotDataItem changing the overall display strategy for non-finites based on the fill setting, which does not have an immediately obvious connection to it. I guess we could document that adjustment to be part of 'auto' mode, and leave the user with the option of setting 'finite' or 'all' manually if the automatic switch is not desirable. Alternatives to consider: If the question is "what should the filled region look like in the presence of non-drawing points?" then my naive expectations (from great to acceptable) would be
|
|
The OpenGL solution looks very good to me! In the long run, it would be good to get the non-OpenGL version working in a similar way, but that obviously wasn't a high-priority concern before, and I don't think this PR changes anything to suddenly make it urgent. I think option 3 (for the fill area only: replace non-finite values by fill-level values) might work as a quick fix to upgrade that from "functionally useless" (as it is now) to merely "visually unpleasant". But that's not the topic of this PR :) Do we have an open issue on the bad fill with non-finites in non-OpenGL mode? It would probably be good to reference this PR from there as illustration and goal. |
|
It seems that I might have over-exaggerated the complexity of implementing the new finite filling behavior for the non-OpenGL path. Curve filling was already implemented in chunks, so all that was needed was to do the same for each finite segment. Implemented in #3071 |
|
use |
PlotCurveItem API ensures that they are either None or instances of QPen, QBrush
|
Thanks @pijyoi this LGTM 👍🏻 |


Continuation of #3055
This PR restricts itself to filling the area under a finite-valued curve.
It will not handle oddball modes like histogram nor the undocumented fillLevel="enclosed".
The implementation is as described in #3055 (comment) and is reasonably short.
Before this PR, if
fillLevelis enabled,paintGLis not used, and Qt's own OpenGL rendering is used.In the updated MouseSelection example below,
fillLevelis enabled for the red curve. Hence, before this PR, the red curve gets drawn by Qt, not by paintGL.It can be seen that the red curve is smooth, but the filling has quantization effects.

i.e. Qt's OpenGL rendering backend does the equivalent of origin shift for curves but not for filling.
With this PR that implements filling in

paintGL, (and hence comes with origin shift to mitigate quantization effects)https://doc.qt.io/qt-6/qbrush.html can be more than just a color. And this PR of course doesn't support anything besides a pure color QBrush.