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 
37 // ===========================================================================
38 // FOX-declarations
39 // ===========================================================================
40 FXIMPLEMENT_ABSTRACT(GNEChange_Selection, GNEChange, NULL, 0)
41 
42 // ===========================================================================
43 // member method definitions
44 // ===========================================================================
45 
46 
47 GNEChange_Selection::GNEChange_Selection(GNENet* net, const std::set<GUIGlID>& selected, const std::set<GUIGlID>& deselected, bool forward):
49  GNEChange(net, forward),
50  mySelectedIDs(selected),
51  myDeselectedIDs(deselected) {
52  assert(myNet);
53 }
54 
55 
57 }
58 
59 
60 void
62  if (myForward) {
63  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
64  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
65  gSelected.deselect(*it);
66  }
67  }
68  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
69  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
70  gSelected.select(*it);
71  }
72  }
73  } else {
74  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
75  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
76  gSelected.select(*it);
77  }
78  }
79  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
80  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
81  gSelected.deselect(*it);
82  }
83  }
84  }
85  myNet->getViewNet()->update();
86 }
87 
88 
89 void
91  if (myForward) {
92  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
93  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
94  gSelected.select(*it);
95  }
96  }
97  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
98  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
99  gSelected.deselect(*it);
100  }
101  }
102  } else {
103  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
104  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
105  gSelected.deselect(*it);
106  }
107  }
108  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
109  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
110  gSelected.select(*it);
111  }
112  }
113  }
114  myNet->getViewNet()->update();
115 }
116 
117 
118 FXString
120  if (myForward) {
121  return ("Undo change selection");
122  } else {
123  return ("Undo change selection");
124  }
125 }
126 
127 
128 FXString
130  if (myForward) {
131  return ("Redo change selection");
132  } else {
133  return ("Redo change selection");
134  }
135 }
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:88
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
FXString undoName() const
return undoName
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:87
GUISelectedStorage gSelected
A global holder of selected objects.
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1165