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-2013 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 "OgreOverlay.h"
35 #include "OgreScriptLoader.h"
36 #include "OgreFrustum.h"
37 
38 namespace Ogre {
39 
51  class _OgreOverlayExport OverlayManager : public Singleton<OverlayManager>, public ScriptLoader, public OverlayAlloc
52  {
53  public:
57  protected:
58  OverlayMap mOverlayMap;
60 
61  void parseNewElement( DataStreamPtr& chunk, String& elemType, String& elemName,
62  bool isContainer, Overlay* pOverlay, bool isTemplate, String templateName = String(""), OverlayContainer* container = 0);
63  void parseAttrib( const String& line, Overlay* pOverlay);
64  void parseElementAttrib( const String& line, Overlay* pOverlay, OverlayElement* pElement );
65  void skipToNextCloseBrace(DataStreamPtr& chunk);
66  void skipToNextOpenBrace(DataStreamPtr& chunk);
67 
68  int mLastViewportWidth, mLastViewportHeight;
71 
72  bool parseChildren( DataStreamPtr& chunk, const String& line,
73  Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL);
74 
75  FactoryMap mFactories;
76 
77  ElementMap mInstances;
78  ElementMap mTemplates;
79 
81  LoadedScripts mLoadedScripts;
82 
83 
84 
85 
86  ElementMap& getElementMap(bool isTemplate);
87 
88  OverlayElement* createOverlayElementImpl(const String& typeName, const String& instanceName, ElementMap& elementMap);
89 
90  OverlayElement* getOverlayElementImpl(const String& name, ElementMap& elementMap);
91 
92  bool hasOverlayElementImpl(const String& name, ElementMap& elementMap);
93 
94  void destroyOverlayElementImpl(const String& instanceName, ElementMap& elementMap);
95 
96  void destroyOverlayElementImpl(OverlayElement* pInstance, ElementMap& elementMap);
97 
98  void destroyAllOverlayElementsImpl(ElementMap& elementMap);
99 
100  public:
101  OverlayManager();
102  virtual ~OverlayManager();
103 
105  const StringVector& getScriptPatterns(void) const;
107  void parseScript(DataStreamPtr& stream, const String& groupName);
109  Real getLoadingOrder(void) const;
110 
112  Overlay* create(const String& name);
116  Overlay* getByName(const String& name);
118  void destroy(const String& name);
120  void destroy(Overlay* overlay);
122  void destroyAll(void);
124  OverlayMapIterator getOverlayIterator(void);
125 
127  void _queueOverlaysForRendering(Camera* cam, RenderQueue* pQueue, Viewport *vp);
128 
133  bool hasViewportChanged(void) const;
134 
136  int getViewportHeight(void) const;
137 
139  int getViewportWidth(void) const;
140  Real getViewportAspectRatio(void) const;
141 
143  OrientationMode getViewportOrientationMode(void) const;
144 
152  OverlayElement* createOverlayElement(const String& typeName, const String& instanceName, bool isTemplate = false);
153 
155  OverlayElement* getOverlayElement(const String& name, bool isTemplate = false);
156 
158  bool hasOverlayElement(const String& name, bool isTemplate = false);
159 
165  void destroyOverlayElement(const String& instanceName, bool isTemplate = false);
166 
172  void destroyOverlayElement(OverlayElement* pInstance, bool isTemplate = false);
173 
179  void destroyAllOverlayElements(bool isTemplate = false);
180 
186  void addOverlayElementFactory(OverlayElementFactory* elemFactory);
187 
189  const FactoryMap& getOverlayElementFactoryMap() const {
190  return mFactories;
191  }
192 
193  OverlayElement* createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isTemplate = false);
199  OverlayElement* cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName);
200 
201  OverlayElement* createOverlayElementFromFactory(const String& typeName, const String& instanceName);
202 
205  TemplateIterator getTemplateIterator ()
206  {
207  return TemplateIterator (mTemplates.begin (), mTemplates.end ()) ;
208  }
209  /* Returns whether the Element with the given name is a Template */
210  bool isTemplate (String strName) const {
211  return (mTemplates.find (strName) != mTemplates.end()) ;
212  }
213 
214 
230  static OverlayManager& getSingleton(void);
246  static OverlayManager* getSingletonPtr(void);
247  };
248 
249 
253 }
254 
255 
256 #endif
TemplateIterator getTemplateIterator()
Returns an iterator over all templates in this manager.
LoadedScripts mLoadedScripts
Abstract class defining the interface used by classes which wish to perform script loading to define ...
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
float Real
Software floating point type.
StringVector mScriptPatterns
Class to manage the scene object rendering queue.
vector< String >::type StringVector
#define _OgreOverlayExport
Manages Overlay objects, parsing them from .overlay files and storing a lookup library of them...
bool isTemplate(String strName) const
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:57
map< String, OverlayElementFactory * >::type FactoryMap
OrientationMode
Specifies orientation mode.
Definition: OgreFrustum.h:49
MapIterator< OverlayMap > OverlayMapIterator
Defines the interface which all components wishing to supply OverlayElement subclasses must implement...
_StringBase String
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
OrientationMode mLastViewportOrientationMode
set< String >::type LoadedScripts
Abstract definition of a 2D element to be displayed in an Overlay.
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
const FactoryMap & getOverlayElementFactoryMap() const
Get const access to the list of registered OverlayElement factories.
A 2D element which contains other OverlayElement instances.
map< String, OverlayElement * >::type ElementMap
MapIterator< ElementMap > TemplateIterator
Represents a layer which is rendered on top of the 'normal' scene contents.
Definition: OgreOverlay.h:70
map< String, Overlay * >::type OverlayMap
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sat Sep 20 2014 20:06:37