taurus-org / taurus_pyqtgraph

Moved to https://gitlab.com/taurus-org/taurus_pyqtgraph
3 stars 14 forks source link

How to clear trend data in user interface? #70

Closed dscran closed 3 years ago

dscran commented 4 years ago

Hi all,

I can't find an easy way to let users clear the data in a trend window. Changing the data source being plotted works, but is quite cumbersome. Maybe I have missed something?

For now, I added an option to clear the current data in the right-click menu by changing trend.py like this.

Is that an acceptable solution or do you see this breaking anything down the line? Should I make a pull request?

Thanks and Cheers,

Michael

cpascual commented 4 years ago

Hi @dscran , first of all: I saw your PR #69 before this issue. It is absolutely ok for me if you start with a PR instead of an issue when you already have a proposal (in fact it simplifies discussing about the code).

Now, your approach seems very good to me. We already had a similar option in the old qwt5 trends and we certainly miss it in the tpg trends.

There are only a couple of implementation details:

Finally: you may also be interested in #47 (in fact, TaurusTrendSet.clearBuffer is already added there). BUT note that #47 has been stalled for a while and needs to be updated after the refactorings of v0.4

cpascual commented 4 years ago

Oh..., and I forgot to thank you for your interest and for contributing! :smiley:

dscran commented 3 years ago

Thanks @cpascual for the feedback!

I tried using the TaurusTrendSet.clearBuffer method from #47:

def clearBuffer(self):
        """Reset the buffered data"""
        for curve in self._curves:
            curve.setData(x=[], y=[])
        self._xBuffer = None
        self._yBuffer = None

However, this does not seem to preserve the plot configuration (pen color etc.) but advances it along the CURVE_COLORS every time it's called. Calling TaurusTrendSet._initBuffers(len(self._curves)) seems to work fine. In the tests I did, it was also not necessary to explicitly empty the curve data (curve.setData(x=[], y=[])) for all PlotDataItem.

Thanks and cheers,

Michael

cpascual commented 3 years ago

I tried using the TaurusTrendSet.clearBuffer method from #47: However, this does not seem to preserve the plot configuration (pen color etc.) but advances it along the CURVE_COLORS every time it's called. Calling TaurusTrendSet._initBuffers(len(self._curves)) seems to work fine. In the tests I did, it was also not necessary to explicitly empty the curve data (curve.setData(x=[], y=[])) for all PlotDataItem.

Yes, this is part of what I had in mind when I mentioned that #47 needs to be adapted to the changes in v0.4

I'll have a look at your PR in #71

cpascual commented 3 years ago

just released 0.4.5, which includes this