Callback for selecting DrawingObjects

Typically: "How do I... ", "How can I... " questions
Post Reply
vrepUser1
Posts: 10
Joined: 22 Oct 2016, 16:20

Callback for selecting DrawingObjects

Post by vrepUser1 »

Hello,
is there a callback which will be executed in a plugin, when I select a DrawingObject in a scene?

And if not, its possible with eventcallback "key_pressed"? And/Or with a ray which hits the drawingobject to identify it?

Best,
vrepUser1

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Callback for selecting DrawingObjects

Post by fferri »

I think drawing objects cannot do the interaction you request.

Try to create a physical object (e.g. a mesh).

What are you trying to do?

vrepUser1
Posts: 10
Joined: 22 Oct 2016, 16:20

Re: Callback for selecting DrawingObjects

Post by vrepUser1 »

Hi fferri,
I'm representing some entities through line drawing objects and this entities have some specific attributes which I want to display through a cutom gui when you click on it.

I found that the "sim_message_eventcallback_proxsensorselectup" is doing what I requested for. But yes I get a '-1' as handle from this callback message, because it doesnt have a real handle like an object. But perhaps we can work with this, because he recognize the click on the line.

Now how can I get the line handle from the mouse click coordinates, which the callback also provides as information?
According to the callback auxiliary data (handle, mouse coordinates) I thought about this way:
1. handle == -1
2. if 1. is true, then continue with 4.
3. if 1. is false, ignore and return
4. check if there is a line drawing object crosses this mouse coordinate and give me the handle, otherwise return
5. fire custom line callback

Challenge: How can I check if the line is crossing the mouse coordinate in an efficient way? I can go through all generated lines with there start and endpoint, create a analytical geometrical line representation an check for the distance (with a suitable threshold) between the line and the mousecoordinate( e.g. with normalform of an line). I think this should work, but is this the most efficient way to iterate thorugh each line?

Best
vrepUser1

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Callback for selecting DrawingObjects

Post by fferri »

As I said, use an object such as a shape, a mesh, an octree or a point cloud. Those objects can register mouse clicks.

Post Reply