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:
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 );
67 
68  int mLastViewportWidth, mLastViewportHeight;
71 
72  bool parseChildren( DataStreamPtr& chunk, const String& line,
73  Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL);
74 
76 
79 
82 
83 
84 
85 
86  ElementMap& getElementMap(bool isTemplate);
87 
88  OverlayElement* createOverlayElementImpl(const String& typeName, const String& instanceName, ElementMap& elementMap);
89 
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 
99 
100  public:
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);
125 
128 
133  bool hasViewportChanged(void) const;
134 
136  int getViewportHeight(void) const;
137 
139  int getViewportWidth(void) const;
141 
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 
187 
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 
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 
247  };
248 
249 
253 }
254 
255 
256 #endif
#define _OgreOverlayExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:87
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
A 2D element which contains other OverlayElement instances.
Defines the interface which all components wishing to supply OverlayElement subclasses must implement...
Abstract definition of a 2D element to be displayed in an Overlay.
Manages Overlay objects, parsing them from .overlay files and storing a lookup library of them.
void destroyOverlayElement(OverlayElement *pInstance, bool isTemplate=false)
Destroys a OverlayElement.
StringVector mScriptPatterns
void destroyOverlayElement(const String &instanceName, bool isTemplate=false)
Destroys a OverlayElement.
OverlayElement * createOverlayElementFromFactory(const String &typeName, const String &instanceName)
int getViewportWidth(void) const
Gets the width of the destination viewport in pixels.
OverlayMapIterator getOverlayIterator(void)
LoadedScripts mLoadedScripts
void _queueOverlaysForRendering(Camera *cam, RenderQueue *pQueue, Viewport *vp)
Internal method for queueing the visible overlays for rendering.
void destroyAllOverlayElementsImpl(ElementMap &elementMap)
OverlayElement * createOverlayElementImpl(const String &typeName, const String &instanceName, ElementMap &elementMap)
virtual ~OverlayManager()
MapIterator< OverlayMap > OverlayMapIterator
OrientationMode mLastViewportOrientationMode
OverlayElement * createOverlayElementFromTemplate(const String &templateName, const String &typeName, const String &instanceName, bool isTemplate=false)
void destroyAllOverlayElements(bool isTemplate=false)
Destroys all the OverlayElement created so far.
void skipToNextOpenBrace(DataStreamPtr &chunk)
OverlayElement * getOverlayElementImpl(const String &name, ElementMap &elementMap)
Real getLoadingOrder(void) const
Gets the relative loading order of scripts of this type.
void destroyOverlayElementImpl(OverlayElement *pInstance, ElementMap &elementMap)
void destroy(const String &name)
Destroys an existing overlay by name.
OverlayElement * createOverlayElement(const String &typeName, const String &instanceName, bool isTemplate=false)
Creates a new OverlayElement of the type requested.
map< String, OverlayElementFactory * >::type FactoryMap
bool hasViewportChanged(void) const
Method for determining if the viewport has changed dimensions.
Overlay * getByName(const String &name)
Retrieve an Overlay by name.
MapIterator< ElementMap > TemplateIterator
void addOverlayElementFactory(OverlayElementFactory *elemFactory)
Registers a new OverlayElementFactory with this manager.
void parseNewElement(DataStreamPtr &chunk, String &elemType, String &elemName, bool isContainer, Overlay *pOverlay, bool isTemplate, String templateName=String(""), OverlayContainer *container=0)
void destroy(Overlay *overlay)
Destroys an existing overlay.
TemplateIterator getTemplateIterator()
Returns an iterator over all templates in this manager.
ElementMap & getElementMap(bool isTemplate)
void parseAttrib(const String &line, Overlay *pOverlay)
set< String >::type LoadedScripts
bool parseChildren(DataStreamPtr &chunk, const String &line, Overlay *pOverlay, bool isTemplate, OverlayContainer *parent=NULL)
Overlay * create(const String &name)
Create a new Overlay.
Real getViewportAspectRatio(void) const
OrientationMode getViewportOrientationMode(void) const
Gets the orientation mode of the destination viewport.
bool hasOverlayElement(const String &name, bool isTemplate=false)
Tests if an element exists.
const FactoryMap & getOverlayElementFactoryMap() const
Get const access to the list of registered OverlayElement factories.
map< String, OverlayElement * >::type ElementMap
bool isTemplate(String strName) const
static OverlayManager * getSingletonPtr(void)
Override standard Singleton retrieval.
void parseScript(DataStreamPtr &stream, const String &groupName)
Parse a script file.
void destroyOverlayElementImpl(const String &instanceName, ElementMap &elementMap)
int getViewportHeight(void) const
Gets the height of the destination viewport in pixels.
static OverlayManager & getSingleton(void)
Override standard Singleton retrieval.
const StringVector & getScriptPatterns(void) const
Gets the file patterns which should be used to find scripts for this class.
void skipToNextCloseBrace(DataStreamPtr &chunk)
void destroyAll(void)
Destroys all existing overlays.
map< String, Overlay * >::type OverlayMap
bool hasOverlayElementImpl(const String &name, ElementMap &elementMap)
OverlayElement * cloneOverlayElementFromTemplate(const String &templateName, const String &instanceName)
OverlayElement * getOverlayElement(const String &name, bool isTemplate=false)
Gets a reference to an existing element.
void parseElementAttrib(const String &line, Overlay *pOverlay, OverlayElement *pElement)
Represents a layer which is rendered on top of the 'normal' scene contents.
Definition: OgreOverlay.h:71
Class to manage the scene object rendering queue.
Abstract class defining the interface used by classes which wish to perform script loading to define ...
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:65
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:58
vector< String >::type StringVector
OrientationMode
Specifies orientation mode.
Definition: OgreFrustum.h:50
float Real
Software floating point type.
_StringBase String

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.