Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-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// The Widget for editing wires
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
29
30#include "GNEWireFrame.h"
31
32// ===========================================================================
33// method definitions
34// ===========================================================================
35
37 GNEFrame(viewParent, viewNet, TL("Wires")) {
38
39 // create item Selector module for wires
41
42 // Create wire parameters
44
45 // Create selector parent
47
48 // Create list for E2Multilane lane selector
50}
51
52
54 // check if we have to delete base wire object
55 if (myBaseWire) {
56 delete myBaseWire;
57 }
58}
59
60
61void
63 // refresh tag selector
65 // show frame
68 FXMessageBox::warning(getApp(), MBOX_OK, TL("Experimental Part"), "%s", TL("Warning: The netedit overhead editor is still in experimental state."));
70 }
71}
72
73
74bool
76 // first check that current selected wire is valid
77 if (myWireTagSelector->getCurrentTemplateAC() == nullptr) {
78 myViewNet->setStatusBarText(TL("Current selected wire isn't valid."));
79 return false;
80 }
81 // show warning dialogbox and stop check if input parameters are valid
83 return false;
84 }
85 // obtain tagproperty (only for improve code legibility)
86 const auto& tagProperties = myWireTagSelector->getCurrentTemplateAC()->getTagProperty();
87 // create base wire
88 if (!createBaseWireObject(tagProperties)) {
89 return false;
90 }
91 // obtain attributes and values
93 if (tagProperties->getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
94 return myConsecutiveLaneSelector->addLane(viewObjects.getLaneFront());
95 } else {
96 // build wire over view
97 return buildWireOverView(tagProperties);
98 }
99}
100
101
106
107
108bool
109GNEWireFrame::createPath(const bool /* useLastRoute */) {
110 // obtain tagproperty (only for improve code legibility)
111 const auto tagProperty = myWireTagSelector->getCurrentTemplateAC()->getTagProperty();
112 // first check that current tag is valid (currently only for overhead wires)
113 if (tagProperty->getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
114 if (myConsecutiveLaneSelector->getLanePath().size() == 1) {
115 WRITE_WARNINGF(TL("A % needs at least two lane positions"), toString(SUMO_TAG_OVERHEAD_WIRE_SECTION));
116 } else if (createBaseWireObject(tagProperty)) {
117 // get attributes and values
119 // Check if ID has to be generated
122 }
123 // add lane IDs
125 // set positions
128 // show warning dialogbox and stop check if input parameters are valid
130 // declare additional handler
134 // build additional
135 additionalHandler.parseSumoBaseObject(myBaseWire);
136 // Refresh wire Parent Selector (For additionals that have a limited number of children)
138 // abort overhead wire creation
140 // refresh additional attributes
142 return true;
143 }
144 }
145 }
146 return false;
147}
148
149
150void
152 // get template AC
153 const auto templateAC = myWireTagSelector->getCurrentTemplateAC();
154 // check if templateAC Exist
155 if (templateAC) {
156 // show wire attributes module
158 // check if we're creating a overhead wire section
159 if (templateAC->getTagProperty()->getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
162 } else {
165 }
166 } else {
167 // hide all modules if wire isn't valid
171 }
172}
173
174
175bool
177 // check if baseWire exist, and if yes, delete it
178 if (myBaseWire) {
179 // go to base wire root
182 }
183 // delete baseWire (and all children)
184 delete myBaseWire;
185 // reset baseWire
186 myBaseWire = nullptr;
187 }
188 // create a base wire object
190 // check if wire is a overheadWIre
191 if (tagProperty->getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
192 // get wire under cursor
194 // if user click over a traction substation, mark int in ParentWireSelector
195 if (wireUnderCursor && (wireUnderCursor->getTagProperty()->getTag() == SUMO_TAG_TRACTION_SUBSTATION)) {
196 // update parent wire selected
197 mySelectorWireParent->setIDSelected(wireUnderCursor->getID());
198 }
199 // stop if currently there isn't a valid selected parent
200 if (mySelectorWireParent->getIdSelected().empty()) {
201 WRITE_WARNING(TLF("A % must be selected before insertion of %.", toString(SUMO_TAG_TRACTION_SUBSTATION), toString(SUMO_TAG_TRACTION_SUBSTATION)));
202 return false;
203 } else {
204 // add tractionsubstation id
206 }
207 }
208 // set baseWire tag
209 myBaseWire->setTag(tagProperty->getTag());
210 // BaseWire created, then return true
211 return true;
212}
213
214
215bool
217 // disable intervals (temporal)
218 if ((tagProperty->getTag() == SUMO_TAG_INTERVAL) ||
219 (tagProperty->getTag() == SUMO_TAG_DEST_PROB_REROUTE) ||
220 (tagProperty->getTag() == SUMO_TAG_CLOSING_REROUTE) ||
221 (tagProperty->getTag() == SUMO_TAG_CLOSING_LANE_REROUTE) ||
222 (tagProperty->getTag() == SUMO_TAG_ROUTE_PROB_REROUTE) ||
223 (tagProperty->getTag() == SUMO_TAG_PARKING_AREA_REROUTE)) {
224 WRITE_WARNING(TL("Currently unsupported. Create rerouter elements using rerouter dialog"));
225 return false;
226 }
227 // disable intervals (temporal)
228 if (tagProperty->getTag() == SUMO_TAG_STEP) {
229 WRITE_WARNING(TL("Currently unsupported. Create VSS steps elements using VSS dialog"));
230 return false;
231 }
232 // Check if ID has to be generated
235 }
236 // Obtain position as the clicked position over view
238 // add position and X-Y-Z attributes
243 // show warning dialogbox and stop check if input parameters are valid
245 return false;
246 } else {
247 // declare additional handler
251 // build wire
252 additionalHandler.parseSumoBaseObject(myBaseWire);
253 // Refresh wire Parent Selector (For wires that have a limited number of children)
255 // refresh wire attributes
257 return true;
258 }
259}
260
261/****************************************************************************/
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:284
#define WRITE_WARNING(msg)
Definition MsgHandler.h:283
#define TL(string)
Definition MsgHandler.h:301
#define TLF(string,...)
Definition MsgHandler.h:303
@ 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
@ GNE_ATTR_ADDITIONAL_FILE
additional save file
@ 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
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
const std::string getID() const
get ID (all Attribute Carriers have one)
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
SumoXMLAttr fillSumoBaseObject(CommonXMLStructure::SumoBaseObject *baseObject) const
fill sumo Base object
void showAttributesEditor(GNEAttributeCarrier *AC, const bool primaryAttributeEditor)
edit attributes of the given AC (usually the edited template AC)
void refreshAttributesEditor()
refresh attribute editor
bool checkAttributes(const bool showWarning)
check if current edited attributes are valid
void hideAttributesEditor()
hide attribute editor
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:121
virtual void show()
show Frame
Definition GNEFrame.cpp:119
std::string generateAdditionalID(SumoXMLTag type) const
generate additional id
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:146
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
void tagSelected()
Tag selected in GNETagSelector.
GNEAttributesEditor * myWireAttributesEditor
internal wire attributes
~GNEWireFrame()
Destructor.
GNEConsecutiveSelector * getConsecutiveLaneSelector() const
get consecutive lane selector
bool createPath(const bool useLastRoute)
create path
bool buildWireOverView(const GNETagProperties *tagProperty)
build wire over view
bool createBaseWireObject(const GNETagProperties *tagProperty)
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
GNEWireFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
CommonXMLStructure::SumoBaseObject * myBaseWire
SumoBaseObject used for create wire.
GNEConsecutiveSelector * myConsecutiveLaneSelector
Module for select consecutive lanes.
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:52
double z() const
Returns the z-position.
Definition Position.h:62
double y() const
Returns the y-position.
Definition Position.h:57