SUMO - Simulation of Urban MObility
GUITextureSubSys.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // Helper for Gifs loading and usage
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #include <fx.h>
31 #include <cassert>
32 #include "GUITextureSubSys.h"
33 
34 #include "GNETexture_Lock.cpp"
36 #include "GNETexture_Empty.cpp"
38 #include "GNETexture_TLS.cpp"
39 #include "GNETexture_E3.cpp"
41 #include "GNETexture_Rerouter.cpp"
45 #include "GNETexture_Vaporizer.cpp"
49 #include "GNETexture_NotMoving.cpp"
51 #include "GNETexture_LaneBus.cpp"
53 #include "GNETexture_LaneBike.cpp"
54 
55 
56 
57 // ===========================================================================
58 // static member variable definitions
59 // ===========================================================================
60 
62 
63 // ===========================================================================
64 // member definitions
65 // ===========================================================================
66 
68  myApp(a) {
69  // Fill map of textures
70  myTextures[GNETEXTURE_E3] = std::pair<bool, GUIGlID>(false, 0);
71  myTextures[GNETEXTURE_E3SELECTED] = std::pair<bool, GUIGlID>(false, 0);
72  myTextures[GNETEXTURE_EMPTY] = std::pair<bool, GUIGlID>(false, 0);
73  myTextures[GNETEXTURE_EMPTYSELECTED] = std::pair<bool, GUIGlID>(false, 0);
74  myTextures[GNETEXTURE_LOCK] = std::pair<bool, GUIGlID>(false, 0);
75  myTextures[GNETEXTURE_LOCKSELECTED] = std::pair<bool, GUIGlID>(false, 0);
76  myTextures[GNETEXTURE_NOTMOVING] = std::pair<bool, GUIGlID>(false, 0);
77  myTextures[GNETEXTURE_NOTMOVINGSELECTED] = std::pair<bool, GUIGlID>(false, 0);
78  myTextures[GNETEXTURE_REROUTER] = std::pair<bool, GUIGlID>(false, 0);
79  myTextures[GNETEXTURE_REROUTERSELECTED] = std::pair<bool, GUIGlID>(false, 0);
80  myTextures[GNETEXTURE_ROUTEPROBE] = std::pair<bool, GUIGlID>(false, 0);
81  myTextures[GNETEXTURE_ROUTEPROBESELECTED] = std::pair<bool, GUIGlID>(false, 0);
82  myTextures[GNETEXTURE_TLS] = std::pair<bool, GUIGlID>(false, 0);
83  myTextures[GNETEXTURE_VAPORIZER] = std::pair<bool, GUIGlID>(false, 0);
84  myTextures[GNETEXTURE_VAPORIZERSELECTED] = std::pair<bool, GUIGlID>(false, 0);
85  myTextures[GNETEXTURE_VARIABLESPEEDSIGN] = std::pair<bool, GUIGlID>(false, 0);
86  myTextures[GNETEXTURE_VARIABLESPEEDSIGNSELECTED] = std::pair<bool, GUIGlID>(false, 0);
87  myTextures[GNETEXTURE_LANEBIKE] = std::pair<bool, GUIGlID>(false, 0);
88  myTextures[GNETEXTURE_LANEBUS] = std::pair<bool, GUIGlID>(false, 0);
89  myTextures[GNETEXTURE_LANEPEDESTRIAN] = std::pair<bool, GUIGlID>(false, 0);
90 }
91 
92 
94 }
95 
96 
97 void
99  assert(myInstance == 0);
100  myInstance = new GUITextureSubSys(a);
101 }
102 
103 
104 GUIGlID
106  // Obtain GLID and boolean associated to this texture
107  std::map<GUITexture, std::pair<bool, GUIGlID> >::iterator i = myInstance->myTextures.find(which);
108  // If texture isn't loaded, load it
109  if (i->second.first == false) {
110  switch (i->first) {
111  case GNETEXTURE_E3 :
112  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
113  break;
114  case GNETEXTURE_E3SELECTED :
115  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3Selected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
116  break;
117  case GNETEXTURE_EMPTY :
118  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Empty, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
119  break;
121  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_EmptySelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
122  break;
123  case GNETEXTURE_LOCK :
124  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Lock, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
125  break;
127  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LockSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
128  break;
129  case GNETEXTURE_NOTMOVING :
130  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMoving, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
131  break;
133  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMovingSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
134  break;
135  case GNETEXTURE_REROUTER :
136  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
137  break;
139  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RerouterSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
140  break;
141  case GNETEXTURE_ROUTEPROBE :
142  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbe, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
143  break;
145  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbeSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
146  break;
147  case GNETEXTURE_TLS :
148  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_TLS, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
149  break;
150  case GNETEXTURE_VAPORIZER :
151  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Vaporizer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
152  break;
154  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VaporizerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
155  break;
157  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSign, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
158  break;
160  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSignSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
161  break;
162  case GNETEXTURE_LANEBIKE :
163  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBike, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
164  break;
165  case GNETEXTURE_LANEBUS :
166  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBus, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
167  break;
169  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LanePedestrian, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
170  break;
171  default:
172  throw ProcessError("Undefined texture");
173  }
174  // Set loaded flag to true
175  i->second.first = true;
176  }
177  // Return GLID associated to the texture
178  return i->second.second;
179 }
180 
181 
182 void
184  // Reset all textures
186  for (std::map<GUITexture, std::pair<bool, GUIGlID> >::iterator i = myInstance->myTextures.begin(); i != myInstance->myTextures.end(); i++) {
187  i->second.first = false;
188  }
189 }
190 
191 
192 void
194  delete myInstance;
195  myInstance = 0;
196 }
197 
198 
199 /****************************************************************************/
200 
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[]
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_LockSelected[]
FXApp * myApp
to Fox App
const unsigned char GNETexture_VariableSpeedSign[]
const unsigned char GNETexture_LaneBus[]
unsigned int GUIGlID
Definition: GUIGlObject.h:49
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:40
const unsigned char GNETexture_E3Selected[]
const unsigned char GNETexture_NotMovingSelected[]