-
Notifications
You must be signed in to change notification settings - Fork 981
Closed as not planned
Closed as not planned
Copy link
Description
In analogy to your function AxisLine.IsUnderMouse in the example of draggable axis lines(cookbook 5.0.36), I tried to do the same with signal plots. The only problem is that I only find points and no lines. Is there is probably a better solution?
ScottPlot Version: 5.0.44
private int GetIndexOfSignalPlot(Pixel mousePixel)
{
Coordinates coord = SP.Plot.GetCoordinates(mousePixel);
double Mindistance = double.PositiveInfinity;
int IndexNearest = -1;
for (int i = 0; i < SignalPlots.Count(); i++)
{
var Index = SignalPlots[i].GetNearestX(coord, SP.Plot.LastRender, float.MaxValue);
if (plotViewModel.ListView_Model.Count > i) plotViewModel.ListView_Model[i].ChannelValue = Index.Y.ToString();
if (!SignalPlots[i].IsVisible) continue;
DataPoint nearest = SignalPlots[i].GetNearest(coord, SP.Plot.LastRender);
if (nearest.IsReal)
{
double distance = Math.Sqrt(Math.Pow(nearest.X - coord.X, 2) + Math.Pow(nearest.X - coord.X, 2));
Log.WriteDebug(i.ToString(), distance.ToString());
if (distance < Mindistance)
{
Mindistance = distance;
IndexNearest = i;
}
}
}
return IndexNearest;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels