VTK  9.2.6
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 
32 #ifndef vtkBlockItem_h
33 #define vtkBlockItem_h
34 
35 #include "vtkContextItem.h"
36 #include "vtkNew.h" // For vtkNew
37 #include "vtkRenderingContext2DModule.h" // For export macro
38 #include "vtkStdString.h" // For vtkStdString ivars
39 
40 class vtkContext2D;
41 class vtkTextProperty;
42 class vtkBrush;
43 class vtkPen;
44 
45 class VTKRENDERINGCONTEXT2D_EXPORT vtkBlockItem : public vtkContextItem
46 {
47 public:
48  vtkTypeMacro(vtkBlockItem, vtkContextItem);
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
51  static vtkBlockItem* New();
52 
56  bool Paint(vtkContext2D* painter) override;
57 
61  bool Hit(const vtkContextMouseEvent& mouse) override;
62 
66  bool MouseEnterEvent(const vtkContextMouseEvent& mouse) override;
67 
71  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
72 
76  bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) override;
77 
81  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
82 
86  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
87 
91  virtual void SetLabel(const vtkStdString& label);
92 
96  virtual vtkStdString GetLabel();
97 
99 
105  vtkSetVector4Macro(Dimensions, float);
107 
109 
115  vtkGetVector4Macro(Dimensions, float);
117 
119 
126  vtkSetMacro(AutoComputeDimensions, bool);
127  vtkGetMacro(AutoComputeDimensions, bool);
128  vtkBooleanMacro(AutoComputeDimensions, bool);
130 
131  enum
132  {
133  LEFT = 0,
138  CUSTOM
139  };
140 
142 
146  vtkSetMacro(HorizontalAlignment, int);
147  vtkGetMacro(HorizontalAlignment, int);
149 
151 
155  vtkSetMacro(VerticalAlignment, int);
156  vtkGetMacro(VerticalAlignment, int);
158 
160 
166  vtkSetVector2Macro(Padding, int);
167  vtkGetVector2Macro(Padding, int);
169 
171 
176  vtkSetVector2Macro(Margins, int);
177  vtkGetVector2Macro(Margins, int);
179 
181 
184  vtkGetObjectMacro(Pen, vtkPen);
186 
188 
191  vtkGetObjectMacro(Brush, vtkBrush);
193 
195 
199  vtkGetObjectMacro(MouseOverBrush, vtkBrush);
201 
203 
207  void SetLabelProperties(vtkTextProperty*);
208  vtkGetObjectMacro(LabelProperties, vtkTextProperty);
210 
211  void SetScalarFunctor(double (*scalarFunction)(double, double));
212 
213 protected:
214  vtkBlockItem();
215  ~vtkBlockItem() override;
216 
217  float Dimensions[4];
218 
220 
221  bool MouseOver;
222 
223  // Some function pointers to optionally do funky things...
224  double (*scalarFunction)(double, double);
225 
226 private:
227  vtkBlockItem(const vtkBlockItem&) = delete;
228  void operator=(const vtkBlockItem&) = delete;
229 
230  vtkTextProperty* LabelProperties;
231  vtkNew<vtkTextProperty> CachedTextProp;
232 
233  vtkNew<vtkPen> Pen;
234  vtkNew<vtkPen> CachedPen;
235 
236  vtkNew<vtkBrush> Brush;
237  vtkNew<vtkBrush> MouseOverBrush;
238  vtkNew<vtkBrush> CachedBrush;
239 
240  int HorizontalAlignment;
241  int VerticalAlignment;
242  bool AutoComputeDimensions;
243  int Padding[2];
244  int Margins[2];
245 };
246 
247 #endif // vtkBlockItem_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
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:45
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
vtkStdString Label
Definition: vtkBlockItem.h:219
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:40
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:39
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:39
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.
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.