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_E3.cpp"
42 #include "GNETexture_Rerouter.cpp"
46 #include "GNETexture_Vaporizer.cpp"
50 #include "GNETexture_NotMoving.cpp"
52 #include "GNETexture_LaneBus.cpp"
54 #include "GNETexture_LaneBike.cpp"
55 
56 
57 
58 // ===========================================================================
59 // static member variable definitions
60 // ===========================================================================
61 
63 
64 // ===========================================================================
65 // member definitions
66 // ===========================================================================
67 
69  myApp(a) {
70  // Fill map of textures
71  myTextures[GNETEXTURE_E3] = std::pair<bool, GUIGlID>(false, 0);
72  myTextures[GNETEXTURE_E3SELECTED] = std::pair<bool, GUIGlID>(false, 0);
73  myTextures[GNETEXTURE_EMPTY] = std::pair<bool, GUIGlID>(false, 0);
74  myTextures[GNETEXTURE_EMPTYSELECTED] = std::pair<bool, GUIGlID>(false, 0);
75  myTextures[GNETEXTURE_LOCK] = std::pair<bool, GUIGlID>(false, 0);
76  myTextures[GNETEXTURE_LOCKSELECTED] = std::pair<bool, GUIGlID>(false, 0);
77  myTextures[GNETEXTURE_NOTMOVING] = std::pair<bool, GUIGlID>(false, 0);
78  myTextures[GNETEXTURE_NOTMOVINGSELECTED] = std::pair<bool, GUIGlID>(false, 0);
79  myTextures[GNETEXTURE_REROUTER] = std::pair<bool, GUIGlID>(false, 0);
80  myTextures[GNETEXTURE_REROUTERSELECTED] = std::pair<bool, GUIGlID>(false, 0);
81  myTextures[GNETEXTURE_ROUTEPROBE] = std::pair<bool, GUIGlID>(false, 0);
82  myTextures[GNETEXTURE_ROUTEPROBESELECTED] = std::pair<bool, GUIGlID>(false, 0);
83  myTextures[GNETEXTURE_TLS] = std::pair<bool, GUIGlID>(false, 0);
84  myTextures[GNETEXTURE_VAPORIZER] = std::pair<bool, GUIGlID>(false, 0);
85  myTextures[GNETEXTURE_VAPORIZERSELECTED] = std::pair<bool, GUIGlID>(false, 0);
86  myTextures[GNETEXTURE_VARIABLESPEEDSIGN] = std::pair<bool, GUIGlID>(false, 0);
87  myTextures[GNETEXTURE_VARIABLESPEEDSIGNSELECTED] = std::pair<bool, GUIGlID>(false, 0);
88  myTextures[GNETEXTURE_LANEBIKE] = std::pair<bool, GUIGlID>(false, 0);
89  myTextures[GNETEXTURE_LANEBUS] = std::pair<bool, GUIGlID>(false, 0);
90  myTextures[GNETEXTURE_LANEPEDESTRIAN] = std::pair<bool, GUIGlID>(false, 0);
91 }
92 
93 
95 }
96 
97 
98 void
100  assert(myInstance == 0);
101  myInstance = new GUITextureSubSys(a);
102 }
103 
104 
105 GUIGlID
107  // Obtain GLID and boolean associated to this texture
108  std::map<GUITexture, std::pair<bool, GUIGlID> >::iterator i = myInstance->myTextures.find(which);
109  // If texture isn't loaded, load it
110  if (i->second.first == false) {
111  switch (i->first) {
112  case GNETEXTURE_E3 :
113  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
114  break;
115  case GNETEXTURE_E3SELECTED :
116  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_E3Selected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
117  break;
118  case GNETEXTURE_EMPTY :
119  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Empty, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
120  break;
122  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_EmptySelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
123  break;
124  case GNETEXTURE_LOCK :
125  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Lock, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
126  break;
128  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LockSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
129  break;
130  case GNETEXTURE_NOTMOVING :
131  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMoving, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
132  break;
134  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_NotMovingSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
135  break;
136  case GNETEXTURE_REROUTER :
137  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Rerouter, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
138  break;
140  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RerouterSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
141  break;
142  case GNETEXTURE_ROUTEPROBE :
143  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbe, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
144  break;
146  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_RouteProbeSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
147  break;
148  case GNETEXTURE_TLS :
149  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_TLS, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
150  break;
151  case GNETEXTURE_VAPORIZER :
152  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_Vaporizer, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
153  break;
155  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VaporizerSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
156  break;
158  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSign, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
159  break;
161  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_VariableSpeedSignSelected, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
162  break;
163  case GNETEXTURE_LANEBIKE :
164  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBike, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
165  break;
166  case GNETEXTURE_LANEBUS :
167  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LaneBus, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
168  break;
170  i->second.second = GUITexturesHelper::add(new FXGIFImage(myInstance->myApp, GNETexture_LanePedestrian, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP));
171  break;
172  default:
173  throw ProcessError("Undefined texture");
174  }
175  // Set loaded flag to true
176  i->second.first = true;
177  }
178  // Return GLID associated to the texture
179  return i->second.second;
180 }
181 
182 
183 void
185  // Reset all textures
187  for (std::map<GUITexture, std::pair<bool, GUIGlID> >::iterator i = myInstance->myTextures.begin(); i != myInstance->myTextures.end(); i++) {
188  i->second.first = false;
189  }
190 }
191 
192 
193 void
195  delete myInstance;
196  myInstance = 0;
197 }
198 
199 
200 /****************************************************************************/
201 
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: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[]