overlay_camera_display.h
Go to the documentation of this file.
1 // -*- mode: c++; -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 #ifndef JSK_RVIZ_PLUGINS_OVERLAY_CAMERA_DISPLAY_H_
37 #define JSK_RVIZ_PLUGINS_OVERLAY_CAMERA_DISPLAY_H_
38 
40 
41 #ifndef Q_MOC_RUN
42 #include <QObject>
43 
44 #include <OgreMaterial.h>
45 #include <OgreRenderTargetListener.h>
46 #include <OgreSharedPtr.h>
47 
48 # include <sensor_msgs/CameraInfo.h>
49 
51 #if ROS_VERSION_MINIMUM(1, 15, 0) // noetic and greater
52 # include <tf2_ros/message_filter.h>
53 #else
54 # include <tf/message_filter.h>
55 #endif
56 
59 # include "rviz/render_panel.h"
60 
61 #include "overlay_utils.h"
62 #endif
63 
64 namespace Ogre
65 {
66 class SceneNode;
67 class ManualObject;
68 class Rectangle2D;
69 class Camera;
70 }
71 
72 namespace rviz
73 {
74 
75 class EnumProperty;
76 class FloatProperty;
77 class IntProperty;
78 class RenderPanel;
79 class RosTopicProperty;
80 class DisplayGroupVisibilityProperty;
81 }
86 namespace jsk_rviz_plugins
87 {
88 using namespace rviz;
89 class OverlayCameraDisplay: public rviz::ImageDisplayBase, public Ogre::RenderTargetListener
90 {
91 Q_OBJECT
92 public:
94  virtual ~OverlayCameraDisplay();
95 
96  // Overrides from Display
97  virtual void onInitialize();
98  virtual void fixedFrameChanged();
99  virtual void update( float wall_dt, float ros_dt );
100  virtual void reset();
101 
102  // Overrides from Ogre::RenderTargetListener
103  virtual void preRenderTargetUpdate( const Ogre::RenderTargetEvent& evt );
104  virtual void postRenderTargetUpdate( const Ogre::RenderTargetEvent& evt );
105 
106  static const QString BACKGROUND;
107  static const QString OVERLAY;
108  static const QString BOTH;
109 
110 protected:
111  // overrides from Display
112  virtual void onEnable();
113  virtual void onDisable();
114 
117 
118 private Q_SLOTS:
119  void forceRender();
120  void updateAlpha();
121 
122  virtual void updateQueueSize();
123 
124 private:
125  void subscribe();
126  void unsubscribe();
127 
128  virtual void processMessage(const sensor_msgs::Image::ConstPtr& msg);
129  void caminfoCallback( const sensor_msgs::CameraInfo::ConstPtr& msg );
130 
131  bool updateCamera();
132 
133  void clear();
134  void updateStatus();
135 
136  Ogre::SceneNode* bg_scene_node_;
137  Ogre::SceneNode* fg_scene_node_;
138 
139  Ogre::Rectangle2D* bg_screen_rect_;
140  Ogre::MaterialPtr bg_material_;
141 
142  Ogre::Rectangle2D* fg_screen_rect_;
143  Ogre::MaterialPtr fg_material_;
144 
146 #if ROS_VERSION_MINIMUM(1, 15, 0) // noetic and greater
148 #else
150 #endif
151 
156 
157  sensor_msgs::CameraInfo::ConstPtr current_caminfo_;
158  boost::mutex caminfo_mutex_;
159 
161 
163 
165 
166  uint32_t vis_bit_;
167 protected:
169  void redraw();
175  int width_, height_;
176  int left_, top_;
179 private Q_SLOTS:
180  void updateWidth();
181  void updateHeight();
182  void updateLeft();
183  void updateTop();
184  void updateTextureAlpha();
185 };
186 
187 }
188 
189 #endif
bool update(const T &new_val, T &my_val)
DisplayGroupVisibilityProperty * visibility_property_
void subscribe()
sensor_msgs::CameraInfo::ConstPtr current_caminfo_
message_filters::Subscriber< sensor_msgs::CameraInfo > caminfo_sub_
tf::MessageFilter< sensor_msgs::CameraInfo > * caminfo_tf_filter_
void unsubscribe()


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Thu Jun 1 2023 02:45:58