Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNERerouterIntervalDialog.cpp
Go to the documentation of this file.
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/****************************************************************************/
18// Dialog for edit rerouter intervals
19/****************************************************************************/
20
27#include <netedit/GNENet.h>
28#include <netedit/GNEUndoList.h>
31
33#include "GNERerouterDialog.h"
35
36// ===========================================================================
37// member method definitions
38// ===========================================================================
39
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
63
64
65void
67 // nothing to do (yet)
68}
69
70
71long
72GNERerouterIntervalDialog::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
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
99 warningTitle, infoA, infoB);
100 return 1;
101 } else {
102 // close dialog accepting changes
103 return acceptElementDialog();
104 }
105}
106
107
108long
109GNERerouterIntervalDialog::onCmdReset(FXObject*, FXSelector, void*) {
110 // reset changes
111 resetChanges();
112 // update tables
118 return 1;
119}
120
121// ---------------------------------------------------------------------------
122// GNERerouterIntervalDialog::ClosingReroutesList - methods
123// ---------------------------------------------------------------------------
124
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
136long
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
145long
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
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
167long
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
176long
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
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
198long
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
207long
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
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
233long
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
242long
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
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
264long
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
273long
275// open attribute carrier dialog
276 GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentAdditionals().back(), myElementDialogParent);
277 return 1;
278}
279
280/****************************************************************************/
DialogType
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:430
#define GUIDesignAuxiliarVerticalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:439
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
const SVCPermissions SVCAll
all VClasses are allowed
@ SVC_AUTHORITY
authorities vehicles
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ SUMO_TAG_ROUTE
description of a route
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * getNet() const
get pointer to net
FXVerticalFrame * myContentFrame
content frame
Definition GNEDialog.h:159
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
Options
FOX-declaration.
void disableList(const std::string &reason)
disable list
bool isListValid() const
check if the current list is valid
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEDemandElement * >, std::hash< int > > & getDemandElements() const
get demand elements
const std::map< std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
const std::unordered_map< const GUIGlObject *, GNELane * > & getLanes() const
get lanes
const std::unordered_map< SumoXMLTag, std::unordered_map< const GUIGlObject *, GNEAdditional * >, std::hash< int > > & getAdditionals() const
get additionals
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:174
GNEApplicationWindow * getGNEApplicationWindow() const
get tag properties database
Definition GNENet.cpp:138
ClosingLaneReroutesList(GNERerouterIntervalDialog *rerouterIntervalDialog, FXVerticalFrame *contentFrame)
constructor
long openElementDialog(const size_t rowIndex)
open element dialog
ClosingReroutesList(GNERerouterIntervalDialog *rerouterIntervalDialog, FXVerticalFrame *contentFrame)
constructor
long openElementDialog(const size_t rowIndex)
open element dialog
DestProbReroutesList(GNERerouterIntervalDialog *rerouterIntervalDialog, FXVerticalFrame *contentFrame)
constructor
long openElementDialog(const size_t rowIndex)
open element dialog
long openElementDialog(const size_t rowIndex)
open element dialog
ParkingAreaReroutesList(GNERerouterIntervalDialog *rerouterIntervalDialog, FXVerticalFrame *contentFrame)
constructor
long openElementDialog(const size_t rowIndex)
open element dialog
RouteProbReroutesList(GNERerouterIntervalDialog *rerouterIntervalDialog, FXVerticalFrame *contentFrame)
constructor
GNERerouterIntervalDialog(GNEAdditional *rerouterInterval, GNEDialog *rerouterDialogParent)
constructor
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
DestProbReroutesList * myDestProbReroutes
list with destination probability reroutes
ClosingLaneReroutesList * myClosingLaneReroutes
list with closing lane reroutes
ClosingReroutesList * myClosingReroutes
list with closing reroutes
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
RouteProbReroutesList * myRouteProbReroutes
list with route probability reroute
ParkingAreaReroutesList * myParkingAreaReroutes
list with parkingAreaReroutes
long onCmdAccept(FXObject *, FXSelector, void *)
event after press accept button
GNEAdditional * myElement
pointer to edited element
T * getElement() const
get edited element
void resetChanges()
reset changes did in this dialog.
long acceptElementDialog()
close dialog commiting changes
const std::vector< elementType * > & getEditedElements() const
get edited elements
long updateList()
update element list
dialog arguments, used for certain modal dialogs that can not be edited using tab