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-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>
30
31#include "GNEWireFrame.h"
32
33// ===========================================================================
34// method definitions
35// ===========================================================================
36
38 GNEFrame(viewParent, viewNet, TL("Wires")) {
39
40 // create item Selector module for wires
42
43 // Create wire parameters
45
46 // Create selector parent
48
49 // Create list for E2Multilane lane selector
51}
52
53
55 // check if we have to delete base wire object
56 if (myBaseWire) {
57 delete myBaseWire;
58 }
59}
60
61
62void
64 // refresh tag selector
66 // show frame
69 // show warning dialogbox about experimental state (only once)
71 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
86 return false;
87 }
88 // obtain tagproperty (only for improve code legibility)
89 const auto& tagProperties = myWireTagSelector->getCurrentTemplateAC()->getTagProperty();
90 // create base wire
91 if (!createBaseWireObject(tagProperties)) {
92 return false;
93 }
94 // obtain attributes and values
96 if (tagProperties->getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
97 return myConsecutiveLaneSelector->addLane(viewObjects.getLaneFront());
98 } else {
99 // build wire over view
100 return buildWireOverView(tagProperties);
101 }
102}
103
104
109
110
111bool
112GNEWireFrame::createPath(const bool /* useLastRoute */) {
113 // obtain tagproperty (only for improve code legibility)
114 const auto tagProperty = myWireTagSelector->getCurrentTemplateAC()->getTagProperty();
115 // first check that current tag is valid (currently only for overhead wires)
116 if (tagProperty->getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
117 if (myConsecutiveLaneSelector->getLanePath().size() == 1) {
118 WRITE_WARNINGF(TL("A % needs at least two lane positions"), toString(SUMO_TAG_OVERHEAD_WIRE_SECTION));
119 } else if (createBaseWireObject(tagProperty)) {
120 // get attributes and values
122 // Check if ID has to be generated
125 }
126 // add lane IDs
128 // set positions
131 // show warning dialogbox and stop check if input parameters are valid
133 // declare additional handler
137 // build additional
138 additionalHandler.parseSumoBaseObject(myBaseWire);
139 // Refresh wire Parent Selector (For additionals that have a limited number of children)
141 // abort overhead wire creation
143 // refresh additional attributes
145 return true;
146 }
147 }
148 }
149 return false;
150}
151
152
153void
155 // get template AC
156 const auto templateAC = myWireTagSelector->getCurrentTemplateAC();
157 // check if templateAC Exist
158 if (templateAC) {
159 // show wire attributes module
161 // check if we're creating a overhead wire section
162 if (templateAC->getTagProperty()->getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
165 } else {
168 }
169 } else {
170 // hide all modules if wire isn't valid
174 }
175}
176
177
178bool
180 // check if baseWire exist, and if yes, delete it
181 if (myBaseWire) {
182 // go to base wire root
185 }
186 // delete baseWire (and all children)
187 delete myBaseWire;
188 // reset baseWire
189 myBaseWire = nullptr;
190 }
191 // create a base wire object
193 // check if wire is a overheadWIre
194 if (tagProperty->getTag() == SUMO_TAG_OVERHEAD_WIRE_SECTION) {
195 // get wire under cursor
197 // if user click over a traction substation, mark int in ParentWireSelector
198 if (wireUnderCursor && (wireUnderCursor->getTagProperty()->getTag() == SUMO_TAG_TRACTION_SUBSTATION)) {
199 // update parent wire selected
200 mySelectorWireParent->setIDSelected(wireUnderCursor->getID());
201 }
202 // stop if currently there isn't a valid selected parent
203 if (mySelectorWireParent->getIdSelected().empty()) {
204 WRITE_WARNING(TLF("A % must be selected before insertion of %.", toString(SUMO_TAG_TRACTION_SUBSTATION), toString(SUMO_TAG_TRACTION_SUBSTATION)));
205 return false;
206 } else {
207 // add tractionsubstation id
209 }
210 }
211 // set baseWire tag
212 myBaseWire->setTag(tagProperty->getTag());
213 // BaseWire created, then return true
214 return true;
215}
216
217
218bool
220 // disable intervals (temporal)
221 if ((tagProperty->getTag() == SUMO_TAG_INTERVAL) ||
222 (tagProperty->getTag() == SUMO_TAG_DEST_PROB_REROUTE) ||
223 (tagProperty->getTag() == SUMO_TAG_CLOSING_REROUTE) ||
224 (tagProperty->getTag() == SUMO_TAG_CLOSING_LANE_REROUTE) ||
225 (tagProperty->getTag() == SUMO_TAG_ROUTE_PROB_REROUTE) ||
226 (tagProperty->getTag() == SUMO_TAG_PARKING_AREA_REROUTE)) {
227 WRITE_WARNING(TL("Currently unsupported. Create rerouter elements using rerouter dialog"));
228 return false;
229 }
230 // disable intervals (temporal)
231 if (tagProperty->getTag() == SUMO_TAG_STEP) {
232 WRITE_WARNING(TL("Currently unsupported. Create VSS steps elements using VSS dialog"));
233 return false;
234 }
235 // Check if ID has to be generated
238 }
239 // Obtain position as the clicked position over view
241 // add position and X-Y-Z attributes
246 // show warning dialogbox and stop check if input parameters are valid
248 return false;
249 } else {
250 // declare additional handler
254 // build wire
255 additionalHandler.parseSumoBaseObject(myBaseWire);
256 // Refresh wire Parent Selector (For wires that have a limited number of children)
258 // refresh wire attributes
260 return true;
261 }
262}
263
264/****************************************************************************/
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:288
#define WRITE_WARNING(msg)
Definition MsgHandler.h:287
#define TL(string)
Definition MsgHandler.h:305
#define TLF(string,...)
Definition MsgHandler.h:307
@ 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:117
std::string generateAdditionalID(SumoXMLTag type) const
generate additional id
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:144
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