Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEVariableSpeedSignDialog.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 variableSpeedSigns
19/****************************************************************************/
20
23#include <netedit/GNENet.h>
24#include <netedit/GNEUndoList.h>
27
29
30// ===========================================================================
31// member method definitions
32// ===========================================================================
33
36 // create variableSpeedSign steps element list
38 // open dialog
39 openDialog();
40}
41
42
44
45
46void
48 // nothing to do
49}
50
51
52long
53GNEVariableSpeedSignDialog::onCmdAccept(FXObject*, FXSelector, void*) {
54 // Check if there is overlapping between Steps
56 // open warning Box
58 TLF("VariableSpeedSign steps of % '%' cannot be saved", toString(SUMO_TAG_VSS), myElement->getID()),
59 TL("Steps has to be sorted."));
60 return 1;
61 } else {
62 // close dialog accepting changes
63 return acceptElementDialog();
64 }
65}
66
67
68long
69GNEVariableSpeedSignDialog::onCmdReset(FXObject*, FXSelector, void*) {
70 // reset changes
72 // update tables
74 return 1;
75}
76
77// ---------------------------------------------------------------------------
78// GNEVariableSpeedSignDialog::VariableSpeedSignStepsList - methods
79// ---------------------------------------------------------------------------
80
82 GNETemplateElementList(variableSpeedSignDialog, variableSpeedSignDialog->getContentFrame(), SUMO_TAG_STEP,
83 GNEElementList::Options::SORTELEMENTS | GNEElementList::Options::FIXED_HEIGHT) {
84}
85
86
87long
89 // create step depending of number of steps
90 if (getEditedElements().empty()) {
91 return insertElement(new GNEVariableSpeedSignStep(myElementDialogParent->getElement(), 0,
92 OptionsCont::getOptions().getFloat("default.speed")));
93 } else {
94 SUMOTime biggestTime = 0;
95 // get end with biggest end
96 for (const auto& step : getEditedElements()) {
97 const auto time = string2time(step->getAttribute(SUMO_ATTR_TIME));
98 if (biggestTime < time) {
99 biggestTime = time;
100 }
101 }
102 return insertElement(new GNEVariableSpeedSignStep(myElementDialogParent->getElement(), biggestTime + string2time("10"),
103 OptionsCont::getOptions().getFloat("default.speed")));
104 }
105}
106
107
108long
110 // nothing to edit in steps
111 return 1;
112}
113
114
115bool
117 // declare a vector to store steps
118 std::vector<double> sortedSteps;
119 // save time steps
120 for (const auto& step : getEditedElements()) {
121 sortedSteps.push_back(step->getAttributeDouble(SUMO_ATTR_TIME));
122 }
123 // check if all are sorted
124 if (sortedSteps.size() > 1) {
125 // check if the next step is bigger than the current step
126 for (int i = 0; i < (int)sortedSteps.size() - 1; i++) {
127 if (sortedSteps.at(i) > sortedSteps.at(i + 1)) {
128 return false;
129 }
130 }
131 }
132 return true;
133}
134
135/****************************************************************************/
DialogType
long long int SUMOTime
Definition GUI.h:36
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
@ SUMO_TAG_STEP
trigger: a step description
@ SUMO_TAG_VSS
A variable speed sign.
@ SUMO_ATTR_TIME
trigger: the time of the step
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
const std::string getID() const
get ID (all Attribute Carriers have one)
GNENet * getNet() const
get pointer to net
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
Options
FOX-declaration.
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
GNEAdditional * myElement
pointer to edited element
void resetChanges()
reset changes did in this dialog.
long acceptElementDialog()
close dialog commiting changes
long updateList()
update element list
VariableSpeedSignStepsList(GNEVariableSpeedSignDialog *variableSpeedSignDialog)
constructor
long openElementDialog(const size_t rowIndex)
open element dialog
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
GNEVariableSpeedSignDialog(GNEAdditional *variableSpeedSign)
Constructor.
long onCmdAccept(FXObject *, FXSelector, void *)
event after press accept button
VariableSpeedSignStepsList * myVariableSpeedSignSteps
Element list for variableSpeedSign steps.
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
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
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static OptionsCont & getOptions()
Retrieves the options.