1 /***************************************************************************
3 * Copyright 2012 BMW Car IT GmbH
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
20 #ifndef __LMCONTROL_H__
21 #define __LMCONTROL_H__
36 * Datastructure that contains all information about a scene
40 map<t_ilm_display, vector<t_ilm_layer> > screenLayers;
41 map<t_ilm_layer, vector<t_ilm_surface> > layerSurfaces;
43 map<t_ilm_surface, ilmSurfaceProperties> surfaceProperties;
44 map<t_ilm_layer, ilmLayerProperties> layerProperties;
46 map<t_ilm_layer, t_ilm_display> layerScreen;
47 map<t_ilm_surface, t_ilm_layer> surfaceLayer;
49 vector<t_ilm_surface> surfaces;
50 vector<t_ilm_surface> layers;
51 vector<t_ilm_display> screens;
53 t_ilm_layer extraLayer;
54 t_ilm_uint screenWidth;
55 t_ilm_uint screenHeight;
59 * Vector of four integers <x y z w>
65 tuple4(int _x, int _y, int _z, int _w) :
66 x(_x), y(_y), z(_z), w(_w)
72 x(0), y(0), z(0), w(0)
77 tuple4(const tuple4& other)
87 x = static_cast<int>(x * s);
88 y = static_cast<int>(y * s);
89 z = static_cast<int>(z * s);
90 w = static_cast<int>(w * s);
93 const tuple4& operator=(const tuple4& other)
106 //=============================================================================
108 //=============================================================================
110 * Captures all information about the rendered scene into an object of type t_scene_data
112 void captureSceneData(t_scene_data* pScene);
115 * Calculates the final coordinates of a surface on the screen in the scene
117 tuple4 getSurfaceScreenCoordinates(t_scene_data* pScene, t_ilm_surface surface);
120 * Gets render order of surfaces in a scene. A surface is execluded from the render order
121 * if it does not belong to a layer or if it belongs to a layer that does not belong to a screen
123 * The surface at index 0 is the deepest surface in the scene, and surface at size()-1 is
124 * the topmost surface
126 vector<t_ilm_surface> getSceneRenderOrder(t_scene_data* pScene);
129 * Sets a scene to be restored if an interrupt signal (Ctrl+C) is received
131 void setSceneToRestore(t_scene_data* pScene);
134 * Clones the given scene into another t_scene_data object that would look exactly the same
135 * but all rendered surfaces are rendered on one (newly created) layer.
136 * Order, sizes and positions of rendered surfaces are preserved relative to screen
139 t_scene_data cloneToUniLayerScene(t_scene_data* pScene);
142 * Hide the currently rendered scene, and render the given scene instead
143 * If clean is set to true all layers and surfaces that do not exist in the given
144 * scene are destroyed
146 void setScene(t_scene_data* pScene, bool clean = false);
149 * Makes a smooth transformation effect from the intial to the final scene
151 void transformScene(t_scene_data* pInitialScene, t_scene_data* pFinalScene, t_ilm_long durationMillis, t_ilm_int frameCount);
154 * Creates a new empty scene
156 void emptyScene(t_scene_data* pScene);
159 * Returns true if the surface is rendered to the screen
160 * (If the surface belongs to a layer that belongs to a screen)
162 t_ilm_bool surfaceRenderedOnScreen(t_scene_data& scene, t_ilm_surface surface);
165 //=============================================================================
167 //=============================================================================
170 * Returns true if the rectangle A is inside (or typical with) rectangle B
171 * (each tuple represents a rectangle in 2-D coordinates as <x1 y1 x2 y2>)
173 t_ilm_bool inside(tuple4 A, tuple4 B);
176 * Returns true if a is in the interval between b1 and b2 (inclusive)
178 t_ilm_bool between(int b1, int a, int b2);
182 * Returns true if the rectangle A intersects (or touches) rectangle B
183 * (each tuple represents a rectangle in 2-D coordinates as <x1 y1 x2 y2>)
185 t_ilm_bool intersect(tuple4 A, tuple4 B);
188 * Trim white space characters from the beginning of the string
190 string rtrim(string s);
193 * Replace all occurances of a in s by b
195 string replaceAll(string s, string a, string b);
196 string replaceAll(string s, char a, char b);
199 * For every pair (a,b) in the map: replace all occurances of a in the string by b
201 string replaceAll(string s, map<string, string> replacements);
204 * Split the string using the giving delimiter
206 set<string> split(string s, char d);
209 //=============================================================================
211 //=============================================================================
214 * Functions for printing arrays, vector and maps
216 void printArray(const char* text, unsigned int* array, int count);
219 void printArray(const char* text, T* array, int count);
222 void printVector(const char* text, vector<T> v);
224 template<typename K, typename V>
225 void printMap(const char* text, std::map<K, V> m);
228 * Prints information about the specified screen
230 void printScreenProperties(unsigned int screenid, const char* prefix = "");
233 * Prints information about the specified layer
235 void printLayerProperties(unsigned int layerid, const char* prefix = "");
238 * Prints information about the specified surface
240 void printSurfaceProperties(unsigned int surfaceid, const char* prefix = "");
243 * Prints information about rendered scene
244 * (All screens, all rendered layers, all rendered surfaces)
249 //=============================================================================
251 //=============================================================================
252 void getCommunicatorPerformance();
253 void setSurfaceKeyboardFocus(t_ilm_surface surface);
254 void getKeyboardFocus();
255 void setSurfaceAcceptsInput(t_ilm_surface surfaceId, string kbdPointerTouch, t_ilm_bool acceptance);
256 void testNotificationLayer(t_ilm_layer layerid);
257 void watchLayer(unsigned int* layerids, unsigned int layeridCount);
258 void watchSurface(unsigned int* surfaceids, unsigned int surfaceidCount);
259 void setOptimization(t_ilm_uint id, t_ilm_uint mode);
260 void getOptimization(t_ilm_uint id);
263 //=============================================================================
265 //=============================================================================
268 * Runs and prints the results for a set of analysis procedures to check if there are any potential problems that
269 * might lead to the surface being not rendered or not visible
271 t_ilm_bool analyzeSurface(t_ilm_surface targetSurfaceId);
274 //=============================================================================
276 //=============================================================================
279 * Divides the screen into a grid of equal sized portions, and displays every rendered
280 * surface in a separate tile with its relative size and position preserved
282 * Only rendred surfaces are considered. Surfaces are displayed according to their render order
283 * topleft-to-rightbottom
289 * Divides the screen into a grid of equal sized portions, and displays every existing surface
290 * in a separate tile with its relative size and position preserved
292 * All existing surfaces are considered. surfaces that have 0 visibility are set to visibility 1.
293 * Surfaces that have 0 opacity are set to opacity 1. Surfaces that are not on any layer and surfaces
294 * that are on layers that are not on any screen are displayed as well
299 * Returns a scattered version of the scene
301 t_scene_data getScatteredScene(t_scene_data* pInitialScene);