[vtkusers] Text Stacking

Veerapuram Varadhan v.varadhan at gmail.com
Thu Jul 8 08:32:52 EDT 2004


Hi Matt,

You don't have to keep adding new actors to the renderer.  Create the
text actor, mapper and its properties at the beginning or during the
initialization of the program.

For example

//After the camera has been rotated:
vtkRenderer *ren = this->CurrentRenderer;
/*******************************************************************************************
/*  Instead of creating and adding new actors every time, keep the
textor as a */
/*  globally accessible variable or a class member.  */
/*  just mapper->SetInput() and a render will work fine.  */
/*  even you can try using textor->Modified(); after changing the text
and other */
/*  properties.
//   vtkActor2D *textor = vtkActor2D::New();
//        ren->AddActor(textor);
//        vtkTextMapper *textmap = vtkTextMapper::New();
//        textor->GetProperty()->SetColor(1,1,1);
//        textor->SetPosition(10,200);
//        textor->SetPosition2(400,350);
//        textor->SetMapper(textmap);
*******************************************************************************************/
anglex = anglex + rxf;                                   //rxf= angle the
camera was rotated through
sprintf(buffer,"Angle x=  %f", anglex);             // anglex and buffer are
global variables
textmap->SetInput(buffer);
   rwi->Render();
   textor->Delete();
   textmap->Delete();
   ren->Clear();
if(anglex > 360)
{
        anglex=anglex-360;
}
if(anglex < -360)
{
        anglex=anglex+360;
}

On Wed, 07 Jul 2004 14:19:43 -0400, Matthew Seier
<mattie_seier at hotmail.com> wrote:
> Hey all (again),
> 
> Using sprintf, I got the angles of the camera I was rotating to display on
> the screen, and dynamically update by putting the outputting code in my
> rotation loop.  Unfortunately, the text stacks on top of itself, so that
> after rotating for a few seconds, angle data has piled up, and the text is a
> white blob. Does anyone know how to clean off the text so that more text can
> be placed on top?  The section of C++ code which renders the text is as
> follows:
> 
> //After the camera has been rotated:
> vtkRenderer *ren = this->CurrentRenderer;
>    vtkActor2D *textor = vtkActor2D::New();
>         ren->AddActor(textor);
>         vtkTextMapper *textmap = vtkTextMapper::New();
>         textor->GetProperty()->SetColor(1,1,1);
>         textor->SetPosition(10,200);
>         textor->SetPosition2(400,350);
>         textor->SetMapper(textmap);
> anglex = anglex + rxf;                                   //rxf= angle the
> camera was rotated through
> sprintf(buffer,"Angle x=  %f", anglex);             // anglex and buffer are
> global variables
> textmap->SetInput(buffer);
>    rwi->Render();
>    textor->Delete();
>    textmap->Delete();
>    ren->Clear();
> if(anglex > 360)
> {
>         anglex=anglex-360;
> }
> if(anglex < -360)
> {
>         anglex=anglex+360;
> }
> 
> Thanks a million,
> Matt
> 
> _________________________________________________________________
> MSN 9 Dial-up Internet Access helps fight spam and pop-ups – now 2 months
> FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/
> 
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list