VTK  9.3.20240424
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
28VTK_ABI_NAMESPACE_BEGIN
29class vtkContext2D;
30class vtkTextProperty;
31class vtkBrush;
32class vtkPen;
33
34class VTKRENDERINGCONTEXT2D_EXPORT vtkBlockItem : public vtkContextItem
35{
36public:
38 void PrintSelf(ostream& os, vtkIndent indent) override;
39
40 static vtkBlockItem* New();
41
45 bool Paint(vtkContext2D* painter) override;
46
50 bool Hit(const vtkContextMouseEvent& mouse) override;
51
55 bool MouseEnterEvent(const vtkContextMouseEvent& mouse) override;
56
60 bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
61
65 bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) override;
66
70 bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
71
75 bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
76
80 virtual void SetLabel(const vtkStdString& label);
81
86
88
94 vtkSetVector4Macro(Dimensions, float);
96
98
104 vtkGetVector4Macro(Dimensions, float);
106
108
115 vtkSetMacro(AutoComputeDimensions, bool);
116 vtkGetMacro(AutoComputeDimensions, bool);
117 vtkBooleanMacro(AutoComputeDimensions, bool);
119
120 enum
121 {
122 LEFT = 0,
127 CUSTOM
128 };
129
131
135 vtkSetMacro(HorizontalAlignment, int);
136 vtkGetMacro(HorizontalAlignment, int);
138
140
144 vtkSetMacro(VerticalAlignment, int);
145 vtkGetMacro(VerticalAlignment, int);
147
149
155 vtkSetVector2Macro(Padding, int);
156 vtkGetVector2Macro(Padding, int);
158
160
165 vtkSetVector2Macro(Margins, int);
166 vtkGetVector2Macro(Margins, int);
168
170
173 vtkGetObjectMacro(Pen, vtkPen);
175
177
180 vtkGetObjectMacro(Brush, vtkBrush);
182
184
188 vtkGetObjectMacro(MouseOverBrush, vtkBrush);
190
192
197 vtkGetObjectMacro(LabelProperties, vtkTextProperty);
199
200 void SetScalarFunctor(double (*scalarFunction)(double, double));
201
202protected:
204 ~vtkBlockItem() override;
205
206 float Dimensions[4];
207
209
211
212 // Some function pointers to optionally do funky things...
213 double (*scalarFunction)(double, double);
214
215private:
216 vtkBlockItem(const vtkBlockItem&) = delete;
217 void operator=(const vtkBlockItem&) = delete;
218
219 vtkTextProperty* LabelProperties;
220 vtkNew<vtkTextProperty> CachedTextProp;
221
222 vtkNew<vtkPen> Pen;
223 vtkNew<vtkPen> CachedPen;
224
225 vtkNew<vtkBrush> Brush;
226 vtkNew<vtkBrush> MouseOverBrush;
227 vtkNew<vtkBrush> CachedBrush;
228
229 int HorizontalAlignment;
230 int VerticalAlignment;
231 bool AutoComputeDimensions;
232 int Padding[2];
233 int Margins[2];
234};
235
236VTK_ABI_NAMESPACE_END
237#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:89
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:160
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition vtkPen.h:78
Wrapper around std::string to keep symbols short.
represent text properties.