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-2017 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:
81  class UpdateTarget {
82 
83  public:
85  virtual ~UpdateTarget() {};
86 
88  virtual void selectionUpdated() = 0;
89  };
90 
91 public:
94 
97 
114  bool isSelected(GUIGlObjectType type, GUIGlID id);
115 
131  void select(GUIGlID id, bool update = true);
132 
148  void deselect(GUIGlID id);
149 
164  void toggleSelection(GUIGlID id);
165 
167  const std::set<GUIGlID>& getSelected() const;
168 
175  const std::set<GUIGlID>& getSelected(GUIGlObjectType type);
176 
183  void clear();
184 
191  std::string load(const std::string& filename, GUIGlObjectType type = GLO_MAX);
192 
202  std::set<GUIGlID> loadIDs(const std::string& filename, std::string& msgOut, GUIGlObjectType type = GLO_MAX, int maxErrors = 16);
203 
209  void save(GUIGlObjectType type, const std::string& filename);
210 
215  void save(const std::string& filename) const;
216 
220  void add2Update(UpdateTarget* updateTarget);
221 
223  void remove2Update();
224 
230 
231  public:
234 
237 
242  bool isSelected(GUIGlID id);
243 
247  void select(GUIGlID id);
248 
252  void deselect(GUIGlID id);
253 
255  void clear();
256 
260  void save(const std::string& filename);
261 
265  const std::set<GUIGlID>& getSelected() const;
266 
267  private:
269  std::set<GUIGlID> mySelected;
270 
271  };
272 
274  friend class SingleTypeSelections;
275 
276 
277 private:
279  std::map<GUIGlObjectType, SingleTypeSelections> mySelections;
280 
282  std::set<GUIGlID> myAllSelected;
283 
286 
288  std::string load(GUIGlObjectType type, const std::string& filename, bool restrictType, std::set<GUIGlID>& into);
289 
291  static void save(const std::string& filename, const std::set<GUIGlID>& ids);
292 };
293 
294 
295 #endif
296 
297 /****************************************************************************/
298 
virtual void selectionUpdated()=0
called when selection is updated
const std::set< GUIGlID > & getSelected() const
Returns the set 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
set SingleTypeSelections as friend class
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
map with the selections
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...
virtual ~UpdateTarget()
virtual destructor
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.