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 
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  {
126  }
127  void mousePressEvent(QMouseEvent* event) override
128  {
130  }
131  void mouseReleaseEvent(QMouseEvent* event) override
132  {
134  }
135  void mouseDoubleClickEvent(QMouseEvent* event) override
136  {
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  void onContextMenuHide();
168 
169 private:
170  Ogre::Camera* default_camera_;
171 };
172 
173 } // namespace rviz
174 
175 #endif
rviz::RenderPanel::context_menu_mutex_
boost::mutex context_menu_mutex_
Definition: render_panel.h:158
Ogre
Definition: axes_display.h:35
rviz::RenderPanel::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: render_panel.h:127
rviz::RenderPanel::onContextMenuHide
void onContextMenuHide()
Definition: render_panel.cpp:177
boost::shared_ptr< QMenu >
ros
rviz::RenderPanel::focus_on_mouse_move_
bool focus_on_mouse_move_
a moving the mouse catches keyboard focus
Definition: render_panel.h:150
rviz::RenderPanel::getViewController
ViewController * getViewController()
Definition: render_panel.h:90
rviz::QtOgreRenderWindow
Definition: qt_ogre_render_window.h:54
rviz::RenderPanel::contextMenuEvent
void contextMenuEvent(QContextMenuEvent *event) override
Definition: render_panel.cpp:187
rviz::RenderPanel::context_menu_
boost::shared_ptr< QMenu > context_menu_
Definition: render_panel.h:157
rviz::RenderPanel::leaveEvent
void leaveEvent(QEvent *event) override
Definition: render_panel.cpp:94
rviz::RenderPanel::~RenderPanel
~RenderPanel() override
Definition: render_panel.cpp:65
rviz::RenderPanel::setViewController
void setViewController(ViewController *controller)
Set the ViewController which should control the camera position for this view.
Definition: render_panel.cpp:153
rviz::Display
Definition: display.h:63
rviz::RenderPanel::context_menu_visible_
bool context_menu_visible_
Definition: render_panel.h:160
rviz::RenderPanel::contextMenuVisible
bool contextMenuVisible()
Definition: render_panel.cpp:182
rviz::RenderPanel::scene_manager_
Ogre::SceneManager * scene_manager_
Definition: render_panel.h:153
rviz::RenderPanel::initialize
void initialize(Ogre::SceneManager *scene_manager, DisplayContext *manager)
Definition: render_panel.cpp:77
rviz::RenderPanel::RenderPanel
RenderPanel(QWidget *parent=nullptr)
Definition: render_panel.cpp:49
rviz
Definition: add_display_dialog.cpp:54
rviz::RenderPanel::getManager
DisplayContext * getManager()
Definition: render_panel.h:85
rviz::RenderPanel::view_controller_
ViewController * view_controller_
Definition: render_panel.h:155
rviz::RenderPanel::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event) override
Definition: render_panel.h:123
rviz::RenderPanel::mouse_y_
int mouse_y_
Y position of the last mouse event.
Definition: render_panel.h:149
rviz::RenderPanel::wheelEvent
void wheelEvent(QWheelEvent *event) override
Called when there is a mouse-wheel event.
Definition: render_panel.cpp:124
rviz::RenderPanel::showContextMenu
void showContextMenu(boost::shared_ptr< QMenu > menu)
Definition: render_panel.cpp:168
rviz::RenderPanel::keyPressEvent
void keyPressEvent(QKeyEvent *event) override
Definition: render_panel.cpp:145
rviz::RenderPanel::setFocusOnMouseMove
void setFocusOnMouseMove(bool enabled)
Definition: render_panel.cpp:217
rviz::DisplayContext
Pure-virtual base class for objects which give Display subclasses context in which to work.
Definition: display_context.h:81
rviz::RenderPanel::mouse_x_
int mouse_x_
X position of the last mouse event.
Definition: render_panel.h:148
rviz::RenderPanel::context_
DisplayContext * context_
Definition: render_panel.h:152
rviz::RenderPanel::onRenderWindowMouseEvents
void onRenderWindowMouseEvents(QMouseEvent *event)
Called when any mouse event happens inside the render window.
Definition: render_panel.cpp:103
rviz::ViewController
Definition: view_controller.h:55
rviz::RenderPanel::getFocusOnMouseMove
bool getFocusOnMouseMove() const
Definition: render_panel.cpp:212
rviz::RenderPanel::default_camera_
Ogre::Camera * default_camera_
A default camera created in initialize().
Definition: render_panel.h:170
rviz::RenderPanel::sceneManagerDestroyed
void sceneManagerDestroyed(Ogre::SceneManager *source) override
Definition: render_panel.cpp:202
rviz::RenderPanel
Definition: render_panel.h:74
rviz::RenderPanel::mouseDoubleClickEvent
void mouseDoubleClickEvent(QMouseEvent *event) override
Definition: render_panel.h:135
rviz::RenderPanel::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event) override
Definition: render_panel.h:131
rviz::RenderPanel::display_
Display * display_
Definition: render_panel.h:164
qt_ogre_render_window.h


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Dec 13 2024 03:31:02