Line data Source code
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 : /****************************************************************************/
14 : /// @file GUITextureSubSys.cpp
15 : /// @author Pablo Alvarez Lopez
16 : /// @date Jul 2016
17 : ///
18 : // Helper for Gifs loading and usage
19 : /****************************************************************************/
20 :
21 :
22 : #include "GUITextureSubSys.h"
23 :
24 : #include "textures/E3.cpp"
25 : #include "textures/E3Selected.cpp"
26 : #include "textures/LaneBike.cpp"
27 : #include "textures/LaneBus.cpp"
28 : #include "textures/LanePedestrian.cpp"
29 : #include "textures/Lock.cpp"
30 : #include "textures/NotMoving.cpp"
31 : #include "textures/NotMovingSelected.cpp"
32 : #include "textures/Rerouter.cpp"
33 : #include "textures/RerouterSelected.cpp"
34 : #include "textures/Rerouter_ClosingLaneReroute.cpp"
35 : #include "textures/Rerouter_ClosingReroute.cpp"
36 : #include "textures/Rerouter_DestProbReroute.cpp"
37 : #include "textures/Rerouter_Interval.cpp"
38 : #include "textures/Rerouter_ParkingAreaReroute.cpp"
39 : #include "textures/Rerouter_RouteProbReroute.cpp"
40 : #include "textures/RouteProbe.cpp"
41 : #include "textures/RouteProbeSelected.cpp"
42 : #include "textures/Stop.cpp"
43 : #include "textures/StopContainer.cpp"
44 : #include "textures/StopContainerSelected.cpp"
45 : #include "textures/StopPerson.cpp"
46 : #include "textures/StopPersonSelected.cpp"
47 : #include "textures/StopSelected.cpp"
48 : #include "textures/TLS.cpp"
49 : #include "textures/TractionSubstation.cpp"
50 : #include "textures/TractionSubstationSelected.cpp"
51 : #include "textures/Vaporizer.cpp"
52 : #include "textures/VaporizerSelected.cpp"
53 : #include "textures/VariableSpeedSign.cpp"
54 : #include "textures/VariableSpeedSignSelected.cpp"
55 : #include "textures/VariableSpeedSign_Step.cpp"
56 :
57 : #include "textures/POITextures/Pin.cpp"
58 : #include "textures/POITextures/Nature.cpp"
59 : #include "textures/POITextures/Hotel.cpp"
60 : #include "textures/POITextures/Fuel.cpp"
61 : #include "textures/POITextures/Charging_station.cpp"
62 :
63 : // ===========================================================================
64 : // static member variable definitions
65 : // ===========================================================================
66 :
67 : GUITextureSubSys* GUITextureSubSys::myInstance = nullptr;
68 :
69 : // ===========================================================================
70 : // member definitions
71 : // ===========================================================================
72 :
73 7551 : GUITextureSubSys::GUITextureSubSys(FXApp* app) :
74 7551 : myApp(app) {
75 7551 : }
76 :
77 :
78 0 : GUITextureSubSys::~GUITextureSubSys() {
79 0 : }
80 :
81 :
82 : void
83 7551 : GUITextureSubSys::initTextures(FXApp* a) {
84 : assert(myInstance == 0);
85 7551 : myInstance = new GUITextureSubSys(a);
86 7551 : }
87 :
88 :
89 : GUIGlID
90 0 : GUITextureSubSys::getTexture(GUITexture textureID) {
91 : // If texture isn't loaded, load it
92 0 : if (myInstance->myTextures.count(textureID) == 0) {
93 0 : switch (textureID) {
94 0 : case GUITexture::E3:
95 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, E3, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
96 0 : break;
97 0 : case GUITexture::E3_SELECTED:
98 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, E3Selected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
99 0 : break;
100 0 : case GUITexture::LOCK:
101 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Lock, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
102 0 : break;
103 0 : case GUITexture::NOTMOVING:
104 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, NotMoving, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
105 0 : break;
106 0 : case GUITexture::NOTMOVING_SELECTED:
107 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, NotMovingSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
108 0 : break;
109 0 : case GUITexture::REROUTER:
110 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
111 0 : break;
112 0 : case GUITexture::REROUTER_SELECTED:
113 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, RerouterSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
114 0 : break;
115 0 : case GUITexture::REROUTER_INTERVAL:
116 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_Interval, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
117 0 : break;
118 0 : case GUITexture::REROUTER_CLOSINGREROUTE:
119 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_ClosingReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
120 0 : break;
121 0 : case GUITexture::REROUTER_CLOSINGLANEREROUTE:
122 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_ClosingLaneReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
123 0 : break;
124 0 : case GUITexture::REROUTER_ROUTEPROBREROUTE:
125 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_RouteProbReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
126 0 : break;
127 0 : case GUITexture::REROUTER_DESTPROBREROUTE:
128 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_DestProbReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
129 0 : break;
130 0 : case GUITexture::REROUTER_PARKINGAREAREROUTE:
131 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Rerouter_ParkingAreaReroute, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
132 0 : break;
133 0 : case GUITexture::ROUTEPROBE:
134 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, RouteProbe, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
135 0 : break;
136 0 : case GUITexture::ROUTEPROBE_SELECTED:
137 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, RouteProbeSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
138 0 : break;
139 0 : case GUITexture::TLS:
140 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, TLS, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
141 0 : break;
142 0 : case GUITexture::VAPORIZER:
143 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Vaporizer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
144 0 : break;
145 0 : case GUITexture::VAPORIZER_SELECTED:
146 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, VaporizerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
147 0 : break;
148 0 : case GUITexture::VARIABLESPEEDSIGN:
149 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, VariableSpeedSign, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
150 0 : break;
151 0 : case GUITexture::VARIABLESPEEDSIGN_SELECTED:
152 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, VariableSpeedSignSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
153 0 : break;
154 0 : case GUITexture::VARIABLESPEEDSIGN_STEP:
155 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, VariableSpeedSign_Step, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
156 0 : break;
157 0 : case GUITexture::LANE_BIKE:
158 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, LaneBike, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
159 0 : break;
160 0 : case GUITexture::LANE_BUS:
161 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, LaneBus, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
162 0 : break;
163 0 : case GUITexture::LANE_PEDESTRIAN:
164 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, LanePedestrian, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
165 0 : break;
166 0 : case GUITexture::STOP:
167 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, Stop, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
168 0 : break;
169 0 : case GUITexture::STOP_SELECTED:
170 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, StopSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
171 0 : break;
172 0 : case GUITexture::STOPPERSON:
173 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, StopPerson, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
174 0 : break;
175 0 : case GUITexture::STOPPERSON_SELECTED:
176 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, StopPersonSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
177 0 : break;
178 0 : case GUITexture::STOPCONTAINER:
179 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, StopContainer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
180 0 : break;
181 0 : case GUITexture::STOPCONTAINER_SELECTED:
182 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, StopContainerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
183 0 : break;
184 0 : case GUITexture::TRACTIONSUBSTATION:
185 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, TractionSubstation, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
186 0 : break;
187 0 : case GUITexture::TRACTIONSUBSTATION_SELECTED:
188 0 : myInstance->myTextures[textureID] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, TractionSubstationSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
189 0 : break;
190 0 : default:
191 0 : throw ProcessError(TL("Undefined texture"));
192 : }
193 : }
194 : // Return GLID associated to the texture
195 0 : return myInstance->myTextures.at(textureID);
196 : }
197 :
198 :
199 : GUIGlID
200 0 : GUITextureSubSys::getPOITexture(POIIcon icon) {
201 : // first check if texture exist
202 0 : if (myInstance->myPOITextures.count(icon) == 0) {
203 0 : switch (icon) {
204 0 : case POIIcon::PIN:
205 0 : myInstance->myPOITextures[icon] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, POITexture_Pin, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
206 0 : break;
207 0 : case POIIcon::NATURE:
208 0 : myInstance->myPOITextures[icon] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, POITexture_Nature, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
209 0 : break;
210 0 : case POIIcon::HOTEL:
211 0 : myInstance->myPOITextures[icon] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, POITexture_Hotel, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
212 0 : break;
213 0 : case POIIcon::FUEL:
214 0 : myInstance->myPOITextures[icon] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, POITexture_Fuel, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
215 0 : break;
216 0 : case POIIcon::CHARGING_STATION:
217 0 : myInstance->myPOITextures[icon] = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, POITexture_Charging_station, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
218 0 : break;
219 0 : default:
220 0 : throw ProcessError("Undefined POI texture");
221 : }
222 : }
223 0 : return myInstance->myPOITextures.at(icon);
224 : }
225 :
226 :
227 : void
228 0 : GUITextureSubSys::resetTextures() {
229 : // Reset all textures
230 0 : GUITexturesHelper::clearTextures();
231 0 : for (auto& texture : myInstance->myTextures) {
232 0 : texture.second = 0;
233 : }
234 : myInstance->myTextures.clear();
235 0 : for (auto& POITexture : myInstance->myPOITextures) {
236 0 : POITexture.second = 0;
237 : }
238 : myInstance->myPOITextures.clear();
239 0 : }
240 :
241 :
242 : void
243 0 : GUITextureSubSys::close() {
244 0 : delete myInstance;
245 0 : myInstance = nullptr;
246 0 : }
247 :
248 : /****************************************************************************/
|