How is vtkCursor2D supposed to be used?

Hello!!

I want to use a cross hair cursor with configurable “aperture” (pick radius) in my app. I found vtkCursor2D and the example, converted the example to Python and ran it. vtkCursor2D gives me the shape I want and I can control the size of the aperture, length of the cross hairs etc.

The vtkCursor2D generates a poly which I can then display just like any other geometry

So far, so good, but then I run out of ideas/info/examples.

How do I actually use the vtkCursor2D or it’s output as a cursor in a render window? I can’t see any obvious way of doing this?

How can I add a custom cursor to a render window?

Thanks,

Doug

Hello,

You said the example worked as expected. So you need to give more details of what you want to achieve that is not present in the example. I mean, the example is supposed to have a render window.

best,

Paulo

Paulo,

I thought I was quite clear about what I wanted to achieve…

“I want to use a cross hair cursor with configurable “aperture” (pick radius) in my app”

The current demo uses the vtkCursor2D class to generate a PolyData that is displayed on the render window via the usual mapper, actor, renderer just like any other geometry object.

Being able to create and control the shape of a cross hair cursor is good… but actually using that shape as a cursor in a render window would be GREAT. That’s where I’m stick - I can’t find any examples or docs on how to do this.

Edit : To be clear, I’d like to be able to replace the standard arrow “mouse” cursor with a cross hair “mouse” cursor

Thanks,

Doug

Doug,
maybe you can create a callback on mouse movement, get the coordinates and change the position of your shape accordingly? You’d have to get rid of the arrow though - don’t know if that’s possible, let alone how to do it.

Best,
Manatee

@Manatee - Yes - I can do that. And add the code to keep the shape the same size and always front facing.
But even then it’s not really a different mouse cursor - it’s just an object that looks like a mouse cursor that you can drag around…

I’m assuming there is a way to provide custom mouse cursors - I’ll keep digging until I find it. Next stop is to look at the source.

By the way, it’s easy enough to use the output from the vtkCursor2D as the representation of a handle widget etc. - maybe that’s what vtkCursor2D is intended for and I’m barking up the wrong tree by trying to use it as a custom mouse cursor

OK - I found a test called “TestCustomCursorShape.cxx” which includes the following snippet.
I’m going to assume I can convert the polydata from vtkCursor2D to whatever format a mouse cursor is defined in and use this approach. Although I’m concerned about a pipeline that includes generating a file and then reading it in to change the cursor in in interactive session since I was planning on using a keyboard gesture to change the aperture and size of the axes on the cursor in a dynamic way - so writing/reading the file tens or hundreds of times in rapid succession may be common.

I’ll try it out and see what happens. If anyone knows a better way, please let me know.

  renWin->Render();
  renWin->SetCursorFileName(fileName);
  renWin->SetCurrentCursor(VTK_CURSOR_CUSTOM);
  renWin->Render();