How to know whether the cursor is on which object or not when CRhinoGetPoint?

I worked CRhinoGetPoint for drawing some points or spheres on the mesh.

Now, I have a problem

I want to delete or move a object when the cursor is on the object.

Can I know whether the cursor is on the some object or not in the event OnMouseMove?

The example is below.
If the cursor is on the Mesh surface #1 and the mouse left button is pressed, it will draw a sphere on the mesh surface #1.
But, if the cursor is on the some objects, Mesh sphere #1 ~ N, I will stop to draw the sphere or delete this object.

I think for that you should use the PointOnObject function. From the header:

  // Call this function to see if the point was on an object.  If
  // PointOnObject() returns true, then the object is returned
  // in the CRhinoObjRef parameter.  Use CRhinoObjRef::CurveParameter() or
  // CRhinoObjRef::SurfaceParameter() to get the parameter values for
  // the point.
  BOOL PointOnObject(CRhinoObjRef&) const;

Thanks you !
So the code looks like below ?
XXX::OnMouseMove(CRhinoViewport &vp, UINT nFlags, const ON_3dPoint &point, const CPoint* view_wnd_point)
{

if( PointOnObject( XXX ) ) //if the cursor is on the object
{
;
}
}

I don’t know if you can use PointOnObject inside the OnMouseMove. But nothing stops you from trying different tactics, right?

I always think about "if the point was on an object."
Why not use “cursor” ?

Use CRhinoGetPoint::PointOnObject after you’ve picked a point. For example:

CRhinoGetPoint gp;
gp.GetPoint();
if (gp.CommandResult() == CRhinoCommand::success)
{
  CRhinoObjRef obj_ref;
  if (gp.PointOnObject(obj_ref))
  {
    // TODO...
  }
}

If you know the locations of your mesh sphere (e.g. the center points), then I would derive a new class from CRhinoGetPoint and override OnMouseMove. In OnMouseMove find the closest point on the curve to the current mouse point. Then, compare this location with that of your mesh spheres. When you create an instance of your derived class, make sure to constrain point picking to the curve using CRhinoGetPoint::Constrain.

Yeah!
Thank you very much for you.
It is pity to use PointOnObject() is after GetPoint finished.

Dale,

Is it possible to use a similar method to change the appearance of the cursor instead of retrieving point data?

I have the mouse over working however I have not been able to modify the cursor appearance yet.

Any help you can offer would be appreciated.

I don’t believe there is a way to change Rhino’s cursor, application wide. But you can override the cursor during point picking. Here is a simple example:

var gp = new GetPoint();
gp.SetCommandPrompt("Pick a point");
gp.SetCursor(System.Windows.Forms.Cursors.Hand);
gp.Get();

Not sure this is what you are looking for…

Dale,

This help is appreciated and in combination with other reading I now understand a little more about how Rhino works in relation to cursors and updating the viewport.

I would like to make a request for an improvement or new feature, if possible. It would be nice to have a method within the mouse events class, in particular OnMouseMove, that ties cursor appearance to the even so that one could define a cursor in some way …

maybe something like …

e.SetCursor(System.Windows.Forms.Cursors.Hand)

or another way if it seems more appropriate from the perspective of your team.

Dale,

This is a correction to my previous post.

The mouse events are fine. The better place for the cursor modification would be with the DrawEventArgs as accessed in a viewport. By using these drawing events and the mouse events it should be possible to have mouse over events with different cursors.