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