VTK  9.2.6
vtkChart.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkChart.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15
24#ifndef vtkChart_h
25#define vtkChart_h
26
27#include "vtkChartsCoreModule.h" // For export macro
28#include "vtkContextItem.h"
29#include "vtkContextScene.h" // For SelectionModifier
30#include "vtkRect.h" // For vtkRectf
31#include "vtkSmartPointer.h" // For SP ivars
32#include "vtkStdString.h" // For vtkStdString ivars
33
34class vtkTransform2D;
35class vtkContextScene;
36class vtkPlot;
37class vtkAxis;
38class vtkBrush;
39class vtkTextProperty;
40class vtkChartLegend;
41
44
45class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem
46{
47public:
48 vtkTypeMacro(vtkChart, vtkContextItem);
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
54 enum
55 {
62 AREA
63 };
64
77 enum
78 {
79 PAN = 0,
83 SELECT_RECTANGLE = SELECT,
86 NOTIFY
87 };
88
93 {
94 UpdateRange = 1002
95 };
96
100 bool Paint(vtkContext2D* painter) override = 0;
101
105 virtual vtkPlot* AddPlot(int type);
106
110 virtual vtkIdType AddPlot(vtkPlot* plot);
111
116 virtual bool RemovePlot(vtkIdType index);
117
123 virtual bool RemovePlotInstance(vtkPlot* plot);
124
128 virtual void ClearPlots();
129
133 virtual vtkPlot* GetPlot(vtkIdType index);
134
139
144 virtual vtkAxis* GetAxis(int axisIndex);
145
150 virtual void SetAxis(int axisIndex, vtkAxis*);
151
156
161 virtual void RecalculateBounds();
162
170 enum
171 {
174 SELECTION_COLUMNS
175 };
176
178
186 virtual void SetSelectionMethod(int method);
187 virtual int GetSelectionMethod();
189
194
196
199 vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
201
203
206 vtkSetVector2Macro(Geometry, int);
207 vtkGetVector2Macro(Geometry, int);
209
211
214 vtkSetVector2Macro(Point1, int);
215 vtkGetVector2Macro(Point1, int);
217
219
222 vtkSetVector2Macro(Point2, int);
223 vtkGetVector2Macro(Point2, int);
225
227
230 virtual void SetShowLegend(bool visible);
231 virtual bool GetShowLegend();
233
239
241
244 virtual void SetTitle(const vtkStdString& title);
247
249
252 vtkGetObjectMacro(TitleProperties, vtkTextProperty);
254
256
259 void SetBottomBorder(int border);
260 void SetTopBorder(int border);
261 void SetLeftBorder(int border);
262 void SetRightBorder(int border);
264
268 void SetBorders(int left, int bottom, int right, int top);
269
275 virtual void SetSize(const vtkRectf& rect);
276
281
285 enum
286 {
287 FILL_SCENE, // Attempt to fill the entire scene.
288 FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
289 AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
290 };
291
293
298 vtkSetMacro(LayoutStrategy, int);
299 vtkGetMacro(LayoutStrategy, int);
301
303
307 virtual void SetAutoSize(bool isAutoSized)
308 {
309 this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE : vtkChart::FILL_RECT;
310 }
311 virtual bool GetAutoSize() { return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false; }
313
315
323 vtkSetMacro(RenderEmpty, bool);
324 vtkGetMacro(RenderEmpty, bool);
326
337 virtual void SetActionToButton(int action, int button);
338
343 virtual int GetActionToButton(int action);
344
350 virtual void SetClickActionToButton(int action, int button);
351
357 virtual int GetClickActionToButton(int action);
358
360
366
368
372 vtkSetClampMacro(
374 vtkGetMacro(SelectionMode, int);
376
377protected:
379 ~vtkChart() override;
380
388
393
398
399 void AxisRangeForwarderCallback(vtkObject*, unsigned long, void*);
400
405
409 int Geometry[2];
410
414 int Point1[2];
415
419 int Point2[2];
420
424 int Borders[4];
425
430
435
440
442 // The layout strategy to employ when fitting the chart into the space.
445
450
451 // The mode when the chart is doing selection.
453
454 // How plot selections are handled, SELECTION_ROWS (default) or
455 // SELECTION_PLOTS - based on the plot that created the selection.
457
459
463 {
464 public:
466 enum
467 {
468 MaxAction = 6
469 };
470 short& Pan() { return Data[0]; }
471 short& Zoom() { return Data[1]; }
472 short& ZoomAxis() { return Data[2]; }
473 short& Select() { return Data[3]; }
474 short& SelectPolygon() { return Data[4]; }
475 short& ClickAndDrag() { return Data[5]; }
476 short& operator[](int index) { return Data[index]; }
477 short Data[MaxAction];
478 };
480 {
481 public:
483 short& Notify() { return Data[0]; }
484 short& Select() { return Data[1]; }
485 short& operator[](int index) { return Data[index]; }
486 short Data[2];
487 };
489
492
493private:
494 vtkChart(const vtkChart&) = delete;
495 void operator=(const vtkChart&) = delete;
496};
497
498#endif // vtkChart_h
takes care of drawing 2D axes
Definition vtkAxis.h:69
provides a brush that fills shapes drawn by vtkContext2D.
Definition vtkBrush.h:38
draw the chart legend
Hold mouse action mappings.
Definition vtkChart.h:463
short & operator[](int index)
Definition vtkChart.h:476
short & SelectPolygon()
Definition vtkChart.h:474
short & operator[](int index)
Definition vtkChart.h:485
Factory class for drawing 2D charts.
Definition vtkChart.h:46
virtual vtkPlot * AddPlot(int type)
Add a plot to the chart, defaults to using the name of the y column.
MouseClickActions ActionsClick
Definition vtkChart.h:491
void AxisRangeForwarderCallback(vtkObject *, unsigned long, void *)
virtual void SetSize(const vtkRectf &rect)
Set the size of the chart.
virtual void SetAutoSize(bool isAutoSized)
Set/get whether the chart should automatically resize to fill the current render window.
Definition vtkChart.h:307
virtual bool GetShowLegend()
Set/get whether the chart should draw a legend.
virtual vtkStdString GetTitle()
Get/set the title text of the chart.
virtual void ClearPlots()
Remove all plots from the chart.
int LayoutStrategy
Definition vtkChart.h:443
virtual void SetTitle(const vtkStdString &title)
Get/set the title text of the chart.
virtual vtkChartLegend * GetLegend()
Get the legend for the chart, if available.
vtkStdString Title
The title of the chart.
Definition vtkChart.h:434
vtkTextProperty * TitleProperties
The text properties associated with the chart.
Definition vtkChart.h:439
@ SELECT_POLYGON
Definition vtkChart.h:84
@ CLICK_AND_DRAG
Definition vtkChart.h:85
@ ZOOM_AXIS
Definition vtkChart.h:81
bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y, vtkTransform2D *transform)
Calculate the unshifted, and unscaled plot transform for the x and y axis.
virtual bool GetAutoSize()
Set/get whether the chart should automatically resize to fill the current render window.
Definition vtkChart.h:311
int SelectionMethod
Definition vtkChart.h:456
virtual void SetAnnotationLink(vtkAnnotationLink *link)
Set the vtkAnnotationLink for the chart.
virtual int GetActionToButton(int action)
Get the mouse button associated with the supplied action.
MouseActions Actions
Definition vtkChart.h:490
void SetRightBorder(int border)
Set/get the borders of the chart (space in pixels around the chart).
vtkAnnotationLink * AnnotationLink
Our annotation link, used for sharing selections etc.
Definition vtkChart.h:404
vtkRectf GetSize()
Get the current size of the chart.
@ FUNCTIONALBAG
Definition vtkChart.h:61
@ STACKED
Definition vtkChart.h:59
void SetBottomBorder(int border)
Set/get the borders of the chart (space in pixels around the chart).
@ SELECTION_PLOTS
Definition vtkChart.h:173
@ SELECTION_ROWS
Definition vtkChart.h:172
virtual int GetClickActionToButton(int action)
Get the mouse button associated with the supplied click action.
vtkRectf Size
Definition vtkChart.h:441
virtual void SetSelectionMethod(int method)
Set the selection method, which controls how selections are handled by the chart.
vtkSmartPointer< vtkBrush > BackgroundBrush
Brush to use for drawing the background.
Definition vtkChart.h:449
virtual void SetClickActionToButton(int action, int button)
Assign action types to single mouse clicks.
@ FILL_SCENE
Definition vtkChart.h:287
@ FILL_RECT
Definition vtkChart.h:288
EventIds
Enum of event type that are triggered by the charts.
Definition vtkChart.h:93
virtual bool RemovePlotInstance(vtkPlot *plot)
Remove the given plot.
int SelectionMode
Definition vtkChart.h:452
void SetTopBorder(int border)
Set/get the borders of the chart (space in pixels around the chart).
bool RenderEmpty
Definition vtkChart.h:444
void SetBackgroundBrush(vtkBrush *brush)
Set/Get the brush to use for the background color.
bool Paint(vtkContext2D *painter) override=0
Paint event for the chart, called whenever the chart needs to be drawn.
virtual void SetShowLegend(bool visible)
Set/get whether the chart should draw a legend.
virtual vtkIdType GetNumberOfPlots()
Get the number of plots the chart contains.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void RecalculateBounds()
Request that the chart recalculates the range of its axes.
virtual void SetAxis(int axisIndex, vtkAxis *)
Set the axis specified by axisIndex.
virtual bool RemovePlot(vtkIdType index)
Remove the plot at the specified index, returns true if successful, false if the index was invalid.
virtual vtkAxis * GetAxis(int axisIndex)
Get the axis specified by axisIndex.
virtual vtkIdType GetNumberOfAxes()
Get the number of axes in the current chart.
virtual void SetActionToButton(int action, int button)
Assign action types to mouse buttons.
void AttachAxisRangeListener(vtkAxis *)
Attach axis range listener so we can forward those events at the chart level.
virtual vtkIdType AddPlot(vtkPlot *plot)
Add a plot to the chart.
virtual vtkPlot * GetPlot(vtkIdType index)
Get the plot at the specified index, returns null if the index is invalid.
virtual int GetSelectionMethod()
Set the selection method, which controls how selections are handled by the chart.
bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y, vtkTransform2D *transform)
Given the x and y vtkAxis, and a transform, calculate the transform that the points in a chart would ...
vtkBrush * GetBackgroundBrush()
Set/Get the brush to use for the background color.
void SetLeftBorder(int border)
Set/get the borders of the chart (space in pixels around the chart).
~vtkChart() override
bool ShowLegend
Display the legend?
Definition vtkChart.h:429
void SetBorders(int left, int bottom, int right, int top)
Set/get the borders of the chart (space in pixels around the chart).
Class for drawing 2D primitives to a graphical context.
base class for items that are part of a vtkContextScene.
Provides a 2D scene for vtkContextItem objects.
a simple class to control print indentation
Definition vtkIndent.h:34
provide event-driven interface to the rendering window (defines trackball mode)
abstract base class for most VTK objects
Definition vtkObject.h:57
Abstract class for 2D plots.
Definition vtkPlot.h:48
Hold a reference to a vtkObjectBase instance.
Wrapper around std::string to keep symbols short.
represent text properties.
describes linear transformations via a 3x3 matrix
int vtkIdType
Definition vtkType.h:332