Point Cloud Library (PCL)  1.8.1
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 #ifndef PCL_VISUALIZATION_PCL_CONTEXT_ITEM_H_
39 #define PCL_VISUALIZATION_PCL_CONTEXT_ITEM_H_
40 
41 #include <pcl/pcl_macros.h>
42 #include <vtkContextItem.h>
43 #include <vector>
44 
45 template <typename T> class vtkSmartPointer;
46 class vtkImageData;
47 class vtkContext2D;
48 
49 namespace pcl
50 {
51  namespace visualization
52  {
53  /** Struct PCLContextItem represents our own custom version of vtkContextItem, used by
54  * the ImageViewer class.
55  *
56  * \author Nizar Sallem
57  */
58  struct PCL_EXPORTS PCLContextItem : public vtkContextItem
59  {
60  vtkTypeMacro (PCLContextItem, vtkContextItem);
61  static PCLContextItem *New();
62  virtual bool Paint (vtkContext2D *) { return (false); };
63  void setColors (unsigned char r, unsigned char g, unsigned char b);
64  void setColors (unsigned char rgb[3]) { memcpy (colors, rgb, 3 * sizeof (unsigned char)); }
65  void setOpacity (double opacity) { SetOpacity (opacity); };
66  unsigned char colors[3];
67  std::vector<float> params;
68  };
69 
70  /** Struct PCLContextImageItem a specification of vtkContextItem, used to add an image to the
71  * scene in the ImageViewer class.
72  *
73  * \author Nizar Sallem
74  */
75  struct PCL_EXPORTS PCLContextImageItem : public vtkContextItem
76  {
77  vtkTypeMacro (PCLContextImageItem, vtkContextItem);
79 
80  static PCLContextImageItem *New ();
81  virtual bool Paint (vtkContext2D *painter);
82  void set (float _x, float _y, vtkImageData *_image);
84  float x, y;
85  };
86 
87  namespace context_items
88  {
89  struct PCL_EXPORTS Point : public PCLContextItem
90  {
91  vtkTypeMacro (Point, PCLContextItem);
92  static Point *New();
93  virtual bool Paint (vtkContext2D *painter);
94  virtual void set (float _x, float _y);
95  };
96 
97  struct PCL_EXPORTS Line : public PCLContextItem
98  {
99  vtkTypeMacro (Line, PCLContextItem);
100  static Line *New();
101  virtual bool Paint (vtkContext2D *painter);
102  virtual void set (float _x_1, float _y_1, float _x_2, float _y_2);
103  };
104 
105  struct PCL_EXPORTS Circle : public PCLContextItem
106  {
107  vtkTypeMacro (Circle, PCLContextItem);
108  static Circle *New();
109  virtual bool Paint (vtkContext2D *painter);
110  virtual void set (float _x, float _y, float _r);
111  };
112 
113  struct PCL_EXPORTS Disk : public Circle
114  {
115  vtkTypeMacro (Disk, Circle);
116  static Disk *New();
117  virtual bool Paint (vtkContext2D *painter);
118  };
119 
120  struct PCL_EXPORTS Rectangle : public PCLContextItem
121  {
122  vtkTypeMacro (Rectangle, Point);
123  static Rectangle *New();
124  virtual bool Paint (vtkContext2D *painter);
125  virtual void set (float _x, float _y, float _w, float _h);
126  };
127 
128  struct PCL_EXPORTS FilledRectangle : public Rectangle
129  {
130  vtkTypeMacro (FilledRectangle, Rectangle);
131  static FilledRectangle *New();
132  virtual bool Paint (vtkContext2D *painter);
133  };
134 
135  struct PCL_EXPORTS Points : public PCLContextItem
136  {
137  vtkTypeMacro (Points, PCLContextItem);
138  static Points *New();
139  virtual bool Paint (vtkContext2D *painter);
140  void set (const std::vector<float>& _xy) { params = _xy; }
141  };
142 
143  struct PCL_EXPORTS Polygon : public Points
144  {
145  vtkTypeMacro (Polygon, Points);
146  static Polygon *New();
147  virtual bool Paint (vtkContext2D *painter);
148  };
149 
150  struct PCL_EXPORTS Text : public PCLContextItem
151  {
152  vtkTypeMacro (Text, PCLContextItem);
153  static Text *New ();
154  virtual bool Paint (vtkContext2D *painter);
155  virtual void set (float x, float y, const std::string& _text);
156  std::string text;
157  };
158 
159  struct PCL_EXPORTS Markers : public Points
160  {
161  vtkTypeMacro (Markers, Points);
162  static Markers *New ();
163  virtual bool Paint (vtkContext2D *painter);
164  void setSize (float _size) { size = _size; }
165  void setPointColors (unsigned char r, unsigned char g, unsigned char b);
166  void setPointColors (unsigned char rgb[3]);
167  float size;
168  unsigned char point_colors[3];
169  };
170  }
171  }
172 }
173 
174 #endif
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...
virtual bool Paint(vtkContext2D *)
void setColors(unsigned char rgb[3])
vtkSmartPointer< vtkImageData > image