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 
150  virtual vtkIdType GetNumberOfAxes();
151 
156  virtual void RecalculateBounds();
157 
165  enum {
168  SELECTION_COLUMNS
169  };
170 
172 
180  virtual void SetSelectionMethod(int method);
181  virtual int GetSelectionMethod();
183 
187  virtual void SetAnnotationLink(vtkAnnotationLink *link);
188 
190 
193  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
195 
197 
200  vtkSetVector2Macro(Geometry, int);
201  vtkGetVector2Macro(Geometry, int);
203 
205 
208  vtkSetVector2Macro(Point1, int);
209  vtkGetVector2Macro(Point1, int);
211 
213 
216  vtkSetVector2Macro(Point2, int);
217  vtkGetVector2Macro(Point2, int);
219 
221 
224  virtual void SetShowLegend(bool visible);
225  virtual bool GetShowLegend();
227 
232  virtual vtkChartLegend * GetLegend();
233 
235 
238  virtual void SetTitle(const vtkStdString &title);
239  virtual vtkStdString GetTitle();
241 
243 
246  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
248 
250 
253  void SetBottomBorder(int border);
254  void SetTopBorder(int border);
255  void SetLeftBorder(int border);
256  void SetRightBorder(int border);
258 
262  void SetBorders(int left, int bottom, int right, int top);
263 
269  void SetSize(const vtkRectf &rect);
270 
274  vtkRectf GetSize();
275 
279  enum {
280  FILL_SCENE, // Attempt to fill the entire scene.
281  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
282  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
283  };
284 
286 
291  vtkSetMacro(LayoutStrategy, int);
292  vtkGetMacro(LayoutStrategy, int);
294 
296 
300  virtual void SetAutoSize(bool isAutoSized)
301  {
302  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
304  }
305  virtual bool GetAutoSize()
306  {
307  return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
308  }
310 
312 
320  vtkSetMacro(RenderEmpty, bool);
321  vtkGetMacro(RenderEmpty, bool);
323 
334  virtual void SetActionToButton(int action, int button);
335 
340  virtual int GetActionToButton(int action);
341 
347  virtual void SetClickActionToButton(int action, int button);
348 
354  virtual int GetClickActionToButton(int action);
355 
357 
360  void SetBackgroundBrush(vtkBrush *brush);
361  vtkBrush* GetBackgroundBrush();
363 
365 
370  virtual void SetSelectionMode(int);
371  vtkGetMacro(SelectionMode, int);
373 
374 protected:
375  vtkChart();
376  ~vtkChart() override;
377 
384  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
385  vtkTransform2D *transform);
386 
390  bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y,
391  vtkTransform2D *transform);
392 
396  void AttachAxisRangeListener(vtkAxis*);
397 
398  void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
399 
404 
408  int Geometry[2];
409 
413  int Point1[2];
414 
418  int Point2[2];
419 
424 
429 
434 
436  // The layout strategy to employ when fitting the chart into the space.
439 
444 
445  // The mode when the chart is doing selection.
447 
448  // How plot selections are handled, SELECTION_ROWS (default) or
449  // SELECTION_PLOTS - based on the plot that created the selection.
451 
453 
457  {
458  public:
459  MouseActions();
460  enum { MaxAction = 6 };
461  short& Pan() { return Data[0]; }
462  short& Zoom() { return Data[1]; }
463  short& ZoomAxis() { return Data[2]; }
464  short& Select() { return Data[3]; }
465  short& SelectPolygon() { return Data[4]; }
466  short& ClickAndDrag() { return Data[5]; }
467  short& operator[](int index) { return Data[index]; }
468  short Data[MaxAction];
469  };
471  {
472  public:
474  short& Notify() { return Data[0]; }
475  short& Select() { return Data[1]; }
476  short& operator[](int index) { return Data[index]; }
477  short Data[2];
478  };
480 
483 
484 private:
485  vtkChart(const vtkChart &) = delete;
486  void operator=(const vtkChart &) = delete;
487 };
488 
489 #endif //vtkChart_h
int SelectionMethod
Definition: vtkChart.h:450
MouseClickActions ActionsClick
Definition: vtkChart.h:482
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
vtkStdString Title
The title of the chart.
Definition: vtkChart.h:428
vtkTextProperty * TitleProperties
The text properties associated with the chart.
Definition: vtkChart.h:433
short & SelectPolygon()
Definition: vtkChart.h:465
abstract base class for most VTK objects
Definition: vtkObject.h:59
bool RenderEmpty
Definition: vtkChart.h:438
vtkAnnotationLink * AnnotationLink
Our annotation link, used for sharing selections etc.
Definition: vtkChart.h:403
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:437
int vtkIdType
Definition: vtkType.h:345
short & ClickAndDrag()
Definition: vtkChart.h:466
int SelectionMode
Definition: vtkChart.h:446
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:435
virtual void SetAutoSize(bool isAutoSized)
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:300
bool ShowLegend
Display the legend?
Definition: vtkChart.h:423
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:305
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:52
represent text properties.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
EventIds
Enum of event type that are triggered by the charts.
Definition: vtkChart.h:94
short & operator[](int index)
Definition: vtkChart.h:467
draw the chart legend
provide event-driven interface to the rendering window (defines trackball mode)
Hold mouse action mappings.
Definition: vtkChart.h:456
vtkSmartPointer< vtkBrush > BackgroundBrush
Brush to use for drawing the background.
Definition: vtkChart.h:443
short & operator[](int index)
Definition: vtkChart.h:476
MouseActions Actions
Definition: vtkChart.h:481