qt_ogre_render_window.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, 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 #ifndef QT_OGRE_RENDER_WINDOW_OGRE_RENDER_WINDOW_H_
30 #define QT_OGRE_RENDER_WINDOW_OGRE_RENDER_WINDOW_H_
31 
32 #include <boost/function.hpp>
33 
34 #include "render_widget.h"
35 
36 #include <OgreColourValue.h>
37 #include <OgreRenderTargetListener.h>
38 
39 namespace Ogre
40 {
41 class Root;
42 class RenderWindow;
43 class Viewport;
44 class Camera;
45 } // namespace Ogre
46 
47 namespace rviz
48 {
54 class QtOgreRenderWindow : public RenderWidget, public Ogre::RenderTargetListener
55 {
56 public:
60  QtOgreRenderWindow(QWidget* parent = nullptr);
61 
63  ~QtOgreRenderWindow() override;
64 
69  virtual void setPreRenderCallback(boost::function<void()> func);
74  virtual void setPostRenderCallback(boost::function<void()> func);
75 
80  QSize sizeHint() const override
81  {
82  return QSize(320, 240);
83  }
84 
91  Ogre::Viewport* getViewport() const;
92 
95  void setCamera(Ogre::Camera* camera);
96 
97  Ogre::Camera* getCamera() const
98  {
99  return camera_;
100  }
101 
106  void setOrthoScale(float scale);
107 
112  bool enableStereo(bool enable);
113 
115  void setupStereo();
116 
117  void setAutoRender(bool auto_render)
118  {
119  auto_render_ = auto_render;
120  }
121 
124  void setOverlaysEnabled(bool overlays_enabled);
125  void setBackgroundColor(Ogre::ColourValue color);
126 
127 protected:
128  void paintEvent(QPaintEvent* e) override;
129  void resizeEvent(QResizeEvent* event) override;
130 
131  // When stereo is enabled, these are called before/after rendering each
132  // viewport.
133  void preViewportUpdate(const Ogre::RenderTargetViewportEvent& evt) override;
134  void postViewportUpdate(const Ogre::RenderTargetViewportEvent& evt) override;
135 
139  void setCameraAspectRatio();
140 
145  void prepareStereoViewport(Ogre::Viewport*);
146 
147 
148  Ogre::Viewport* viewport_;
149 
150  Ogre::Root* ogre_root_;
151 
152  boost::function<void()> pre_render_callback_;
153  boost::function<void()> post_render_callback_;
154 
157 
158  Ogre::Camera* camera_;
160  Ogre::ColourValue background_color_;
161 
162  // stereo rendering
163  bool stereo_enabled_; // true if we were asked to render stereo
164  bool rendering_stereo_; // true if we are actually rendering stereo
165  Ogre::Camera* left_camera_;
166  Ogre::Camera* right_camera_;
167  Ogre::Viewport* right_viewport_;
168 };
169 
170 } // namespace rviz
171 
172 #endif // QT_OGRE_RENDER_WINDOW_OGRE_RENDER_WINDOW_H_
boost::function< void()> pre_render_callback_
Functor which is called before each render.
void setAutoRender(bool auto_render)
Ogre::Camera * getCamera() const
Ogre::ColourValue background_color_
boost::function< void()> post_render_callback_
Functor which is called after each render.
QSize sizeHint() const override


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