[vtkusers] Display float value in Text Actor

Veerapuram Varadhan v.varadhan at gmail.com
Thu Jul 8 08:15:27 EDT 2004


Did you render after setting the input to the mapper?  (I could not
see a ren->render in your code snippet.

Try adding,

ren->render();
after
textprop->SetColor(1,1,1);

HTH,

V. Varadhan.

On Wed, 07 Jul 2004 12:38:46 -0400, Matthew Seier
<mattie_seier at hotmail.com> wrote:
> Mr. Varadhan,
> 
> When I use sprintf to convert from float to const char, the program compiles
> fine.  When I run the program with a sample text, it displays as normal.
> However, when I try running the program in TextMapper or TextActor using the
> buffer as the input, the program compiles and runs, but no text displays.
> What is the problem?  Here are some snippets of my code:
> 
> float anglex=0;
>   float angley=0;
>   char buffer[10];
> 
> camera->Azimuth(rxf);
> anglex = anglex + rxf;
> sprintf(buffer,"%f", anglex);
> cout << buffer << endl;                    //Prints out the buffer value
> perfectly in the console
> 
> //Create text actors
>         vtkActor2D *textor = vtkActor2D::New();
>         ren->AddActor(textor);
>         vtkTextMapper *textmap = vtkTextMapper::New();
>         vtkProperty2D *textprop = vtkProperty2D::New();
>         textor->SetPosition(10,200);
>         textor->SetPosition2(400,350);
>         textor->SetMapper(textmap);
>         textmap->SetInput(buffer);
>         Sample Text //textmap->SetInput("Angle x =");
>         textor->SetProperty(textprop);
>         textmap->SetFontSize(10);
>         textprop->SetColor(1,1,1);
> 
> Thanks,
> Matt
> 
> >From: Veerapuram Varadhan <v.varadhan at gmail.com>
> >To: Matthew Seier <mattie_seier at hotmail.com>
> >CC: vtkusers at vtk.org
> >Subject: Re: [vtkusers] Display float value in Text Actor
> >Date: Wed, 7 Jul 2004 10:51:52 +0530
> 
> 
> >
> >Hi Matt,
> >You can use sprintf for converting float to char array and then use
> >this char array in vtkTextMapper/vtkTextActor.
> >
> >HTH,
> >
> >V. Varadhan.
> >
> >On Tue, 06 Jul 2004 17:07:15 -0400, Matthew Seier
> ><mattie_seier at hotmail.com> wrote:
> > > Hey all,
> > >
> > > I have a project where I am rotating the camera around an actor, and
> > > generating the angles through which the camera rotates.  The problem is
> >that
> > > these are generated as a float value, and apparently the vtkTextMapper
> >and
> > > vtkTextActor can only map const char values.  Does anyone know how to
> > > display a constantly changing float value in the Render Window(not the
> > > console) in C++??
> > >
> > > Yours,
> > > Matt
> > >
> > > _________________________________________________________________
> > > MSN Life Events gives you the tips and tools to handle the turning
> >points in
> > > your life. http://lifeevents.msn.com
> > >
> > > _______________________________________________
> > > 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
> > >
> 
> _________________________________________________________________
> Get fast, reliable Internet access with MSN 9 Dial-up – now 2 months FREE!
> http://join.msn.click-url.com/go/onm00200361ave/direct/01/
> 
>



More information about the vtkusers mailing list