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