Point Cloud Library (PCL)  1.9.1-dev
pcl_context_item.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012-, Open Perception, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #pragma once
39 
40 #include <pcl/pcl_macros.h>
41 #include <vtkContextItem.h>
42 #include <vector>
43 
44 template <typename T> class vtkSmartPointer;
45 class vtkImageData;
46 class vtkContext2D;
47 
48 namespace pcl
49 {
50  namespace visualization
51  {
52  /** Struct PCLContextItem represents our own custom version of vtkContextItem, used by
53  * the ImageViewer class.
54  *
55  * \author Nizar Sallem
56  */
57  struct PCL_EXPORTS PCLContextItem : public vtkContextItem
58  {
59  vtkTypeMacro (PCLContextItem, vtkContextItem);
60  static PCLContextItem *New();
61  bool Paint (vtkContext2D *) override { return (false); };
62  void setColors (unsigned char r, unsigned char g, unsigned char b);
63  void setColors (unsigned char rgb[3]) { memcpy (colors, rgb, 3 * sizeof (unsigned char)); }
64  void setOpacity (double opacity) { SetOpacity (opacity); };
65  unsigned char colors[3];
66  std::vector<float> params;
67  };
68 
69  /** Struct PCLContextImageItem a specification of vtkContextItem, used to add an image to the
70  * scene in the ImageViewer class.
71  *
72  * \author Nizar Sallem
73  */
74  struct PCL_EXPORTS PCLContextImageItem : public vtkContextItem
75  {
76  vtkTypeMacro (PCLContextImageItem, vtkContextItem);
78 
79  static PCLContextImageItem *New ();
80  bool Paint (vtkContext2D *painter) override;
81  void set (float _x, float _y, vtkImageData *_image);
83  float x, y;
84  };
85 
86  namespace context_items
87  {
89  {
90  vtkTypeMacro (Point, PCLContextItem);
91  static Point *New();
92  bool Paint (vtkContext2D *painter) override;
93  virtual void set (float _x, float _y);
94  };
95 
97  {
98  vtkTypeMacro (Line, PCLContextItem);
99  static Line *New();
100  bool Paint (vtkContext2D *painter) override;
101  virtual void set (float _x_1, float _y_1, float _x_2, float _y_2);
102  };
103 
105  {
106  vtkTypeMacro (Circle, PCLContextItem);
107  static Circle *New();
108  bool Paint (vtkContext2D *painter) override;
109  virtual void set (float _x, float _y, float _r);
110  };
111 
112  struct PCL_EXPORTS Disk : public Circle
113  {
114  vtkTypeMacro (Disk, Circle);
115  static Disk *New();
116  bool Paint (vtkContext2D *painter) override;
117  };
118 
120  {
121  vtkTypeMacro (Rectangle, Point);
122  static Rectangle *New();
123  bool Paint (vtkContext2D *painter) override;
124  virtual void set (float _x, float _y, float _w, float _h);
125  };
126 
128  {
129  vtkTypeMacro (FilledRectangle, Rectangle);
130  static FilledRectangle *New();
131  bool Paint (vtkContext2D *painter) override;
132  };
133 
135  {
136  vtkTypeMacro (Points, PCLContextItem);
137  static Points *New();
138  bool Paint (vtkContext2D *painter) override;
139  void set (const std::vector<float>& _xy) { params = _xy; }
140  };
141 
142  struct PCL_EXPORTS Polygon : public Points
143  {
144  vtkTypeMacro (Polygon, Points);
145  static Polygon *New();
146  bool Paint (vtkContext2D *painter) override;
147  };
148 
150  {
151  vtkTypeMacro (Text, PCLContextItem);
152  static Text *New ();
153  bool Paint (vtkContext2D *painter) override;
154  virtual void set (float x, float y, const std::string& _text);
155  std::string text;
156  };
157 
158  struct PCL_EXPORTS Markers : public Points
159  {
160  vtkTypeMacro (Markers, Points);
161  static Markers *New ();
162  bool Paint (vtkContext2D *painter) override;
163  void setSize (float _size) { size = _size; }
164  void setPointColors (unsigned char r, unsigned char g, unsigned char b);
165  void setPointColors (unsigned char rgb[3]);
166  float size;
167  unsigned char point_colors[3];
168  };
169  }
170  }
171 }
Struct PCLContextItem represents our own custom version of vtkContextItem, used by the ImageViewer cl...
Struct PCLContextImageItem a specification of vtkContextItem, used to add an image to the scene in th...
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
void setColors(unsigned char rgb[3])
bool Paint(vtkContext2D *) override
vtkSmartPointer< vtkImageData > image
#define PCL_EXPORTS
Definition: pcl_macros.h:226
Defines all the PCL and non-PCL macros used.