VTK  9.7.1
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 
29 VTK_ABI_NAMESPACE_BEGIN
30 class vtkContext2D;
31 class vtkTextProperty;
32 class vtkBrush;
33 class vtkPen;
34 
35 class VTKRENDERINGCONTEXT2D_EXPORT VTK_MARSHALAUTO vtkBlockItem : public vtkContextItem
36 {
37 public:
38  vtkTypeMacro(vtkBlockItem, vtkContextItem);
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 
86  virtual vtkStdString GetLabel();
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 
197  void SetLabelProperties(vtkTextProperty*);
198  vtkGetObjectMacro(LabelProperties, vtkTextProperty);
200 
201  void SetScalarFunctor(double (*scalarFunction)(double, double));
202 
203 protected:
204  vtkBlockItem();
205  ~vtkBlockItem() override;
206 
207  float Dimensions[4];
208 
210 
211  bool MouseOver;
212 
213  // Some function pointers to optionally do funky things...
214  double (*scalarFunction)(double, double);
215 
216 private:
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 
237 VTK_ABI_NAMESPACE_END
238 #endif // vtkBlockItem_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:27
base class for items that are part of a vtkContextScene.
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...
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
a vtkContextItem that draws a block (optional label).
Definition: vtkBlockItem.h:35
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
vtkStdString Label
Definition: vtkBlockItem.h:209
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:30
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:28
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:29
represent text properties.
virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse)
Mouse enter event.
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.
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse)
Mouse leave event.