VTK  9.0.20200928
vtkBlockItem.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkBlockItem.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
29 #ifndef vtkBlockItem_h
30 #define vtkBlockItem_h
31 
32 #include "vtkContextItem.h"
33 #include "vtkNew.h" // For vtkNew
34 #include "vtkRenderingContext2DModule.h" // For export macro
35 #include "vtkStdString.h" // For vtkStdString ivars
36 
37 class vtkContext2D;
38 class vtkTextProperty;
39 class vtkBrush;
40 class vtkPen;
41 
42 class VTKRENDERINGCONTEXT2D_EXPORT vtkBlockItem : public vtkContextItem
43 {
44 public:
45  vtkTypeMacro(vtkBlockItem, vtkContextItem);
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
48  static vtkBlockItem* New();
49 
53  bool Paint(vtkContext2D* painter) override;
54 
58  bool Hit(const vtkContextMouseEvent& mouse) override;
59 
63  bool MouseEnterEvent(const vtkContextMouseEvent& mouse) override;
64 
68  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
69 
73  bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) override;
74 
78  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
79 
83  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
84 
88  virtual void SetLabel(const vtkStdString& label);
89 
93  virtual vtkStdString GetLabel();
94 
96 
102  vtkSetVector4Macro(Dimensions, float);
104 
106 
112  vtkGetVector4Macro(Dimensions, float);
114 
116 
123  vtkSetMacro(AutoComputeDimensions, bool);
124  vtkGetMacro(AutoComputeDimensions, bool);
125  vtkBooleanMacro(AutoComputeDimensions, bool);
127 
128  enum
129  {
130  LEFT = 0,
135  CUSTOM
136  };
137 
139 
143  vtkSetMacro(HorizontalAlignment, int);
144  vtkGetMacro(HorizontalAlignment, int);
146 
148 
152  vtkSetMacro(VerticalAlignment, int);
153  vtkGetMacro(VerticalAlignment, int);
155 
157 
163  vtkSetVector2Macro(Padding, int);
164  vtkGetVector2Macro(Padding, int);
166 
168 
173  vtkSetVector2Macro(Margins, int);
174  vtkGetVector2Macro(Margins, int);
176 
178 
181  vtkGetObjectMacro(Pen, vtkPen);
183 
185 
188  vtkGetObjectMacro(Brush, vtkBrush);
190 
192 
196  vtkGetObjectMacro(MouseOverBrush, vtkBrush);
198 
200 
204  void SetLabelProperties(vtkTextProperty*);
205  vtkGetObjectMacro(LabelProperties, vtkTextProperty);
207 
208  void SetScalarFunctor(double (*scalarFunction)(double, double));
209 
210 protected:
211  vtkBlockItem();
212  ~vtkBlockItem() override;
213 
214  float Dimensions[4];
215 
217 
218  bool MouseOver;
219 
220  // Some function pointers to optionally do funky things...
221  double (*scalarFunction)(double, double);
222 
223 private:
224  vtkBlockItem(const vtkBlockItem&) = delete;
225  void operator=(const vtkBlockItem&) = delete;
226 
227  vtkTextProperty* LabelProperties;
228  vtkNew<vtkTextProperty> CachedTextProp;
229 
230  vtkNew<vtkPen> Pen;
231  vtkNew<vtkPen> CachedPen;
232 
233  vtkNew<vtkBrush> Brush;
234  vtkNew<vtkBrush> MouseOverBrush;
235  vtkNew<vtkBrush> CachedBrush;
236 
237  int HorizontalAlignment;
238  int VerticalAlignment;
239  bool AutoComputeDimensions;
240  int Padding[2];
241  int Margins[2];
242 };
243 
244 #endif // vtkBlockItem_h
vtkBrush
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:37
vtkStdString.h
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:34
vtkBlockItem::RIGHT
Definition: vtkBlockItem.h:132
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
vtkContextItem.h
vtkBlockItem::CENTER
Definition: vtkBlockItem.h:131
vtkBlockItem::TOP
Definition: vtkBlockItem.h:133
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkAbstractContextItem::Hit
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
vtkNew< vtkTextProperty >
vtkContextItem::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkBlockItem::MouseOver
bool MouseOver
Definition: vtkBlockItem.h:218
vtkAbstractContextItem::MouseMoveEvent
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
vtkAbstractContextItem::MouseButtonReleaseEvent
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:33
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:31
vtkNew.h
vtkAbstractContextItem::Paint
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
vtkBlockItem::Label
vtkStdString Label
Definition: vtkBlockItem.h:216
vtkAbstractContextItem::MouseEnterEvent
virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse)
Mouse enter event.
vtkAbstractContextItem::MouseLeaveEvent
virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse)
Mouse leave event.
vtkAbstractContextItem::MouseButtonPressEvent
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...
vtkPen
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:36
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:34
vtkBlockItem::BOTTOM
Definition: vtkBlockItem.h:134
vtkBlockItem
a vtkContextItem that draws a block (optional label).
Definition: vtkBlockItem.h:42