Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

XYCursor.XPosition

I do have problem when I assign values to XYCursor.XPosition or YPosition , after I have assigned the value the cursor is still 0 value.
In the measurement studio 7.0 I didn't have any problem. Is there any changes affecting XPosition and YPosition properties between 7.0 and 7.1?
 
 
Regards
Xirtam
0 Kudos
Message 1 of 10
(4,917 Views)

This may be a side effect of the cursor's snap mode. If you set XPosition, then set YPosition, XPosition may change when you set YPosition if the snap mode determines that the nearest point at YPosition is at a different XPosition. Try either A.) setting the SnapMode property to CursorSnapMode.Fixed or CursorSnapMode.Floating (depending on if you want the cursor to be interactive), or B.) setting the x/y positions simultaneously via the MoveCursor method. If neither of these suggestions resolve your problem, could you please post a small test project that reproduces the behavior that you're seeing? Thanks.

- Elton

Message Edited by Elton Wells on 09-12-2005 10:51 AM

0 Kudos
Message 2 of 10
(4,899 Views)

I have lready tried your solutions and it didn't work . Any other suggestions ?

 

0 Kudos
Message 3 of 10
(4,889 Views)

I forgot my requirements are that the SnapMode has to be seto "toPlot"

This are the settings for the Cursor number one , I have two cursor tied to the same plot, I will illustrate what happen with only one cursor

this.xyCursor_1.Color = System.Drawing.Color.Yellow;

this.xyCursor_1.HorizontalCrosshairMode = NationalInstruments.UI.CursorCrosshairMode.None;

this.xyCursor_1.LabelXFormat = new NationalInstruments.UI.FormatString(NationalInstruments.UI.FormatStringMode.Numeric, "F3");

this.xyCursor_1.LineStyle = NationalInstruments.UI.LineStyle.None;

this.xyCursor_1.Plot = this.waveformPlot;

this.xyCursor_1.PointSize = new System.Drawing.Size(9, 9);

this.xyCursor_1.PointStyle = NationalInstruments.UI.PointStyle.SolidCircle;

this.xyCursor_1.SnapMode = NationalInstruments.UI.CursorSnapMode.ToPlot;

this.xyCursor_1.VerticalCrosshairMode = NationalInstruments.UI.CursorCrosshairMode.None;

this.xyCursor_1.Visible = false;

// -------------------------------------------------------------------------------------------------------------------------------------------------------

This the method I call to set up the Cursors ant it fails randomly , with this I mean that sometimes the cursor succed changing position

and most of the time fails. I noticed though that if I call this method more than once with the some coordinates the cursor eventually get set. 

public

void UpdateMarkers(double x1Data, double y1Data,double x2Data, double y2Data,bool enabeData)

{

xyCursor_1.XPosition = x1Data;

xyCursor_1.YPosition = y1Data;

xyCursor_2.XPosition = x2Data;

xyCursor_2.YPosition = y2Data;

if((x1Data==0 && y1Data ==0)||(x2Data==0 && y2Data ==0))

{

xyCursor_1.Visible =

false;

xyCursor_2.Visible =

false;

waveformPlot.Visible =

false;

waveformGraph.Enabled =

false;

}

else

{

xyCursor_1.Visible =

true;

xyCursor_1.AfterMove +=

new AfterMoveXYCursorEventHandler(NiPotCurve_AfterMove);

xyCursor_2.Visible =

true;

xyCursor_2.AfterMove +=

new AfterMoveXYCursorEventHandler(NiPotCurve_AfterMove);

waveformGraph.Invalidate();

}

}

0 Kudos
Message 4 of 10
(4,888 Views)

Hi Elton,

 

I have to apologize but I come to know that I never tried one of the suggestions that you gave to me in the previous post.

I setup the cursor snap mode to fixed and everithingh worked , I remeber that Ihave tried snap mode to near point and it failed then toplot but I never tried fixed .

So for some reason using Fixed as a snap mode works and toPlot doesn't work anymore like the 7.0

Is there any reason for this?

The code I have is the some except the cursor snap mode.

 

Regards

Marcello Giannoni

0 Kudos
Message 5 of 10
(4,884 Views)
Try moving the code where you set the XPosition and YPosition to the bottom of the UpdateMarkers method. There was a problem where the XYCursors would not update to their positions if they were not visible.
0 Kudos
Message 6 of 10
(4,869 Views)

Thank you Elton,

Yes this is my default case ,the cursor are not visible at the beginning .

I will update the code and see what happen .

Thank you again

0 Kudos
Message 7 of 10
(4,865 Views)

Ok Elton ,

I have updated the code like you said and it definitly works , also I changed again the CursorSnap mode to back to "toPlot" like it was before and it works.

The problem ,like you said before, is definitly that when the cursor are not visible if I change the cursors coordinate , the cursors wont move; but if I set the cursor visibility to true and then I move the cursor the all thingh is working.

Thank you very much Elton this take a lot of thinghs off of my shoulder .

Regards

Marcello

PS here is how the working code looks now:

public

void UpdateMarkers(double x1Data, double y1Data,double x2Data, double y2Data,bool enabeData)

{

if((x1Data==0 && y1Data ==0)||(x2Data==0 && y2Data ==0))

{

xyCursor_1.Visible =

false;

xyCursor_2.Visible =

false;

waveformPlot.Visible =

false;

waveformGraph.Enabled =

false;

}

else

{

xyCursor_1.Visible =

true;

xyCursor_2.Visible =

true;

xyCursor_1.XPosition = x1Data;

xyCursor_1.YPosition = y1Data;

xyCursor_2.XPosition = x2Data;

xyCursor_2.YPosition = y2Data;

xyCursor_1.AfterMove +=

new AfterMoveXYCursorEventHandler(NiPotCurve_AfterMove);

xyCursor_2.AfterMove +=

new AfterMoveXYCursorEventHandler(NiPotCurve_AfterMove);

}

}

0 Kudos
Message 8 of 10
(4,864 Views)

Actually, it was Brock that posted the answer that solved your problem. I'm glad that things are working for you now.

- Elton

0 Kudos
Message 9 of 10
(4,856 Views)

Ophs !  Thank you Broke and thank you Elton

 

Marcello

0 Kudos
Message 10 of 10
(4,853 Views)