[vtkusers] how can I scale a vtkActor2D?

Peter F Bradshaw pfb at exadios.com
Tue Nov 25 20:39:24 EST 2008


Hi Liang Ma;

On Tue, 25 Nov 2008, Liang Ma wrote:

> Dear Peter,
>
> Thank you so much for your reply. I did try  this->pvtkRenderer->Render()
> after     this->pvtkRenderer->AddActor(this->pvtkActor); It does not work.

I think that this may be the wrong place to call Render().

I should have been a little clearer. The way vtkRenderer works is that
you make changes to the components of the scene (actors, camera, etc.)
and then, as the very last thing to do, to implement the change you call
Render(). This is because rendering is an expensive process.

So, applying this to your zoom code:

this->pvtkRenderer->GetActiveCamera()->Zoom(5);
this->pvtkRenderer->GetRenderWindow()->Render();

>
> my pvtkActor is a vtkActor2D:
>
>   vtkActor2D            *pvtkActor2D;
>
> In fact  this->pvtkActor->GetPositionCoordinate()->SetValue(0.5, 0.5); will
> move the actor to the center. But
> this->pvtkActor->GetPosition2Coordinate()->SetValue(0.9, 0.9);  will not
> scale the actor.
>
> I searched in the archive of  vtkuser and could not fond the answer. I read
> from the help that  vtkActor2D->GetPosition2Coordinate()->SetValue sometims
> will not work "Some 2D actor subclasses ignore the position2 variable ". But
> I do not know why. Will a vtkXYPlotActor be better? I can change the size of
> the font in the same program.Whould you please give me some more advices?
> Thanks again.
>
> Best regards
>
> Liang Ma
>
>
>
> ----- Original Message -----
> From: "Peter F Bradshaw" <pfb at exadios.com>
> To: "VTK Users" <vtkusers at vtk.org>
> Sent: Tuesday, November 25, 2008 11:15 AM
> Subject: Re: [vtkusers] how can I scale a vtkActor2D?
>
>
> > Hi Liang Ma;
> >
> > Are you calling this->pvtkRenderer->Render() anywhere?
> >
> > On Mon, 24 Nov 2008, Liang Ma wrote:
> >
> >> Hi all,
> >>
> >> I tried to scale a 2D actor but it doesn't work. I tried
> >> GetPosition2Coordinate() function but it doesn't work.  Also I tried to
> >> zoom the camera. It does not work either.
> >>
> >> Whould you give me some advices? Thanks.
> >>
> >> Regards
> >>
> >> Liang Ma
> >>
> >> Here is the code:
> >>
> >>   vtkActor2D   *pvtkActor;
> >>            ..........................
> >>
> >> this->pvtkActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
> >>  this->pvtkActor->GetPositionCoordinate()->SetValue(0.5, 0.5);  //
> >> works, could move the actor to the center
> >>  this->pvtkActor->GetPosition2Coordinate()->SetValue(0.9, 0.9); // does
> >> not work, no effect
> >>  this->pvtkActor->GetProperty()->SetColor(1, 0, 0);
> >>
> >> the code for zoom:
> >>
> >> ////////////////////////////////////////////////////////////////////////
> >>         this->pvtkCamera = this->pvtkRenderer->GetActiveCamera ();
> >>         this->pvtkCamera->Zoom(5);    //     zoom doesn't work
> >>         this->pvtkRenderer->SetActiveCamera (this->pvtkCamera) ;
> >> ///////////////////////////////////////////////////////////////////////////
> >>
> >
> > Cheers
> >

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.



More information about the vtkusers mailing list