render_panel.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef RVIZ_RENDER_PANEL_H
31 #define RVIZ_RENDER_PANEL_H
32 
34 
35 #ifndef Q_MOC_RUN
36 #include <OgreSceneManager.h>
37 
38 #include <boost/thread/mutex.hpp>
39 #endif
40 
41 #include <vector>
42 #include <map>
43 
44 namespace Ogre
45 {
46 class Root;
47 class Camera;
48 class RaySceneQuery;
49 class ParticleSystem;
50 } // namespace Ogre
51 
52 namespace ros
53 {
54 class Node;
55 }
56 
57 class QMenu;
58 class QKeyEvent;
59 class PropertyTreeWidget;
60 
61 namespace rviz
62 {
63 class Display;
64 class DisplayContext;
65 class ViewController;
66 
74 class RenderPanel : public QtOgreRenderWindow, public Ogre::SceneManager::Listener
75 {
76  Q_OBJECT
77 public:
79  RenderPanel(QWidget* parent = nullptr);
80  ~RenderPanel() override;
81 
83  void initialize(Ogre::SceneManager* scene_manager, DisplayContext* manager);
84 
86  {
87  return context_;
88  }
89 
91  {
92  return view_controller_;
93  }
94 
97  void setViewController(ViewController* controller);
98 
101  void showContextMenu(boost::shared_ptr<QMenu> menu);
102 
104  bool contextMenuVisible();
105 
106  void sceneManagerDestroyed(Ogre::SceneManager* source) override;
107 
109  bool getFocusOnMouseMove() const;
110 
112  void setFocusOnMouseMove(bool enabled);
113 
114 protected:
115  // Override from QWidget
116  void contextMenuEvent(QContextMenuEvent* event) override;
117 
119  void onRenderWindowMouseEvents(QMouseEvent* event);
120 
121  // QWidget mouse events all get sent to onRenderWindowMouseEvents().
122  // QMouseEvent.type() distinguishes them later.
123  void mouseMoveEvent(QMouseEvent* event) override
124  {
125  onRenderWindowMouseEvents(event);
126  }
127  void mousePressEvent(QMouseEvent* event) override
128  {
129  onRenderWindowMouseEvents(event);
130  }
131  void mouseReleaseEvent(QMouseEvent* event) override
132  {
133  onRenderWindowMouseEvents(event);
134  }
135  void mouseDoubleClickEvent(QMouseEvent* event) override
136  {
137  onRenderWindowMouseEvents(event);
138  }
139 
140  void leaveEvent(QEvent* event) override;
141 
143  void wheelEvent(QWheelEvent* event) override;
144 
145  void keyPressEvent(QKeyEvent* event) override;
146 
147  // Mouse handling
148  int mouse_x_;
149  int mouse_y_;
151 
153  Ogre::SceneManager* scene_manager_;
154 
156 
158  boost::mutex context_menu_mutex_;
159 
161 
162  // Pointer to the Display which is using this render panel, or NULL
163  // if this does not belong to a Display.
165 
166 private Q_SLOTS:
167  // TODO(simonschmeisser) remove this in noetic
168  void sendMouseMoveEvent();
169  void onContextMenuHide();
170 
171 private:
172  // TODO(simonschmeisser) remove this in noetic
174  Ogre::Camera* default_camera_;
175 };
176 
177 } // namespace rviz
178 
179 #endif
DisplayContext * getManager()
Definition: render_panel.h:85
ViewController * view_controller_
Definition: render_panel.h:155
ViewController * getViewController()
Definition: render_panel.h:90
ROSCONSOLE_DECL void initialize()
void mouseReleaseEvent(QMouseEvent *event) override
Definition: render_panel.h:131
Ogre::SceneManager * scene_manager_
Definition: render_panel.h:153
Pure-virtual base class for objects which give Display subclasses context in which to work...
int mouse_y_
Y position of the last mouse event.
Definition: render_panel.h:149
void mousePressEvent(QMouseEvent *event) override
Definition: render_panel.h:127
DisplayContext * context_
Definition: render_panel.h:152
QTimer * fake_mouse_move_event_timer_
Definition: render_panel.h:173
bool focus_on_mouse_move_
a moving the mouse catches keyboard focus
Definition: render_panel.h:150
int mouse_x_
X position of the last mouse event.
Definition: render_panel.h:148
void mouseDoubleClickEvent(QMouseEvent *event) override
Definition: render_panel.h:135
Display * display_
Definition: render_panel.h:164
boost::shared_ptr< QMenu > context_menu_
Definition: render_panel.h:157
void mouseMoveEvent(QMouseEvent *event) override
Definition: render_panel.h:123
boost::mutex context_menu_mutex_
Definition: render_panel.h:158
Ogre::Camera * default_camera_
A default camera created in initialize().
Definition: render_panel.h:174


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:25