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 
34 
35 #include "GNEChange_Selection.h"
36 #include "GNENet.h"
37 #include "GNEViewNet.h"
38 
39 
40 // ===========================================================================
41 // FOX-declarations
42 // ===========================================================================
43 FXIMPLEMENT_ABSTRACT(GNEChange_Selection, GNEChange, NULL, 0)
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
48 
49 
50 GNEChange_Selection::GNEChange_Selection(GNENet* net, const std::set<GUIGlID>& selected, const std::set<GUIGlID>& deselected, bool forward):
52  GNEChange(net, forward),
53  mySelectedIDs(selected),
54  myDeselectedIDs(deselected) {
55  assert(myNet);
56 }
57 
58 
60 }
61 
62 
63 void
65  if (myForward) {
66  int counter = 0;
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  counter++;
71  }
72  }
73  // show information if testing mode is enabled
74  if ((counter > 0) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
75  WRITE_WARNING("Deselected " + toString(counter) + " elements in GNEChange_Selection");
76  }
77  counter = 0;
78  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
79  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
80  gSelected.select(*it);
81  counter++;
82  }
83  }
84  // show information if testing mode is enabled
85  if ((counter > 0) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
86  WRITE_WARNING("Selected " + toString(counter) + " elements in GNEChange_Selection");
87  }
88  } else {
89  int counter = 0;
90  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
91  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
92  gSelected.select(*it);
93  counter++;
94  }
95  }
96  // show information if testing mode is enabled
97  if ((counter > 0) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
98  WRITE_WARNING("Selected " + toString(counter) + " elements in GNEChange_Selection");
99  }
100  counter = 0;
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  counter++;
105  }
106  }
107  // show information if testing mode is enabled
108  if ((counter > 0) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
109  WRITE_WARNING("Deselected " + toString(counter) + " elements in GNEChange_Selection");
110  }
111  }
112  myNet->getViewNet()->update();
113 }
114 
115 
116 void
118  if (myForward) {
119  int counter = 0;
120  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
121  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
122  gSelected.select(*it);
123  counter++;
124  }
125  }
126  // show information if testing mode is enabled
127  if ((counter > 0) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
128  WRITE_WARNING("Selected " + toString(counter) + " elements in GNEChange_Selection");
129  }
130  counter = 0;
131  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
132  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
133  gSelected.deselect(*it);
134  counter++;
135  }
136  }
137  // show information if testing mode is enabled
138  if ((counter > 0) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
139  WRITE_WARNING("Deselected " + toString(counter) + " elements in GNEChange_Selection");
140  }
141  } else {
142  int counter = 0;
143  for (std::set<GUIGlID>::const_iterator it = mySelectedIDs.begin(); it != mySelectedIDs.end(); it++) {
144  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
145  gSelected.deselect(*it);
146  counter++;
147  }
148  }
149  // show information if testing mode is enabled
150  if ((counter > 0) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
151  WRITE_WARNING("Deselected " + toString(counter) + " elements in GNEChange_Selection");
152  }
153  counter = 0;
154  for (std::set<GUIGlID>::const_iterator it = myDeselectedIDs.begin(); it != myDeselectedIDs.end(); it++) {
155  if (GUIGlObjectStorage::gIDStorage.getObjectBlocking(*it)) {
156  gSelected.select(*it);
157  counter++;
158  }
159  }
160  // show information if testing mode is enabled
161  if ((counter > 0) && (OptionsCont::getOptions().getBool("gui-testing-debug"))) {
162  WRITE_WARNING("Selected " + toString(counter) + " elements in GNEChange_Selection");
163  }
164  }
165  myNet->getViewNet()->update();
166 }
167 
168 
169 FXString
171  if (myForward) {
172  return ("Undo change selection");
173  } else {
174  return ("Undo change selection");
175  }
176 }
177 
178 
179 FXString
181  if (myForward) {
182  return ("Redo change selection");
183  } else {
184  return ("Redo change selection");
185  }
186 }
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:92
std::set< GUIGlID > myDeselectedIDs
all ids that were deselected in this change
void redo()
redo action
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
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:1519