[vtkusers] Actors disappeared after switching windows
rchqh at polyu.edu.hk
rchqh at polyu.edu.hk
Tue Mar 2 04:03:24 EST 2004
Dear VTK users,
I am programming with VTK 4.0. I tried to add several actors into a renderer
as follows.
vtkActor *actor[3];
actor[0] = vtkActor::New();
actor[1] = vtkActor::New();
actor[2] = vtkActor::New();
vtkPlaneSource *plane[3];
plane[0] = vtkPlaneSource::New();
plane[1] = vtkPlaneSource::New();
plane[2] = vtkPlaneSource::New();
vtkPolyDataMapper *pMapper[3];
pMapper[0] = vtkPolyDataMapper::New();
pMapper[1] = vtkPolyDataMapper::New();
pMapper[2] = vtkPolyDataMapper::New();
vtkTexture *text[3];
text[0] = vtkTexture::New();
text[1] = vtkTexture::New();
text[2] = vtkTexture::New();
plane[0]->SetOrigin(,,,);
plane[0]->SetPoint1(,,,);
plane[0]->SetPoint2(,,,);
plane[1]->SetOrigin(,,,);
plane[1]->SetPoint1(,,,);
plane[1]->SetPoint2(,,,);
plane[2]->SetOrigin(,,,);
plane[2]->SetPoint1(,,,);
plane[2]->SetPoint2(,,,);
pMapper[0]->SetInput(plane[0]->GetOutput());
pMapper[1]->SetInput(plane[1]->GetOutput());
pMapper[2]->SetInput(plane[2]->GetOutput());
text[0]->SetInput(imagedata0);
text[1]->SetInput(imagedata1);
text[2]->SetInput(imagedata2);
actor[0]->SetMapper(pMapper[0]);
actor[1]->SetMapper(pMapper[1]);
actor[2]->SetMapper(pMapper[2]);
actor[0]->SetTexture(text[0]);
actor[1]->SetTexture(text[1]);
actor[2]->SetTexture(text[2]);
actor[0]->RotateX(90);
actor[1]->RotateY(-90);
actor[2]->SetPosition(,,,);
ren->GetActors()->RemoveAllItems(); //ren is a vtkRenderer defined in
other part of my program
ren->AddActor(actor[0]);
ren->AddActor(actor[1]);
ren->AddActor(actor[2]);
renWin->Render(); //renWin is a vtkRenderWindow defined in other part of
my program;ren is the only renderer in this window
The program worked very well and the actors were displayed properly.However,
after I switched to other windows using Alt+Tab and switched back to my vtk
window, two actors disappeared.I also found the only actor left in the
renderwindow had incorrect position and size. Did anyone meet same problem
as mine? Could you help me?
Any reply is appreciated.
Thanks in advance!
HW Wong
More information about the vtkusers
mailing list