[vtkusers] vtk iteration over actors to change entity parameters, how?
Dr. A. M. Zsaki
zsaki at encs.concordia.ca
Mon Feb 27 19:21:56 EST 2006
Hello,
I'm building my first 'real' application using VTK. I have a set of actors
and I would like to change their appearance after they have been created.
I'm using the FOX GUI as the user interface. Where I'm stuck at the moment
is that, say, I have three actors (0, 1, 2). I want to change the color of
the second one but so far I have not discovered any means of differentiating
actors from each other...
Is there a better way of doing this other than keeping track of which actor
is where in the list of actors (and when it was added,etc), like assigning a
name to an actor or something similar?!?
Any pointers are appreciated!
Attila
My code 'works' like this so far:
FXColorDialog* colordlg=new FXColorDialog(this,"Mesh color picker");
if(colordlg->execute()) {
FXColor color=colordlg->getRGBA();
int iRed=FXREDVAL(color);
int iGreen=FXGREENVAL(color);
int iBlue=FXBLUEVAL(color);
vtkActorCollection* actors=vtkActorCollection::New();
actors=ren->GetActors();
actors->InitTraversal();
int iNumberOfActors=actors->GetNumberOfItems();
if (iNumberOfActors>0) {
for (int i=0;i<iNumberOfActors;++i) {
if (i==1) {
vtkActor* actor=actors->GetNextActor();
actor->GetProperty()->SetColor((float)(iRed/256),(float)(iGreen/256),(float)
(iBlue/256));
break;
}
actors->GetNextActor();
}
}
actors->Delete();
}
More information about the vtkusers
mailing list