1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
/*=========================================================================
Program: Visualization Toolkit
Module: TestStringToPath.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkTextActor.h"
#include "vtkCamera.h"
#include "vtkGL2PSExporter.h"
#include "vtkNew.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTestingInteractor.h"
#include "vtkTextProperty.h"
//----------------------------------------------------------------------------
int TestGL2PSMathTextActor(int, char *[])
{
vtkNew<vtkTextActor> actor1;
actor1->SetInput("$\\langle\\psi_i\\mid\\psi_j\\rangle = \\delta_{ij}$");
actor1->GetTextProperty()->SetFontSize(36);
actor1->GetTextProperty()->SetOrientation(0.0);
actor1->GetTextProperty()->SetColor(0.8, 0.8, 0.6);
actor1->SetPosition(0, 0);
actor1->GetTextProperty()->SetVerticalJustificationToBottom();
actor1->GetTextProperty()->SetJustificationToLeft();
vtkNew<vtkTextActor> actor2;
actor2->SetInput("$\\langle\\psi_i\\mid\\psi_j\\rangle = \\delta_{ij}$");
actor2->GetTextProperty()->SetFontSize(36);
actor2->SetPosition(300, 300);
actor2->GetTextProperty()->SetColor(0.7, 0.3, 0.2);
actor2->GetTextProperty()->SetVerticalJustificationToCentered();
actor2->GetTextProperty()->SetJustificationToCentered();
actor2->GetTextProperty()->SetOrientation(90.0);
vtkNew<vtkTextActor> actor3;
actor3->SetInput("$\\langle\\psi_i\\mid\\psi_j\\rangle = \\delta_{ij}$");
actor3->GetTextProperty()->SetFontSize(36);
actor3->SetPosition(600, 600);
actor3->GetTextProperty()->SetColor(0.6, 0.5, 0.8);
actor3->GetTextProperty()->SetVerticalJustificationToTop();
actor3->GetTextProperty()->SetJustificationToRight();
vtkNew<vtkTextActor> actor4;
actor4->SetInput("$\\langle\\psi_i\\mid\\psi_j\\rangle = \\delta_{ij}$");
actor4->GetTextProperty()->SetFontSize(22);
actor4->SetPosition(150, 300);
actor4->GetTextProperty()->SetColor(0.2, 0.6, 0.4);
actor4->GetTextProperty()->SetVerticalJustificationToCentered();
actor4->GetTextProperty()->SetJustificationToCentered();
actor4->GetTextProperty()->SetOrientation(45.0);
vtkNew<vtkTextActor> actor5;
actor5->ShallowCopy(actor4.GetPointer());
actor5->SetPosition(450, 300);
vtkNew<vtkRenderer> ren;
vtkNew<vtkRenderWindow> win;
win->AddRenderer(ren.GetPointer());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(win.GetPointer());
ren->AddActor(actor1.GetPointer());
ren->AddActor(actor2.GetPointer());
ren->AddActor(actor3.GetPointer());
ren->AddActor(actor4.GetPointer());
ren->AddActor(actor5.GetPointer());
ren->SetBackground(0.0, 0.0, 0.0);
win->SetSize(600, 600);
win->Render();
vtkNew<vtkGL2PSExporter> exp;
exp->SetRenderWindow(win.GetPointer());
exp->SetFileFormatToPS();
exp->CompressOff();
exp->SetSortToSimple();
exp->DrawBackgroundOn();
std::string fileprefix = vtkTestingInteractor::TempDirectory +
std::string("/TestGL2PSMathTextActor");
exp->SetFilePrefix(fileprefix.c_str());
exp->Write();
// Finally render the scene and compare the image to a reference image
win->SetMultiSamples(0);
win->GetInteractor()->Initialize();
win->GetInteractor()->Start();
return EXIT_SUCCESS;
}
|