VTK  9.5.20250716
TestSingleTextActorInternal.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3#include "vtkRegressionTestImage.h"
4#include "vtkTesting.h"
5
6#include "vtkProp.h"
7#include "vtkRenderWindow.h"
9#include "vtkRenderer.h"
10#include "vtkTextProperty.h"
11
13{
14inline std::string InputText()
15{
16 return "0123456789.";
17}
18
19inline int CreatePipeline(
20 int argc, char* argv[], vtkProp* textActor, vtkTextProperty* textProperty, bool depthPeeling)
21{
24 iren->SetRenderWindow(renWin);
25
26 vtkNew<vtkRenderer> renderer;
27 renWin->AddRenderer(renderer);
28
29 renderer->SetBackground(0.0, 0.0, 0.5);
30 renWin->SetSize(300, 300);
31
32 if (depthPeeling)
33 {
34 renWin->SetMultiSamples(1);
35 renWin->SetAlphaBitPlanes(1);
36 renderer->SetUseDepthPeeling(1);
37 renderer->SetMaximumNumberOfPeels(200);
38 renderer->SetOcclusionRatio(0.1);
39 }
40
41 renderer->AddActor(textActor);
42
43 textProperty->SetJustificationToCentered();
44 textProperty->SetVerticalJustificationToCentered(); // default
45 textProperty->SetFontFamilyToArial(); // default.
46 textProperty->SetFontSize(36);
47
48 renWin->Render();
49 renderer->ResetCamera();
50
51 renWin->Render();
52 if (depthPeeling && !renderer->GetLastRenderingUsedDepthPeeling())
53 {
54 std::cerr << "depth peeling was not used\n";
55 }
56
57 // usual font issues so we up the tolerance a bit
58 // int retVal = vtkTesting::Test(argc, argv, renWin, 0.07);
59 int retVal = vtkRegressionTestImage(renWin);
60 if (retVal == vtkRegressionTester::DO_INTERACTOR)
61 {
62 iren->Start();
63 }
64
65 return !retVal;
66}
67}
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
represent text properties.
void SetFontFamilyToArial()
Set/Get the font family.
void SetJustificationToCentered()
Set/Get the horizontal justification to left (default), centered, or right.
void SetVerticalJustificationToCentered()
Set/Get the vertical justification to bottom (default), middle, or top.
virtual void SetFontSize(int)
Set/Get the font size (in points).
int CreatePipeline(int argc, char *argv[], vtkProp *textActor, vtkTextProperty *textProperty, bool depthPeeling)