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
34
35// ===========================================================================
36// member method definitions
37// ===========================================================================
38
40 GNETemplateElementDialog<GNEAdditional>(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
62
63
64void
66 // nothing to do (yet)
67}
68
69
70long
71GNERerouterIntervalDialog::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
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
106long
107GNERerouterIntervalDialog::onCmdReset(FXObject*, FXSelector, void*) {
108 // reset changes
109 resetChanges();
110 // update tables
116 return 1;
117}
118
119// ---------------------------------------------------------------------------
120// GNERerouterIntervalDialog::ClosingReroutesList - methods
121// ---------------------------------------------------------------------------
122
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
134long
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
143long
145 // open attribute carrier dialog
146 GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentEdges().front());
147 return 1;
148}
149
150// ---------------------------------------------------------------------------
151// GNERerouterIntervalDialog::ClosingLaneReroutesList - methods
152// ---------------------------------------------------------------------------
153
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
165long
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
174long
176 // open attribute carrier dialog
177 GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentLanes().front());
178 return 1;
179}
180
181// ---------------------------------------------------------------------------
182// GNERerouterIntervalDialog::DestProbReroutesList - methods
183// ---------------------------------------------------------------------------
184
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
196long
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
205long
207 // open attribute carrier dialog
208 GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentEdges().front());
209 return 1;
210}
211
212// ---------------------------------------------------------------------------
213// GNERerouterIntervalDialog::RouteProbReroutesList - methods
214// ---------------------------------------------------------------------------
215
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
231long
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
240long
242 // open attribute carrier dialog
243 GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentDemandElements().front());
244 return 1;
245}
246
247// ---------------------------------------------------------------------------
248// GNERerouterIntervalDialog::ParkingAreaReroutesList - methods
249// ---------------------------------------------------------------------------
250
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
262long
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
271long
273// open attribute carrier dialog
274 GNEAttributeCarrierDialog(myEditedElements.at(rowIndex)->getParentAdditionals().back());
275 return 1;
276}
277
278/****************************************************************************/
#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:305
#define TLF(string,...)
Definition MsgHandler.h:307
const SVCPermissions SVCAll
all VClasses are allowed
@ 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:135
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:144
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
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
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
GNERerouterIntervalDialog(GNEAdditional *rerouterInterval)
constructor
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
GNEViewParent * getViewParent() const
get the net object
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
dialog arguments, used for certain modal dialogs that can not be edited using tab