Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEWireFrame.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2021-2024 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// The Widget for editing wires
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
27
28#include "GNEWireFrame.h"
29
30
31// ===========================================================================
32// method definitions
33// ===========================================================================
34
35
37 GNEFrame(viewParent, viewNet, TL("Wires")) {
38
39 // create item Selector module for wires
41
42 // Create wire parameters
44
45 // Create Netedit parameter
47
48 // Create selector parent
50
51 // Create list for E2Multilane lane selector
53}
54
55
57 // check if we have to delete base wire object
58 if (myBaseWire) {
59 delete myBaseWire;
60 }
61}
62
63
64void
66 // refresh tag selector
68 // show frame
71 FXMessageBox::warning(getApp(), MBOX_OK, TL("Experimental Part"), "%s", TL("Warning: The netedit overhead editor is still in experimental state."));
73 }
74}
75
76
77bool
79 // first check that current selected wire is valid
80 if (myWireTagSelector->getCurrentTemplateAC() == nullptr) {
81 myViewNet->setStatusBarText(TL("Current selected wire isn't valid."));
82 return false;
83 }
84 // show warning dialogbox and stop check if input parameters are valid
87 return false;
88 }
89 // obtain tagproperty (only for improve code legibility)
90 const auto& tagProperties = myWireTagSelector->getCurrentTemplateAC()->getTagProperty();
91 // create base wire
92 if (!createBaseWireObject(tagProperties)) {
93 return false;
94 }
95 // obtain attributes and values
97 // fill netedit attributes
99 return false;
100 }
101 if (tagProperties.getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
102 return myConsecutiveLaneSelector->addLane(viewObjects.getLaneFront());
103 } else {
104 // build wire over view
105 return buildWireOverView(tagProperties);
106 }
107}
108
109
114
115
116bool
117GNEWireFrame::createPath(const bool /* useLastRoute */) {
118 // obtain tagproperty (only for improve code legibility)
119 const auto& tagProperty = myWireTagSelector->getCurrentTemplateAC()->getTagProperty();
120 // first check that current tag is valid (currently only for overhead wires)
121 if (tagProperty.getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
122 if (myConsecutiveLaneSelector->getLanePath().size() == 1) {
123 WRITE_WARNINGF(TL("A % needs at least two lane positions"), toString(SUMO_TAG_OVERHEAD_WIRE_SECTION));
124 } else if (createBaseWireObject(tagProperty)) {
125 // get attributes and values
127 // fill netedit attributes
129 // Check if ID has to be generated
132 }
133 // add lane IDs
135 // set positions
138 // show warning dialogbox and stop check if input parameters are valid
141 } else {
142 // declare additional handler
144 // build additional
145 additionalHandler.parseSumoBaseObject(myBaseWire);
146 // Refresh wire Parent Selector (For additionals that have a limited number of children)
148 // abort overhead wire creation
150 // refresh additional attributes
152 return true;
153 }
154 }
155 }
156 }
157 return false;
158}
159
160
161void
163 // get template AC
164 const auto templateAC = myWireTagSelector->getCurrentTemplateAC();
165 // check if templateAC Exist
166 if (templateAC) {
167 // show wire attributes module
169 // show netedit attributes
171 // check if we're creating a overhead wire section
172 if (templateAC->getTagProperty().getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
175 } else {
178 }
179 } else {
180 // hide all modules if wire isn't valid
185 }
186}
187
188
189bool
191 // check if baseWire exist, and if yes, delete it
192 if (myBaseWire) {
193 // go to base wire root
196 }
197 // delete baseWire (and all children)
198 delete myBaseWire;
199 // reset baseWire
200 myBaseWire = nullptr;
201 }
202 // create a base wire object
204 // check if wire is a overheadWIre
205 if (tagProperty.getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
206 // get wire under cursor
208 // if user click over a traction substation, mark int in ParentWireSelector
209 if (wireUnderCursor && (wireUnderCursor->getTagProperty().getTag() == SUMO_TAG_TRACTION_SUBSTATION)) {
210 // update parent wire selected
211 mySelectorWireParent->setIDSelected(wireUnderCursor->getID());
212 }
213 // stop if currently there isn't a valid selected parent
214 if (mySelectorWireParent->getIdSelected().empty()) {
215 myWireAttributes->showWarningMessage("A " + toString(SUMO_TAG_TRACTION_SUBSTATION) + " must be selected before insertion of " + toString(SUMO_TAG_TRACTION_SUBSTATION) + ".");
216 return false;
217 } else {
218 // add tractionsubstation id
220 }
221 }
222 // set baseWire tag
223 myBaseWire->setTag(tagProperty.getTag());
224 // BaseWire created, then return true
225 return true;
226}
227
228
229bool
231 // disable intervals (temporal)
232 if ((tagProperties.getTag() == SUMO_TAG_INTERVAL) ||
233 (tagProperties.getTag() == SUMO_TAG_DEST_PROB_REROUTE) ||
234 (tagProperties.getTag() == SUMO_TAG_CLOSING_REROUTE) ||
235 (tagProperties.getTag() == SUMO_TAG_CLOSING_LANE_REROUTE) ||
236 (tagProperties.getTag() == SUMO_TAG_ROUTE_PROB_REROUTE) ||
237 (tagProperties.getTag() == SUMO_TAG_PARKING_AREA_REROUTE)) {
238 WRITE_WARNING(TL("Currently unsupported. Create rerouter elements using rerouter dialog"));
239 return false;
240 }
241 // disable intervals (temporal)
242 if (tagProperties.getTag() == SUMO_TAG_STEP) {
243 WRITE_WARNING(TL("Currently unsupported. Create VSS steps elements using VSS dialog"));
244 return false;
245 }
246 // Check if ID has to be generated
249 }
250 // Obtain position as the clicked position over view
252 // add position and X-Y-Z attributes
257 // show warning dialogbox and stop check if input parameters are valid
260 return false;
261 } else {
262 // declare additional handler
264 // build wire
265 additionalHandler.parseSumoBaseObject(myBaseWire);
266 // Refresh wire Parent Selector (For wires that have a limited number of children)
268 // refresh wire attributes
270 return true;
271 }
272}
273
274/****************************************************************************/
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define WRITE_WARNING(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:315
@ SUMO_TAG_TRACTION_SUBSTATION
A traction substation.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_STEP
trigger: a step description
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ SUMO_TAG_OVERHEAD_WIRE_SECTION
An overhead wire section.
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_Y
@ SUMO_ATTR_SUBSTATIONID
id of a traction substation substation
@ SUMO_ATTR_Z
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_X
@ SUMO_ATTR_LANES
@ SUMO_ATTR_ID
@ SUMO_ATTR_POSITION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
void parseSumoBaseObject(CommonXMLStructure::SumoBaseObject *obj)
parse SumoBaseObject (it's called recursivelly)
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
void setTag(const SumoXMLTag tag)
set SumoBaseObject tag
SumoBaseObject * getParentSumoBaseObject() const
get pointer to mySumoBaseObjectParent SumoBaseObject (if is null, then is the root)
void addStringListAttribute(const SumoXMLAttr attr, const std::vector< std::string > &value)
add string list attribute into current SumoBaseObject node
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void addPositionAttribute(const SumoXMLAttr attr, const Position &value)
add Position attribute into current SumoBaseObject node
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
add string attribute into current SumoBaseObject node
Builds additional objects for GNENet (busStops, chargingStations, detectors, etc.....
An Element which don't belong to GNENet but has influence in the simulation.
const std::string getID() const
get ID (all Attribute Carriers have one)
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
void getAttributesAndValues(CommonXMLStructure::SumoBaseObject *baseObject, bool includeAll) const
get attributes and their values
bool areValuesValid() const
check if parameters of attributes are valid
void showAttributesCreatorModule(GNEAttributeCarrier *templateAC, const std::vector< SumoXMLAttr > &hiddenAttributes)
show GNEAttributesCreator modul
void hideAttributesCreatorModule()
hide group box
void showWarningMessage(std::string extra="") const
show warning message with information about non-valid attributes
void refreshAttributesCreator()
refresh attribute creator
bool addLane(GNELane *lane)
add lane
void abortPathCreation()
abort path creation
void showConsecutiveLaneSelectorModule()
show GNEConsecutiveSelector
const std::vector< std::pair< GNELane *, double > > & getLanePath() const
get vector with lanes and clicked positions
void hideConsecutiveLaneSelectorModule()
show GNEConsecutiveSelector
const std::vector< std::string > getLaneIDPath() const
get lane IDs
GNEViewNet * myViewNet
FOX need this.
Definition GNEFrame.h:115
virtual void show()
show Frame
Definition GNEFrame.cpp:115
std::string generateAdditionalID(SumoXMLTag type) const
generate additional id
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
void showNeteditAttributesModule(GNEAttributeCarrier *templateAC)
show Netedit attributes modul
void hideNeteditAttributesModule()
hide Netedit attributes modul
bool getNeteditAttributesAndValues(CommonXMLStructure::SumoBaseObject *baseObject, const GNELane *lane) const
fill valuesMap with netedit attributes
void setIDSelected(const std::string &id)
select manually a element of the list
void showSelectorParentModule(const std::vector< SumoXMLTag > &parentTags)
Show list of GNESelectorParent Module.
void refreshSelectorParentModule()
Refresh list of Additional Parents Module.
std::string getIdSelected() const
get currently parent additional selected
void hideSelectorParentModule()
hide GNESelectorParent Module
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
void refreshTagSelector()
refresh tagSelector (used when frameParent is show)
GNEAttributeCarrier * getCurrentTemplateAC() const
get current templateAC
class used to group all variables related with objects under cursor after a click over view
GNELane * getLaneFront() const
get front lane or a pointer to nullptr
GNEAdditional * getAdditionalFront() const
get front additional element or a pointer to nullptr
GNENet * getNet() const
get the net object
GNEViewParent * getViewParent() const
get the net object
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
void setStatusBarText(const std::string &text)
set statusBar text
A single child window which contains a view of the simulation area.
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
GNEAttributesCreator * myWireAttributes
internal wire attributes
void tagSelected()
Tag selected in GNETagSelector.
~GNEWireFrame()
Destructor.
GNEConsecutiveSelector * getConsecutiveLaneSelector() const
get consecutive lane selector
bool createPath(const bool useLastRoute)
create path
GNENeteditAttributes * myNeteditAttributes
Netedit parameter.
void show()
show wire frame
bool myWarnedExperimental
Warn about experimental state.
bool addWire(const GNEViewNetHelper::ViewObjectsSelector &viewObjects)
add wire element
GNESelectorParent * mySelectorWireParent
Select wire parent.
GNETagSelector * myWireTagSelector
item selector
bool buildWireOverView(const GNETagProperties &tagValues)
build wire over view
GNEWireFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
CommonXMLStructure::SumoBaseObject * myBaseWire
SumoBaseObject used for create wire.
GNEConsecutiveSelector * myConsecutiveLaneSelector
Module for select consecutive lanes.
bool createBaseWireObject(const GNETagProperties &tagProperty)
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double x() const
Returns the x-position.
Definition Position.h:55
double z() const
Returns the z-position.
Definition Position.h:65
double y() const
Returns the y-position.
Definition Position.h:60