1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkChartParallelCoordinates.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 
16 /**
17  * @class   vtkChartParallelCoordinates
18  * @brief   Factory class for drawing 2D charts
19  *
20  *
21  * This defines the interface for a parallel coordinates chart.
22 */
23 
24 #ifndef vtkChartParallelCoordinates_h
25 #define vtkChartParallelCoordinates_h
26 
27 #include "vtkChartsCoreModule.h" // For export macro
28 #include "vtkNew.h" // For vtkNew
29 #include "vtkChart.h"
30 
31 class vtkIdTypeArray;
32 class vtkStdString;
33 class vtkStringArray;
34 class vtkPlotParallelCoordinates;
35 
36 class VTKCHARTSCORE_EXPORT vtkChartParallelCoordinates : public vtkChart
37 {
38 public:
39   vtkTypeMacro(vtkChartParallelCoordinates, vtkChart);
40   void PrintSelf(ostream &os, vtkIndent indent) override;
41 
42   /**
43    * Creates a parallel coordinates chart
44    */
45   static vtkChartParallelCoordinates* New();
46 
47   /**
48    * Perform any updates to the item that may be necessary before rendering.
49    * The scene should take care of calling this on all items before their
50    * Paint function is invoked.
51    */
52   void Update() override;
53 
54   /**
55    * Paint event for the chart, called whenever the chart needs to be drawn
56    */
57   bool Paint(vtkContext2D *painter) override;
58 
59   /**
60    * Set the visibility of the specified column.
61    */
62   void SetColumnVisibility(const vtkStdString& name, bool visible);
63 
64   /**
65    * Set the visibility of all columns (true will make them all visible, false
66    * will remove all visible columns).
67    */
68   void SetColumnVisibilityAll(bool visible);
69 
70   /**
71    * Get the visibility of the specified column.
72    */
73   bool GetColumnVisibility(const vtkStdString& name);
74 
75   /**
76    * Get a list of the columns, and the order in which they are displayed.
77    */
78   virtual vtkStringArray* GetVisibleColumns();
79 
80   /**
81    * Set the list of visible columns, and the order in which they will be displayed.
82    */
83   virtual void SetVisibleColumns(vtkStringArray* visColumns);
84 
85   /**
86    * Get the plot at the specified index, returns null if the index is invalid.
87    */
88   vtkPlot* GetPlot(vtkIdType index) override;
89 
90   /**
91    * Get the number of plots the chart contains.
92    */
93   vtkIdType GetNumberOfPlots() override;
94 
95   /**
96    * Get the axis specified by axisIndex.
97    */
98   vtkAxis* GetAxis(int axisIndex) override;
99 
100   /**
101    * Get the number of axes in the current chart.
102    */
103   vtkIdType GetNumberOfAxes() override;
104 
105   /**
106    * Request that the chart recalculates the range of its axes. Especially
107    * useful in applications after the parameters of plots have been modified.
108    */
109   void RecalculateBounds() override;
110 
111   /**
112    * Set plot to use for the chart. Since this type of chart can
113    * only contain one plot, this will replace the previous plot.
114    */
115   virtual void SetPlot(vtkPlotParallelCoordinates *plot);
116 
117   /**
118    * Return true if the supplied x, y coordinate is inside the item.
119    */
120   bool Hit(const vtkContextMouseEvent &mouse) override;
121 
122   /**
123    * Mouse enter event.
124    */
125   bool MouseEnterEvent(const vtkContextMouseEvent &mouse) override;
126 
127   /**
128    * Mouse move event.
129    */
130   bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override;
131 
132   /**
133    * Mouse leave event.
134    */
135   bool MouseLeaveEvent(const vtkContextMouseEvent &mouse) override;
136 
137   /**
138    * Mouse button down event
139    */
140   bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override;
141 
142   /**
143    * Mouse button release event.
144    */
145   bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override;
146 
147   /**
148    * Mouse wheel event, positive delta indicates forward movement of the wheel.
149    */
150   bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta) override;
151 
152 protected:
153   vtkChartParallelCoordinates();
154   ~vtkChartParallelCoordinates() override;
155 
156   //@{
157   /**
158    * Private storage object - where we hide all of our STL objects...
159    */
160   class Private;
161   Private *Storage;
162   //@}
163 
164   bool GeometryValid;
165 
166   /**
167    * Selected indices for the table the plot is rendering
168    */
169   vtkIdTypeArray *Selection;
170 
171   /**
172    * Strongly owned internal data for the column visibility.
173    */
174   vtkNew<vtkStringArray> VisibleColumns;
175 
176   /**
177    * The point cache is marked dirty until it has been initialized.
178    */
179   vtkTimeStamp BuildTime;
180 
181   void ResetSelection();
182   bool ResetAxeSelection(int axe);
183   void ResetAxesSelection();
184   void UpdateGeometry();
185   void CalculatePlotTransform();
186   void SwapAxes(int a1, int a2);
187 
188 private:
189   vtkChartParallelCoordinates(const vtkChartParallelCoordinates &) = delete;
190   void operator=(const vtkChartParallelCoordinates &) = delete;
191 
192 };
193 
194 #endif //vtkChartParallelCoordinates_h
195