VTK  9.2.5
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 
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 
208  vtkGetObjectMacro(LabelProperties, vtkTextProperty);
210 
211  void SetScalarFunctor(double (*scalarFunction)(double, double));
212 
213 protected:
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
a vtkContextItem that draws a block (optional label).
Definition: vtkBlockItem.h:46
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
vtkStdString Label
Definition: vtkBlockItem.h:219
static vtkBlockItem * New()
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.
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:100
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:77
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:119
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:139
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:108
represent text properties.