SUMO - Simulation of Urban MObility
GUISelectedStorage.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Storage for "selected" objects
20 /****************************************************************************/
21 #ifndef GUISelectedStorage_h
22 #define GUISelectedStorage_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <set>
35 #include <string>
36 #include <map>
37 #include <fstream>
38 #include <fx.h>
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class OutputDevice;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
77 
78 public:
80  class UpdateTarget {
81 
82  public:
84  virtual ~UpdateTarget() {};
85 
87  virtual void selectionUpdated() = 0;
88  };
89 
90 public:
93 
96 
113  bool isSelected(GUIGlObjectType type, GUIGlID id);
114 
130  void select(GUIGlID id, bool update = true);
131 
147  void deselect(GUIGlID id);
148 
163  void toggleSelection(GUIGlID id);
164 
166  const std::set<GUIGlID>& getSelected() const;
167 
174  const std::set<GUIGlID>& getSelected(GUIGlObjectType type);
175 
182  void clear();
183 
190  std::string load(const std::string& filename, GUIGlObjectType type = GLO_MAX);
191 
201  std::set<GUIGlID> loadIDs(const std::string& filename, std::string& msgOut, GUIGlObjectType type = GLO_MAX, int maxErrors = 16);
202 
208  void save(GUIGlObjectType type, const std::string& filename);
209 
214  void save(const std::string& filename) const;
215 
219  void add2Update(UpdateTarget* updateTarget);
220 
222  void remove2Update();
223 
229 
230  public:
233 
236 
241  bool isSelected(GUIGlID id);
242 
246  void select(GUIGlID id);
247 
251  void deselect(GUIGlID id);
252 
254  void clear();
255 
259  void save(const std::string& filename);
260 
264  const std::set<GUIGlID>& getSelected() const;
265 
266  private:
268  std::set<GUIGlID> mySelected;
269 
270  };
271 
273  friend class SingleTypeSelections;
274 
275 
276 private:
278  std::map<GUIGlObjectType, SingleTypeSelections> mySelections;
279 
281  std::set<GUIGlID> myAllSelected;
282 
285 
287  std::string load(GUIGlObjectType type, const std::string& filename, bool restrictType, std::set<GUIGlID>& into);
288 
290  static void save(const std::string& filename, const std::set<GUIGlID>& ids);
291 };
292 
293 
294 #endif
295 
296 /****************************************************************************/
297 
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:49
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:70
empty max
GUISelectedStorage()
Constructor.
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.
UpdateTarget * myUpdateTarget
The dialog to be updated.