0

Purpose of EnableCurrentPosition property

everytimer 6 years ago in Question updated by anonymous 3 years ago 3
What is the purpose of the EnableCurrentPosition property?

If we inspect the code we can see that it controls whether CurrentPosition is calculated or not:

[HelixViewport3D.cs]
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);


if (this.EnableCurrentPosition)
{
var pt = e.GetPosition(this);
var pos = this.FindNearestPoint(pt);
if (pos != null)
{
this.CurrentPosition = pos.Value;
}
else
{
var p = this.Viewport.UnProject(pt);
if (p != null)
{
this.CurrentPosition = p.Value;
}
}
}
}

So, each time OnMouseMove method is called the (Point3D) pos is calculated (by FindNearstPoint) and that may be a costly operation to perform each time the mouse is moved.

Why CurrentPosition is needed and why it is optional?
By default EnableCurrentPosition is set to false so that calculation is skipped.
If it is enabled, then CurrentPosition (Point3D) property can be used in order to know the 3D point that is under the mouse.
We use this property to show the actual position on screen. (see top left corner)



Kind regards,
Christof