VTK  9.7.1
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 "vtkNew.h" // For vtkNew
45 #include "vtkRenderingAnnotationModule.h" // For export macro
46 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
47 
48 VTK_ABI_NAMESPACE_BEGIN
49 class vtkAlgorithmOutput;
50 class vtkAxisActor2D;
51 class vtkDataObject;
52 class vtkPolyData;
54 class vtkTextMapper;
55 class vtkTextProperty;
56 class vtkLegendBoxActor;
57 class vtkGlyphSource2D;
58 class vtkAxisLabelArray;
59 class vtkAxisRanges;
60 class vtkSpiderPlotActorConnection;
61 
62 #define VTK_IV_COLUMN 0
63 #define VTK_IV_ROW 1
64 
65 class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkSpiderPlotActor : public vtkActor2D
66 {
67 public:
69 
73  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
79  static vtkSpiderPlotActor* New();
80 
82 
87  VTK_MARSHALSETTER(Input)
88  virtual void SetInputData(vtkDataObject*);
89  virtual void SetInputConnection(vtkAlgorithmOutput*);
91 
95  VTK_MARSHALGETTER(Input)
96  virtual vtkDataObject* GetInput();
97 
99 
104  vtkSetClampMacro(IndependentVariables, int, VTK_IV_COLUMN, VTK_IV_ROW);
105  vtkGetMacro(IndependentVariables, int);
106  void SetIndependentVariablesToColumns() { this->SetIndependentVariables(VTK_IV_COLUMN); }
107  void SetIndependentVariablesToRows() { this->SetIndependentVariables(VTK_IV_ROW); }
109 
111 
114  vtkSetMacro(TitleVisibility, vtkTypeBool);
115  vtkGetMacro(TitleVisibility, vtkTypeBool);
116  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
118 
120 
123  vtkSetStringMacro(Title);
124  vtkGetStringMacro(Title);
126 
128 
131  virtual void SetTitleTextProperty(vtkTextProperty* p);
132  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
134 
135  // Enable/Disable the display axes titles. These are arranged on the end
136  // of each radial axis on the circumference of the spider plot. The label
137  // text strings are derived from the names of the data object arrays
138  // associated with the input.
139  vtkSetMacro(LabelVisibility, vtkTypeBool);
140  vtkGetMacro(LabelVisibility, vtkTypeBool);
141  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
142 
144 
149  virtual void SetLabelTextProperty(vtkTextProperty* p);
150  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
152 
154 
158  vtkSetClampMacro(NumberOfRings, int, 0, VTK_INT_MAX);
159  vtkGetMacro(NumberOfRings, int);
161 
163 
167  void SetAxisLabel(int i, const char*);
168  const char* GetAxisLabel(int i);
169  int GetNumberOfAxisLabels();
171 
173 
177  void SetAxisRange(int i, double min, double max);
178  void SetAxisRange(int i, double range[2]);
179  void GetAxisRange(int i, double range[2]);
180  int GetNumberOfAxisRanges();
182 
184 
187  void SetPlotColor(int i, double r, double g, double b);
188  void SetPlotColor(int i, const double color[3])
189  {
190  this->SetPlotColor(i, color[0], color[1], color[2]);
191  }
192  double* GetPlotColor(int i);
194 
196 
201  vtkSetMacro(LegendVisibility, vtkTypeBool);
202  vtkGetMacro(LegendVisibility, vtkTypeBool);
203  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
205 
207 
211  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
213 
215 
218  int RenderOverlay(vtkViewport*) override;
219  int RenderOpaqueGeometry(vtkViewport*) override;
220  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
222 
227 
233  void ReleaseGraphicsResources(vtkWindow*) override;
234 
235 protected:
237  ~vtkSpiderPlotActor() override;
238 
239 private:
240  vtkSpiderPlotActorConnection* ConnectionHolder;
241 
242  int IndependentVariables; // Use column or row
243  vtkTypeBool TitleVisibility; // Should I see the title?
244  char* Title; // The title string
245  vtkTextProperty* TitleTextProperty;
246  vtkTypeBool LabelVisibility;
247  vtkTextProperty* LabelTextProperty;
248  vtkAxisLabelArray* Labels;
249  vtkTypeBool LegendVisibility;
250  vtkNew<vtkLegendBoxActor> LegendActor;
251  vtkGlyphSource2D* GlyphSource;
252  int NumberOfRings;
253 
254  // Local variables needed to plot
255  vtkIdType N; // The number of independent variables
256  double* Mins; // Minimum data value along this row/column
257  double* Maxs; // Maximum data value along this row/column
258  vtkAxisRanges* Ranges;
259 
260  vtkTextMapper** LabelMappers; // a label for each radial spoke
261  vtkActor2D** LabelActors;
262 
263  vtkTextMapper* TitleMapper;
264  vtkActor2D* TitleActor;
265 
266  vtkPolyData* WebData; // The web of the spider plot
267  vtkPolyDataMapper2D* WebMapper;
268  vtkActor2D* WebActor;
269 
270  vtkPolyData* PlotData; // The lines drawn within the axes
271  vtkPolyDataMapper2D* PlotMapper;
272  vtkActor2D* PlotActor;
273 
274  vtkTimeStamp BuildTime;
275 
276  double Center[3];
277  double Radius;
278  double Theta;
279 
280  int LastPosition[2];
281  int LastPosition2[2];
282  double P1[3];
283  double P2[3];
284 
285  void Initialize();
286  int PlaceAxes(vtkViewport* viewport, const int* size);
287  int BuildPlot(vtkViewport*);
288 
289  vtkSpiderPlotActor(const vtkSpiderPlotActor&) = delete;
290  void operator=(const vtkSpiderPlotActor&) = delete;
291 };
292 
293 VTK_ABI_NAMESPACE_END
294 #endif
draw symbols with text
void SetIndependentVariablesToRows()
Specify whether to use the rows or columns as independent variables.
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
abstract specification for Viewports
Definition: vtkViewport.h:46
#define VTK_IV_COLUMN
#define VTK_INT_MAX
Definition: vtkType.h:192
a actor that draws 2D data
Definition: vtkActor2D.h:35
record modification and/or execution time
Definition: vtkTimeStamp.h:24
Create an axis with tick marks and labels.
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
#define VTK_IV_ROW
create a spider plot from input field
2D text annotation
Definition: vtkTextMapper.h:39
Proxy object to connect input/output ports.
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetPlotColor(int i, const double color[3])
Specify colors for each plot.
#define VTK_MARSHALGETTER(property)
static vtkActor2D * New()
Creates an actor2D with the following defaults: position (0,0) (coordinate system is viewport); at la...
represent text properties.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
int RenderOpaqueGeometry(vtkViewport *viewport) override
Support the standard render methods.
#define VTK_MARSHALAUTO
create 2D glyphs represented by vtkPolyData
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the spider plot.
general representation of visualization data
Definition: vtkDataObject.h:55
draw vtkPolyData onto the image plane
#define max(a, b)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_MARSHALSETTER(property)