/*************************************************************************** * * Copyright 2012 BMW Car IT GmbH * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ****************************************************************************/ #ifndef __LMCONTROL_H__ #define __LMCONTROL_H__ #include using std::map; #include using std::vector; #include using std::set; #include using std::string; #include "ilm_common.h" /* * Datastructure that contains all information about a scene */ struct t_scene_data { map > screenLayers; map > layerSurfaces; map surfaceProperties; map layerProperties; map layerScreen; map surfaceLayer; vector surfaces; vector layers; vector screens; t_ilm_layer extraLayer; t_ilm_uint screenWidth; t_ilm_uint screenHeight; }; /* * Vector of four integers */ struct tuple4 { public: int x; int y; int z; int w; tuple4(int _x, int _y, int _z, int _w) : x(_x), y(_y), z(_z), w(_w) { } tuple4() : x(0), y(0), z(0), w(0) { } tuple4(const tuple4& other) { x = other.x; y = other.y; z = other.z; w = other.w; } void scale(float s) { x = static_cast(x * s); y = static_cast(y * s); z = static_cast(z * s); w = static_cast(w * s); } const tuple4& operator=(const tuple4& other) { x = other.x; y = other.y; z = other.z; w = other.w; return *this; } }; //============================================================================= //common.cpp //============================================================================= /* * Captures all information about the rendered scene into an object of type t_scene_data */ void captureSceneData(t_scene_data* pScene); /* * Calculates the final coordinates of a surface on the screen in the scene */ tuple4 getSurfaceScreenCoordinates(t_scene_data* pScene, t_ilm_surface surface); /* * Gets render order of surfaces in a scene. A surface is execluded from the render order * if it does not belong to a layer or if it belongs to a layer that does not belong to a screen * * The surface at index 0 is the deepest surface in the scene, and surface at size()-1 is * the topmost surface */ vector getSceneRenderOrder(t_scene_data* pScene); //============================================================================= //util.cpp //============================================================================= /* * Returns true if the rectangle A is inside (or typical with) rectangle B * (each tuple represents a rectangle in 2-D coordinates as ) */ t_ilm_bool inside(tuple4 A, tuple4 B); /* * Returns true if a is in the interval between b1 and b2 (inclusive) */ t_ilm_bool between(int b1, int a, int b2); /* * Returns true if the rectangle A intersects (or touches) rectangle B * (each tuple represents a rectangle in 2-D coordinates as ) */ t_ilm_bool intersect(tuple4 A, tuple4 B); /* * Trim white space characters from the beginning of the string */ string rtrim(string s); /* * Replace all occurances of a in s by b */ string replaceAll(string s, string a, string b); string replaceAll(string s, char a, char b); /* * For every pair (a,b) in the map: replace all occurances of a in the string by b */ string replaceAll(string s, map replacements); /* * Split the string using the giving delimiter */ set split(string s, char d); //============================================================================= //print.cpp //============================================================================= /* * Functions for printing arrays, vector and maps */ void printArray(const char* text, unsigned int* array, int count); template void printArray(const char* text, T* array, int count); template void printVector(const char* text, vector v); template void printMap(const char* text, std::map m); /* * Prints information about the specified screen */ void printScreenProperties(unsigned int screenid, const char* prefix = ""); /* * Prints information about the specified layer */ void printLayerProperties(unsigned int layerid, const char* prefix = ""); /* * Prints information about the specified surface */ void printSurfaceProperties(unsigned int surfaceid, const char* prefix = ""); /* * Prints information about rendered scene * (All screens, all rendered layers, all rendered surfaces) */ void printScene(); //============================================================================= //control.cpp //============================================================================= void testNotificationLayer(t_ilm_layer layerid); void watchLayer(unsigned int* layerids, unsigned int layeridCount); void watchSurface(unsigned int* surfaceids, unsigned int surfaceidCount); //============================================================================= //analyze.cpp //============================================================================= /* * Runs and prints the results for a set of analysis procedures to check if there are any potential problems that * might lead to the surface being not rendered or not visible */ t_ilm_bool analyzeSurface(t_ilm_surface targetSurfaceId); /* * Returns a scattered version of the scene */ t_scene_data getScatteredScene(t_scene_data* pInitialScene); //============================================================================= //sceneio.cpp //============================================================================= /* * Saves a representation of the current rendered scene to a file */ void exportSceneToFile(string filename); /* * Saves an xtext representation of the grammar of the scene */ void exportXtext(string fileName, string grammar, string url); #endif