1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2006-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
10 /// @file    GUITexturesHelper.h
11 /// @author  Daniel Krajzewicz
12 /// @author  Michael Behrisch
13 /// @author  Jakob Erdmann
14 /// @date    Sept 2006
15 /// @version $Id$
16 ///
17 // Global storage for textures; manages and draws them
18 /****************************************************************************/
19 #ifndef GUITexturesHelper_h
20 #define GUITexturesHelper_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <fx.h>
29 #include <utils/gui/globjects/GUIGlObject.h>
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
35 /**
36  * @class GUITexturesHelper
37  * @brief Global storage for textures; manages and draws them
38  */
39 class GUITexturesHelper {
40 public:
41     /// @brief return maximum number of pixels in x and y direction
42     static int getMaxTextureSize();
43 
44     /// @brief Adds a texture to use
45     static GUIGlID add(FXImage* i);
46 
47     /// @brief Draws a named texture as a box with the given size
48     static void drawTexturedBox(int which, double size);
49 
50     /// @brief Draws a named texture as a rectangle with the given sizes
51     static void drawTexturedBox(int which, double sizeX1, double sizeY1, double sizeX2, double sizeY2);
52 
53     /**@brief return texture id for the given filename (initialize on first use)
54      * @note return -1 on failure
55      */
56     static int getTextureID(const std::string& filename, const bool mirrorX = false);
57 
58     /// @brief clears loaded textures
59     static void clearTextures();
60 
61     /// @brief switch texture drawing on and off
allowTextures(const bool val)62     static void allowTextures(const bool val) {
63         myAllowTextures = val;
64     }
65 
66     /// @brief ask whether texture drawing is enabled
texturesAllowed()67     static bool texturesAllowed() {
68         return myAllowTextures;
69     }
70 
71 private:
72     /// @brief mapping from image paths to decals (initialization on first use)
73     static std::map<std::string, int> myTextures;
74 
75     /// @brief whether textures are drawn
76     static bool myAllowTextures;
77 };
78 
79 
80 #endif
81 
82 /****************************************************************************/
83