[vtkusers] Text problems with GL2PS

Joe Miller lpe540 at yahoo.com
Thu Nov 4 15:36:54 EST 2004


Hi,

I have simple program that creates a plane and line of
2d text. All my actors are 2d. However, when I try to
export the image to postscript using vtkGL2PSExporter,
the text never shows up in the postscript file. If I
don't add the plane to the renderer the text appears
just fine. I've tried playing with the different gl2ps
flags. I've also tried setting the visibility of plane
to off. Everything appears on the window just fine but
no text in the postscript. I was wondering if anyones
run across this before or had any suggestions. I'm
using vtk version 4.3. I've included my program below
I apologize if it makes this a very long email. 

Thanks in advance.

-joe

int main ()
{

    vtkPoints *pts = vtkPoints::New ();
   pts->SetNumberOfPoints (4);
   pts->InsertPoint (0, 0, 0, 0);
   pts->InsertPoint (1, 0, 100, 0);
   pts->InsertPoint (2, 100, 100, 0);
   pts->InsertPoint (3, 100, 0, 0);

   vtkCellArray *arr = vtkCellArray::New ();
   arr->InsertNextCell (4);
   arr->InsertCellPoint (0); arr->InsertCellPoint (1);
   arr->InsertCellPoint (2); arr->InsertCellPoint (3);

   vtkPolyData *plane_data = vtkPolyData::New ();

   plane_data->SetPoints (pts);
   plane_data->SetPolys (arr);

   vtkPolyDataMapper2D *mapper =
vtkPolyDataMapper2D::New ();
   mapper->SetInput (plane_data);

   vtkActor2D *plane = vtkActor2D::New ();
   plane->SetMapper (mapper);

   plane->GetProperty ()->SetColor (1, 1, 0);
   plane->SetPosition (0, 0);

   pts->Delete ();
   arr->Delete ();
   mapper->Delete ();

   vtkTextProperty *vtext = vtkTextProperty::New();
   vtext->SetBold(1);
   vtext->SetItalic(1);
   vtext->SetShadow(0);
   vtext->SetFontFamilyToArial();

   vtkTextMapper *txt_mapper = vtkTextMapper::New();
   vtkActor2D *txt_actor = vtkActor2D::New();
   txt_actor->SetMapper(txt_mapper);
   txt_mapper->SetInput ("test");
   txt_mapper->GetTextProperty()->ShallowCopy(vtext);
   txt_actor->GetProperty ()->SetColor (1, 0, 1);
   txt_actor->SetPosition (150, 55);


    vtkRenderer *ren1 = vtkRenderer::New ();
    vtkRenderWindow *renWin = vtkRenderWindow::New ();
    renWin->AddRenderer (ren1);
    renWin->SetSize (300, 300);

    vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::New ();
    iren->SetRenderWindow (renWin);
ren1->SetBackground (1, 1, 1);

    ren1->AddActor (txt_actor);
    ren1->AddActor (plane);

    renWin->Render ();
    vtkGL2PSExporter *psExporter =
vtkGL2PSExporter::New();
      psExporter->SetRenderWindow(renWin);
      psExporter->SetFileFormatToPS();
      psExporter->TextOn();
      psExporter->SetWrite3DPropsAsRasterImage(0);
      psExporter->SetFilePrefix("tmp");
      psExporter->Write();
      psExporter->Delete();

    iren->Initialize ();

}



		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 




More information about the vtkusers mailing list