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 
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 
40 class vtkTransform2D;
41 class vtkContextScene;
42 class vtkPlot;
43 class vtkAxis;
44 class vtkBrush;
45 class vtkTextProperty;
46 class vtkChartLegend;
47 
48 class vtkInteractorStyle;
49 class vtkAnnotationLink;
50 
51 class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem
52 {
53 public:
54  vtkTypeMacro(vtkChart, vtkContextItem);
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
60  enum
61  {
64  BAR,
66  BAG,
68  AREA
69  };
70 
83  enum
84  {
85  PAN = 0,
89  SELECT_RECTANGLE = SELECT,
92  NOTIFY
93  };
94 
98  enum EventIds
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 
144  virtual vtkIdType GetNumberOfPlots();
145 
150  virtual vtkAxis* GetAxis(int axisIndex);
151 
156  virtual void SetAxis(int axisIndex, vtkAxis*);
157 
161  virtual vtkIdType GetNumberOfAxes();
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 
199  virtual void SetAnnotationLink(vtkAnnotationLink* link);
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 
244  virtual vtkChartLegend* GetLegend();
245 
247 
250  virtual void SetTitle(const vtkStdString& title);
251  virtual vtkStdString GetTitle();
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 
286  vtkRectf GetSize();
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 
369  void SetBackgroundBrush(vtkBrush* brush);
370  vtkBrush* GetBackgroundBrush();
372 
374 
378  vtkSetClampMacro(
380  vtkGetMacro(SelectionMode, int);
382 
383 protected:
384  vtkChart();
385  ~vtkChart() override;
386 
393  bool CalculatePlotTransform(vtkAxis* x, vtkAxis* y, vtkTransform2D* transform);
394 
398  bool CalculateUnscaledPlotTransform(vtkAxis* x, vtkAxis* y, vtkTransform2D* transform);
399 
403  void AttachAxisRangeListener(vtkAxis*);
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:
471  MouseActions();
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 
499 private:
500  vtkChart(const vtkChart&) = delete;
501  void operator=(const vtkChart&) = delete;
502 };
503 
504 #endif // vtkChart_h
int SelectionMethod
Definition: vtkChart.h:462
MouseClickActions ActionsClick
Definition: vtkChart.h:497
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
vtkStdString Title
The title of the chart.
Definition: vtkChart.h:440
void UpdateRange(A &min0, A &max0, const A &value, typename std::enable_if<!std::is_floating_point< A >::value >::type *=0)
vtkTextProperty * TitleProperties
The text properties associated with the chart.
Definition: vtkChart.h:445
short & SelectPolygon()
Definition: vtkChart.h:480
abstract base class for most VTK objects
Definition: vtkObject.h:62
bool RenderEmpty
Definition: vtkChart.h:450
vtkAnnotationLink * AnnotationLink
Our annotation link, used for sharing selections etc.
Definition: vtkChart.h:410
base class for items that are part of a vtkContextScene.
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
int LayoutStrategy
Definition: vtkChart.h:449
int vtkIdType
Definition: vtkType.h:332
short & ClickAndDrag()
Definition: vtkChart.h:481
int SelectionMode
Definition: vtkChart.h:458
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
Factory class for drawing 2D charts.
Definition: vtkChart.h:51
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:40
takes care of drawing 2D axes
Definition: vtkAxis.h:71
Provides a 2D scene for vtkContextItem objects.
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkRectf Size
Definition: vtkChart.h:447
virtual void SetAutoSize(bool isAutoSized)
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:313
bool ShowLegend
Display the legend?
Definition: vtkChart.h:435
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool GetAutoSize()
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:317
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:53
represent text properties.
EventIds
Enum of event type that are triggered by the charts.
Definition: vtkChart.h:98
short & operator[](int index)
Definition: vtkChart.h:482
draw the chart legend
provide event-driven interface to the rendering window (defines trackball mode)
Hold mouse action mappings.
Definition: vtkChart.h:468
vtkSmartPointer< vtkBrush > BackgroundBrush
Brush to use for drawing the background.
Definition: vtkChart.h:455
short & operator[](int index)
Definition: vtkChart.h:491
MouseActions Actions
Definition: vtkChart.h:496