[vtkusers] how can I scale a vtkActor2D?
Liang Ma
leo at esit.com
Wed Nov 26 10:04:42 EST 2008
Sorry, still not clear last time.
// remove old actors
this->pvtkRenderer->RemoveActor(this->pvtkActor);
this->pvtkRenderer->RemoveActor(this->pvtkActor2D);
// read new data of 3D model from a STL file
if (!this->pvtkSTLReader)
this->pvtkSTLReader = vtkSTLReader::New();
this->pvtkSTLReader->SetFileName(cFileDialog.GetPathName());
//Cut the 3D model
m_VTKPD_data = pvtkSTLReader->GetOutput();
m_VTKPD_data->Update();
m_dOrigin1 = m_VTKPD_data->GetCenter();
this->cplane->SetOrigin(m_dOrigin1[0], m_dOrigin1[1], m_dOrigin1[2]);
float normal_x = 0;
float normal_y = 0;
float normal_z = 1;
cplane->SetNormal(normal_x, normal_y, normal_z);
planeCut->SetInput(m_VTKPD_data);
planeCut->SetCutFunction(cplane);
// Setmapper
this->pvtkDataSetMapper->SetInput(planeCut->GetOutput());
this->pvtkActor->SetMapper(this->pvtkDataSetMapper);
// Try to scale the 2D actor
this->pvtkActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
this->pvtkActor->GetPositionCoordinate()->SetValue(0.3, 0.5);
this->pvtkActor->GetPosition2Coordinate()->SetValue(0.9, 0.9);
this->pvtkActor->GetProperty()->SetColor(1, 0, 0);
// Add the txt of thefile name
this->pvtkTextMapper->SetInput(pvtkSTLReader->GetFileName());
this->pvtkTextMapper->GetTextProperty()->SetFontSize(12);
this->pvtkActor2D->SetMapper(this->pvtkTextMapper);
// Set background and add actors to render
this->pvtkRenderer->SetBackground(0.4,0.4,0.4);
this->pvtkRenderer->AddActor(this->pvtkActor);
this->pvtkRenderer->AddActor(this->pvtkActor2D);
// try to zoom, then render
this->pvtkRenderer->GetActiveCamera()->Zoom(5);
this->pvtkRenderer->GetRenderWindow()->Render();
More information about the vtkusers
mailing list