VTK  9.5.20250718
TestPolarAxesInternal.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
4#include "vtkBYUReader.h"
5#include "vtkCamera.h"
6#include "vtkLODActor.h"
7#include "vtkLight.h"
8#include "vtkNew.h"
9#include "vtkOutlineFilter.h"
10#include "vtkPolarAxesActor.h"
11#include "vtkPolyDataMapper.h"
12#include "vtkPolyDataNormals.h"
13#include "vtkProperty.h"
14#include "vtkRegressionTestImage.h"
15#include "vtkRenderWindow.h"
17#include "vtkRenderer.h"
18#include "vtkSmartPointer.h"
19#include "vtkTextProperty.h"
20
21#include "vtkTestUtilities.h"
22
23namespace
24{
25//------------------------------------------------------------------------------
26inline void InitializeAxes(vtkPolarAxesActor* polarAxes)
27{
28 polarAxes->SetPole(.5, 1., 3.);
29 polarAxes->SetMaximumRadius(3.);
30 polarAxes->SetMinimumAngle(-60.);
31 polarAxes->SetMaximumAngle(210.);
32 polarAxes->SetRequestedNumberOfRadialAxes(10);
33 polarAxes->SetPolarLabelFormat("%6.1f");
34 polarAxes->GetLastRadialAxisProperty()->SetColor(0.0, 1.0, 0.0);
35 polarAxes->GetSecondaryRadialAxesProperty()->SetColor(0.0, 0.0, 1.0);
36 polarAxes->GetPolarArcsProperty()->SetColor(1.0, 0.0, 0.0);
37 polarAxes->GetSecondaryPolarArcsProperty()->SetColor(1.0, 0.0, 1.0);
38 polarAxes->GetPolarAxisProperty()->SetColor(1.0, 0.5, 0.0);
39 polarAxes->GetPolarAxisTitleTextProperty()->SetColor(0.0, 0.0, 0.0);
41 polarAxes->GetPolarAxisLabelTextProperty()->SetColor(1.0, 1.0, 0.0);
43 polarAxes->GetLastRadialAxisTextProperty()->SetColor(0.0, 0.5, 0.0);
44 polarAxes->GetSecondaryRadialAxesTextProperty()->SetColor(0.0, 1.0, 1.0);
45 polarAxes->SetScreenSize(19.0);
46}
47
52inline void CreatePolarAxesPipeline(
53 int argc, char* argv[], vtkPolarAxesActor* polarAxes, vtkRenderWindowInteractor* interactor)
54{
56 char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/teapot.g");
57 reader->SetGeometryFileName(fname);
58 delete[] fname;
59
61 normals->SetInputConnection(reader->GetOutputPort());
62
63 vtkNew<vtkPolyDataMapper> readerMapper;
64 readerMapper->SetInputConnection(normals->GetOutputPort());
65
66 vtkNew<vtkLODActor> readerActor;
67 readerActor->SetMapper(readerMapper);
68 readerActor->GetProperty()->SetDiffuseColor(.5, .8, .3);
69
71 outline->SetInputConnection(normals->GetOutputPort());
72
74 mapOutline->SetInputConnection(outline->GetOutputPort());
75
76 vtkNew<vtkActor> outlineActor;
77 outlineActor->SetMapper(mapOutline);
78 outlineActor->GetProperty()->SetColor(1., 1., 1.);
79
80 vtkNew<vtkCamera> camera;
81 camera->SetClippingRange(1., 100.);
82 camera->SetFocalPoint(0., .5, 0.);
83 camera->SetPosition(5., 6., 14.);
84
85 vtkNew<vtkLight> light;
86 light->SetFocalPoint(0.21406, 1.5, 0.0);
87 light->SetPosition(7., 7., 4.);
88
89 vtkNew<vtkRenderer> renderer;
90 renderer->SetActiveCamera(camera);
91 renderer->AddLight(light);
92
93 // Update normals in order to get correct bounds for polar axes
94 normals->Update();
95
96 polarAxes->SetBounds(normals->GetOutput()->GetBounds());
97 polarAxes->SetCamera(renderer->GetActiveCamera());
98
100 renWin->SetMultiSamples(0);
101 renWin->AddRenderer(renderer);
102 renWin->SetWindowName("VTK - Polar Axes");
103 renWin->SetSize(600, 600);
104
105 interactor->SetRenderWindow(renWin);
106
107 renderer->SetBackground(.8, .8, .8);
108 renderer->AddViewProp(readerActor);
109 renderer->AddViewProp(outlineActor);
110 renderer->AddViewProp(polarAxes);
111 renWin->Render();
112}
113
114};
Allocate and hold a VTK object.
Definition vtkNew.h:167
create an actor of a polar axes -
vtkProperty * GetLastRadialAxisProperty()
Get/Set last radial axis actor properties.
virtual void SetCamera(vtkCamera *)
Set/Get the camera to perform scaling and translation of the vtkPolarAxesActor.
vtkTextProperty * GetLastRadialAxisTextProperty()
Set/Get the last radial axis text property.
vtkTextProperty * GetSecondaryRadialAxesTextProperty()
Set/Get the secondary radial axes text property.
virtual void SetRequestedNumberOfRadialAxes(vtkIdType)
Gets/Sets the number of radial axes.
vtkTextProperty * GetPolarAxisTitleTextProperty()
Set/Get the polar axis title text property.
virtual void SetMinimumAngle(double)
Set/Get the minimum radius of the polar coordinates (in degrees).
vtkProperty * GetPolarArcsProperty()
Get/Set principal polar arc actor property.
virtual void SetPole(double[3])
Explicitly specify the coordinate of the pole.
virtual void SetScreenSize(double)
Explicitly specify the screen size of title and label text.
virtual void SetBounds(double, double, double, double, double, double)
Explicitly specify the region in space around which to draw the bounds.
vtkProperty * GetSecondaryPolarArcsProperty()
Get/Set secondary polar arcs actors property.
virtual void SetPolarLabelFormat(const char *)
Set/Get the format with which to print the polar axis labels.
vtkProperty * GetSecondaryRadialAxesProperty()
Get/Set secondary radial axes actors properties.
virtual void SetMaximumRadius(double)
Set/Get the maximum radius of the polar coordinates.
virtual void SetMaximumAngle(double)
Set/Get the maximum radius of the polar coordinates (in degrees).
vtkTextProperty * GetPolarAxisLabelTextProperty()
Set/Get the polar axis labels text property.
vtkProperty * GetPolarAxisProperty()
Get/Set polar axis actor properties.
virtual void SetColor(double r, double g, double b)
Set the color of the object.
platform-independent render window interaction including picking and frame rate control.
void SetRenderWindow(vtkRenderWindow *aren)
Set/Get the rendering window being controlled by this object.
virtual void SetFontSize(int)
Set/Get the font size (in points).
virtual void SetColor(double, double, double)
Set the color of the text.