SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
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 // Constructor for changing selection
52 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 }
57 
58 
60 }
61 
62 
64  if (myForward) {
65  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
66  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
67  gSelected.deselect(*it);
68  }
69  }
70  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
71  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
72  gSelected.select(*it);
73  }
74  }
75  } else {
76  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
77  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
78  gSelected.select(*it);
79  }
80  }
81  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
82  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
83  gSelected.deselect(*it);
84  }
85  }
86  }
87  myNet->getViewNet()->update();
88 }
89 
90 
92  if (myForward) {
93  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
94  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
95  gSelected.select(*it);
96  }
97  }
98  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
99  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
100  gSelected.deselect(*it);
101  }
102  }
103  } else {
104  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
105  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
106  gSelected.deselect(*it);
107  }
108  }
109  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
110  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
111  gSelected.select(*it);
112  }
113  }
114  }
115  myNet->getViewNet()->update();
116 }
117 
118 
120  if (myForward) {
121  return ("Undo change selection");
122  } else {
123  return ("Undo change selection");
124  }
125 }
126 
127 
129  if (myForward) {
130  return ("Redo change selection");
131  } else {
132  return ("Redo change selection");
133  }
134 }
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:1082