[vtkusers] cursor management

Dean Inglis dean.inglis at camris.ca
Tue May 11 07:55:19 EDT 2010


Hi Karthik,

thanks for the info.  I fudged something for wxPython on
Win32 that works by creating a .ico file in visual studio IDE
and then
myCursor = wxCursor(r"rotate.ico",wxBITMAP_TYPE_ICO,16,16)

then added a callback to the render window interactor for MouseMoveEvent
to switch the cursor

    def ReportCursorState(evt, obj):
        state = rep.GetInteractionState()
        if state == 0:
            textMapper2.SetInput("off")
            cursor = wxStockCursor(wxCURSOR_ARROW)
        elif state == 1:
            textMapper2.SetInput("translate")
            cursor = wxStockCursor(wxCURSOR_SIZING)
        elif state == 2:
            textMapper2.SetInput("rotate")
            cursor = myCursor
        else:
            textMapper2.SetInput("rotate")
            cursor = myCursor
        frame.SetCursor(cursor)

yes, it would be great if VTK had an extensible cursor factory
mechanism.  I saw some code David Gobbi was working on
that had 3D cursors constructed entirely of existing vtk base classes
that oriented themselves along surface normals etc. Maybe 2D
cursors could be done with vtkActor2D's although Im guessing
native platform cursor management would be faster?

Dean

----- Original Message ----- 
From: "Karthik Krishnan" <karthik.krishnan at kitware.com>
To: "Dean Inglis" <dean.inglis at camris.ca>
Cc: "vtkusers archive" <vtkusers at vtk.org>
Sent: Tuesday, May 11, 2010 3:22 AM
Subject: Re: [vtkusers] cursor management


> This is great.. I'm sure custom cursors would be very useful. If your 
> cursor
> isn't supported in the default list of cursors (for instance for unix
> (xfree86/xorg), here is a typical list that can be added to the
> corresponding render windows (vtkXOpenGLRenderWindow etc).
>
>  http://tronche.com/gui/x/xlib/appendix/b/
>
> The niche ones like a Rotate cursor etc aren't available. I took a cursory
> (laughing) look at how OpenInventor does this.. As you know they have a
> rotate cursor for the roll action (search for so_xt_roll_bits to get the
> bitmap). The bitmaps for the cursors (see SoXtCursor) and allow custom
> bitmaps..
>
> See the OpenInventor chapter "Using cursors for feedback" on how to set
> these custom bitmaps..
>
>
> http://docs.sgi.com/library/tpl/cgi-bin/getdoc.cgi/0530/bks/SGI_Developer/books/Inventor_TM/sgi_html/ch10.html#id11605
>
>
> // This routine is used to define cursors..
> void simpleViewer::defineCursors()
> {
>   XColor foreground;
>   Pixmap source;
>
>   ...
>
>   // View plane translate cursor
>   source = XCreateBitmapFromData(display, d,
>            so_xt_flat_hand_bits, so_xt_flat_hand_width,
>            so_xt_flat_hand_height);
>   vwrCursor = XCreatePixmapCursor(display, source, source,
>               &foreground, &foreground, so_xt_flat_hand_x_hot,
>               so_xt_flat_hand_y_hot);
>   XFreePixmap(display, source);
>
>   // Seek cursor
>   source = XCreateBitmapFromData(display, d,
>            so_xt_target_bits, so_xt_target_width,
>            so_xt_target_height);
>   seekCursor = XCreatePixmapCursor(display, source, source,
>                &foreground, &foreground, so_xt_target_x_hot,
>                so_xt_target_y_hot);
>   XFreePixmap(display, source);
>
>   createdCursors = TRUE;
> }
>
>
> It would be great to add this kind of functionality to expand VTK's cursor
> management.
>
>
>
> On Mon, May 3, 2010 at 12:08 PM, Dean Inglis <dean.inglis at camris.ca> 
> wrote:
>
>> I have an application in which Id like to have
>> a cursor to indicate rotation is occuring during widget interaction,
>> however,
>> VTK is limited to a basic set of cursors which does
>> not include such a cursor.  Im guessing
>> this is to maintain cross-platform compatibility.
>> Anyone have any experience coding a custom
>> cursor they could share (Windows or any other
>> platform)?
>> thanks,
>> Dean
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
> 




More information about the vtkusers mailing list