Point Cloud Library (PCL)  1.7.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  double opacity;
68  std::vector<float> params;
69  };
70 
71  /** Struct PCLContextImageItem a specification of vtkContextItem, used to add an image to the
72  * scene in the ImageViewer class.
73  *
74  * \author Nizar Sallem
75  */
76  struct PCL_EXPORTS PCLContextImageItem : public vtkContextItem
77  {
78  vtkTypeMacro (PCLContextImageItem, vtkContextItem);
80 
81  static PCLContextImageItem *New ();
82  virtual bool Paint (vtkContext2D *painter);
83  void set (float _x, float _y, vtkImageData *_image);
85  float x, y;
86  };
87 
88  namespace context_items
89  {
90  struct PCL_EXPORTS Point : public PCLContextItem
91  {
92  vtkTypeMacro (Point, PCLContextItem);
93  static Point *New();
94  virtual bool Paint (vtkContext2D *painter);
95  virtual void set (float _x, float _y);
96  };
97 
98  struct PCL_EXPORTS Line : public PCLContextItem
99  {
100  vtkTypeMacro (Line, PCLContextItem);
101  static Line *New();
102  virtual bool Paint (vtkContext2D *painter);
103  virtual void set (float _x_1, float _y_1, float _x_2, float _y_2);
104  };
105 
106  struct PCL_EXPORTS Circle : public PCLContextItem
107  {
108  vtkTypeMacro (Circle, PCLContextItem);
109  static Circle *New();
110  virtual bool Paint (vtkContext2D *painter);
111  virtual void set (float _x, float _y, float _r);
112  };
113 
114  struct PCL_EXPORTS Disk : public Circle
115  {
116  vtkTypeMacro (Disk, Circle);
117  static Disk *New();
118  virtual bool Paint (vtkContext2D *painter);
119  };
120 
121  struct PCL_EXPORTS Rectangle : public PCLContextItem
122  {
123  vtkTypeMacro (Rectangle, Point);
124  static Rectangle *New();
125  virtual bool Paint (vtkContext2D *painter);
126  virtual void set (float _x, float _y, float _w, float _h);
127  };
128 
129  struct PCL_EXPORTS FilledRectangle : public Rectangle
130  {
131  vtkTypeMacro (FilledRectangle, Rectangle);
132  static FilledRectangle *New();
133  virtual bool Paint (vtkContext2D *painter);
134  };
135 
136  struct PCL_EXPORTS Points : public PCLContextItem
137  {
138  vtkTypeMacro (Points, PCLContextItem);
139  static Points *New();
140  virtual bool Paint (vtkContext2D *painter);
141  void set (const std::vector<float>& _xy) { params = _xy; }
142  };
143 
144  struct PCL_EXPORTS Polygon : public Points
145  {
146  vtkTypeMacro (Polygon, Points);
147  static Polygon *New();
148  virtual bool Paint (vtkContext2D *painter);
149  };
150  }
151  }
152 }
153 
154 #endif