[vtkusers] About 'callback function' in vtk UI programming

Leon Chen liming.leon at gmail.com
Wed Jul 6 14:10:37 EDT 2005


Hi all,

The callback function is quite important if user wants to do something
with the programm.

Now I can change the color of the actor via the following code:
 =====================
ASSUMING that i can get the vtkRenderWindow in some way

vtkRenderWindow *rw

 vtkRendererCollection *rc = rw->GetRenderers();

 rc->InitTraversal();
//here get the first renderer, even there is just one renderer
 vtkRenderer *rr = rc->GetNextItem();

 vtkActorCollection *as = rr->GetActors();
 as->InitTraversal();
// here get the first actor, even there is just one actor
 vtkActor *actor = as->GetNextActor();
// NOW I can change the color of the actor
actor->GetProperty()->SetColor(<color value here>);

==============================

It works, but I am not sure wether the code is efficient or not, or is
there some other way to 'get' the actor(s)?

*************
My another problem is how can i change the position of a sphere?

I generate the shpere from vtkSphereSource, and map it on a
vtkPolyDataMapper, to an actor. I don't know how to get back to the
spheresource given the renderer, then the center of the sphere can be
re-set.
*************

Thank you in advance. :P



More information about the vtkusers mailing list