VTK  9.2.5
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
30#ifndef vtkChart_h
31#define vtkChart_h
32
33#include "vtkChartsCoreModule.h" // For export macro
34#include "vtkContextItem.h"
35#include "vtkContextScene.h" // For SelectionModifier
36#include "vtkRect.h" // For vtkRectf
37#include "vtkSmartPointer.h" // For SP ivars
38#include "vtkStdString.h" // For vtkStdString ivars
39
40class vtkTransform2D;
41class vtkContextScene;
42class vtkPlot;
43class vtkAxis;
44class vtkBrush;
45class vtkTextProperty;
46class vtkChartLegend;
47
50
51class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem
52{
53public:
54 vtkTypeMacro(vtkChart, vtkContextItem);
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
60 enum
61 {
68 AREA
69 };
70
83 enum
84 {
85 PAN = 0,
89 SELECT_RECTANGLE = SELECT,
92 NOTIFY
93 };
94
99 {
100 UpdateRange = 1002
101 };
102
106 bool Paint(vtkContext2D* painter) override = 0;
107
111 virtual vtkPlot* AddPlot(int type);
112
116 virtual vtkIdType AddPlot(vtkPlot* plot);
117
122 virtual bool RemovePlot(vtkIdType index);
123
129 virtual bool RemovePlotInstance(vtkPlot* plot);
130
134 virtual void ClearPlots();
135
139 virtual vtkPlot* GetPlot(vtkIdType index);
140
145
150 virtual vtkAxis* GetAxis(int axisIndex);
151
156 virtual void SetAxis(int axisIndex, vtkAxis*);
157
162
167 virtual void RecalculateBounds();
168
176 enum
177 {
180 SELECTION_COLUMNS
181 };
182
184
192 virtual void SetSelectionMethod(int method);
193 virtual int GetSelectionMethod();
195
200
202
205 vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
207
209
212 vtkSetVector2Macro(Geometry, int);
213 vtkGetVector2Macro(Geometry, int);
215
217
220 vtkSetVector2Macro(Point1, int);
221 vtkGetVector2Macro(Point1, int);
223
225
228 vtkSetVector2Macro(Point2, int);
229 vtkGetVector2Macro(Point2, int);
231
233
236 virtual void SetShowLegend(bool visible);
237 virtual bool GetShowLegend();
239
245
247
250 virtual void SetTitle(const vtkStdString& title);
253
255
258 vtkGetObjectMacro(TitleProperties, vtkTextProperty);
260
262
265 void SetBottomBorder(int border);
266 void SetTopBorder(int border);
267 void SetLeftBorder(int border);
268 void SetRightBorder(int border);
270
274 void SetBorders(int left, int bottom, int right, int top);
275
281 virtual void SetSize(const vtkRectf& rect);
282
287
291 enum
292 {
293 FILL_SCENE, // Attempt to fill the entire scene.
294 FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
295 AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
296 };
297
299
304 vtkSetMacro(LayoutStrategy, int);
305 vtkGetMacro(LayoutStrategy, int);
307
309
313 virtual void SetAutoSize(bool isAutoSized)
314 {
315 this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE : vtkChart::FILL_RECT;
316 }
317 virtual bool GetAutoSize() { return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false; }
319
321
329 vtkSetMacro(RenderEmpty, bool);
330 vtkGetMacro(RenderEmpty, bool);
332
343 virtual void SetActionToButton(int action, int button);
344
349 virtual int GetActionToButton(int action);
350
356 virtual void SetClickActionToButton(int action, int button);
357
363 virtual int GetClickActionToButton(int action);
364
366
372
374
378 vtkSetClampMacro(
380 vtkGetMacro(SelectionMode, int);
382
383protected:
385 ~vtkChart() override;
386
394
399
404
405 void AxisRangeForwarderCallback(vtkObject*, unsigned long, void*);
406
411
415 int Geometry[2];
416
420 int Point1[2];
421
425 int Point2[2];
426
430 int Borders[4];
431
436
441
446
448 // The layout strategy to employ when fitting the chart into the space.
451
456
457 // The mode when the chart is doing selection.
459
460 // How plot selections are handled, SELECTION_ROWS (default) or
461 // SELECTION_PLOTS - based on the plot that created the selection.
463
465
469 {
470 public:
472 enum
473 {
474 MaxAction = 6
475 };
476 short& Pan() { return Data[0]; }
477 short& Zoom() { return Data[1]; }
478 short& ZoomAxis() { return Data[2]; }
479 short& Select() { return Data[3]; }
480 short& SelectPolygon() { return Data[4]; }
481 short& ClickAndDrag() { return Data[5]; }
482 short& operator[](int index) { return Data[index]; }
483 short Data[MaxAction];
484 };
486 {
487 public:
489 short& Notify() { return Data[0]; }
490 short& Select() { return Data[1]; }
491 short& operator[](int index) { return Data[index]; }
492 short Data[2];
493 };
495
498
499private:
500 vtkChart(const vtkChart&) = delete;
501 void operator=(const vtkChart&) = delete;
502};
503
504#endif // vtkChart_h
takes care of drawing 2D axes
Definition: vtkAxis.h:72
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:41
draw the chart legend
Hold mouse action mappings.
Definition: vtkChart.h:469
short & operator[](int index)
Definition: vtkChart.h:482
short & ClickAndDrag()
Definition: vtkChart.h:481
short & SelectPolygon()
Definition: vtkChart.h:480
short & operator[](int index)
Definition: vtkChart.h:491
Factory class for drawing 2D charts.
Definition: vtkChart.h:52
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:497
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:313
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:449
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:440
vtkTextProperty * TitleProperties
The text properties associated with the chart.
Definition: vtkChart.h:445
@ SELECT_POLYGON
Definition: vtkChart.h:90
@ CLICK_AND_DRAG
Definition: vtkChart.h:91
@ ZOOM_AXIS
Definition: vtkChart.h:87
@ SELECT
Definition: vtkChart.h:88
@ ZOOM
Definition: vtkChart.h:86
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:317
int SelectionMethod
Definition: vtkChart.h:462
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:496
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:410
vtkRectf GetSize()
Get the current size of the chart.
@ FUNCTIONALBAG
Definition: vtkChart.h:67
@ LINE
Definition: vtkChart.h:62
@ STACKED
Definition: vtkChart.h:65
@ POINTS
Definition: vtkChart.h:63
void SetBottomBorder(int border)
Set/get the borders of the chart (space in pixels around the chart).
@ SELECTION_PLOTS
Definition: vtkChart.h:179
@ SELECTION_ROWS
Definition: vtkChart.h:178
virtual int GetClickActionToButton(int action)
Get the mouse button associated with the supplied click action.
vtkRectf Size
Definition: vtkChart.h:447
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:455
virtual void SetClickActionToButton(int action, int button)
Assign action types to single mouse clicks.
@ FILL_SCENE
Definition: vtkChart.h:293
@ FILL_RECT
Definition: vtkChart.h:294
EventIds
Enum of event type that are triggered by the charts.
Definition: vtkChart.h:99
virtual bool RemovePlotInstance(vtkPlot *plot)
Remove the given plot.
int SelectionMode
Definition: vtkChart.h:458
void SetTopBorder(int border)
Set/get the borders of the chart (space in pixels around the chart).
bool RenderEmpty
Definition: vtkChart.h:450
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:435
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.
Definition: vtkContext2D.h:58
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:40
provide event-driven interface to the rendering window (defines trackball mode)
abstract base class for most VTK objects
Definition: vtkObject.h:63
Abstract class for 2D plots.
Definition: vtkPlot.h:54
Hold a reference to a vtkObjectBase instance.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:39
represent text properties.
describes linear transformations via a 3x3 matrix
int vtkIdType
Definition: vtkType.h:332