Commit 82e58fc1 authored by David C. Lonie's avatar David C. Lonie

Update vtkGL2PSExporter, add Rendering/GL2PS module

* Fixed bitmap rasterization.
* Added ability to exclude specific 3D props from the rasterization
  process, if enabled.
* Improved support for text rendering.
* Added method to vtkRenderWindow to collect all visible
  vtkActor2D objects that are vtk[Math]TextActors or use a
  vtkTextMapper.
* Add support for Context2D drawings
* Add CMake/CompareFileMD5.cmake script to compare postscript files
* Remove old GL2PSExporter python test
* Modify gl2ps sources to disable writing timestamps (prevents
  useful MD5 hashing for regression tests)
* A static string is used as the image title by default.
* Add vtkGL2PSUtilities, a collection of static functions that
  interact with GL2PS to render vtk objects.
* Add a gl2psGetFileFormat() function to the bundled gl2ps library.

Change-Id: Ia6fafc8e4d0a49bd9fdbecf32f43925a0aab7050
parent e74980cc
#
# Simple CMake -P script to compare the MD5 hash of files. Usage:
#
# cmake -DTESTFILE=<filespec> -DGLOBEXP=<glob expression> -DCLEANTESTFILE=<bool> -P CompareFileMD5.cmake
#
# TESTFILE is the test file, GLOB expression referring to a collection of
# reference files. This can be used to compare file produced by a test
# (TESTFILE) to one or more baselines (glob expression GLOBEXP). If
# CLEANTESTFILE is set to some true value, the test file will be deleted if a
# matching hash is found.
#
# The script will exit silently if the test file's hash matches the hash
# of any reference file (success), or print a line starting with MATCH_FAIL
# and several lines of supplemental information otherwise.
#
macro(dumpoutput lines)
foreach(line ${lines})
message("MATCH_FAIL: ${line}")
endforeach()
endmacro()
set(HASH_FOUND FALSE)
set(output "Comparing MD5 sum of; \"${TESTFILE}\"; to glob; \"${GLOBEXP}\"")
file(GLOB REFFILES ${GLOBEXP})
if(NOT REFFILES)
list(APPEND output "glob expression '${GLOBEXP}' does not refer to any files.")
else()
file(MD5 ${TESTFILE} TESTHASH)
set(output ${output} "Testfile:;${TESTHASH} - ${TESTFILE};Baselines:")
foreach(FILEN ${REFFILES})
file(MD5 ${FILEN} HASHN)
set(output ${output} "${HASHN} - ${FILEN}")
if(${TESTHASH} STREQUAL ${HASHN})
set(HASH_FOUND TRUE)
endif()
endforeach()
endif()
if(NOT HASH_FOUND)
set(output ${output} "Matching hash not found!")
dumpoutput("${output}")
else()
if(${CLEANTESTFILE})
file(REMOVE ${TESTFILE})
endif()
endif()
......@@ -8,6 +8,7 @@
)
if(VTK_DATA_ROOT)
# add tests that require data
set(MyTests ${MyTests}
TestBarGraph.cxx
......
......@@ -8,5 +8,6 @@ vtk_module(vtkChartsCore
vtkTestingCore
vtkTestingRendering
vtkViewsContext2D
vtkIOExport
vtkIOInfovis
)
......@@ -17,17 +17,6 @@ set(Module_SRCS
vtkGL2PSExporter.cxx
)
if(NOT VTK_USE_SYSTEM_GL2PS)
# TODO: Build vtkgl2ps library over in its module
list(APPEND Module_SRCS ${VTK_SOURCE_DIR}/ThirdParty/gl2ps/vtkgl2ps/gl2ps.c)
add_definitions(-DGL2PS_HAVE_ZLIB)
add_definitions(-DGL2PS_HAVE_LIBPNG)
set_source_files_properties(
${VTK_SOURCE_DIR}/ThirdParty/gl2ps/vtkgl2ps/gl2ps
WRAP_EXCLUDE
)
endif()
set_source_files_properties(
vtkX3D
vtkX3DExporterWriter
......
create_test_sourcelist(Tests ${vtk-module}CxxTests.cxx
set(GL2PSTests
TestContextGL2PS.cxx
TestGL2PSExporterRaster.cxx
TestGL2PSExporterRasterExclusion.cxx
TestGL2PSExporterVector.cxx
TestGL2PSExporterVolumeRaster.cxx
TestStackedPlotGL2PS.cxx
)
set(MyTests
X3DTest.cxx
EXTRA_INCLUDE vtkTestDriver.h
)
if (VTK_DATA_ROOT)
set(MyTests
${MyTest}
${GL2PSTests}
)
endif()
# Use the testing object factory, to reduce boilerplate code in tests.
include("${vtkTestingRendering_SOURCE_DIR}/vtkTestingObjectFactory.cmake")
vtk_module_test_executable(${vtk-module}CxxTests ${Tests})
set(TestsToRun ${Tests})
list(REMOVE_ITEM TestsToRun ${vtk-module}CxxTests.cxx)
remove(TestsToRun CxxTests.cxx)
# Add all the executables
foreach(test ${TestsToRun})
......@@ -22,3 +39,32 @@ foreach(test ${TestsToRun})
COMMAND ${vtk-module}CxxTests ${TName})
endif()
endforeach()
# The GL2PS tests produce postscript output, which cannot be compared using
# the built-in image regression framework. Instead, calculate and compare
# md5 sums using a CMake script.
# The file(MD5 ...) subcommand is not available in CMake < 2.8.7
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.8 OR
("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" EQUAL 2.8 AND
"${CMAKE_PATCH_VERSION}" GREATER 7))
set(CMAKE_HAS_FILE_MD5_SUBCOMMAND TRUE)
endif()
if(CMAKE_HAS_FILE_MD5_SUBCOMMAND AND GL2PSTests AND VTK_DATA_ROOT)
foreach(test ${GL2PSTests})
get_filename_component(TName ${test} NAME_WE)
add_test(NAME ${vtk-module}Cxx-${TName}-CheckMD5sum
COMMAND ${CMAKE_COMMAND}
-DTESTFILE=${VTK_BINARY_DIR}/Testing/Temporary/${TName}.ps
-DGLOBEXP=${VTK_DATA_ROOT}/Baseline/Hybrid/${TName}*.ps
-DCLEANTESTFILE=1
-P ${VTK_SOURCE_DIR}/CMake/CompareFileMD5.cmake
)
set_tests_properties("${vtk-module}Cxx-${TName}-CheckMD5sum"
PROPERTIES
DEPENDS "${vtk-module}Cxx-${TName}"
REQUIRED_FILES
"${VTK_DATA_ROOT}/Baseline/Hybrid/${TName}.ps;${VTK_BINARY_DIR}/Testing/Temporary/${TName}.ps"
FAIL_REGULAR_EXPRESSION "MATCH_FAIL"
)
endforeach()
endif()
/*=========================================================================
Program: Visualization Toolkit
Module: TestContextGL2PS.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 "vtkBrush.h"
#include "vtkContext2D.h"
#include "vtkContextItem.h"
#include "vtkContextScene.h"
#include "vtkContextView.h"
#include "vtkGL2PSExporter.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLContextDevice2D.h"
#include "vtkPen.h"
#include "vtkPoints2D.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSmartPointer.h"
#include "vtkTestingInteractor.h"
#include "vtkTextProperty.h"
#include "vtkTransform2D.h"
#include <string>
//----------------------------------------------------------------------------
class ContextGL2PSTest : public vtkContextItem
{
public:
static ContextGL2PSTest *New();
vtkTypeMacro(ContextGL2PSTest, vtkContextItem);
// Paint event for the chart, called whenever the chart needs to be drawn
virtual bool Paint(vtkContext2D *painter);
};
//----------------------------------------------------------------------------
int TestContextGL2PS( int, char *[] )
{
// Set up a 2D context view, context test object and add it to the scene
vtkNew<vtkContextView> view;
view->GetRenderer()->SetBackground(1.0, 1.0, 1.0);
view->GetRenderWindow()->SetSize(800, 600);
vtkNew<ContextGL2PSTest> test;
view->GetScene()->AddItem(test.GetPointer());
// Force the use of the freetype based rendering strategy
vtkOpenGLContextDevice2D::SafeDownCast(view->GetContext()->GetDevice())
->SetStringRendererToFreeType();
view->GetRenderWindow()->SetMultiSamples(0);
view->GetRenderWindow()->Render();
vtkNew<vtkGL2PSExporter> exp;
exp->SetRenderWindow(view->GetRenderWindow());
exp->SetFileFormatToPS();
exp->CompressOff();
exp->SetSortToOff();
exp->DrawBackgroundOn();
std::string fileprefix = vtkTestingInteractor::TempDirectory +
std::string("/TestContextGL2PS");
exp->SetFilePrefix(fileprefix.c_str());
exp->WriteTimeStampOff(); // Otherwise hashes won't match
exp->Write();
return EXIT_SUCCESS;
}
// Make our new derived class to draw a diagram
vtkStandardNewMacro(ContextGL2PSTest);
// This function aims to test the primitives provided by the 2D API.
bool ContextGL2PSTest::Paint(vtkContext2D *painter)
{
// Test the string drawing functionality of the context
painter->GetTextProp()->SetVerticalJustificationToCentered();
painter->GetTextProp()->SetJustificationToCentered();
painter->GetTextProp()->SetColor(0.0, 0.0, 0.0);
painter->GetTextProp()->SetFontSize(24);
painter->GetTextProp()->SetFontFamilyToArial();
painter->GetPen()->SetColor(0, 0, 0, 255);
painter->GetBrush()->SetColor(0, 0, 0, 255);
painter->DrawString(400, 25, "GL2PS is used as a backend to the context.");
// Draw some individual lines of different thicknesses.
for (int i = 0; i < 10; ++i)
{
painter->GetPen()->SetColor(255,
static_cast<unsigned char>(float(i)*25.0),
0);
painter->GetPen()->SetWidth(1.0 + float(i));
painter->DrawLine(10, 50 + float(i)*10, 60, 50 + float(i)*10);
}
// Draw some individual lines of different thicknesses.
painter->GetPen()->SetWidth(10);
for (int i = 0; i < 10; ++i)
{
painter->GetPen()->SetLineType(i % (vtkPen::DASH_DOT_DOT_LINE+1));
painter->GetPen()->SetColor(255,
static_cast<unsigned char>(float(i)*25.0),
0);
painter->DrawLine(10, 250 + float(i)*10, 60, 250 + float(i)*10);
}
painter->GetPen()->SetLineType(vtkPen::SOLID_LINE);
// Use the draw lines function now to draw a shape.
vtkSmartPointer<vtkPoints2D> points = vtkSmartPointer<vtkPoints2D>::New();
points->SetNumberOfPoints(30);
for (int i = 0; i < 30; ++i)
{
double point[2] = { float(i) * 25.0 + 10.0,
sin(float(i) / 5.0) * 100.0 + 200.0 };
points->SetPoint(i, point);
}
painter->GetPen()->SetColor(0, 255, 0);
painter->GetPen()->SetWidth(5.0);
painter->DrawPoly(points);
// Now to draw some points
painter->GetPen()->SetColor(0, 0, 255);
painter->GetPen()->SetWidth(5.0);
painter->DrawPoint(10, 10);
painter->DrawPoint(790, 10);
painter->DrawPoint(10, 590);
painter->DrawPoint(790, 590);
// Draw some individual lines of different thicknesses.
for (int i = 0; i < 10; ++i)
{
painter->GetPen()->SetColor(0,
static_cast<unsigned char>(float(i)*25.0),
255);
painter->GetPen()->SetWidth(1.0 + float(i));
painter->DrawPoint(75, 50 + float(i)*10);
}
painter->GetPen()->SetColor(0, 0, 255);
painter->GetPen()->SetWidth(3.0);
painter->DrawPoints(points);
// Now draw a rectangle
painter->GetPen()->SetColor(100, 200, 255);
painter->GetPen()->SetWidth(3.0);
painter->GetBrush()->SetColor(100, 255, 100);
painter->DrawRect(100, 50, 200, 100);
// Add in an arbitrary quad
painter->GetPen()->SetColor(159, 0, 255);
painter->GetPen()->SetWidth(1.0);
painter->GetBrush()->SetColor(100, 55, 0, 200);
painter->DrawQuad(350, 50, 375, 150,
525, 199, 666, 45);
// Now to test out the transform...
vtkNew<vtkTransform2D> transform;
transform->Translate(20, 200);
painter->GetDevice()->SetMatrix(transform->GetMatrix());
painter->GetPen()->SetColor(255, 0, 0);
painter->GetPen()->SetWidth(6.0);
painter->DrawPoly(points);
transform->Translate(0, 10);
painter->GetDevice()->SetMatrix(transform->GetMatrix());
painter->GetPen()->SetColor(0, 0, 200);
painter->GetPen()->SetWidth(2.0);
painter->DrawPoints(points);
transform->Translate(0, -20);
painter->GetDevice()->SetMatrix(transform->GetMatrix());
painter->GetPen()->SetColor(100, 0, 200);
painter->GetPen()->SetWidth(5.0);
painter->DrawPoints(points);
// Now for an ellipse...
painter->GetPen()->SetColor(0, 0, 0);
painter->GetPen()->SetWidth(1.0);
painter->GetBrush()->SetColor(0, 0, 100, 69);
painter->DrawEllipse(110.0, 89.0, 20, 100);
return true;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestGL2PSExporterRaster.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 "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include "vtkGL2PSExporter.h"
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkCubeAxesActor2D.h"
#include "vtkConeSource.h"
#include "vtkNew.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkProperty2D.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkTestingInteractor.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
#include <string>
int TestGL2PSExporterRaster( int, char *[] )
{
vtkNew<vtkConeSource> coneSource;
vtkNew<vtkPolyDataMapper> coneMapper;
vtkNew<vtkActor> coneActor;
coneSource->SetResolution(25);
coneMapper->SetInputConnection(coneSource->GetOutputPort());
coneActor->SetMapper(coneMapper.GetPointer());
coneActor->GetProperty()->SetColor(0.5, 0.5, 1.0);
vtkNew<vtkCubeAxesActor2D> axes;
axes->SetInputConnection(coneSource->GetOutputPort());
axes->SetFontFactor(2.0);
axes->SetCornerOffset(0.0);
axes->GetProperty()->SetColor(0.0, 0.0, 0.0);
vtkNew<vtkTextActor> text1;
text1->SetDisplayPosition(250, 435);
text1->SetInput("Test\nmultiline\ntext"); // Won't render properly
text1->GetTextProperty()->SetFontSize(18);
text1->GetTextProperty()->SetFontFamilyToArial();
text1->GetTextProperty()->SetJustificationToCentered();
text1->GetTextProperty()->BoldOn();
text1->GetTextProperty()->ItalicOn();
text1->GetTextProperty()->SetColor(0.0, 0.0, 1.0);
vtkNew<vtkTextActor> text2;
text2->SetDisplayPosition(400, 250);
text2->SetInput("Test rotated text");
text2->GetTextProperty()->SetFontSize(22);
text2->GetTextProperty()->SetFontFamilyToTimes();
text2->GetTextProperty()->SetJustificationToCentered();
text2->GetTextProperty()->SetVerticalJustificationToCentered();
text2->GetTextProperty()->BoldOn();
text2->GetTextProperty()->SetOrientation(45);
text2->GetTextProperty()->SetColor(1.0, 0.0, 0.0);
vtkNew<vtkTextActor> text3;
text3->SetDisplayPosition(20, 20);
text3->SetInput("Big text!");
text3->GetTextProperty()->SetFontSize(45);
text3->GetTextProperty()->SetFontFamilyToCourier();
text3->GetTextProperty()->SetJustificationToLeft();
text3->GetTextProperty()->BoldOn();
text3->GetTextProperty()->SetOrientation(0);
text3->GetTextProperty()->SetColor(0.2, 1.0, 0.2);
vtkNew<vtkRenderer> ren;
axes->SetCamera(ren->GetActiveCamera());
ren->AddActor(coneActor.GetPointer());
ren->AddActor(axes.GetPointer());
ren->AddActor(text1.GetPointer());
ren->AddActor(text2.GetPointer());
ren->AddActor(text3.GetPointer());
ren->SetBackground(0.8, 0.8, 0.8);
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(ren.GetPointer());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
vtkSmartPointer<vtkCamera> camera = ren->GetActiveCamera();
ren->ResetCamera();
camera->Azimuth(30);
renWin->SetSize(500, 500);
renWin->Render();
vtkNew<vtkGL2PSExporter> exp;
exp->SetRenderWindow(renWin.GetPointer());
exp->SetFileFormatToPS();
exp->CompressOff();
exp->SetSortToBSP();
exp->DrawBackgroundOn();
exp->Write3DPropsAsRasterImageOn();
std::string fileprefix = vtkTestingInteractor::TempDirectory +
std::string("/TestGL2PSExporterRaster");
exp->SetFilePrefix(fileprefix.c_str());
exp->WriteTimeStampOff(); // Otherwise hashes won't match
exp->Write();
return EXIT_SUCCESS;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestGL2PSExporterRaster.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 "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include "vtkGL2PSExporter.h"
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkCubeAxesActor.h"
#include "vtkConeSource.h"
#include "vtkNew.h"
#include "vtkPolyDataMapper.h"
#include "vtkProp3DCollection.h"
#include "vtkProperty.h"
#include "vtkProperty2D.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkTestingInteractor.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
#include <string>
int TestGL2PSExporterRasterExclusion( int, char *[] )
{
vtkNew<vtkConeSource> coneSource;
vtkNew<vtkPolyDataMapper> coneMapper;
vtkNew<vtkActor> coneActor;
coneSource->SetResolution(25);
coneMapper->SetInputConnection(coneSource->GetOutputPort());
coneActor->SetMapper(coneMapper.GetPointer());
coneActor->GetProperty()->SetColor(0.5, 0.5, 1.0);
vtkNew<vtkTextActor> text1;
text1->SetDisplayPosition(250, 435);
text1->SetInput("Test\nmultiline\ntext"); // Won't render properly
text1->GetTextProperty()->SetFontSize(18);
text1->GetTextProperty()->SetFontFamilyToArial();
text1->GetTextProperty()->SetJustificationToCentered();
text1->GetTextProperty()->BoldOn();
text1->GetTextProperty()->ItalicOn();
text1->GetTextProperty()->SetColor(0.0, 0.0, 1.0);
vtkNew<vtkTextActor> text2;
text2->SetDisplayPosition(400, 250);
text2->SetInput("Test rotated text");
text2->GetTextProperty()->SetFontSize(22);
text2->GetTextProperty()->SetFontFamilyToTimes();
text2->GetTextProperty()->SetJustificationToCentered();
text2->GetTextProperty()->SetVerticalJustificationToCentered();
text2->GetTextProperty()->BoldOn();
text2->GetTextProperty()->SetOrientation(45);
text2->GetTextProperty()->SetColor(1.0, 0.0, 0.0);
vtkNew<vtkTextActor> text3;
text3->SetDisplayPosition(20, 20);
text3->SetInput("Big text!");
text3->GetTextProperty()->SetFontSize(45);
text3->GetTextProperty()->SetFontFamilyToCourier();
text3->GetTextProperty()->SetJustificationToLeft();
text3->GetTextProperty()->BoldOn();
text3->GetTextProperty()->SetOrientation(0);
text3->GetTextProperty()->SetColor(0.2, 1.0, 0.2);
vtkNew<vtkCubeAxesActor> axes;
coneMapper->Update();
axes->SetBounds(coneMapper->GetBounds());
vtkNew<vtkRenderer> ren;
axes->SetCamera(ren->GetActiveCamera());
ren->AddActor(coneActor.GetPointer());
ren->AddActor(axes.GetPointer());
ren->AddActor(text1.GetPointer());
ren->AddActor(text2.GetPointer());
ren->AddActor(text3.GetPointer());
ren->SetBackground(0.8, 0.8, 0.8);
vtkNew<vtkRenderWindow> renWin;
renWin->SetMultiSamples(0);
renWin->AddRenderer(ren.GetPointer());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
vtkSmartPointer<vtkCamera> camera = ren->GetActiveCamera();
ren->ResetCamera();
camera->Azimuth(30);
renWin->SetSize(500, 500);
renWin->Render();
vtkNew<vtkProp3DCollection> exclusions;
exclusions->AddItem(axes.GetPointer());
vtkNew<vtkGL2PSExporter> exp;
exp->SetRenderWindow(renWin.GetPointer());
exp->SetFileFormatToPS();
exp->CompressOff();
exp->SetSortToBSP();
exp->DrawBackgroundOn();
exp->Write3DPropsAsRasterImageOn();
exp->SetRasterExclusions(exclusions.GetPointer());
std::string fileprefix = vtkTestingInteractor::TempDirectory +
std::string("/TestGL2PSExporterRasterExclusion");
exp->SetFilePrefix(fileprefix.c_str());
exp->WriteTimeStampOff(); // Otherwise hashes won't match
exp->Write();
renWin->GetInteractor()->Initialize();
renWin->GetInteractor()->Start();
return EXIT_SUCCESS;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestGL2PSExporterVector.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 "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include "vtkGL2PSExporter.h"
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkCubeAxesActor2D.h"
#include "vtkConeSource.h"
#include "vtkNew.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkProperty2D.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkTestingInteractor.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
#include <string>
int TestGL2PSExporterVector( int, char *[] )
{
vtkNew<vtkConeSource> coneSource;
vtkNew<vtkPolyDataMapper> coneMapper;
vtkNew<vtkActor> coneActor;
coneSource->SetResolution(25);
coneMapper->SetInputConnection(coneSource->GetOutputPort());
coneActor->SetMapper(coneMapper.GetPointer());
coneActor->GetProperty()->SetColor(0.5, 0.5, 1.0);
vtkNew<vtkCubeAxesActor2D> axes;
axes->SetInputConnection(coneSource->GetOutputPort());
axes->SetFontFactor(2.0);
axes->SetCornerOffset(0.0);
axes->GetProperty()->SetColor(0.0, 0.0, 0.0);
vtkNew<vtkTextActor> text1;
text1->SetDisplayPosition(250, 435);
text1->SetInput("Test\nmultiline\ntext"); // Won't render properly
text1->GetTextProperty()->SetFontSize(18);
text1->GetTextProperty()->SetFontFamilyToArial();
text1->GetTextProperty()->SetJustificationToCentered();
text1->GetTextProperty()->BoldOn();
text1->GetTextProperty()->ItalicOn();
text1->GetTextProperty()->SetColor(0.0, 0.0, 1.0);
vtkNew<vtkTextActor> text2;
text2->SetDisplayPosition(400, 250);
text2->SetInput("Test rotated text");
text2->GetTextProperty()->SetFontSize(22);
text2->GetTextProperty()->SetFontFamilyToTimes();
text2->GetTextProperty()->SetJustificationToCentered();
text2->GetTextProperty()->SetVerticalJustificationToCentered();
text2->GetTextProperty()->BoldOn();
text2->GetTextProperty()->SetOrientation(45);
text2->GetTextProperty()->SetColor(1.0, 0.0, 0.0);
vtkNew<vtkTextActor> text3;
text3->SetDisplayPosition(20, 20);
text3->SetInput("Big text!");
text3->GetTextProperty()->SetFontSize(45);
text3->GetTextProperty()->SetFontFamilyToCourier();
text3->GetTextProperty()->SetJustificationToLeft();
text3->GetTextProperty()->BoldOn();
text3->GetTextProperty()->SetOrientation(0);
text3->GetTextProperty()->SetColor(0.2, 1.0, 0.2);
vtkNew<vtkRenderer> ren;
axes->SetCamera(ren->GetActiveCamera());
ren->AddActor(coneActor.GetPointer());
ren->AddActor(axes.GetPointer());
ren->AddActor(text1.GetPointer());
ren->AddActor(text2.GetPointer());
ren->AddActor(text3.GetPointer());
ren->SetBackground(0.8, 0.8, 0.8);
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(ren.GetPointer());