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-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 
57 
58 #ifdef CHECK_MEMORY_LEAKS
59 #include <foreign/nvwa/debug_new.h>
60 #endif // CHECK_MEMORY_LEAKS
61 
62 
63 // ===========================================================================
64 // static member variable definitions
65 // ===========================================================================
66 
68 
69 // ===========================================================================
70 // member definitions
71 // ===========================================================================
72 
74  myApp(a) {
75  // Fill map of textures
76  myTextures[GNETEXTURE_E1] = std::pair<bool, GUIGlID>(false, 0);
77  myTextures[GNETEXTURE_E2] = std::pair<bool, GUIGlID>(false, 0);
78  myTextures[GNETEXTURE_E3] = std::pair<bool, GUIGlID>(false, 0);
79  myTextures[GNETEXTURE_E3SELECTED] = std::pair<bool, GUIGlID>(false, 0);
80  myTextures[GNETEXTURE_EMPTY] = std::pair<bool, GUIGlID>(false, 0);
81  myTextures[GNETEXTURE_EMPTYSELECTED] = std::pair<bool, GUIGlID>(false, 0);
82  myTextures[GNETEXTURE_ENTRY] = std::pair<bool, GUIGlID>(false, 0);
83  myTextures[GNETEXTURE_EXIT] = std::pair<bool, GUIGlID>(false, 0);
84  myTextures[GNETEXTURE_LOCK] = std::pair<bool, GUIGlID>(false, 0);
85  myTextures[GNETEXTURE_LOCKSELECTED] = std::pair<bool, GUIGlID>(false, 0);
86  myTextures[GNETEXTURE_NOTMOVING] = std::pair<bool, GUIGlID>(false, 0);
87  myTextures[GNETEXTURE_NOTMOVINGSELECTED] = std::pair<bool, GUIGlID>(false, 0);
88  myTextures[GNETEXTURE_REROUTER] = std::pair<bool, GUIGlID>(false, 0);
89  myTextures[GNETEXTURE_REROUTERSELECTED] = std::pair<bool, GUIGlID>(false, 0);
90  myTextures[GNETEXTURE_ROUTEPROBE] = std::pair<bool, GUIGlID>(false, 0);
91  myTextures[GNETEXTURE_ROUTEPROBESELECTED] = std::pair<bool, GUIGlID>(false, 0);
92  myTextures[GNETEXTURE_TLS] = std::pair<bool, GUIGlID>(false, 0);
93  myTextures[GNETEXTURE_VAPORIZER] = std::pair<bool, GUIGlID>(false, 0);
94  myTextures[GNETEXTURE_VAPORIZERSELECTED] = std::pair<bool, GUIGlID>(false, 0);
95  myTextures[GNETEXTURE_VARIABLESPEEDSIGNAL] = std::pair<bool, GUIGlID>(false, 0);
96  myTextures[GNETEXTURE_VARIABLESPEEDSIGNALSELECTED] = std::pair<bool, GUIGlID>(false, 0);
97 }
98 
99 
101 }
102 
103 
104 void
106  assert(myInstance == 0);
107  myInstance = new GUITextureSubSys(a);
108 }
109 
110 
111 GUIGlID
113  // Obtain GLID and boolean associated to this texture
114  std::map<GUITexture, std::pair<bool, GUIGlID> >::iterator i = myInstance->myTextures.find(which);
115 
116  // If texture isn't loaded
117  if (i->second.first == false) {
118  switch (i->first) {
119  case GNETEXTURE_E1 :
120  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E1, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
121  break;
122  case GNETEXTURE_E2 :
123  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E2, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
124  break;
125  case GNETEXTURE_E3 :
126  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
127  break;
128  case GNETEXTURE_E3SELECTED :
129  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3Selected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
130  break;
131  case GNETEXTURE_EMPTY :
132  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Empty, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
133  break;
135  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_EmptySelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
136  break;
137  case GNETEXTURE_ENTRY :
138  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Entry, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
139  break;
140  case GNETEXTURE_EXIT :
141  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Exit, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
142  break;
143  case GNETEXTURE_LOCK :
144  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Lock, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
145  break;
147  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LockSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
148  break;
149  case GNETEXTURE_NOTMOVING :
150  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMoving, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
151  break;
153  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMovingSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
154  break;
155  case GNETEXTURE_REROUTER :
156  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
157  break;
159  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RerouterSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
160  break;
161  case GNETEXTURE_ROUTEPROBE :
162  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbe, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
163  break;
165  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbeSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
166  break;
167  case GNETEXTURE_TLS :
168  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_TLS, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
169  break;
170  case GNETEXTURE_VAPORIZER :
171  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Vaporizer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
172  break;
174  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VaporizerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
175  break;
177  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSignal, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
178  break;
180  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSignalSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
181  break;
182  default:
183  throw ProcessError("Undefined texture");
184  }
185 
186  }
187  // Return GLID associated to the texture
188  return i->second.second;
189 }
190 
191 
192 void
194  // Reset all textures
195  for (std::map<GUITexture, std::pair<bool, GUIGlID> >::iterator i = myInstance->myTextures.begin(); i != myInstance->myTextures.end(); i++) {
196  i->second.first = false;
197  }
198 }
199 
200 
201 void
203  delete myInstance;
204  myInstance = 0;
205 }
206 
207 
208 /****************************************************************************/
209 
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_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[]
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[]