Eclipse 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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Helper for Gifs loading and usage
19 /****************************************************************************/
20 #include <config.h>
21 
23 #include <cassert>
25 #include <utils/common/ToString.h>
27 
28 #include "GUITextureSubSys.h"
29 
30 #include "GNETexture_E3.cpp"
32 #include "GNETexture_LaneBike.cpp"
33 #include "GNETexture_LaneBus.cpp"
35 #include "GNETexture_Lock.cpp"
36 #include "GNETexture_NotMoving.cpp"
38 #include "GNETexture_Rerouter.cpp"
48 #include "GNETexture_Stop.cpp"
54 #include "GNETexture_TLS.cpp"
55 #include "GNETexture_Vaporizer.cpp"
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
103 }
104 
105 
107 }
108 
109 
110 void
112  assert(myInstance == 0);
113  myInstance = new GUITextureSubSys(a);
114 }
115 
116 
117 GUIGlID
119  // If texture isn't loaded, load it
120  if (myInstance->myTextures.at(which) == 0) {
121  switch (which) {
122  case GUITexture::E3 :
123  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
124  break;
126  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3Selected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
127  break;
128  case GUITexture::LOCK :
129  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Lock, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
130  break;
131  case GUITexture::NOTMOVING :
132  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMoving, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
133  break;
135  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMovingSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
136  break;
137  case GUITexture::REROUTER :
138  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
139  break;
141  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RerouterSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
142  break;
144  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter_Interval, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
145  break;
147  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter_ClosingReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
148  break;
150  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter_ClosingLaneReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
151  break;
153  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter_RouteProbReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
154  break;
156  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter_DestProbReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
157  break;
159  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter_ParkingAreaReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
160  break;
162  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbe, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
163  break;
165  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbeSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
166  break;
167  case GUITexture::TLS :
168  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_TLS, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
169  break;
170  case GUITexture::VAPORIZER :
171  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Vaporizer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
172  break;
174  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VaporizerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
175  break;
177  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSign, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
178  break;
180  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSignSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
181  break;
183  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSign_Step, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
184  break;
185  case GUITexture::LANE_BIKE :
186  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBike, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
187  break;
188  case GUITexture::LANE_BUS :
189  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBus, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
190  break;
192  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LanePedestrian, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
193  break;
194  case GUITexture::STOP:
195  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Stop, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
196  break;
198  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_StopSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
199  break;
201  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_StopPerson, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
202  break;
204  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_StopPersonSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
205  break;
207  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_StopContainer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
208  break;
210  myInstance->myTextures[which] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_StopContainerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
211  break;
212  default:
213  throw ProcessError("Undefined texture");
214  }
215  }
216  // Return GLID associated to the texture
217  return myInstance->myTextures.at(which);
218 }
219 
220 
221 void
223  // Reset all textures
225  for (auto& i : myInstance->myTextures) {
226  i.second = 0;
227  }
228 }
229 
230 
231 void
233  delete myInstance;
234  myInstance = nullptr;
235 }
236 
237 
238 /****************************************************************************/
const unsigned char GNETexture_E3[]
const unsigned char GNETexture_E3Selected[]
const unsigned char GNETexture_LaneBike[]
const unsigned char GNETexture_LaneBus[]
const unsigned char GNETexture_LanePedestrian[]
const unsigned char GNETexture_Lock[]
const unsigned char GNETexture_NotMoving[]
const unsigned char GNETexture_NotMovingSelected[]
const unsigned char GNETexture_Rerouter[]
const unsigned char GNETexture_Rerouter_ClosingLaneReroute[]
const unsigned char GNETexture_Rerouter_ClosingReroute[]
const unsigned char GNETexture_Rerouter_DestProbReroute[]
const unsigned char GNETexture_Rerouter_Interval[]
const unsigned char GNETexture_Rerouter_ParkingAreaReroute[]
const unsigned char GNETexture_Rerouter_RouteProbReroute[]
const unsigned char GNETexture_RerouterSelected[]
const unsigned char GNETexture_RouteProbe[]
const unsigned char GNETexture_RouteProbeSelected[]
const unsigned char GNETexture_Stop[]
const unsigned char GNETexture_StopContainer[]
const unsigned char GNETexture_StopContainerSelected[]
const unsigned char GNETexture_StopPerson[]
const unsigned char GNETexture_StopPersonSelected[]
const unsigned char GNETexture_StopSelected[]
const unsigned char GNETexture_TLS[]
const unsigned char GNETexture_Vaporizer[]
const unsigned char GNETexture_VaporizerSelected[]
const unsigned char GNETexture_VariableSpeedSign[]
const unsigned char GNETexture_VariableSpeedSign_Step[]
const unsigned char GNETexture_VariableSpeedSignSelected[]
unsigned int GUIGlID
Definition: GUIGlObject.h:40
GUITexture
An enumeration of gifs used by the gui applications.
Definition: GUITextures.h:31
@ STOPCONTAINER_SELECTED
@ VAPORIZER_SELECTED
@ REROUTER_CLOSINGREROUTE
@ REROUTER_ROUTEPROBREROUTE
@ STOPPERSON_SELECTED
@ VARIABLESPEEDSIGN_STEP
@ ROUTEPROBE_SELECTED
@ REROUTER_CLOSINGLANEREROUTE
@ VARIABLESPEEDSIGN_SELECTED
@ REROUTER_DESTPROBREROUTE
@ REROUTER_PARKINGAREAREROUTE
@ NOTMOVING_SELECTED
static void close()
close GUITextureSubSys
static void resetTextures()
Reset textures.
std::map< GUITexture, GUIGlID > myTextures
vector with the Gifs
static void initTextures(FXApp *a)
Initiate GUITextureSubSys for textures.
~GUITextureSubSys()
destructor
static GUITextureSubSys * myInstance
instance of GUITextureSubSys
FXApp * myApp
@pointer to Fox App
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
GUITextureSubSys(FXApp *a)
constructor private because is called by the static function init(FXApp* a
static GUIGlID add(FXImage *i)
Adds a texture to use.
static void clearTextures()
clears loaded textures