Point Cloud Library (PCL)  1.11.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 }
pcl::visualization::context_items::Points::set
void set(const std::vector< float > &_xy)
Definition: pcl_context_item.h:139
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl::visualization::context_items::Line
Definition: pcl_context_item.h:96
pcl::visualization::context_items::Text::text
std::string text
Definition: pcl_context_item.h:155
pcl
Definition: convolution.h:46
pcl::visualization::context_items::Rectangle
Definition: pcl_context_item.h:119
pcl::visualization::PCLContextImageItem::image
vtkSmartPointer< vtkImageData > image
Definition: pcl_context_item.h:82
pcl::visualization::context_items::Polygon
Definition: pcl_context_item.h:142
pcl::visualization::context_items::Point
Definition: pcl_context_item.h:88
pcl::visualization::context_items::Disk
Definition: pcl_context_item.h:112
pcl::visualization::context_items::FilledRectangle
Definition: pcl_context_item.h:127
pcl::visualization::PCLContextItem::params
std::vector< float > params
Definition: pcl_context_item.h:66
pcl::visualization::PCLContextItem
Struct PCLContextItem represents our own custom version of vtkContextItem, used by the ImageViewer cl...
Definition: pcl_context_item.h:57
pcl::visualization::PCLContextItem::setOpacity
void setOpacity(double opacity)
Definition: pcl_context_item.h:64
pcl::visualization::PCLContextItem::Paint
bool Paint(vtkContext2D *) override
Definition: pcl_context_item.h:61
pcl::visualization::context_items::Points
Definition: pcl_context_item.h:134
pcl::visualization::PCLContextImageItem
Struct PCLContextImageItem a specification of vtkContextItem, used to add an image to the scene in th...
Definition: pcl_context_item.h:74
pcl::visualization::PCLContextItem::setColors
void setColors(unsigned char rgb[3])
Definition: pcl_context_item.h:63
pcl::visualization::context_items::Markers
Definition: pcl_context_item.h:158
pcl::visualization::PCLContextImageItem::y
float y
Definition: pcl_context_item.h:83
pcl::visualization::context_items::Markers::setSize
void setSize(float _size)
Definition: pcl_context_item.h:163
pcl::visualization::context_items::Text
Definition: pcl_context_item.h:149
pcl::visualization::context_items::Markers::size
float size
Definition: pcl_context_item.h:166
pcl::visualization::context_items::Circle
Definition: pcl_context_item.h:104
PCL_EXPORTS
#define PCL_EXPORTS
Definition: pcl_macros.h:323
vtkSmartPointer
Definition: actor_map.h:49