Closed dscran closed 3 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:
clearTrends()
, instead of looping over self.getPlotItem().listDataItems()
and then filtering, you can use self.getTrendSet()
clearTrends()
you are accessing a non-public member of the TaurusTrendSet. We should create a TaurusTrendSet.clearBuffer
public methodFinally: 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
Oh..., and I forgot to thank you for your interest and for contributing! :smiley:
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
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 allPlotDataItem
.
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
just released 0.4.5, which includes this
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