SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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-2016 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_VARIABLESPEEDSIGNAL] = std::pair<bool, GUIGlID>(false, 0);
99  myTextures[GNETEXTURE_VARIABLESPEEDSIGNALSELECTED] = 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 
122  // If texture isn't loaded
123  if (i->second.first == false) {
124  switch (i->first) {
125  case GNETEXTURE_E1 :
126  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E1, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
127  break;
128  case GNETEXTURE_E2 :
129  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E2, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
130  break;
131  case GNETEXTURE_E3 :
132  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
133  break;
134  case GNETEXTURE_E3SELECTED :
135  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3Selected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
136  break;
137  case GNETEXTURE_EMPTY :
138  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Empty, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
139  break;
141  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_EmptySelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
142  break;
143  case GNETEXTURE_ENTRY :
144  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Entry, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
145  break;
146  case GNETEXTURE_EXIT :
147  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Exit, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
148  break;
149  case GNETEXTURE_LOCK :
150  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Lock, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
151  break;
153  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LockSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
154  break;
155  case GNETEXTURE_NOTMOVING :
156  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMoving, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
157  break;
159  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMovingSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
160  break;
161  case GNETEXTURE_REROUTER :
162  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
163  break;
165  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RerouterSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
166  break;
167  case GNETEXTURE_ROUTEPROBE :
168  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbe, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
169  break;
171  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbeSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
172  break;
173  case GNETEXTURE_TLS :
174  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_TLS, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
175  break;
176  case GNETEXTURE_VAPORIZER :
177  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Vaporizer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
178  break;
180  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VaporizerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
181  break;
183  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSignal, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
184  break;
186  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSignalSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
187  break;
188  case GNETEXTURE_LANEBIKE :
189  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBike, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
190  break;
191  case GNETEXTURE_LANEBUS :
192  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBus, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
193  break;
195  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LanePedestrian, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
196  break;
197  default:
198  throw ProcessError("Undefined texture");
199  }
200  // Set loaded flag to true
201  i->second.first = true;
202  }
203  // Return GLID associated to the texture
204  return i->second.second;
205 }
206 
207 
208 void
210  // 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_RouteProbe[]
const unsigned char GNETexture_VariableSpeedSignal[]
const unsigned char GNETexture_NotMoving[]
static GUIGlID add(FXImage *i)
Adds a texture to use.
const unsigned char GNETexture_RerouterSelected[]
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[]
const unsigned char GNETexture_E3[]
const unsigned char GNETexture_Vaporizer[]
const unsigned char GNETexture_VaporizerSelected[]
const unsigned char GNETexture_TLS[]
GUITextureSubSys(FXApp *a)
constructor
const unsigned char GNETexture_Lock[]
~GUITextureSubSys()
destructor
static void close()
close GUITextureSubSys
const unsigned char GNETexture_Exit[]
const unsigned char GNETexture_LockSelected[]
FXApp * myApp
to Fox App
const unsigned char GNETexture_E2[]
const unsigned char GNETexture_LaneBus[]
static void reset()
Reset textures.
unsigned int GUIGlID
Definition: GUIGlObject.h:50
const unsigned char GNETexture_EmptySelected[]
static GUITextureSubSys * myInstance
instance of GUITextureSubSys
static void init(FXApp *a)
Initiate GUITextureSubSys for textures.
const unsigned char GNETexture_VariableSpeedSignalSelected[]
const unsigned char GNETexture_RouteProbeSelected[]
static GUIGlID getGif(GUITexture which)
returns a texture Gif previously defined in the enum GUITexture
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[]