Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEContainerFrame.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// The Widget for add Container elements
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
23#include <netedit/GNEUndoList.h>
33
34#include "GNEContainerFrame.h"
35
36// ===========================================================================
37// method definitions
38// ===========================================================================
39
41 GNEFrame(viewParent, viewNet, TL("Containers")),
42 myContainerBaseObject(new CommonXMLStructure::SumoBaseObject(nullptr)) {
43
44 // create tag Selector module for containers
46
47 // create container types selector module and set DEFAULT_PEDTYPE_ID as default element
49
50 // Create attributes editor
52
53 // create plan selector module for container plans
55
56 // Create attributes editor
58
59 // create GNEPlanCreator Module
61
62 // create plan creator legend
64}
65
66
70
71
72void
81
82
83void
85 // reset candidate edges
86 for (const auto& edge : myViewNet->getNet()->getAttributeCarriers()->getEdges()) {
87 edge.second->resetCandidateFlags();
88 }
89 // hide frame
91}
92
93
94bool
96 // first check that we clicked over an AC
97 if (viewObjects.getAttributeCarrierFront() == nullptr) {
98 return false;
99 }
100 // obtain tags (only for improve code legibility)
102 // first check that current selected container is valid
103 if (containerTag == SUMO_TAG_NOTHING) {
104 myViewNet->setStatusBarText(TL("Current selected container isn't valid."));
105 return false;
106 }
107 // now check that pType is valid
108 if (myTypeSelector->getCurrentDemandElement() == nullptr) {
109 myViewNet->setStatusBarText(TL("Current selected container type isn't valid."));
110 return false;
111 }
112 // finally check that container plan selected is valid
113 if (myPlanSelector->getCurrentPlanTemplate() == nullptr) {
114 myViewNet->setStatusBarText(TL("Current selected container plan isn't valid."));
115 return false;
116 }
117 for (GNEAdditional* o : viewObjects.getAdditionals()) {
118 if (o->getTagProperty()->isStoppingPlace()) {
120 }
121 }
122 for (GNEDemandElement* o : viewObjects.getDemandElements()) {
123 if (o->getTagProperty()->getTag() == SUMO_TAG_ROUTE) {
124 return myPlanCreator->addRoute(o);
125 }
126 }
127 if (viewObjects.getAttributeCarrierFront() == viewObjects.getJunctionFront()) {
128 return myPlanCreator->addJunction(viewObjects.getJunctions().front());
129 }
130 if (viewObjects.getAttributeCarrierFront() == viewObjects.getLaneFront()) {
131 return myPlanCreator->addEdge(viewObjects.getLanes().front());
132 }
133 if (viewObjects.getAttributeCarrierFront() == viewObjects.getTAZFront()) {
134 return myPlanCreator->addTAZ(viewObjects.getTAZs().front());
135 }
136 return false;
137}
138
139
144
145
150
151
156
157
162
163// ===========================================================================
164// protected
165// ===========================================================================
166
167void
169 // first check if container is valid
171 // show PType selector and container plan selector
173 // check if current container type selected is valid
175 // show container attributes
177 // show container plan tag selector
179 // check current plan template
181 // show container plan attributes
183 // show edge path creator module
185 // show path legend
187 } else {
188 // hide modules
193 }
194 } else {
195 // hide modules
201 }
202 } else {
203 // hide all modules if container isn't valid
210 }
211}
212
213
214void
243
244
245bool
246GNEContainerFrame::createPath(const bool /*useLastRoute*/) {
247 // first check that all attributes are valid
249 return false;
251 // begin undo-redo operation
255 // create container
256 GNEDemandElement* container = buildContainer();
257 // declare route handler
260 // check if container and container plan can be created
263 // end undo-redo operation
265 // abort path creation
267 // refresh container and containerPlan attributes
270 // compute container
271 container->computePathElement();
272 // enable show all container plans
274 return true;
275 } else {
276 // abort container creation
278 return false;
279 }
280 } else {
281 return false;
282 }
283}
284
285// ---------------------------------------------------------------------------
286// GNEContainerFrame - private methods
287// ---------------------------------------------------------------------------
288
291 // first container base object
293 // obtain container tag (only for improve code legibility)
295 // set tag
296 myContainerBaseObject->setTag(containerTag);
297 // get attributes
299 // add pType parameter
301 // declare route handler
304 // check if we're creating a container or containerFlow
305 if (containerTag == SUMO_TAG_CONTAINER) {
306 // Add parameter departure
309 }
310 // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
312 // obtain container parameters
313 SUMOVehicleParameter* containerParameters = SUMOVehicleParserHelper::parseVehicleAttributes(SUMO_TAG_CONTAINER, SUMOSAXAttrs, false, false, false);
314 // check containerParameters
315 if (containerParameters) {
316 myContainerBaseObject->setVehicleParameter(containerParameters);
317 // parse vehicle
318 routeHandler.parseSumoBaseObject(myContainerBaseObject);
319 // delete containerParameters
320 delete containerParameters;
321 }
322 } else {
323 // set begin and end attributes
326 }
327 // adjust poisson value
330 }
331 // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
333 // obtain containerFlow parameters
334 SUMOVehicleParameter* containerFlowParameters = SUMOVehicleParserHelper::parseFlowAttributes(SUMO_TAG_CONTAINERFLOW, SUMOSAXAttrs, false, true, 0, SUMOTime_MAX);
335 // check containerParameters
336 if (containerFlowParameters) {
337 myContainerBaseObject->setVehicleParameter(containerFlowParameters);
338 // parse vehicle
339 routeHandler.parseSumoBaseObject(myContainerBaseObject);
340 // delete containerParameters
341 delete containerFlowParameters;
342 }
343 }
344 // refresh container and containerPlan attributes
347 // return created container
349}
350
351
352/****************************************************************************/
#define TL(string)
Definition MsgHandler.h:301
#define SUMOTime_MAX
Definition SUMOTime.h:34
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_ROUTE
description of a route
@ GNE_ATTR_DEMAND_FILE
demand demand file
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_BEGIN
weights: time range begin
@ GNE_ATTR_POISSON
poisson definition (used in flow)
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
std::map< std::string, std::string > getAllAttributes() const
get all attributes in string format
void setTag(const SumoXMLTag tag)
set SumoBaseObject tag
bool hasDoubleAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given double attribute
void setVehicleParameter(const SUMOVehicleParameter *vehicleParameter)
set vehicle parameters
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
add string attribute into current SumoBaseObject node
double getDoubleAttribute(const SumoXMLAttr attr) const
get double attribute
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
void tagSelected()
Tag selected in GNETagSelector.
GNEPlanCreator * getPlanCreator() const
get plan creator module
GNEPlanSelector * myPlanSelector
containerPlan selector
GNEAttributesEditor * myContainerPlanAttributesEditor
plan attributes editor
bool addContainer(const GNEViewNetHelper::ViewObjectsSelector &viewObjects)
add vehicle element
GNEDemandElementSelector * myTypeSelector
Container Type selectors.
GNEPlanSelector * getPlanSelector() const
get containerPlan selector
GNEPlanCreator * myPlanCreator
plan creator
CommonXMLStructure::SumoBaseObject * myContainerBaseObject
container base object
GNEDemandElementSelector * getTypeSelector() const
get Type selectors
GNEContainerFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
void hide()
hide Frame
void demandElementSelected()
selected demand element in DemandElementSelector
GNEAttributesEditor * getContainerAttributesEditor() const
get attributes editor
GNEPlanCreatorLegend * myPlanCreatorLegend
plan creator legend
void show()
show Frame
~GNEContainerFrame()
Destructor.
GNEAttributesEditor * myContainerAttributesEditor
attributes editor
GNETagSelector * myContainerTagSelector
container tag selector (used to select diffent kind of containers)
GNEDemandElement * buildContainer()
build container and return it (note: function includes a call to begin(...), but NOT a call to end(....
bool createPath(const bool useLastRoute)
create path
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual void computePathElement()=0
implement in children+
void showDemandElementSelector()
show demand element selector
void refreshDemandElementSelector()
refresh demand element selector
GNEDemandElement * getCurrentDemandElement() const
get current demand element
void hideDemandElementSelector()
hide demand element selector
GNEViewNet * myViewNet
FOX need this.
Definition GNEFrame.h:121
virtual void show()
show Frame
Definition GNEFrame.cpp:119
virtual void hide()
hide Frame
Definition GNEFrame.cpp:128
const std::vector< std::string > & getPredefinedTagsMML() const
get predefinedTagsMML
Definition GNEFrame.cpp:314
const std::map< std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:176
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:146
bool addStoppingPlace(GNEAdditional *stoppingPlace)
add from to stoppingPlace
bool addRoute(GNEDemandElement *route)
add route
bool planCanBeCreated(const GNEDemandElement *planTemplate) const
check if plan can be created
void hidePathCreatorModule()
show GNEPlanCreator
bool addTAZ(GNEAdditional *taz)
add TAZ
bool addJunction(GNEJunction *junction)
add junction
bool addEdge(GNELane *lane)
add edge (clicking over lanes)
void abortPathCreation()
abort path creation
void showPlanCreatorModule(const GNEPlanSelector *planSelector, const GNEDemandElement *previousPlan)
show plan creator for the given tag property
void showPlanCreatorLegend()
show plan creator legend
void hidePlanCreatorLegend()
hide Legend modul
GNEDemandElement * getCurrentPlanTemplate() const
get current plan template
void showPlanSelector()
show plan selector
void hidePlanSelector()
plan item selector
const GNETagProperties * getCurrentPlanTagProperties() const
get current plan tag properties
void refreshPlanSelector()
refresh plan selector (used when frameParent is show)
bool buildContainerPlan(const GNEDemandElement *planTemplate, GNEDemandElement *containerParent, GNEAttributesEditor *containerPlanAttributesEditor, GNEPlanCreator *planCreator, const bool centerAfterCreation)
build container plan
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
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
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void abortAllChangeGroups()
reverts and discards ALL active chained change groups
class used to group all variables related with objects under cursor after a click over view
const std::vector< GNETAZ * > & getTAZs() const
get vector with TAZs
GNEAttributeCarrier * getAttributeCarrierFront() const
get front attribute carrier or a pointer to nullptr
const std::vector< GNEDemandElement * > & getDemandElements() const
get vector with Demand Elements
GNETAZ * getTAZFront() const
get front TAZ or a pointer to nullptr
GNELane * getLaneFront() const
get front lane or a pointer to nullptr
GNEJunction * getJunctionFront() const
get front junction or a pointer to nullptr
const std::vector< GNEJunction * > & getJunctions() const
get vector with junctions
const std::vector< GNELane * > & getLanes() const
get lanes
const std::vector< GNEAdditional * > & getAdditionals() const
get vector with additionals
GNENet * getNet() const
get the net object
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
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 setChecked(bool val, const bool inform=false)
check or uncheck this MFXCheckableButton
Encapsulated Xerces-SAX-attributes.
Structure representing possible vehicle parameter.
static SUMOVehicleParameter * parseVehicleAttributes(int element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false, const bool allowInternalRoutes=false)
Parses a vehicle's attributes.
static SUMOVehicleParameter * parseFlowAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs, const bool hardFail, const bool needID, const SUMOTime beginDefault, const SUMOTime endDefault, const bool allowInternalRoutes=false)
Parses a flow's attributes.
MFXCheckableButton * menuCheckShowAllContainerPlans
show all container plans