VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
21 
22 VTK_ABI_NAMESPACE_BEGIN
23 class vtkIdTypeArray;
24 class vtkPlotBox;
25 class vtkStdString;
26 class vtkStringArray;
27 class vtkTooltipItem;
28 
29 class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkChartBox : public vtkChart
30 {
31 public:
32  vtkTypeMacro(vtkChartBox, vtkChart);
33  void PrintSelf(ostream& os, vtkIndent indent) override;
34 
38  static vtkChartBox* New();
39 
45  void Update() override;
46 
50  bool Paint(vtkContext2D* painter) override;
51 
53 
56  void SetColumnVisibility(const vtkStdString& name, bool visible);
57  void SetColumnVisibility(vtkIdType column, bool visible);
59 
64  void SetColumnVisibilityAll(bool visible);
65 
67 
70  bool GetColumnVisibility(const vtkStdString& name);
71  bool GetColumnVisibility(vtkIdType column);
73 
77  vtkIdType GetColumnId(const vtkStdString& name);
78 
80 
83  vtkGetObjectMacro(VisibleColumns, vtkStringArray);
85 
86  // Index of the selected column in the visible columns list.
87  vtkGetMacro(SelectedColumn, int);
88  vtkSetMacro(SelectedColumn, int);
89 
93  vtkPlot* GetPlot(vtkIdType index) override;
94 
98  vtkIdType GetNumberOfPlots() override;
99 
103  virtual vtkAxis* GetYAxis();
104 
108  virtual float GetXPosition(int index);
109 
113  virtual vtkIdType GetNumberOfVisibleColumns();
114 
119  virtual void SetPlot(vtkPlotBox* plot);
120 
124  bool Hit(const vtkContextMouseEvent& mouse) override;
125 
129  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
130 
134  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
135 
139  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
140 
144  virtual void SetTooltip(vtkTooltipItem* tooltip);
145 
149  virtual vtkTooltipItem* GetTooltip();
150 
154  virtual void SetTooltipInfo(const vtkContextMouseEvent&, const vtkVector2d&, vtkIdType, vtkPlot*,
155  vtkIdType segmentIndex = -1);
156 
161  void SetSize(const vtkRectf& rect) override;
162 
167  void SetGeometry(int arg1, int arg2) override;
168 
173  void SetLayoutStrategy(int strategy) override;
174 
175 protected:
176  vtkChartBox();
177  ~vtkChartBox() override;
178 
180 
183  class Private;
184  Private* Storage;
186 
188 
193 
198 
200 
206 
211 
216 
217  void ResetSelection();
218  void UpdateGeometry(vtkContext2D*);
219  void CalculatePlotTransform();
220  void SwapAxes(int a1, int a2);
221 
227  bool LocatePointInPlots(const vtkContextMouseEvent& mouse, int invokeEvent = -1);
228 
229  int LocatePointInPlot(const vtkVector2f& position, const vtkVector2f& tolerance,
230  vtkVector2f& plotPos, vtkPlot* plot, vtkIdType& segmentId);
231 
232 private:
233  vtkChartBox(const vtkChartBox&) = delete;
234  void operator=(const vtkChartBox&) = delete;
235 };
236 
238 
244 {
248  int Index;
249 };
251 
252 VTK_ABI_NAMESPACE_END
253 #endif // vtkChartBox_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:27
Small struct used by InvokeEvent to send some information about the point that was clicked on...
Definition: vtkChartBox.h:243
vtkIdTypeArray * Selection
Selected indices for the table the plot is rendering.
Definition: vtkChartBox.h:192
vtkStringArray * VisibleColumns
A list of the visible columns in the chart.
Definition: vtkChartBox.h:197
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:245
vtkVector2f Position
Definition: vtkChartBox.h:246
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:363
virtual void SetLayoutStrategy(int)
Set/get the layout strategy that should be used by the chart.
bool GeometryValid
Definition: vtkChartBox.h:187
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:41
virtual void SetGeometry(int, int)
Set/get the width and the height of the chart.
takes care of drawing 2D axes
Definition: vtkAxis.h:61
int SelectedColumn
Index of the selected column in the visible columns list.
Definition: vtkChartBox.h:203
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:410
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:204
Abstract class for 2D plots.
Definition: vtkPlot.h:43
Class for drawing box plots.
Definition: vtkPlotBox.h:30
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:210
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.
#define VTK_MARSHALAUTO
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:247
vtkSmartPointer< vtkTooltipItem > Tooltip
The tooltip item for the chart - can be used to display extra information.
Definition: vtkChartBox.h:215
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:29
Private * Storage
Definition: vtkChartBox.h:183