[vtkusers] Re: Text problems with GL2PS
Goodwin Lawlor
goodwin.lawlor at ucd.ie
Thu Nov 4 18:03:09 EST 2004
Hi Joe,
Your text and renderer background are both white... so you can't see the
text.
Insert into your code:
vtext->SetColor(1,0,1);
... and your code outputs visible text in the postscript file.
txt_actor->GetProperty ()->SetColor (1, 0, 1); wont change the text color
hth
Goodwin
"Joe Miller" <lpe540 at yahoo.com> wrote in message
news:20041104203654.50846.qmail at web50007.mail.yahoo.com...
> 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
>
>
> _______________________________________________
> 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