[vtkusers] how can I scale a vtkActor2D?
Liang Ma
leo at esit.com
Thu Nov 27 10:34:45 EST 2008
Hi Peter,
I tried, still can not scale the actor. I also tried vtkShrinkPolydata to
scale the poly data before mapper. Not succeed. I think maybe use a
vtkTransform to scale the data before map it is a possible way.
Thanks.
Regards
Liang Ma
----- Original Message -----
From: "Peter F Bradshaw" <pfb at exadios.com>
To: "VTK users" <vtkusers at vtk.org>
Sent: Wednesday, November 26, 2008 7:25 PM
Subject: Re: [vtkusers] how can I scale a vtkActor2D?
> Hi Liang Ma;
>
> You may need to set the camera into parallel projection mode.
>
> On Wed, 26 Nov 2008, Liang Ma wrote:
>
>> 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();
>
> Try:
> this->pvtkRenderer->GetActiveCamera()->ParallelProjectionOn();
> this->pvtkRenderer->GetActiveCamera()->Zoom(5);
> this->pvtkRenderer->GetRenderWindow()->Render();
>
> Cheers
>
> --
> Peter F Bradshaw: http://www.exadios.com (public keys avaliable there).
> Personal site: http://personal.exadios.com
> "I love truth, and the way the government still uses it occasionally to
> keep us guessing." - Sam Kekovich.
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list