VTK  9.5.2
vtkChart.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
17
18#ifndef vtkChart_h
19#define vtkChart_h
20
21#include "vtkChartsCoreModule.h" // For export macro
22#include "vtkContextItem.h"
23#include "vtkContextScene.h" // For SelectionModifier
24#include "vtkRect.h" // For vtkRectf
25#include "vtkSmartPointer.h" // For SP ivars
26#include "vtkStdString.h" // For vtkStdString ivars
27#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
28
29VTK_ABI_NAMESPACE_BEGIN
30class vtkTransform2D;
31class vtkContextScene;
32class vtkPlot;
33class vtkAxis;
34class vtkBrush;
35class vtkTextProperty;
36class vtkChartLegend;
37
40
41class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkChart : public vtkContextItem
42{
43public:
44 vtkTypeMacro(vtkChart, vtkContextItem);
45 void PrintSelf(ostream& os, vtkIndent indent) override;
46
50 enum
51 {
59 };
60
75 enum
76 {
77 PAN = 0,
86 };
87
92 {
94 };
95
99 bool Paint(vtkContext2D* painter) override = 0;
100
104 virtual vtkPlot* AddPlot(int type);
105
109 virtual vtkIdType AddPlot(vtkPlot* plot);
110
115 virtual bool RemovePlot(vtkIdType index);
116
122 virtual bool RemovePlotInstance(vtkPlot* plot);
123 bool RemovePlot(vtkPlot* plot) { return this->RemovePlotInstance(plot); }
124
128 virtual void ClearPlots();
129 void RemoveAllPlots() { this->ClearPlots(); }
130
134 virtual vtkPlot* GetPlot(vtkIdType index);
135
140
145 virtual vtkAxis* GetAxis(int axisIndex);
146
151 virtual void SetAxis(int axisIndex, vtkAxis*);
152
157
162 virtual void RecalculateBounds();
163
171 enum
172 {
176 };
177
179
187 virtual void SetSelectionMethod(int method);
188 virtual int GetSelectionMethod();
190
195
197
202
204
207 vtkSetVector2Macro(Geometry, int);
208 vtkGetVector2Macro(Geometry, int);
210
212
215 vtkSetVector2Macro(Point1, int);
216 vtkGetVector2Macro(Point1, int);
218
220
223 vtkSetVector2Macro(Point2, int);
224 vtkGetVector2Macro(Point2, int);
226
228
231 virtual void SetShowLegend(bool visible);
232 virtual bool GetShowLegend();
234
240
242
245 virtual void SetTitle(const vtkStdString& title);
248
250
253 vtkGetObjectMacro(TitleProperties, vtkTextProperty);
255
257
260 void SetBottomBorder(int border);
261 void SetTopBorder(int border);
262 void SetLeftBorder(int border);
263 void SetRightBorder(int border);
265
269 void SetBorders(int left, int bottom, int right, int top);
270
276 virtual void SetSize(const vtkRectf& rect);
277
282
286 enum
287 {
288 FILL_SCENE, // Attempt to fill the entire scene.
289 FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
290 AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
291 };
292
294
299 vtkSetMacro(LayoutStrategy, int);
300 vtkGetMacro(LayoutStrategy, int);
302
304
308 virtual void SetAutoSize(bool isAutoSized)
309 {
311 }
312 virtual bool GetAutoSize() { return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false; }
314
316
324 vtkSetMacro(RenderEmpty, bool);
325 vtkGetMacro(RenderEmpty, bool);
327
338 virtual void SetActionToButton(int action, int button);
339
344 virtual int GetActionToButton(int action);
345
351 virtual void SetClickActionToButton(int action, int button);
352
358 virtual int GetClickActionToButton(int action);
359
361
367
369
373 vtkSetClampMacro(
375 vtkGetMacro(SelectionMode, int);
377
378protected:
380 ~vtkChart() override;
381
389
394
399
400 void AxisRangeForwarderCallback(vtkObject*, unsigned long, void*);
401
406
410 int Geometry[2];
411
415 int Point1[2];
416
420 int Point2[2];
421
425 int Borders[4];
426
431
436
441
443 // The layout strategy to employ when fitting the chart into the space.
446
451
452 // The mode when the chart is doing selection.
454
455 // How plot selections are handled, SELECTION_ROWS (default) or
456 // SELECTION_PLOTS - based on the plot that created the selection.
458
460
464 {
465 public:
467 enum
468 {
470 };
471 short& Pan() { return Data[0]; }
472 short& Zoom() { return Data[1]; }
473 short& ZoomAxis() { return Data[2]; }
474 short& Select() { return Data[3]; }
475 short& SelectPolygon() { return Data[4]; }
476 short& ClickAndDrag() { return Data[5]; }
477 short& operator[](int index) { return Data[index]; }
479 };
481 {
482 public:
484 short& Notify() { return Data[0]; }
485 short& Select() { return Data[1]; }
486 short& operator[](int index) { return Data[index]; }
487 short Data[2];
488 };
489
490
493
494private:
495 vtkChart(const vtkChart&) = delete;
496 void operator=(const vtkChart&) = delete;
497};
498
499VTK_ABI_NAMESPACE_END
500#endif // vtkChart_h
takes care of drawing 2D axes
Definition vtkAxis.h:62
provides a brush that fills shapes drawn by vtkContext2D.
Definition vtkBrush.h:31
draw the chart legend
Hold mouse action mappings.
Definition vtkChart.h:464
short Data[MaxAction]
Definition vtkChart.h:478
short & operator[](int index)
Definition vtkChart.h:477
short & SelectPolygon()
Definition vtkChart.h:475
short & operator[](int index)
Definition vtkChart.h:486
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:492
void AxisRangeForwarderCallback(vtkObject *, unsigned long, void *)
bool RemovePlot(vtkPlot *plot)
Definition vtkChart.h:123
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:308
@ FUNCTIONALBAG
Definition vtkChart.h:57
@ STACKED
Definition vtkChart.h:55
int Point2[2]
The position of the upper right corner of the chart.
Definition vtkChart.h:420
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:444
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:435
vtkTextProperty * TitleProperties
The text properties associated with the chart.
Definition vtkChart.h:440
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:312
int SelectionMethod
Definition vtkChart.h:457
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.
@ SELECT_RECTANGLE
Definition vtkChart.h:81
@ ACTION_TYPES_COUNT
Definition vtkChart.h:85
@ SELECT_POLYGON
Definition vtkChart.h:82
@ CLICK_AND_DRAG
Definition vtkChart.h:83
@ ZOOM_AXIS
Definition vtkChart.h:79
@ SELECTION_COLUMNS
Definition vtkChart.h:175
@ SELECTION_PLOTS
Definition vtkChart.h:174
@ SELECTION_ROWS
Definition vtkChart.h:173
MouseActions Actions
Definition vtkChart.h:491
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:405
vtkRectf GetSize()
Get the current size of the chart.
void SetBottomBorder(int border)
Set/get the borders of the chart (space in pixels around the chart).
virtual int GetClickActionToButton(int action)
Get the mouse button associated with the supplied click action.
vtkRectf Size
Definition vtkChart.h:442
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:450
virtual void SetClickActionToButton(int action, int button)
Assign action types to single mouse clicks.
EventIds
Enum of event type that are triggered by the charts.
Definition vtkChart.h:92
@ UpdateRange
Definition vtkChart.h:93
int Point1[2]
The position of the lower left corner of the chart.
Definition vtkChart.h:415
virtual bool RemovePlotInstance(vtkPlot *plot)
Remove the given plot.
int SelectionMode
Definition vtkChart.h:453
int Geometry[2]
The width and the height of the chart.
Definition vtkChart.h:410
void SetTopBorder(int border)
Set/get the borders of the chart (space in pixels around the chart).
bool RenderEmpty
Definition vtkChart.h:445
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.
int Borders[4]
The borders around the chart.
Definition vtkChart.h:425
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.
void RemoveAllPlots()
Definition vtkChart.h:129
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.
@ FILL_SCENE
Definition vtkChart.h:288
@ FILL_RECT
Definition vtkChart.h:289
@ AXES_TO_RECT
Definition vtkChart.h:290
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:430
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.
vtkContextItem()=default
Provides a 2D scene for vtkContextItem objects.
a simple class to control print indentation
Definition vtkIndent.h:29
provide event-driven interface to the rendering window (defines trackball mode)
Abstract class for 2D plots.
Definition vtkPlot.h:44
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
#define VTK_MARSHALAUTO