VTK  9.3.1
vtkChartBox.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
15 #ifndef vtkChartBox_h
16 #define vtkChartBox_h
17 
18 #include "vtkChart.h"
19 #include "vtkChartsCoreModule.h" // For export macro
20 
21 VTK_ABI_NAMESPACE_BEGIN
22 class vtkIdTypeArray;
23 class vtkPlotBox;
24 class vtkStdString;
25 class vtkStringArray;
26 class vtkTooltipItem;
27 
28 class VTKCHARTSCORE_EXPORT vtkChartBox : public vtkChart
29 {
30 public:
31  vtkTypeMacro(vtkChartBox, vtkChart);
32  void PrintSelf(ostream& os, vtkIndent indent) override;
33 
37  static vtkChartBox* New();
38 
44  void Update() override;
45 
49  bool Paint(vtkContext2D* painter) override;
50 
52 
55  void SetColumnVisibility(const vtkStdString& name, bool visible);
56  void SetColumnVisibility(vtkIdType column, bool visible);
58 
63  void SetColumnVisibilityAll(bool visible);
64 
66 
69  bool GetColumnVisibility(const vtkStdString& name);
70  bool GetColumnVisibility(vtkIdType column);
72 
76  vtkIdType GetColumnId(const vtkStdString& name);
77 
79 
82  vtkGetObjectMacro(VisibleColumns, vtkStringArray);
84 
85  // Index of the selected column in the visible columns list.
86  vtkGetMacro(SelectedColumn, int);
87  vtkSetMacro(SelectedColumn, int);
88 
92  vtkPlot* GetPlot(vtkIdType index) override;
93 
97  vtkIdType GetNumberOfPlots() override;
98 
102  virtual vtkAxis* GetYAxis();
103 
107  virtual float GetXPosition(int index);
108 
112  virtual vtkIdType GetNumberOfVisibleColumns();
113 
118  virtual void SetPlot(vtkPlotBox* plot);
119 
123  bool Hit(const vtkContextMouseEvent& mouse) override;
124 
128  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
129 
133  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
134 
138  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
139 
143  virtual void SetTooltip(vtkTooltipItem* tooltip);
144 
148  virtual vtkTooltipItem* GetTooltip();
149 
153  virtual void SetTooltipInfo(const vtkContextMouseEvent&, const vtkVector2d&, vtkIdType, vtkPlot*,
154  vtkIdType segmentIndex = -1);
155 
160  void SetSize(const vtkRectf& rect) override;
161 
166  void SetGeometry(int arg1, int arg2) override;
167 
172  void SetLayoutStrategy(int strategy) override;
173 
174 protected:
175  vtkChartBox();
176  ~vtkChartBox() override;
177 
179 
182  class Private;
183  Private* Storage;
185 
187 
192 
197 
199 
205 
210 
215 
216  void ResetSelection();
217  void UpdateGeometry(vtkContext2D*);
218  void CalculatePlotTransform();
219  void SwapAxes(int a1, int a2);
220 
226  bool LocatePointInPlots(const vtkContextMouseEvent& mouse, int invokeEvent = -1);
227 
228  int LocatePointInPlot(const vtkVector2f& position, const vtkVector2f& tolerance,
229  vtkVector2f& plotPos, vtkPlot* plot, vtkIdType& segmentId);
230 
231 private:
232  vtkChartBox(const vtkChartBox&) = delete;
233  void operator=(const vtkChartBox&) = delete;
234 };
235 
237 
243 {
247  int Index;
248 };
250 
251 VTK_ABI_NAMESPACE_END
252 #endif // vtkChartBox_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:28
Small struct used by InvokeEvent to send some information about the point that was clicked on...
Definition: vtkChartBox.h:242
vtkIdTypeArray * Selection
Selected indices for the table the plot is rendering.
Definition: vtkChartBox.h:191
vtkStringArray * VisibleColumns
A list of the visible columns in the chart.
Definition: vtkChartBox.h:196
virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
Mouse button down event Return true if the item holds the event, false if the event can be propagated...
vtkStdString SeriesName
Definition: vtkChartBox.h:244
vtkVector2f Position
Definition: vtkChartBox.h:245
record modification and/or execution time
Definition: vtkTimeStamp.h:24
bool Paint(vtkContext2D *painter) override=0
Paint event for the chart, called whenever the chart needs to be drawn.
a vtkAbstractArray subclass for strings
bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y, vtkTransform2D *transform)
Given the x and y vtkAxis, and a transform, calculate the transform that the points in a chart would ...
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:315
virtual void SetLayoutStrategy(int)
Set/get the layout strategy that should be used by the chart.
bool GeometryValid
Definition: vtkChartBox.h:186
virtual void SetSize(const vtkRectf &rect)
Set the size of the chart.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
Factory class for drawing 2D charts.
Definition: vtkChart.h:40
virtual void SetGeometry(int, int)
Set/get the width and the height of the chart.
takes care of drawing 2D axes
Definition: vtkAxis.h:60
int SelectedColumn
Index of the selected column in the visible columns list.
Definition: vtkChartBox.h:202
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:28
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:440
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
virtual vtkIdType GetNumberOfPlots()
Get the number of plots the chart contains.
float SelectedColumnDelta
Index of the selected column in the visible columns list.
Definition: vtkChartBox.h:203
Abstract class for 2D plots.
Definition: vtkPlot.h:43
Class for drawing box plots.
Definition: vtkPlotBox.h:29
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTimeStamp BuildTime
The point cache is marked dirty until it has been initialized.
Definition: vtkChartBox.h:209
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
virtual vtkPlot * GetPlot(vtkIdType index)
Get the plot at the specified index, returns null if the index is invalid.
takes care of drawing 2D axes
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkVector2i ScreenPosition
Definition: vtkChartBox.h:246
vtkSmartPointer< vtkTooltipItem > Tooltip
The tooltip item for the chart - can be used to display extra information.
Definition: vtkChartBox.h:214
virtual void Update()
Perform any updates to the item that may be necessary before rendering.
Factory class for drawing box plot charts.
Definition: vtkChartBox.h:28
Private * Storage
Definition: vtkChartBox.h:182