SUMO - Simulation of Urban MObility
GUISelectedStorage.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Storage for "selected" objects
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef GUISelectedStorage_h
23 #define GUISelectedStorage_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <set>
36 #include <string>
37 #include <map>
38 #include <fstream>
39 #include <fx.h>
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class OutputDevice;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
78 
79 public:
80  class UpdateTarget {
81  public:
82  virtual ~UpdateTarget() {};
83  virtual void selectionUpdated() = 0;
84  };
85 
86 public:
89 
90 
93 
94 
111  bool isSelected(GUIGlObjectType type, GUIGlID id);
112 
113 
129  void select(GUIGlID id, bool update = true);
130 
131 
147  void deselect(GUIGlID id);
148 
149 
164  void toggleSelection(GUIGlID id);
165 
166 
172  const std::set<GUIGlID>& getSelected() const;
173 
174 
181  const std::set<GUIGlID>& getSelected(GUIGlObjectType type);
182 
183 
190  void clear();
191 
192 
199  std::string load(const std::string& filename, GUIGlObjectType type = GLO_MAX);
200 
201 
211  std::set<GUIGlID> loadIDs(const std::string& filename, std::string& msgOut, GUIGlObjectType type = GLO_MAX, int maxErrors = 16);
212 
213 
219  void save(GUIGlObjectType type, const std::string& filename);
220 
225  void save(const std::string& filename) const;
226 
227 
231  void add2Update(UpdateTarget* updateTarget);
232 
233 
236  void remove2Update();
237 
238 
244  public:
247 
250 
251 
256  bool isSelected(GUIGlID id);
257 
258 
262  void select(GUIGlID id);
263 
264 
268  void deselect(GUIGlID id);
269 
270 
272  void clear();
273 
274 
278  void save(const std::string& filename);
279 
280 
284  const std::set<GUIGlID>& getSelected() const;
285 
286  private:
288  std::set<GUIGlID> mySelected;
289 
290  };
291  friend class SingleTypeSelections;
292 
293 
294 private:
295  std::map<GUIGlObjectType, SingleTypeSelections> mySelections;
296 
298  std::set<GUIGlID> myAllSelected;
299 
302 
303  /* @brief load items into the given set, optionally restricting to type
304  */
305  std::string load(GUIGlObjectType type, const std::string& filename, bool restrictType, std::set<GUIGlID>& into);
306 
307 
309  static void save(const std::string& filename, const std::set<GUIGlID>& ids);
310 
311 };
312 
313 
314 #endif
315 
316 /****************************************************************************/
317 
const std::set< GUIGlID > & getSelected() const
Returns the list of ids of all selected objects.
~GUISelectedStorage()
Destructor.
GUIGlObjectType
std::set< GUIGlID > mySelected
The list of selected ids.
void toggleSelection(GUIGlID id)
Toggles selection of an object.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
friend class SingleTypeSelections
void remove2Update()
Removes the dialog to be updated.
std::set< GUIGlID > myAllSelected
List of selected objects.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
std::map< GUIGlObjectType, SingleTypeSelections > mySelections
std::set< GUIGlID > loadIDs(const std::string &filename, std::string &msgOut, GUIGlObjectType type=GLO_MAX, int maxErrors=16)
Loads a selection list (optionally with restricted type) and returns the ids of all active objects...
A container for ids of selected objects of a certain type.
std::string load(const std::string &filename, GUIGlObjectType type=GLO_MAX)
Loads a selection list (optionally with restricted type)
Storage for "selected" objects.
unsigned int GUIGlID
Definition: GUIGlObject.h:50
void deselect(GUIGlID id)
Deselects the object with the given id.
void add2Update(UpdateTarget *updateTarget)
Adds a dialog to be updated.
void clear()
Clears the list of selected objects.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
empty max
GUISelectedStorage()
Constructor.
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.
UpdateTarget * myUpdateTarget
The dialog to be updated.