VTK  9.4.20241113
vtkBlockItem.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
20#ifndef vtkBlockItem_h
21#define vtkBlockItem_h
22
23#include "vtkContextItem.h"
24#include "vtkNew.h" // For vtkNew
25#include "vtkRenderingContext2DModule.h" // For export macro
26#include "vtkStdString.h" // For vtkStdString ivars
27#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
28
29VTK_ABI_NAMESPACE_BEGIN
30class vtkContext2D;
31class vtkTextProperty;
32class vtkBrush;
33class vtkPen;
34
35class VTKRENDERINGCONTEXT2D_EXPORT VTK_MARSHALAUTO vtkBlockItem : public vtkContextItem
36{
37public:
39 void PrintSelf(ostream& os, vtkIndent indent) override;
40
41 static vtkBlockItem* New();
42
46 bool Paint(vtkContext2D* painter) override;
47
51 bool Hit(const vtkContextMouseEvent& mouse) override;
52
56 bool MouseEnterEvent(const vtkContextMouseEvent& mouse) override;
57
61 bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
62
66 bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) override;
67
71 bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
72
76 bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
77
81 virtual void SetLabel(const vtkStdString& label);
82
87
89
95 vtkSetVector4Macro(Dimensions, float);
97
99
105 vtkGetVector4Macro(Dimensions, float);
107
109
116 vtkSetMacro(AutoComputeDimensions, bool);
117 vtkGetMacro(AutoComputeDimensions, bool);
118 vtkBooleanMacro(AutoComputeDimensions, bool);
120
121 enum
122 {
123 LEFT = 0,
128 CUSTOM
129 };
130
132
136 vtkSetMacro(HorizontalAlignment, int);
137 vtkGetMacro(HorizontalAlignment, int);
139
141
145 vtkSetMacro(VerticalAlignment, int);
146 vtkGetMacro(VerticalAlignment, int);
148
150
156 vtkSetVector2Macro(Padding, int);
157 vtkGetVector2Macro(Padding, int);
159
161
166 vtkSetVector2Macro(Margins, int);
167 vtkGetVector2Macro(Margins, int);
169
171
174 vtkGetObjectMacro(Pen, vtkPen);
176
178
181 vtkGetObjectMacro(Brush, vtkBrush);
183
185
189 vtkGetObjectMacro(MouseOverBrush, vtkBrush);
191
193
198 vtkGetObjectMacro(LabelProperties, vtkTextProperty);
200
201 void SetScalarFunctor(double (*scalarFunction)(double, double));
202
203protected:
205 ~vtkBlockItem() override;
206
207 float Dimensions[4];
208
210
212
213 // Some function pointers to optionally do funky things...
214 double (*scalarFunction)(double, double);
215
216private:
217 vtkBlockItem(const vtkBlockItem&) = delete;
218 void operator=(const vtkBlockItem&) = delete;
219
220 vtkTextProperty* LabelProperties;
221 vtkNew<vtkTextProperty> CachedTextProp;
222
223 vtkNew<vtkPen> Pen;
224 vtkNew<vtkPen> CachedPen;
225
226 vtkNew<vtkBrush> Brush;
227 vtkNew<vtkBrush> MouseOverBrush;
228 vtkNew<vtkBrush> CachedBrush;
229
230 int HorizontalAlignment;
231 int VerticalAlignment;
232 bool AutoComputeDimensions;
233 int Padding[2];
234 int Margins[2];
235};
236
237VTK_ABI_NAMESPACE_END
238#endif // vtkBlockItem_h
a vtkContextItem that draws a block (optional label).
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
vtkStdString Label
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual vtkStdString GetLabel()
Get the block label.
bool MouseEnterEvent(const vtkContextMouseEvent &mouse) override
Mouse enter event.
void SetScalarFunctor(double(*scalarFunction)(double, double))
virtual void SetLabel(const vtkStdString &label)
Set the block label.
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override
Mouse button release event.
bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override
Mouse button down event.
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the supplied x, y coordinate is inside the item.
~vtkBlockItem() override
bool MouseLeaveEvent(const vtkContextMouseEvent &mouse) override
Mouse leave event.
bool Paint(vtkContext2D *painter) override
Paint event for the item.
void SetLabelProperties(vtkTextProperty *)
Provides access to the vtkTextProperty object that controls the way the label is rendered.
static vtkBlockItem * New()
provides a brush that fills shapes drawn by vtkContext2D.
Definition vtkBrush.h:90
Class for drawing 2D primitives to a graphical context.
base class for items that are part of a vtkContextScene.
data structure to represent mouse events.
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:167
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition vtkPen.h:79
Wrapper around std::string to keep symbols short.
represent text properties.
#define VTK_MARSHALAUTO