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-2017 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 
32 #include "GNEChange_Selection.h"
33 #include "GNENet.h"
34 #include "GNEViewNet.h"
35 
36 #ifdef CHECK_MEMORY_LEAKS
37 #include <foreign/nvwa/debug_new.h>
38 #endif
39 
40 
41 // ===========================================================================
42 // FOX-declarations
43 // ===========================================================================
44 FXIMPLEMENT_ABSTRACT(GNEChange_Selection, GNEChange, NULL, 0)
45 
46 // ===========================================================================
47 // member method definitions
48 // ===========================================================================
49 
50 
51 GNEChange_Selection::GNEChange_Selection(GNENet* net, const std::set<GUIGlID>& selected, const std::set<GUIGlID>& deselected, bool forward):
53  GNEChange(net, forward),
54  mySelectedIDs(selected),
55  myDeselectedIDs(deselected) {
56  assert(myNet);
57 }
58 
59 
61 }
62 
63 
64 void
66  if (myForward) {
67  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
68  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
69  gSelected.deselect(*it);
70  }
71  }
72  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
73  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
74  gSelected.select(*it);
75  }
76  }
77  } else {
78  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
79  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
80  gSelected.select(*it);
81  }
82  }
83  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
84  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
85  gSelected.deselect(*it);
86  }
87  }
88  }
89  myNet->getViewNet()->update();
90 }
91 
92 
93 void
95  if (myForward) {
96  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
97  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
98  gSelected.select(*it);
99  }
100  }
101  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
102  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
103  gSelected.deselect(*it);
104  }
105  }
106  } else {
107  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
108  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
109  gSelected.deselect(*it);
110  }
111  }
112  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
113  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
114  gSelected.select(*it);
115  }
116  }
117  }
118  myNet->getViewNet()->update();
119 }
120 
121 
122 FXString
124  if (myForward) {
125  return ("Undo change selection");
126  } else {
127  return ("Undo change selection");
128  }
129 }
130 
131 
132 FXString
134  if (myForward) {
135  return ("Redo change selection");
136  } else {
137  return ("Redo change selection");
138  }
139 }
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.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:87
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
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
void undo()
undo action
unsigned int GUIGlID
Definition: GUIGlObject.h:50
GNENet * myNet
the net to which operations shall be applied or which shall be informed about gui updates (we are not...
Definition: GNEChange.h:82
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.
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1114