Improve GetPointNearest support for generic signal plots#886
Improve GetPointNearest support for generic signal plots#886swharden merged 12 commits intoScottPlot:masterfrom
Conversation
|
Ah, I've gotten that error before. Looks like you added a public method but not documentation for it (or removed documentation from a public method). From a quick glance it looks like it might bet this one: https://github.com/StendProg/ScottPlot/blob/201c85c0385515510aed526af71534faa9627a2e/src/ScottPlot/Plottable/SignalPlotBase.cs#L167 However running the test in debug mode will track it down if I'm wrong. |
|
Thanks for the tip, I spent some time trying to figure out this test.Checked all public methods, but somehow forgot about constructors. I miscalculated over time a bit, I can only continue to deal with this tomorrow. |
|
|
|
I made private new (double x, TY, int index) GetPointNearestX(double X) |
- simplify code by adding argument names - new() syntax - inline using statements
Required XML Documentation
Sorry this took a while to figure out! A few weeks ago I added tests to ensure plottables are documented (without requiring every module to be documented). I think the tests require public methods and constructors to have XML, but ignores public fields and properties. I see that links to https://www.fuget.org/packages/ScottPlot now appear on official NuGet pages, so I'm hoping that better XML documentation may make the API easier to figure out just using this website. For example, the ScatterPlot API. It's nice for flat classes, but not quite as easy to navigate for complex inheritance trees. Eventually I'd like to work toward enabling #1591 at the project level... Generic Support for IHasPointsThanks for this PR! At first I was reluctant to include the second commit because those interfaces seemed pretty complex and the compiled generic lambda expression was somewhat hard to understand at first. I think I made it a little easier to read by changing some of the names, making the expression readonly, adding XML documentation, and wrapping the expression in typed functions calls so it doesn't have to be directly interacted with in the rendering/searching routines. This extra function call may slightly impair performance, but these methods are only called from ScottPlot/src/ScottPlot/Plottable/SignalPlotBase.cs Lines 167 to 188 in a1ff357 OffsetX and OffsetY are broken in SignalPlotXYI don't think this is a new bug, but I created a cookbook example to demonstrate it in this PR. It should probably be addressed in another PR (I opened an issue #890) |
Purpose:
PlottableSignalXYused the implementation fromPlottableSignaldue to inheritance, which led to inconsistent results when calling theGetPointNearestX. #809, #882This PR brings to
PlottableSignalXYit's ownGetPointNearestXimplementation with correct behavior.This pull request consists of 2 commits. The very first one fixes the described problem.
In the second commit, I decided to go further, split the original interface into several, and make it so that
PlottableSignalsexplicitly implement only what it is capable ofIHasPointsXCalculatablewith a singleGetPointNearestX()methodOn top of that, I made interfaces generic, since signals inherently support generics and this is more natural for them.
Old nongeneric
IHasPointsare derived from these interfaces and are essentially unchanged. These changes should not affect thePlottableScatterin any way. ButPlottableSignalslose API compatibility because they now implement a different interface, and users will have to change the interface type, although the method has remained with the same name.If you think I went too far in the second commit, just revert it (I'm not entirely sure myself).
If you find the changes acceptable, I will be glad to have better names for the interfaces. And I would like to have time until tomorrow to once again take a fresh look at all this (I really do not want to drag out as last time, I am still ashamed).