VTK
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 "vtkRect.h" // For vtkRectf
36 #include "vtkStdString.h" // For vtkStdString ivars
37 #include "vtkSmartPointer.h" // For SP ivars
38 
39 class vtkTransform2D;
40 class vtkContextScene;
41 class vtkPlot;
42 class vtkAxis;
43 class vtkBrush;
44 class vtkTextProperty;
45 class vtkChartLegend;
46 
47 class vtkInteractorStyle;
48 class vtkAnnotationLink;
49 
50 class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem
51 {
52 public:
53  vtkTypeMacro(vtkChart, vtkContextItem);
54  void PrintSelf(ostream &os, vtkIndent indent) override;
55 
59  enum {
62  BAR,
64  BAG,
66  AREA};
67 
80  enum {
81  PAN = 0,
85  SELECT_RECTANGLE = SELECT,
88  NOTIFY
89  };
90 
94  enum EventIds {
95  UpdateRange = 1002
96  };
97 
101  bool Paint(vtkContext2D *painter) override = 0;
102 
106  virtual vtkPlot* AddPlot(int type);
107 
111  virtual vtkIdType AddPlot(vtkPlot* plot);
112 
117  virtual bool RemovePlot(vtkIdType index);
118 
124  virtual bool RemovePlotInstance(vtkPlot* plot);
125 
129  virtual void ClearPlots();
130 
134  virtual vtkPlot* GetPlot(vtkIdType index);
135 
139  virtual vtkIdType GetNumberOfPlots();
140 
145  virtual vtkAxis* GetAxis(int axisIndex);
146 
151  virtual void SetAxis(int axisIndex, vtkAxis*);
152 
156  virtual vtkIdType GetNumberOfAxes();
157 
162  virtual void RecalculateBounds();
163 
171  enum {
174  SELECTION_COLUMNS
175  };
176 
178 
186  virtual void SetSelectionMethod(int method);
187  virtual int GetSelectionMethod();
189 
193  virtual void SetAnnotationLink(vtkAnnotationLink *link);
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 
238  virtual vtkChartLegend * GetLegend();
239 
241 
244  virtual void SetTitle(const vtkStdString &title);
245  virtual vtkStdString GetTitle();
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  void SetSize(const vtkRectf &rect);
276 
280  vtkRectf GetSize();
281 
285  enum {
286  FILL_SCENE, // Attempt to fill the entire scene.
287  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
288  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
289  };
290 
292 
297  vtkSetMacro(LayoutStrategy, int);
298  vtkGetMacro(LayoutStrategy, int);
300 
302 
306  virtual void SetAutoSize(bool isAutoSized)
307  {
308  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
310  }
311  virtual bool GetAutoSize()
312  {
313  return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
314  }
316 
318 
326  vtkSetMacro(RenderEmpty, bool);
327  vtkGetMacro(RenderEmpty, bool);
329 
340  virtual void SetActionToButton(int action, int button);
341 
346  virtual int GetActionToButton(int action);
347 
353  virtual void SetClickActionToButton(int action, int button);
354 
360  virtual int GetClickActionToButton(int action);
361 
363 
366  void SetBackgroundBrush(vtkBrush *brush);
367  vtkBrush* GetBackgroundBrush();
369 
371 
376  virtual void SetSelectionMode(int);
377  vtkGetMacro(SelectionMode, int);
379 
380 protected:
381  vtkChart();
382  ~vtkChart() override;
383 
390  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
391  vtkTransform2D *transform);
392 
396  bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y,
397  vtkTransform2D *transform);
398 
402  void AttachAxisRangeListener(vtkAxis*);
403 
404  void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
405 
410 
414  int Geometry[2];
415 
419  int Point1[2];
420 
424  int Point2[2];
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:
465  MouseActions();
466  enum { MaxAction = 6 };
467  short& Pan() { return Data[0]; }
468  short& Zoom() { return Data[1]; }
469  short& ZoomAxis() { return Data[2]; }
470  short& Select() { return Data[3]; }
471  short& SelectPolygon() { return Data[4]; }
472  short& ClickAndDrag() { return Data[5]; }
473  short& operator[](int index) { return Data[index]; }
474  short Data[MaxAction];
475  };
477  {
478  public:
480  short& Notify() { return Data[0]; }
481  short& Select() { return Data[1]; }
482  short& operator[](int index) { return Data[index]; }
483  short Data[2];
484  };
486 
489 
490 private:
491  vtkChart(const vtkChart &) = delete;
492  void operator=(const vtkChart &) = delete;
493 };
494 
495 #endif //vtkChart_h
int SelectionMethod
Definition: vtkChart.h:456
MouseClickActions ActionsClick
Definition: vtkChart.h:488
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
vtkStdString Title
The title of the chart.
Definition: vtkChart.h:434
vtkTextProperty * TitleProperties
The text properties associated with the chart.
Definition: vtkChart.h:439
short & SelectPolygon()
Definition: vtkChart.h:471
abstract base class for most VTK objects
Definition: vtkObject.h:59
bool RenderEmpty
Definition: vtkChart.h:444
vtkAnnotationLink * AnnotationLink
Our annotation link, used for sharing selections etc.
Definition: vtkChart.h:409
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:443
int vtkIdType
Definition: vtkType.h:347
short & ClickAndDrag()
Definition: vtkChart.h:472
int SelectionMode
Definition: vtkChart.h:452
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:58
Factory class for drawing 2D charts.
Definition: vtkChart.h:50
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:441
virtual void SetAutoSize(bool isAutoSized)
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:306
bool ShowLegend
Display the legend?
Definition: vtkChart.h:429
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:311
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:52
represent text properties.
EventIds
Enum of event type that are triggered by the charts.
Definition: vtkChart.h:94
short & operator[](int index)
Definition: vtkChart.h:473
draw the chart legend
provide event-driven interface to the rendering window (defines trackball mode)
Hold mouse action mappings.
Definition: vtkChart.h:462
vtkSmartPointer< vtkBrush > BackgroundBrush
Brush to use for drawing the background.
Definition: vtkChart.h:449
short & operator[](int index)
Definition: vtkChart.h:482
MouseActions Actions
Definition: vtkChart.h:487