SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-sim.org/
12 // Copyright (C) 2001-2014 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 
~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.
void remove2Update()
Removes the dialog to be updated.
std::set< GUIGlID > myAllSelected
List of selected objects.
void clear()
Clears the list of selected objects.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
void save(const std::string &filename)
Saves the list of selected objects to a file named as given.
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...
const std::set< GUIGlID > & getSelected() const
Returns the list of ids of all selected objects.
A container for ids of selected objects of a certain type.
void select(GUIGlID id)
Adds the object with the given id to the list of selected objects.
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:48
void deselect(GUIGlID id)
Deselects the object with the given id from the list of selected objects.
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
bool isSelected(GUIGlID id)
Returns the information whether the object with the given id is qithin the selection.
empty max
GUISelectedStorage()
Constructor.
const std::set< GUIGlID > & getSelected() const
Returns the list of selected ids.
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.
UpdateTarget * myUpdateTarget
The dialog to be updated.