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 
62 // ===========================================================================
63 // static member variable definitions
64 // ===========================================================================
65 
67 
68 // ===========================================================================
69 // member definitions
70 // ===========================================================================
71 
73  myApp(a) {
74  // Fill map of textures
75  myTextures[GNETEXTURE_E1] = std::pair<bool, GUIGlID>(false, 0);
76  myTextures[GNETEXTURE_E2] = std::pair<bool, GUIGlID>(false, 0);
77  myTextures[GNETEXTURE_E3] = std::pair<bool, GUIGlID>(false, 0);
78  myTextures[GNETEXTURE_E3SELECTED] = std::pair<bool, GUIGlID>(false, 0);
79  myTextures[GNETEXTURE_EMPTY] = std::pair<bool, GUIGlID>(false, 0);
80  myTextures[GNETEXTURE_EMPTYSELECTED] = std::pair<bool, GUIGlID>(false, 0);
81  myTextures[GNETEXTURE_ENTRY] = std::pair<bool, GUIGlID>(false, 0);
82  myTextures[GNETEXTURE_EXIT] = std::pair<bool, GUIGlID>(false, 0);
83  myTextures[GNETEXTURE_LOCK] = std::pair<bool, GUIGlID>(false, 0);
84  myTextures[GNETEXTURE_LOCKSELECTED] = std::pair<bool, GUIGlID>(false, 0);
85  myTextures[GNETEXTURE_NOTMOVING] = std::pair<bool, GUIGlID>(false, 0);
86  myTextures[GNETEXTURE_NOTMOVINGSELECTED] = std::pair<bool, GUIGlID>(false, 0);
87  myTextures[GNETEXTURE_REROUTER] = std::pair<bool, GUIGlID>(false, 0);
88  myTextures[GNETEXTURE_REROUTERSELECTED] = std::pair<bool, GUIGlID>(false, 0);
89  myTextures[GNETEXTURE_ROUTEPROBE] = std::pair<bool, GUIGlID>(false, 0);
90  myTextures[GNETEXTURE_ROUTEPROBESELECTED] = std::pair<bool, GUIGlID>(false, 0);
91  myTextures[GNETEXTURE_TLS] = std::pair<bool, GUIGlID>(false, 0);
92  myTextures[GNETEXTURE_VAPORIZER] = std::pair<bool, GUIGlID>(false, 0);
93  myTextures[GNETEXTURE_VAPORIZERSELECTED] = std::pair<bool, GUIGlID>(false, 0);
94  myTextures[GNETEXTURE_VARIABLESPEEDSIGN] = std::pair<bool, GUIGlID>(false, 0);
95  myTextures[GNETEXTURE_VARIABLESPEEDSIGNSELECTED] = std::pair<bool, GUIGlID>(false, 0);
96  myTextures[GNETEXTURE_LANEBIKE] = std::pair<bool, GUIGlID>(false, 0);
97  myTextures[GNETEXTURE_LANEBUS] = std::pair<bool, GUIGlID>(false, 0);
98  myTextures[GNETEXTURE_LANEPEDESTRIAN] = std::pair<bool, GUIGlID>(false, 0);
99 }
100 
101 
103 }
104 
105 
106 void
108  assert(myInstance == 0);
109  myInstance = new GUITextureSubSys(a);
110 }
111 
112 
113 GUIGlID
115  // Obtain GLID and boolean associated to this texture
116  std::map<GUITexture, std::pair<bool, GUIGlID> >::iterator i = myInstance->myTextures.find(which);
117  // If texture isn't loaded, load it
118  if (i->second.first == false) {
119  switch (i->first) {
120  case GNETEXTURE_E1 :
121  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E1, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
122  break;
123  case GNETEXTURE_E2 :
124  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E2, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
125  break;
126  case GNETEXTURE_E3 :
127  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
128  break;
129  case GNETEXTURE_E3SELECTED :
130  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3Selected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
131  break;
132  case GNETEXTURE_EMPTY :
133  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Empty, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
134  break;
136  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_EmptySelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
137  break;
138  case GNETEXTURE_ENTRY :
139  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Entry, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
140  break;
141  case GNETEXTURE_EXIT :
142  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Exit, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
143  break;
144  case GNETEXTURE_LOCK :
145  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Lock, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
146  break;
148  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LockSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
149  break;
150  case GNETEXTURE_NOTMOVING :
151  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMoving, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
152  break;
154  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMovingSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
155  break;
156  case GNETEXTURE_REROUTER :
157  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
158  break;
160  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RerouterSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
161  break;
162  case GNETEXTURE_ROUTEPROBE :
163  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbe, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
164  break;
166  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbeSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
167  break;
168  case GNETEXTURE_TLS :
169  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_TLS, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
170  break;
171  case GNETEXTURE_VAPORIZER :
172  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Vaporizer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
173  break;
175  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VaporizerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
176  break;
178  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSign, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
179  break;
181  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSignSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
182  break;
183  case GNETEXTURE_LANEBIKE :
184  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBike, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
185  break;
186  case GNETEXTURE_LANEBUS :
187  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBus, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
188  break;
190  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LanePedestrian, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
191  break;
192  default:
193  throw ProcessError("Undefined texture");
194  }
195  // Set loaded flag to true
196  i->second.first = true;
197  }
198  // Return GLID associated to the texture
199  return i->second.second;
200 }
201 
202 
203 void
205  // Reset all textures
207  for (std::map<GUITexture, std::pair<bool, GUIGlID> >::iterator i = myInstance->myTextures.begin(); i != myInstance->myTextures.end(); i++) {
208  i->second.first = false;
209  }
210 }
211 
212 
213 void
215  delete myInstance;
216  myInstance = 0;
217 }
218 
219 
220 /****************************************************************************/
221 
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[]