Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/dialogs/elements/GNERerouterIntervalDialog.cpp
169685 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file GNERerouterIntervalDialog.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date eb 2017
17
///
18
// Dialog for edit rerouter intervals
19
/****************************************************************************/
20
21
#include <netedit/dialogs/basic/GNEWarningBasicDialog.h>
22
#include <netedit/elements/additional/GNEClosingLaneReroute.h>
23
#include <netedit/elements/additional/GNEClosingReroute.h>
24
#include <netedit/elements/additional/GNEDestProbReroute.h>
25
#include <netedit/elements/additional/GNEParkingAreaReroute.h>
26
#include <netedit/elements/additional/GNERouteProbReroute.h>
27
#include <netedit/GNENet.h>
28
#include <netedit/GNEUndoList.h>
29
#include <netedit/GNEViewParent.h>
30
#include <utils/gui/div/GUIDesigns.h>
31
32
#include "GNEAttributeCarrierDialog.h"
33
#include "GNERerouterIntervalDialog.h"
34
35
// ===========================================================================
36
// member method definitions
37
// ===========================================================================
38
39
GNERerouterIntervalDialog::GNERerouterIntervalDialog(GNEAdditional* rerouterInterval) :
40
GNETemplateElementDialog<GNEAdditional>(rerouterInterval, DialogType::REROUTERINTERVAL) {
41
// Create auxiliar frames for tables
42
FXHorizontalFrame* columns = new FXHorizontalFrame(myContentFrame, GUIDesignAuxiliarHorizontalFrame);
43
FXVerticalFrame* columnLeft = new FXVerticalFrame(columns, GUIDesignAuxiliarVerticalFrame);
44
FXVerticalFrame* columnCenter = new FXVerticalFrame(columns, GUIDesignAuxiliarVerticalFrame);
45
FXVerticalFrame* columnRight = new FXVerticalFrame(columns, GUIDesignAuxiliarVerticalFrame);
46
// create closing reroute element list
47
myClosingReroutes = new ClosingReroutesList(this, columnLeft);
48
// create closing lane reroute element list
49
myClosingLaneReroutes = new ClosingLaneReroutesList(this, columnLeft);
50
// dest prob reroute
51
myDestProbReroutes = new DestProbReroutesList(this, columnCenter);
52
// route prob reroute
53
myRouteProbReroutes = new RouteProbReroutesList(this, columnCenter);
54
// parking area reroute
55
myParkingAreaReroutes = new ParkingAreaReroutesList(this, columnRight);
56
// open dialog
57
openDialog();
58
}
59
60
61
GNERerouterIntervalDialog::~GNERerouterIntervalDialog() {}
62
63
64
void
65
GNERerouterIntervalDialog::runInternalTest(const InternalTestStep::DialogArgument* /*dialogArgument*/) {
66
// nothing to do (yet)
67
}
68
69
70
long
71
GNERerouterIntervalDialog::onCmdAccept(FXObject*, FXSelector, void*) {
72
// get rerouter parent
73
const auto rerouterParent = myElement->getParentAdditionals().at(0);
74
// declare strings
75
const std::string warningTitle = TLF("Error updating % of % '%'", myElement->getTagStr(), rerouterParent->getTagStr(), rerouterParent->getID());
76
const std::string infoA = TLF("% of % '%' cannot be updated because", myElement->getTagStr(), rerouterParent->getTagStr(), rerouterParent->getID());
77
std::string infoB;
78
// set infoB
79
if (myClosingReroutes->getEditedElements().empty() && myClosingLaneReroutes->getEditedElements().empty() &&
80
myRouteProbReroutes->getEditedElements().empty() && myDestProbReroutes->getEditedElements().empty() &&
81
myParkingAreaReroutes->getEditedElements().empty()) {
82
infoB = TLF("at least one % must be defined.", myElement->getTagStr());
83
} else if (!myClosingReroutes->isListValid()) {
84
infoB = TLF("there are invalid %s.", toString(SUMO_TAG_CLOSING_REROUTE));
85
} else if (!myClosingLaneReroutes->isListValid()) {
86
infoB = TLF("there are invalid %s.", toString(SUMO_TAG_CLOSING_LANE_REROUTE));
87
} else if (!myRouteProbReroutes->isListValid()) {
88
infoB = TLF("there are invalid %s.", toString(SUMO_TAG_ROUTE_PROB_REROUTE));
89
} else if (!myDestProbReroutes->isListValid()) {
90
infoB = TLF("there are invalid %s.", toString(SUMO_TAG_DEST_PROB_REROUTE));
91
} else if (!myParkingAreaReroutes->isListValid()) {
92
infoB = TLF("there are invalid %s.", toString(SUMO_TAG_PARKING_AREA_REROUTE));
93
}
94
// continue depending of info
95
if (infoB.size() > 0) {
96
// open question dialog box with two lines
97
GNEWarningBasicDialog(myElement->getNet()->getViewNet()->getViewParent()->getGNEAppWindows(), warningTitle, infoA, infoB);
98
return 1;
99
} else {
100
// close dialog accepting changes
101
return acceptElementDialog();
102
}
103
}
104
105
106
long
107
GNERerouterIntervalDialog::onCmdReset(FXObject*, FXSelector, void*) {
108
// reset changes
109
resetChanges();
110
// update tables
111
myClosingReroutes->updateList();
112
myClosingLaneReroutes->updateList();
113
myDestProbReroutes->updateList();
114
myRouteProbReroutes->updateList();
115
myParkingAreaReroutes->updateList();
116
return 1;
117
}
118
119
// ---------------------------------------------------------------------------
120
// GNERerouterIntervalDialog::ClosingReroutesList - methods
121
// ---------------------------------------------------------------------------
122
123
GNERerouterIntervalDialog::ClosingReroutesList::ClosingReroutesList(GNERerouterIntervalDialog* rerouterIntervalDialog,
124
FXVerticalFrame* contentFrame) :
125
GNETemplateElementList(rerouterIntervalDialog, contentFrame, SUMO_TAG_CLOSING_REROUTE,
126
GNEElementList::Options::DIALOG_ELEMENT | GNEElementList::Options::DIALOG_VCLASS | GNEElementList::Options::FIXED_HEIGHT) {
127
// disable if there are no edges in net
128
if (rerouterIntervalDialog->getElement()->getNet()->getAttributeCarriers()->getEdges().size() == 0) {
129
disableList(TL("No edges in net"));
130
}
131
}
132
133
134
long
135
GNERerouterIntervalDialog::ClosingReroutesList::addNewElement() {
136
// get edge
137
const auto edge = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getEdges().begin()->second;
138
// create closing reroute
139
return insertElement(new GNEClosingReroute(myElementDialogParent->getElement(), edge, SVCAll));
140
}
141
142
143
long
144
GNERerouterIntervalDialog::ClosingReroutesList::openElementDialog(const size_t rowIndex) {
145
// open attribute carrier dialog
146
GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentEdges().front());
147
return 1;
148
}
149
150
// ---------------------------------------------------------------------------
151
// GNERerouterIntervalDialog::ClosingLaneReroutesList - methods
152
// ---------------------------------------------------------------------------
153
154
GNERerouterIntervalDialog::ClosingLaneReroutesList::ClosingLaneReroutesList(GNERerouterIntervalDialog* rerouterIntervalDialog,
155
FXVerticalFrame* contentFrame) :
156
GNETemplateElementList(rerouterIntervalDialog, contentFrame, SUMO_TAG_CLOSING_LANE_REROUTE,
157
GNEElementList::Options::DIALOG_ELEMENT | GNEElementList::Options::DIALOG_VCLASS | GNEElementList::Options::FIXED_HEIGHT) {
158
// disable if there are no edges in net
159
if (rerouterIntervalDialog->getElement()->getNet()->getAttributeCarriers()->getLanes().size() == 0) {
160
disableList(TL("No lanes in net"));
161
}
162
}
163
164
165
long
166
GNERerouterIntervalDialog::ClosingLaneReroutesList::addNewElement() {
167
// get lane
168
const auto lane = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getEdges().begin()->second->getChildLanes().front();
169
// create closing lane reroute
170
return insertElement(new GNEClosingLaneReroute(myElementDialogParent->getElement(), lane, SVCAll));
171
}
172
173
174
long
175
GNERerouterIntervalDialog::ClosingLaneReroutesList::openElementDialog(const size_t rowIndex) {
176
// open attribute carrier dialog
177
GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentLanes().front());
178
return 1;
179
}
180
181
// ---------------------------------------------------------------------------
182
// GNERerouterIntervalDialog::DestProbReroutesList - methods
183
// ---------------------------------------------------------------------------
184
185
GNERerouterIntervalDialog::DestProbReroutesList::DestProbReroutesList(GNERerouterIntervalDialog* rerouterIntervalDialog,
186
FXVerticalFrame* contentFrame) :
187
GNETemplateElementList(rerouterIntervalDialog, contentFrame, SUMO_TAG_DEST_PROB_REROUTE,
188
GNEElementList::Options::DIALOG_ELEMENT | GNEElementList::Options::FIXED_HEIGHT) {
189
// disable if there are no edges in net
190
if (rerouterIntervalDialog->getElement()->getNet()->getAttributeCarriers()->getEdges().size() == 0) {
191
disableList(TL("No edges in net"));
192
}
193
}
194
195
196
long
197
GNERerouterIntervalDialog::DestProbReroutesList::addNewElement() {
198
// get edge
199
const auto edge = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getEdges().begin()->second;
200
// create dest prob reroute
201
return insertElement(new GNEDestProbReroute(myElementDialogParent->getElement(), edge, 1));
202
}
203
204
205
long
206
GNERerouterIntervalDialog::DestProbReroutesList::openElementDialog(const size_t rowIndex) {
207
// open attribute carrier dialog
208
GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentEdges().front());
209
return 1;
210
}
211
212
// ---------------------------------------------------------------------------
213
// GNERerouterIntervalDialog::RouteProbReroutesList - methods
214
// ---------------------------------------------------------------------------
215
216
GNERerouterIntervalDialog::RouteProbReroutesList::RouteProbReroutesList(GNERerouterIntervalDialog* rerouterIntervalDialog,
217
FXVerticalFrame* contentFrame) :
218
GNETemplateElementList(rerouterIntervalDialog, contentFrame, SUMO_TAG_ROUTE_PROB_REROUTE,
219
GNEElementList::Options::DIALOG_ELEMENT | GNEElementList::Options::FIXED_HEIGHT) {
220
// disable if the rerouter has multiple edges (random routes can only work from one edge)
221
if (rerouterIntervalDialog->getElement()->getParentAdditionals().at(0)->getChildEdges().size() > 1) {
222
disableList(TL("Rerouter has more than one edge"));
223
}
224
// disable if there are no routes in net
225
if (rerouterIntervalDialog->getElement()->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_ROUTE).size() == 0) {
226
disableList(TL("No routes in net"));
227
}
228
}
229
230
231
long
232
GNERerouterIntervalDialog::RouteProbReroutesList::addNewElement() {
233
// get route
234
const auto route = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_ROUTE).begin()->second;
235
// create route prob reroute
236
return insertElement(new GNERouteProbReroute(myElementDialogParent->getElement(), route, 1));
237
}
238
239
240
long
241
GNERerouterIntervalDialog::RouteProbReroutesList::openElementDialog(const size_t rowIndex) {
242
// open attribute carrier dialog
243
GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentDemandElements().front());
244
return 1;
245
}
246
247
// ---------------------------------------------------------------------------
248
// GNERerouterIntervalDialog::ParkingAreaReroutesList - methods
249
// ---------------------------------------------------------------------------
250
251
GNERerouterIntervalDialog::ParkingAreaReroutesList::ParkingAreaReroutesList(GNERerouterIntervalDialog* rerouterIntervalDialog,
252
FXVerticalFrame* contentFrame) :
253
GNETemplateElementList(rerouterIntervalDialog, contentFrame, SUMO_TAG_PARKING_AREA_REROUTE,
254
GNEElementList::Options::DIALOG_ELEMENT) {
255
// disable if there are no parking areas in net
256
if (rerouterIntervalDialog->getElement()->getNet()->getAttributeCarriers()->getAdditionals().at(SUMO_TAG_PARKING_AREA).size() == 0) {
257
disableList(TL("No parkingAreas in net"));
258
}
259
}
260
261
262
long
263
GNERerouterIntervalDialog::ParkingAreaReroutesList::addNewElement() {
264
// get parking area
265
const auto parkingArea = myElementDialogParent->getElement()->getNet()->getAttributeCarriers()->getAdditionals().at(SUMO_TAG_PARKING_AREA).begin()->second;
266
// create parking area reroute
267
return insertElement(new GNEParkingAreaReroute(myElementDialogParent->getElement(), parkingArea, 1, 1));
268
}
269
270
271
long
272
GNERerouterIntervalDialog::ParkingAreaReroutesList::openElementDialog(const size_t rowIndex) {
273
// open attribute carrier dialog
274
GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentAdditionals().back());
275
return 1;
276
}
277
278
/****************************************************************************/
279
280