Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Plot point context menu

Hi guys, I have a question 🙂

 

I will tell you the full story, because I might be wrong in the direction that I am working in..

I am using WaveformGraph and I plot WaveformPlot objects to it.

And I was given I requirement to implement "point marker feature".

This feature gives user the ability to select some special point of his interest on the plot and mark it by some marker. This marker will be visualized on the graph (I can draw it, it is not a problem, using public class CustomPointStyle : PointStyle that depends on data)

 

public class CustomPointStyle : PointStyle
{
public override void Draw(object context, PointStyleDrawArgs args)
{
   var g = args.Graphics;
   var color = Color.Yellow; // Default color
   var x = args.X;
   var index = GetIndexByXValue(x); // Not relevant how it is implemented
   if (MarkerIndexes.Contains(index)) //Color for marked point
    color = GetColorForMarker(index);// Not relevant how it is implemented

// Draw whatever you want
g.FillRectangle(new SolidBrush(color), new Rectangle(0, 0, 5, 5));
}
}

 And this marker will be used in some user control for browsing existed markers. User can select marked point and pan the graph so that this point will be right in the middle.

 

Since my plots have quite a lot of points I disable showing points from the beginning, and I give the user an ability to decide whenever he want to enable points on the plot.

_waveformGraph.BeginUpdate();
foreach (var plot in _waveformGraph.Plots)
{
     plot.PointStyle = _isPointsVisible ? new CustomPointStyle() : PointStyle.None;//PointStyle.SolidSquare : PointStyle.None;
}
_waveformGraph.EndUpdate();

 

So, the scenario of user actions should be like 

1) Zoom to some area so that the number of points in this area is reasonably small so that you can enable points

2) Enable showing plot points

3) Open context menu for some point

4) Select this point to be marked using the context menu

 

Now, what I am missing is how to make mouse browser "stick" to point. Do you know the "sticky targeting" concept?
So I need to hold closest point to mouse cursor in some variable, to access the point from context menu. What can you suggest?

A bit off topic:
May be the described above "marker" feature is already implemented and I just missed it? If not, don't you think that is it worth implementing it by NI team?
In my application user can save the data and load it later for analysis. And one of the tools used for this analysis is the marker feature.

 

 

Regards Smiley Happy

 

0 Kudos
Message 1 of 1
(5,279 Views)