EditorMaterialSwitcher.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef _GAZEBO_EDITOR_MATERIAL_SWITCHER_HH_
19 #define _GAZEBO_EDITOR_MATERIAL_SWITCHER_HH_
20 
21 #include <string>
22 
24 #include "gazebo/util/system.hh"
25 
26 namespace gazebo
27 {
28  namespace gui
29  {
30  // forward declarations
31  class EditorMaterialListener;
32  class EditorRenderTargetListener;
33 
34  // typedefs that are used only in this class
36  std::shared_ptr<EditorRenderTargetListener>;
38  std::shared_ptr<EditorMaterialListener>;
39 
43  class GZ_GUI_VISIBLE EditorMaterialSwitcher
44  {
48  public: EditorMaterialSwitcher(const rendering::CameraPtr &_camera);
49 
51  public: ~EditorMaterialSwitcher() = default;
52 
56  public: void SetMaterialScheme(const std::string &_scheme);
57 
60  public: std::string MaterialScheme() const;
61 
64  private: EditorRenderTargetListenerPtr renderTargetListener;
65 
68  private: EditorMaterialListenerPtr materialListener;
69 
71  private: rendering::CameraPtr camera;
72 
74  private: std::string originalMaterialScheme;
75 
77  private: std::string materialScheme;
78  };
79 
82  class EditorRenderTargetListener : public Ogre::RenderTargetListener
83  {
88  const EditorMaterialListenerPtr &_switcher);
89 
91  public: ~EditorRenderTargetListener() = default;
92 
96  public: virtual void preRenderTargetUpdate(
97  const Ogre::RenderTargetEvent &_evt);
98 
102  public: virtual void postRenderTargetUpdate(
103  const Ogre::RenderTargetEvent &_evt);
104 
106  private: EditorMaterialListenerPtr materialListener;
107  };
108 
111  class EditorMaterialListener : public Ogre::MaterialManager::Listener
112  {
116  public: EditorMaterialListener(const rendering::CameraPtr &_camera);
117 
119  public: ~EditorMaterialListener() = default;
120 
131  public: virtual Ogre::Technique *handleSchemeNotFound(
132  uint16_t _schemeIndex, const Ogre::String &_schemeName,
133  Ogre::Material *_originalMaterial, uint16_t _lodIndex,
134  const Ogre::Renderable *_rend);
135 
137  private: rendering::CameraPtr camera;
138  };
139  }
140 }
141 #endif
std::shared_ptr< EditorMaterialListener > EditorMaterialListenerPtr
Definition: EditorMaterialSwitcher.hh:38
Ogre render target listener.
Definition: EditorMaterialSwitcher.hh:82
virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent &_evt)
Ogre's post-render update callback.
Ogre material listener.
Definition: EditorMaterialSwitcher.hh:111
EditorMaterialListener(const rendering::CameraPtr &_camera)
Constructor.
EditorRenderTargetListener(const EditorMaterialListenerPtr &_switcher)
Constructor.
Material switcher for the model editor used to toggle the material of the model.
Definition: EditorMaterialSwitcher.hh:43
virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent &_evt)
Ogre's pre-render update callback.
virtual Ogre::Technique * handleSchemeNotFound(uint16_t _schemeIndex, const Ogre::String &_schemeName, Ogre::Material *_originalMaterial, uint16_t _lodIndex, const Ogre::Renderable *_rend)
Ogre callback that is used to specify the material to use when the requested scheme is not found...
std::shared_ptr< EditorRenderTargetListener > EditorRenderTargetListenerPtr
Definition: EditorMaterialSwitcher.hh:36
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:88
~EditorMaterialListener()=default
Destructor.
~EditorRenderTargetListener()=default
Destructor.