OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreOverlayManager.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __OverlayManager_H__
29 #define __OverlayManager_H__
30 
32 #include "OgreSingleton.h"
33 #include "OgreStringVector.h"
34 #include "OgreScriptLoader.h"
35 #include "OgreFrustum.h"
36 
37 namespace Ogre {
38 
50  class _OgreOverlayExport OverlayManager : public Singleton<OverlayManager>, public ScriptLoader, public OverlayAlloc
51  {
52  public:
56  protected:
59 
60  void parseNewElement( DataStreamPtr& chunk, String& elemType, String& elemName,
61  bool isContainer, Overlay* pOverlay, bool isTemplate, String templateName = String(""), OverlayContainer* container = 0);
62  void parseAttrib( const String& line, Overlay* pOverlay);
63  void parseElementAttrib( const String& line, Overlay* pOverlay, OverlayElement* pElement );
64  void skipToNextCloseBrace(DataStreamPtr& chunk);
65  void skipToNextOpenBrace(DataStreamPtr& chunk);
66 
67  int mLastViewportWidth, mLastViewportHeight;
70 
71  bool parseChildren( DataStreamPtr& chunk, const String& line,
72  Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL);
73 
75 
78 
81 
82 
83 
84 
85  ElementMap& getElementMap(bool isTemplate);
86 
87  OverlayElement* createOverlayElementImpl(const String& typeName, const String& instanceName, ElementMap& elementMap);
88 
89  OverlayElement* getOverlayElementImpl(const String& name, ElementMap& elementMap);
90 
91  bool hasOverlayElementImpl(const String& name, ElementMap& elementMap);
92 
93  void destroyOverlayElementImpl(const String& instanceName, ElementMap& elementMap);
94 
95  void destroyOverlayElementImpl(OverlayElement* pInstance, ElementMap& elementMap);
96 
97  void destroyAllOverlayElementsImpl(ElementMap& elementMap);
98 
99  public:
100  OverlayManager();
101  virtual ~OverlayManager();
102 
104  const StringVector& getScriptPatterns(void) const;
106  void parseScript(DataStreamPtr& stream, const String& groupName);
108  Real getLoadingOrder(void) const;
109 
111  Overlay* create(const String& name);
115  Overlay* getByName(const String& name);
117  void destroy(const String& name);
119  void destroy(Overlay* overlay);
121  void destroyAll(void);
123  OverlayMapIterator getOverlayIterator(void);
124 
126  void _queueOverlaysForRendering( RenderQueue* pQueue, Viewport *vp );
127 
132  bool hasViewportChanged(void) const;
133 
135  int getViewportHeight(void) const;
136 
138  int getViewportWidth(void) const;
139  Real getViewportAspectRatio(void) const;
140 
142  OrientationMode getViewportOrientationMode(void) const;
143 
151  OverlayElement* createOverlayElement(const String& typeName, const String& instanceName, bool isTemplate = false);
152 
154  OverlayElement* getOverlayElement(const String& name, bool isTemplate = false);
155 
157  bool hasOverlayElement(const String& name, bool isTemplate = false);
158 
164  void destroyOverlayElement(const String& instanceName, bool isTemplate = false);
165 
171  void destroyOverlayElement(OverlayElement* pInstance, bool isTemplate = false);
172 
178  void destroyAllOverlayElements(bool isTemplate = false);
179 
185  void addOverlayElementFactory(OverlayElementFactory* elemFactory);
186 
189  return mFactories;
190  }
191 
192  OverlayElement* createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isTemplate = false);
198  OverlayElement* cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName);
199 
200  OverlayElement* createOverlayElementFromFactory(const String& typeName, const String& instanceName);
201 
205  {
206  return TemplateIterator (mTemplates.begin (), mTemplates.end ()) ;
207  }
208  /* Returns whether the Element with the given name is a Template */
209  bool isTemplate (String strName) const {
210  return (mTemplates.find (strName) != mTemplates.end()) ;
211  }
212 
213 
229  static OverlayManager& getSingleton(void);
245  static OverlayManager* getSingletonPtr(void);
246  };
247 
248 
252 }
253 
254 
255 #endif
MapIterator< OverlayMap > OverlayMapIterator
StringVector mScriptPatterns
float Real
Software floating point type.
LoadedScripts mLoadedScripts
#define _OgreOverlayExport
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Defines the interface which all components wishing to supply OverlayElement subclasses must implement...
A 2D element which contains other OverlayElement instances.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Manages Overlay objects, parsing them from .overlay files and storing a lookup library of them...
Abstract class defining the interface used by classes which wish to perform script loading to define ...
OrientationMode
Specifies orientation mode.
Definition: OgreFrustum.h:48
map< String, OverlayElementFactory * >::type FactoryMap
OrientationMode mLastViewportOrientationMode
map< String, OverlayElement * >::type ElementMap
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
set< String >::type LoadedScripts
vector< String >::type StringVector
const FactoryMap & getOverlayElementFactoryMap() const
Get const access to the list of registered OverlayElement factories.
bool isTemplate(String strName) const
TemplateIterator getTemplateIterator()
Returns an iterator over all templates in this manager.
Abstract definition of a 2D element to be displayed in an Overlay.
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:56
Class to manage the scene object rendering queue.
MapIterator< ElementMap > TemplateIterator
_StringBase String
Definition: OgreCommon.h:53
map< String, Overlay * >::type OverlayMap
Represents a layer which is rendered on top of the 'normal' scene contents.
Definition: OgreOverlay.h:69