SUMO - Simulation of Urban MObility
GUITextureSubSys.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // Helper for Gifs loading and usage
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <fx.h>
32 #include <cassert>
33 #include "GUITextureSubSys.h"
34 
35 #include "GNETexture_Lock.cpp"
37 #include "GNETexture_Empty.cpp"
39 #include "GNETexture_TLS.cpp"
40 #include "GNETexture_E1.cpp"
41 #include "GNETexture_E2.cpp"
42 #include "GNETexture_E3.cpp"
44 #include "GNETexture_Entry.cpp"
45 #include "GNETexture_Exit.cpp"
46 #include "GNETexture_Rerouter.cpp"
50 #include "GNETexture_Vaporizer.cpp"
54 #include "GNETexture_NotMoving.cpp"
56 #include "GNETexture_LaneBus.cpp"
58 #include "GNETexture_LaneBike.cpp"
59 
60 
61 #ifdef CHECK_MEMORY_LEAKS
62 #include <foreign/nvwa/debug_new.h>
63 #endif // CHECK_MEMORY_LEAKS
64 
65 
66 // ===========================================================================
67 // static member variable definitions
68 // ===========================================================================
69 
71 
72 // ===========================================================================
73 // member definitions
74 // ===========================================================================
75 
77  myApp(a) {
78  // Fill map of textures
79  myTextures[GNETEXTURE_E1] = std::pair<bool, GUIGlID>(false, 0);
80  myTextures[GNETEXTURE_E2] = std::pair<bool, GUIGlID>(false, 0);
81  myTextures[GNETEXTURE_E3] = std::pair<bool, GUIGlID>(false, 0);
82  myTextures[GNETEXTURE_E3SELECTED] = std::pair<bool, GUIGlID>(false, 0);
83  myTextures[GNETEXTURE_EMPTY] = std::pair<bool, GUIGlID>(false, 0);
84  myTextures[GNETEXTURE_EMPTYSELECTED] = std::pair<bool, GUIGlID>(false, 0);
85  myTextures[GNETEXTURE_ENTRY] = std::pair<bool, GUIGlID>(false, 0);
86  myTextures[GNETEXTURE_EXIT] = std::pair<bool, GUIGlID>(false, 0);
87  myTextures[GNETEXTURE_LOCK] = std::pair<bool, GUIGlID>(false, 0);
88  myTextures[GNETEXTURE_LOCKSELECTED] = std::pair<bool, GUIGlID>(false, 0);
89  myTextures[GNETEXTURE_NOTMOVING] = std::pair<bool, GUIGlID>(false, 0);
90  myTextures[GNETEXTURE_NOTMOVINGSELECTED] = std::pair<bool, GUIGlID>(false, 0);
91  myTextures[GNETEXTURE_REROUTER] = std::pair<bool, GUIGlID>(false, 0);
92  myTextures[GNETEXTURE_REROUTERSELECTED] = std::pair<bool, GUIGlID>(false, 0);
93  myTextures[GNETEXTURE_ROUTEPROBE] = std::pair<bool, GUIGlID>(false, 0);
94  myTextures[GNETEXTURE_ROUTEPROBESELECTED] = std::pair<bool, GUIGlID>(false, 0);
95  myTextures[GNETEXTURE_TLS] = std::pair<bool, GUIGlID>(false, 0);
96  myTextures[GNETEXTURE_VAPORIZER] = std::pair<bool, GUIGlID>(false, 0);
97  myTextures[GNETEXTURE_VAPORIZERSELECTED] = std::pair<bool, GUIGlID>(false, 0);
98  myTextures[GNETEXTURE_VARIABLESPEEDSIGN] = std::pair<bool, GUIGlID>(false, 0);
99  myTextures[GNETEXTURE_VARIABLESPEEDSIGNSELECTED] = std::pair<bool, GUIGlID>(false, 0);
100  myTextures[GNETEXTURE_LANEBIKE] = std::pair<bool, GUIGlID>(false, 0);
101  myTextures[GNETEXTURE_LANEBUS] = std::pair<bool, GUIGlID>(false, 0);
102  myTextures[GNETEXTURE_LANEPEDESTRIAN] = std::pair<bool, GUIGlID>(false, 0);
103 }
104 
105 
107 }
108 
109 
110 void
112  assert(myInstance == 0);
113  myInstance = new GUITextureSubSys(a);
114 }
115 
116 
117 GUIGlID
119  // Obtain GLID and boolean associated to this texture
120  std::map<GUITexture, std::pair<bool, GUIGlID> >::iterator i = myInstance->myTextures.find(which);
121  // If texture isn't loaded, load it
122  if (i->second.first == false) {
123  switch (i->first) {
124  case GNETEXTURE_E1 :
125  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E1, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
126  break;
127  case GNETEXTURE_E2 :
128  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E2, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
129  break;
130  case GNETEXTURE_E3 :
131  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
132  break;
133  case GNETEXTURE_E3SELECTED :
134  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3Selected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
135  break;
136  case GNETEXTURE_EMPTY :
137  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Empty, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
138  break;
140  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_EmptySelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
141  break;
142  case GNETEXTURE_ENTRY :
143  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Entry, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
144  break;
145  case GNETEXTURE_EXIT :
146  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Exit, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
147  break;
148  case GNETEXTURE_LOCK :
149  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Lock, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
150  break;
152  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LockSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
153  break;
154  case GNETEXTURE_NOTMOVING :
155  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMoving, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
156  break;
158  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMovingSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
159  break;
160  case GNETEXTURE_REROUTER :
161  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
162  break;
164  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RerouterSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
165  break;
166  case GNETEXTURE_ROUTEPROBE :
167  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbe, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
168  break;
170  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbeSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
171  break;
172  case GNETEXTURE_TLS :
173  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_TLS, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
174  break;
175  case GNETEXTURE_VAPORIZER :
176  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Vaporizer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
177  break;
179  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VaporizerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
180  break;
182  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSign, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
183  break;
185  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSignSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
186  break;
187  case GNETEXTURE_LANEBIKE :
188  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBike, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
189  break;
190  case GNETEXTURE_LANEBUS :
191  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBus, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
192  break;
194  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LanePedestrian, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
195  break;
196  default:
197  throw ProcessError("Undefined texture");
198  }
199  // Set loaded flag to true
200  i->second.first = true;
201  }
202  // Return GLID associated to the texture
203  return i->second.second;
204 }
205 
206 
207 void
209  // Reset all textures
211  for (std::map<GUITexture, std::pair<bool, GUIGlID> >::iterator i = myInstance->myTextures.begin(); i != myInstance->myTextures.end(); i++) {
212  i->second.first = false;
213  }
214 }
215 
216 
217 void
219  delete myInstance;
220  myInstance = 0;
221 }
222 
223 
224 /****************************************************************************/
225 
const unsigned char GNETexture_LanePedestrian[]
const unsigned char GNETexture_VariableSpeedSignSelected[]
const unsigned char GNETexture_RouteProbe[]
const unsigned char GNETexture_NotMoving[]
static GUIGlID add(FXImage *i)
Adds a texture to use.
const unsigned char GNETexture_RerouterSelected[]
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
const unsigned char GNETexture_LaneBike[]
const unsigned char GNETexture_Empty[]
const unsigned char GNETexture_Rerouter[]
const unsigned char GNETexture_Entry[]
const unsigned char GNETexture_E1[]
static void resetTextures()
Reset textures.
const unsigned char GNETexture_E3[]
const unsigned char GNETexture_Vaporizer[]
const unsigned char GNETexture_VaporizerSelected[]
const unsigned char GNETexture_TLS[]
GUITextureSubSys(FXApp *a)
constructor private because is called by the static function init(FXApp* a
const unsigned char GNETexture_Lock[]
~GUITextureSubSys()
destructor
static void clearTextures()
clears loaded textures
static void close()
close GUITextureSubSys
const unsigned char GNETexture_Exit[]
const unsigned char GNETexture_LockSelected[]
FXApp * myApp
to Fox App
const unsigned char GNETexture_VariableSpeedSign[]
const unsigned char GNETexture_E2[]
const unsigned char GNETexture_LaneBus[]
unsigned int GUIGlID
Definition: GUIGlObject.h:50
const unsigned char GNETexture_EmptySelected[]
static GUITextureSubSys * myInstance
instance of GUITextureSubSys
const unsigned char GNETexture_RouteProbeSelected[]
static void initTextures(FXApp *a)
Initiate GUITextureSubSys for textures.
std::map< GUITexture, std::pair< bool, GUIGlID > > myTextures
vector with the Gifs
GUITexture
An enumeration of gifs used by the gui applications.
Definition: GUITextures.h:41
const unsigned char GNETexture_E3Selected[]
const unsigned char GNETexture_NotMovingSelected[]