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 
24 #ifndef vtkChart_h
25 #define vtkChart_h
26 
27 #include "vtkChartsCoreModule.h" // For export macro
28 #include "vtkContextItem.h"
29 #include "vtkRect.h" // For vtkRectf
30 #include "vtkStdString.h" // For vtkStdString ivars
31 #include "vtkSmartPointer.h" // For SP ivars
32 
33 class vtkTransform2D;
34 class vtkContextScene;
35 class vtkPlot;
36 class vtkAxis;
37 class vtkBrush;
38 class vtkTextProperty;
39 class vtkChartLegend;
40 
41 class vtkInteractorStyle;
42 class vtkAnnotationLink;
43 
44 class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem
45 {
46 public:
47  vtkTypeMacro(vtkChart, vtkContextItem);
48  void PrintSelf(ostream &os, vtkIndent indent) override;
49 
53  enum {
56  BAR,
58  BAG,
60  AREA};
61 
74  enum {
75  PAN = 0,
79  SELECT_RECTANGLE = SELECT,
82  NOTIFY
83  };
84 
88  enum EventIds {
89  UpdateRange = 1002
90  };
91 
95  bool Paint(vtkContext2D *painter) override = 0;
96 
100  virtual vtkPlot* AddPlot(int type);
101 
105  virtual vtkIdType AddPlot(vtkPlot* plot);
106 
111  virtual bool RemovePlot(vtkIdType index);
112 
118  virtual bool RemovePlotInstance(vtkPlot* plot);
119 
123  virtual void ClearPlots();
124 
128  virtual vtkPlot* GetPlot(vtkIdType index);
129 
133  virtual vtkIdType GetNumberOfPlots();
134 
139  virtual vtkAxis* GetAxis(int axisIndex);
140 
144  virtual vtkIdType GetNumberOfAxes();
145 
150  virtual void RecalculateBounds();
151 
159  enum {
162  SELECTION_COLUMNS
163  };
164 
166 
174  virtual void SetSelectionMethod(int method);
175  virtual int GetSelectionMethod();
177 
181  virtual void SetAnnotationLink(vtkAnnotationLink *link);
182 
184 
187  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
189 
191 
194  vtkSetVector2Macro(Geometry, int);
195  vtkGetVector2Macro(Geometry, int);
197 
199 
202  vtkSetVector2Macro(Point1, int);
203  vtkGetVector2Macro(Point1, int);
205 
207 
210  vtkSetVector2Macro(Point2, int);
211  vtkGetVector2Macro(Point2, int);
213 
215 
218  virtual void SetShowLegend(bool visible);
219  virtual bool GetShowLegend();
221 
226  virtual vtkChartLegend * GetLegend();
227 
229 
232  virtual void SetTitle(const vtkStdString &title);
233  virtual vtkStdString GetTitle();
235 
237 
240  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
242 
244 
247  void SetBottomBorder(int border);
248  void SetTopBorder(int border);
249  void SetLeftBorder(int border);
250  void SetRightBorder(int border);
252 
256  void SetBorders(int left, int bottom, int right, int top);
257 
263  void SetSize(const vtkRectf &rect);
264 
268  vtkRectf GetSize();
269 
273  enum {
274  FILL_SCENE, // Attempt to fill the entire scene.
275  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
276  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
277  };
278 
280 
285  vtkSetMacro(LayoutStrategy, int);
286  vtkGetMacro(LayoutStrategy, int);
288 
290 
294  virtual void SetAutoSize(bool isAutoSized)
295  {
296  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
298  }
299  virtual bool GetAutoSize()
300  {
301  return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
302  }
304 
306 
314  vtkSetMacro(RenderEmpty, bool);
315  vtkGetMacro(RenderEmpty, bool);
317 
328  virtual void SetActionToButton(int action, int button);
329 
334  virtual int GetActionToButton(int action);
335 
341  virtual void SetClickActionToButton(int action, int button);
342 
348  virtual int GetClickActionToButton(int action);
349 
351 
354  void SetBackgroundBrush(vtkBrush *brush);
355  vtkBrush* GetBackgroundBrush();
357 
359 
364  virtual void SetSelectionMode(int);
365  vtkGetMacro(SelectionMode, int);
367 
368 protected:
369  vtkChart();
370  ~vtkChart() override;
371 
378  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
379  vtkTransform2D *transform);
380 
384  bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y,
385  vtkTransform2D *transform);
386 
390  void AttachAxisRangeListener(vtkAxis*);
391 
392  void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
393 
398 
402  int Geometry[2];
403 
407  int Point1[2];
408 
412  int Point2[2];
413 
418 
423 
428 
430  // The layout strategy to employ when fitting the chart into the space.
433 
438 
439  // The mode when the chart is doing selection.
441 
442  // How plot selections are handled, SELECTION_ROWS (default) or
443  // SELECTION_PLOTS - based on the plot that created the selection.
445 
447 
451  {
452  public:
453  MouseActions();
454  enum { MaxAction = 6 };
455  short& Pan() { return Data[0]; }
456  short& Zoom() { return Data[1]; }
457  short& ZoomAxis() { return Data[2]; }
458  short& Select() { return Data[3]; }
459  short& SelectPolygon() { return Data[4]; }
460  short& ClickAndDrag() { return Data[5]; }
461  short& operator[](int index) { return Data[index]; }
462  short Data[MaxAction];
463  };
465  {
466  public:
468  short& Notify() { return Data[0]; }
469  short& Select() { return Data[1]; }
470  short& operator[](int index) { return Data[index]; }
471  short Data[2];
472  };
474 
477 
478 private:
479  vtkChart(const vtkChart &) = delete;
480  void operator=(const vtkChart &) = delete;
481 };
482 
483 #endif //vtkChart_h
int SelectionMethod
Definition: vtkChart.h:444
MouseClickActions ActionsClick
Definition: vtkChart.h:476
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:34
vtkStdString Title
The title of the chart.
Definition: vtkChart.h:422
vtkTextProperty * TitleProperties
The text properties associated with the chart.
Definition: vtkChart.h:427
short & SelectPolygon()
Definition: vtkChart.h:459
abstract base class for most VTK objects
Definition: vtkObject.h:53
bool RenderEmpty
Definition: vtkChart.h:432
vtkAnnotationLink * AnnotationLink
Our annotation link, used for sharing selections etc.
Definition: vtkChart.h:397
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:431
int vtkIdType
Definition: vtkType.h:345
short & ClickAndDrag()
Definition: vtkChart.h:460
int SelectionMode
Definition: vtkChart.h:440
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
Factory class for drawing 2D charts.
Definition: vtkChart.h:44
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:37
takes care of drawing 2D axes
Definition: vtkAxis.h:68
Provides a 2D scene for vtkContextItem objects.
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkRectf Size
Definition: vtkChart.h:429
virtual void SetAutoSize(bool isAutoSized)
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:294
bool ShowLegend
Display the legend?
Definition: vtkChart.h:417
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:299
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:46
represent text properties.
EventIds
Enum of event type that are triggered by the charts.
Definition: vtkChart.h:88
short & operator[](int index)
Definition: vtkChart.h:461
draw the chart legend
provide event-driven interface to the rendering window (defines trackball mode)
Hold mouse action mappings.
Definition: vtkChart.h:450
vtkSmartPointer< vtkBrush > BackgroundBrush
Brush to use for drawing the background.
Definition: vtkChart.h:437
short & operator[](int index)
Definition: vtkChart.h:470
MouseActions Actions
Definition: vtkChart.h:475