VTK  9.3.0
vtkSpiderPlotActor.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
40 #ifndef vtkSpiderPlotActor_h
41 #define vtkSpiderPlotActor_h
42 
43 #include "vtkActor2D.h"
44 #include "vtkRenderingAnnotationModule.h" // For export macro
45 
46 VTK_ABI_NAMESPACE_BEGIN
47 class vtkAlgorithmOutput;
48 class vtkAxisActor2D;
49 class vtkDataObject;
50 class vtkPolyData;
52 class vtkTextMapper;
53 class vtkTextProperty;
54 class vtkLegendBoxActor;
55 class vtkGlyphSource2D;
56 class vtkAxisLabelArray;
57 class vtkAxisRanges;
58 class vtkSpiderPlotActorConnection;
59 
60 #define VTK_IV_COLUMN 0
61 #define VTK_IV_ROW 1
62 
63 class VTKRENDERINGANNOTATION_EXPORT vtkSpiderPlotActor : public vtkActor2D
64 {
65 public:
67 
71  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
78 
80 
85  virtual void SetInputData(vtkDataObject*);
88 
92  virtual vtkDataObject* GetInput();
93 
95 
100  vtkSetClampMacro(IndependentVariables, int, VTK_IV_COLUMN, VTK_IV_ROW);
101  vtkGetMacro(IndependentVariables, int);
102  void SetIndependentVariablesToColumns() { this->SetIndependentVariables(VTK_IV_COLUMN); }
103  void SetIndependentVariablesToRows() { this->SetIndependentVariables(VTK_IV_ROW); }
105 
107 
110  vtkSetMacro(TitleVisibility, vtkTypeBool);
111  vtkGetMacro(TitleVisibility, vtkTypeBool);
112  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
114 
116 
119  vtkSetStringMacro(Title);
120  vtkGetStringMacro(Title);
122 
124 
128  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
130 
131  // Enable/Disable the display axes titles. These are arranged on the end
132  // of each radial axis on the circumference of the spider plot. The label
133  // text strings are derived from the names of the data object arrays
134  // associated with the input.
135  vtkSetMacro(LabelVisibility, vtkTypeBool);
136  vtkGetMacro(LabelVisibility, vtkTypeBool);
137  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
138 
140 
146  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
148 
150 
154  vtkSetClampMacro(NumberOfRings, int, 0, VTK_INT_MAX);
155  vtkGetMacro(NumberOfRings, int);
157 
159 
163  void SetAxisLabel(int i, const char*);
164  const char* GetAxisLabel(int i);
166 
168 
172  void SetAxisRange(int i, double min, double max);
173  void SetAxisRange(int i, double range[2]);
174  void GetAxisRange(int i, double range[2]);
176 
178 
181  void SetPlotColor(int i, double r, double g, double b);
182  void SetPlotColor(int i, const double color[3])
183  {
184  this->SetPlotColor(i, color[0], color[1], color[2]);
185  }
186  double* GetPlotColor(int i);
188 
190 
195  vtkSetMacro(LegendVisibility, vtkTypeBool);
196  vtkGetMacro(LegendVisibility, vtkTypeBool);
197  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
199 
201 
205  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
207 
209 
212  int RenderOverlay(vtkViewport*) override;
214  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
216 
221 
228 
229 protected:
232 
233 private:
234  vtkSpiderPlotActorConnection* ConnectionHolder;
235 
236  int IndependentVariables; // Use column or row
237  vtkTypeBool TitleVisibility; // Should I see the title?
238  char* Title; // The title string
239  vtkTextProperty* TitleTextProperty;
240  vtkTypeBool LabelVisibility;
241  vtkTextProperty* LabelTextProperty;
242  vtkAxisLabelArray* Labels;
243  vtkTypeBool LegendVisibility;
244  vtkLegendBoxActor* LegendActor;
245  vtkGlyphSource2D* GlyphSource;
246  int NumberOfRings;
247 
248  // Local variables needed to plot
249  vtkIdType N; // The number of independent variables
250  double* Mins; // Minimum data value along this row/column
251  double* Maxs; // Maximum data value along this row/column
252  vtkAxisRanges* Ranges;
253 
254  vtkTextMapper** LabelMappers; // a label for each radial spoke
255  vtkActor2D** LabelActors;
256 
257  vtkTextMapper* TitleMapper;
258  vtkActor2D* TitleActor;
259 
260  vtkPolyData* WebData; // The web of the spider plot
261  vtkPolyDataMapper2D* WebMapper;
262  vtkActor2D* WebActor;
263 
264  vtkPolyData* PlotData; // The lines drawn within the axes
265  vtkPolyDataMapper2D* PlotMapper;
266  vtkActor2D* PlotActor;
267 
268  vtkTimeStamp BuildTime;
269 
270  double Center[3];
271  double Radius;
272  double Theta;
273 
274  int LastPosition[2];
275  int LastPosition2[2];
276  double P1[3];
277  double P2[3];
278 
279  void Initialize();
280  int PlaceAxes(vtkViewport* viewport, const int* size);
281  int BuildPlot(vtkViewport*);
282 
283  vtkSpiderPlotActor(const vtkSpiderPlotActor&) = delete;
284  void operator=(const vtkSpiderPlotActor&) = delete;
285 };
286 
287 VTK_ABI_NAMESPACE_END
288 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:35
Proxy object to connect input/output ports.
Create an axis with tick marks and labels.
general representation of visualization data
Definition: vtkDataObject.h:55
create 2D glyphs represented by vtkPolyData
a simple class to control print indentation
Definition: vtkIndent.h:29
draw symbols with text
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:80
create a spider plot from input field
void SetIndependentVariablesToRows()
Specify whether to use the rows or columns as independent variables.
int RenderOpaqueGeometry(vtkViewport *) override
Draw the spider plot.
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
const char * GetAxisLabel(int i)
Specify the names of the radial spokes (i.e., the radial axes).
void SetPlotColor(int i, double r, double g, double b)
Specify colors for each plot.
virtual void SetInputConnection(vtkAlgorithmOutput *)
Set the input to the pie chart actor.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
void SetPlotColor(int i, const double color[3])
Specify colors for each plot.
double * GetPlotColor(int i)
Specify colors for each plot.
virtual void SetInputData(vtkDataObject *)
Set the input to the pie chart actor.
void GetAxisRange(int i, double range[2])
Specify the range of data on each radial axis.
virtual void SetTitleTextProperty(vtkTextProperty *p)
Set/Get the title text property.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the spider plot.
void SetIndependentVariablesToColumns()
Specify whether to use the rows or columns as independent variables.
virtual vtkDataObject * GetInput()
Get the input data object to this actor.
~vtkSpiderPlotActor() override
virtual void SetLabelTextProperty(vtkTextProperty *p)
Enable/Disable the creation of a legend.
void SetAxisRange(int i, double range[2])
Specify the range of data on each radial axis.
void SetAxisLabel(int i, const char *)
Specify the names of the radial spokes (i.e., the radial axes).
void SetAxisRange(int i, double min, double max)
Specify the range of data on each radial axis.
int RenderOverlay(vtkViewport *) override
Draw the spider plot.
static vtkSpiderPlotActor * New()
Instantiate this class.
2D text annotation
Definition: vtkTextMapper.h:40
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:25
abstract specification for Viewports
Definition: vtkViewport.h:45
window superclass for vtkRenderWindow
Definition: vtkWindow.h:28
@ range
Definition: vtkX3D.h:238
@ color
Definition: vtkX3D.h:221
@ size
Definition: vtkX3D.h:253
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_IV_ROW
#define VTK_IV_COLUMN
int vtkIdType
Definition: vtkType.h:315
#define VTK_INT_MAX
Definition: vtkType.h:144
#define max(a, b)