SUMO - Simulation of Urban MObility
GNEChange_Selection.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A change to the network selection
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2016 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 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
31 #include "GNEChange_Selection.h"
32 
33 #ifdef CHECK_MEMORY_LEAKS
34 #include <foreign/nvwa/debug_new.h>
35 #endif
36 
37 
38 // ===========================================================================
39 // FOX-declarations
40 // ===========================================================================
41 FXIMPLEMENT_ABSTRACT(GNEChange_Selection, GNEChange, NULL, 0)
42 
43 // ===========================================================================
44 // member method definitions
45 // ===========================================================================
46 
47 
48 // Constructor for changing selection
49 GNEChange_Selection::GNEChange_Selection(const std::set<GUIGlID>& selected, const std::set<GUIGlID>& deselected, bool forward):
50  GNEChange(0, forward),
51  mySelectedIDs(selected),
52  myDeselectedIDs(deselected) {
53 }
54 
55 
57 }
58 
59 
61  if (myForward) {
62  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
63  gSelected.deselect(*it);
64  }
65  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
66  gSelected.select(*it);
67  }
68  } else {
69  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
70  gSelected.select(*it);
71  }
72  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
73  gSelected.deselect(*it);
74  }
75  }
76 }
77 
78 
80  if (myForward) {
81  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
82  gSelected.select(*it);
83  }
84  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
85  gSelected.deselect(*it);
86  }
87  } else {
88  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
89  gSelected.deselect(*it);
90  }
91  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
92  gSelected.select(*it);
93  }
94  }
95 }
96 
97 
99  if (myForward) {
100  return ("Undo change selection");
101  } else {
102  return ("Undo change selection");
103  }
104 }
105 
106 
108  if (myForward) {
109  return ("Redo change selection");
110  } else {
111  return ("Redo change selection");
112  }
113 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:49
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
~GNEChange_Selection()
Destructor.
std::set< GUIGlID > myDeselectedIDs
all ids that were deselected in this change
void redo()
redo action
std::set< GUIGlID > mySelectedIDs
all ids that were selected in this change
void undo()
undo action
unsigned int GUIGlID
Definition: GUIGlObject.h:50
void deselect(GUIGlID id)
Deselects the object with the given id.
FXString redoName() const
get Redo name
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:87
FXString undoName() const
return undoName
GUISelectedStorage gSelected
A global holder of selected objects.