[vtkusers] Simple ContextView (2D API) problem

Marcus D. Hanwell marcus.hanwell at kitware.com
Mon May 24 09:44:17 EDT 2010


On Mon, May 24, 2010 at 8:52 AM, Eric E. Monson <emonson at cs.duke.edu> wrote:

> Hello,
>
> I was trying to figure out something with the 2D API, but I'm having
> trouble with the mouse events. In this simple example, the block I create
> doesn't seem to actively respond to mouse events. Really it does, but
> they're just not rendered until I spin the scroll wheel on my mouse, and
> then you see the block suddenly move or turn red or resize as it's supposed
> to...
>
> #======================
> #!/usr/bin/env python
> import vtk
>
> cView = vtk.vtkContextView()
> cItem = vtk.vtkBlockItem()
> cItem.SetLabel('x')
> cItem.SetDimensions(60,100,60,30)
> cView.GetScene().AddItem(cItem)
>
> iren = cView.GetRenderWindow().GetInteractor()
> iren.Initialize()
> iren.Start()
> #======================
>
> Can anyone point me to what's going wrong? I'm sure most things work fine
> since I use the parallel coordinates charts almost every day which are based
> on the same 2D API, but I must be leaving out some step.
>
> It is tough for the scene to know when to re-render. I also wanted to allow
batch operations before rendering again. You want to call SetDirty(true) on
the context scene. This sets an ivar in the scene, and when mouse
interaction is done it will trigger a render.

It was pointed out to me that you should never unset a scene to dirty. And
so the bool argument will probably disappear/be ignored.

Hope that helps.

Marcus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100524/b840d88a/attachment.htm>


More information about the vtkusers mailing list