Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / inc / FUiEffects_RuntimeRenderDataScene.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file        FUiEffects_RuntimeRenderDataScene.h
19  * @brief               This is the header file for the render structures for all scene (for EffectModel instance entire)
20  */
21
22 #ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_RENDER_DATA_SCENE_H_
23 #define _FUI_EFFECTS_INTERNAL_RUNTIME_RENDER_DATA_SCENE_H_
24
25 #include <unique_ptr.h>
26 #include <string>
27 #include <map>
28 #include <set>
29 #include <list>
30 #include <vector>
31 #include <utils/FUiEffects_Utils.h>
32 #include <FUiEffects_RuntimePropertyCast.h>
33 #include <FUiEffects_RuntimeModel.h>
34 #include <FUiEffects_RuntimeRenderDataSurface.h>
35
36 namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime
37 {
38
39 class UnitLight;
40
41 class RenderDataScene
42 {
43 public:
44
45         /**
46          * Adds specified unit light into scene
47          *
48          * @since 2.0
49          *
50          * @remarks             For using in lua also
51          *
52          */
53         bool AddUnitLight(UnitLight& unitLight);
54
55         /**
56          * Excludes specified unit light from scene with using unique unit light name
57          *
58          * @since 2.0
59          *
60          * @remarks             For using in lua also
61          *
62          */
63         bool RemoveUnitLight(const std::string& name);
64
65         /**
66          * Excludes all units light of specified type from scene
67          *
68          * @since 2.0
69          *
70          * @remarks             For using in lua also
71          *
72          */
73         bool RemoveAllUnitsLightType(TypeUnitLight typeUnitLight);
74
75         /**
76          * Returns specified unit light to a client with using unique unit light name
77          *
78          * @since 2.0
79          *
80          * @remarks             For using in lua also
81          *
82          */
83         PropertyCast GetUnitLight(const std::string& name) const;
84
85         /**
86          * Sets ambient colour for entire scene
87          *
88          * @since 2.0
89          *
90          * @remarks             For using in lua also
91          *
92          */
93         void SetLightAmbientColour(const Tizen::Ui::Effects::_Utils::Vec3f& ambientColour);
94
95         /**
96          * Sets ambient colour for entire scene
97          *
98          * @since 2.0
99          *
100          * @remarks             For using in lua also
101          *
102          */
103         void SetLightAmbientColour(float red, float green, float blue);
104
105         /**
106          * Sets light intensity for entire scene
107          *
108          * @since 2.0
109          *
110          * @remarks             For using in lua also
111          *
112          */
113         void SetLightIntensity(float intensity);
114
115         /**
116          * Sets attenuation for units light as environment variable (How far does unit light can light?)
117          *
118          * @since 2.0
119          *
120          * @remarks             For using in lua also
121          *
122          */
123         void SetLightAttenuation(float attenuation);
124
125         /**
126          * Returns attenuation for units light as environment variable
127          *
128          * @since 2.0
129          *
130          * @remarks             For using in lua also
131          *
132          */
133         const Tizen::Ui::Effects::_Utils::Vec3f& GetLightAmbientColour(void) const;
134
135         /**
136          * Returns intensity for units light as environment variable
137          *
138          * @since 2.0
139          *
140          * @remarks             For using in lua also
141          *
142          */
143         float GetLightIntensity(void) const;
144
145         /**
146          * Returns attenuation for units light as environment variable
147          *
148          * @since 2.0
149          *
150          * @remarks             For using in lua also
151          *
152          */
153         float GetLightAttenuation(void) const;
154
155         /**
156          * Returns size of units light container
157          *
158          * @since 2.0
159          *
160          * @remarks             For working with units light collection
161          *
162          */
163         long GetSizeUnitLightContainer(void) const;
164
165         /**
166          * Returns type of current units light from units light container
167          *
168          * @since 2.0
169          *
170          * @remarks             For working with units light collection
171          *
172          */
173         TypeUnitLight GetTypeOfCurrentUnitLight(void) const;
174
175         /**
176          * Returns a pointer to current units light from units light container
177          *
178          * @since 2.0
179          *
180          * @remarks             For working with units light collection
181          *
182          */
183         template<class T> const T* GetCurrentUnitLight(void) const;
184
185         /**
186          * Assignments next value for internal iterator for access to next unit light in units light container
187          *
188          * @since 2.0
189          *
190          * @remarks             For working with units light collection
191          * Returns true if transition was succeeded and false otherwise
192          *
193          */
194         bool GoToNextUnitLight(void);
195
196         /**
197          * Locks units light container for future work with units light from it
198          *
199          * @since 2.0
200          *
201          * @remarks             For working with units light collection
202          * Return true if the locking was succeeded and false otherwise
203          * Without performing this function client can not performs any action on units light from units light container
204          *
205          */
206         bool LockUnitsLightContainer(void);
207
208         /**
209          * Unlocks units light container with purpose to prohibit any future actions on units light container
210          *
211          * @since 2.0
212          *
213          * @remarks             For working with units light collection
214          * This function calls automatically when client adds or removes some unit light from scene
215          *
216          */
217         void UnlockUnitsLightContainer(void);
218
219         /**
220          * Returns true if units light container is locked and false otherwise
221          *
222          * @since 2.0
223          *
224          * @remarks             For working with units light collection
225          *
226          */
227         bool GetIsLockedUnitsLightContainer(void) const;
228
229         /**
230          * Resets all signs for current unit light (e.g. isIntensityChanged, isColourChanged)
231          *
232          * @since 2.0
233          *
234          */
235         bool ResetSignsCurrentUnitLight(void);
236
237         /**
238          * Returns a reference to collection of render data for each graphical surface
239          *
240          * @since 2.0
241          *
242          */
243         RenderDataSurfaceCollection& GetRenderDataSurfaceCollection(void);
244
245 private:
246
247         /**
248          * Class constructor
249          *
250          * @since 2.0
251          *
252          */
253         RenderDataScene(void);
254
255         /**
256          * Class destructor
257          *
258          * @since 2.0
259          *
260          */
261         ~RenderDataScene(void);
262
263         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
264         RenderDataScene(const RenderDataScene& rhs);
265         // The implementation of this assignment operator is intentionally blank and declared as private to prohibit copying of objects.
266         RenderDataScene& operator=(const RenderDataScene& rhs);
267
268         /**
269          * For internal purposes only
270          *
271          * @since 2.0
272          *
273          */
274         template<class T> const T* GetCurrentUnitLightInternal(void) const;
275
276         /**
277          * For internal purposes only
278          *
279          * @since 2.0
280          *
281          */
282         PropertyCast GetConcreteUnitLight(const UnitLight& unitLight) const;
283
284         /**
285          * For internal purposes only
286          *
287          * @since 2.0
288          *
289          */
290         void RemoveUnitLight(UnitLight& unitLight);
291
292 public:
293
294         bool isAmbientColourChanged;
295         bool isIntensityChanged;
296         bool isAttenuationChanged;
297         bool isSomethingChanged;
298
299 private:
300
301         typedef std::map<std::string, UnitLight*> UnitLightNameTree;
302         typedef std::list<UnitLight*> UnitLightCollection;
303
304         RenderDataSurfaceCollection __renderDataSurfaceCollection;      /**< a container of pointers to graphical surfaces render data*/
305
306         UnitLightCollection __unitsLight;                                                       /**< units light container*/
307         UnitLightCollection::iterator __iteratorCurrentUnitLight;       /**< an iterator to point to current units light*/
308         bool __isLockedUnitsLightContainer;                                                     /**< is units light container locked or not*/
309
310         UnitLightNameTree __unitLightNameTree;                                          /*< a map for quick search need unit light with using a name of it */
311
312         Tizen::Ui::Effects::_Utils::Vec3f __ambientColour;      /**< ambient colour*/
313         float __intensity;                                                                      /**< intensity for units light as environment variable*/
314         float __attenuation;                                                            /**< attenuation for units light as environment variable (this variable has no influence on directionals light)*/
315
316         friend class EffectModel;                                                       //for building the container __renderDataSurfaceCollection
317         friend class boost::default_delete<RenderDataScene>;//for deleting RenderDataScene instance
318 };
319
320 } } } } // Tizen::Ui::Effects::_Runtime
321
322 #endif // _FUI_EFFECTS_INTERNAL_RUNTIME_RENDER_DATA_SCENE_H_