Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUITextureSubSys.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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
21
22#include "GUITextureSubSys.h"
23
24#include "textures/E3.cpp"
26#include "textures/LaneBike.cpp"
27#include "textures/LaneBus.cpp"
29#include "textures/Lock.cpp"
32#include "textures/Rerouter.cpp"
42#include "textures/Stop.cpp"
48#include "textures/TLS.cpp"
56
62
63// ===========================================================================
64// static member variable definitions
65// ===========================================================================
66
68
69// ===========================================================================
70// member definitions
71// ===========================================================================
72
74 myApp(app) {
75}
76
77
80
81
82void
84 assert(myInstance == 0);
86}
87
88
91 // If texture isn't loaded, load it
92 if (myInstance->myTextures.count(textureID) == 0) {
93 switch (textureID) {
94 case GUITexture::E3:
95 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, E3, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
96 break;
98 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, E3Selected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
99 break;
100 case GUITexture::LOCK:
101 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Lock, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
102 break;
104 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, NotMoving, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
105 break;
107 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, NotMovingSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
108 break;
110 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
111 break;
113 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, RerouterSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
114 break;
116 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_Interval, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
117 break;
119 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_ClosingReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
120 break;
122 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_ClosingLaneReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
123 break;
125 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_RouteProbReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
126 break;
128 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_DestProbReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
129 break;
131 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_ParkingAreaReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
132 break;
134 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, RouteProbe, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
135 break;
137 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, RouteProbeSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
138 break;
139 case GUITexture::TLS:
140 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, TLS, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
141 break;
143 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Vaporizer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
144 break;
146 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, VaporizerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
147 break;
149 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, VariableSpeedSign, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
150 break;
152 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, VariableSpeedSignSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
153 break;
155 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, VariableSpeedSign_Step, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
156 break;
158 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, LaneBike, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
159 break;
161 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, LaneBus, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
162 break;
164 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, LanePedestrian, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
165 break;
166 case GUITexture::STOP:
167 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Stop, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
168 break;
170 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, StopSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
171 break;
173 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, StopPerson, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
174 break;
176 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, StopPersonSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
177 break;
179 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, StopContainer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
180 break;
182 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, StopContainerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
183 break;
185 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, TractionSubstation, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
186 break;
188 myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, TractionSubstationSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
189 break;
190 default:
191 throw ProcessError(TL("Undefined texture"));
192 }
193 }
194 // Return GLID associated to the texture
195 return myInstance->myTextures.at(textureID);
196}
197
198
201 // first check if texture exist
202 if (myInstance->myPOITextures.count(icon) == 0) {
203 switch (icon) {
204 case POIIcon::PIN:
205 myInstance->myPOITextures[icon] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, POITexture_Pin, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
206 break;
207 case POIIcon::NATURE:
208 myInstance->myPOITextures[icon] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, POITexture_Nature, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
209 break;
210 case POIIcon::HOTEL:
211 myInstance->myPOITextures[icon] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, POITexture_Hotel, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
212 break;
213 case POIIcon::FUEL:
214 myInstance->myPOITextures[icon] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, POITexture_Fuel, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
215 break;
217 myInstance->myPOITextures[icon] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, POITexture_Charging_station, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
218 break;
219 default:
220 throw ProcessError("Undefined POI texture");
221 }
222 }
223 return myInstance->myPOITextures.at(icon);
224}
225
226
227void
229 // Reset all textures
231 for (auto& texture : myInstance->myTextures) {
232 texture.second = 0;
233 }
234 myInstance->myTextures.clear();
235 for (auto& POITexture : myInstance->myPOITextures) {
236 POITexture.second = 0;
237 }
238 myInstance->myPOITextures.clear();
239}
240
241
242void
244 delete myInstance;
245 myInstance = nullptr;
246}
247
248/****************************************************************************/
const unsigned char POITexture_Charging_station[]
const unsigned char E3[]
Definition E3.cpp:22
const unsigned char E3Selected[]
const unsigned char POITexture_Fuel[]
Definition Fuel.cpp:23
unsigned int GUIGlID
Definition GUIGlObject.h:43
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
@ TRACTIONSUBSTATION_SELECTED
@ TRACTIONSUBSTATION
@ REROUTER_CLOSINGLANEREROUTE
@ VARIABLESPEEDSIGN_SELECTED
@ REROUTER_DESTPROBREROUTE
@ REROUTER_PARKINGAREAREROUTE
@ NOTMOVING_SELECTED
const unsigned char POITexture_Hotel[]
Definition Hotel.cpp:22
const unsigned char LaneBike[]
Definition LaneBike.cpp:22
const unsigned char LaneBus[]
Definition LaneBus.cpp:22
const unsigned char LanePedestrian[]
const unsigned char Lock[]
Definition Lock.cpp:23
#define TL(string)
Definition MsgHandler.h:315
const unsigned char POITexture_Nature[]
Definition Nature.cpp:23
const unsigned char NotMoving[]
Definition NotMoving.cpp:22
const unsigned char NotMovingSelected[]
const unsigned char POITexture_Pin[]
Definition Pin.cpp:23
const unsigned char Rerouter_ClosingLaneReroute[]
const unsigned char Rerouter_ClosingReroute[]
const unsigned char Rerouter_DestProbReroute[]
const unsigned char Rerouter_Interval[]
const unsigned char Rerouter_ParkingAreaReroute[]
const unsigned char Rerouter_RouteProbReroute[]
const unsigned char RerouterSelected[]
const unsigned char RouteProbeSelected[]
POIIcon
POI icons.
@ CHARGING_STATION
const unsigned char StopContainer[]
const unsigned char StopContainerSelected[]
const unsigned char StopPerson[]
const unsigned char StopPersonSelected[]
const unsigned char StopSelected[]
const unsigned char TLS[]
Definition TLS.cpp:22
const unsigned char TractionSubstation[]
const unsigned char TractionSubstationSelected[]
const unsigned char Vaporizer[]
Definition Vaporizer.cpp:22
const unsigned char VaporizerSelected[]
const unsigned char VariableSpeedSign_Step[]
const unsigned char VariableSpeedSignSelected[]
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(FXApp *app)
constructor private because is called by the static function init(FXApp* a
~GUITextureSubSys()
destructor
static GUIGlID getPOITexture(POIIcon POIIcon)
returns texture associated to the given POI image
static GUITextureSubSys * myInstance
instance of GUITextureSubSys
std::map< POIIcon, GUIGlID > myPOITextures
map with textures
FXApp * myApp
@pointer to Fox App
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
static GUIGlID add(FXImage *i)
Adds a texture to use.
static void clearTextures()
clears loaded textures
C++ TraCI client API implementation.
C++ TraCI client API implementation.
Definition of vehicle stop (position and duration)
C++ TraCI client API implementation.