Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEPersonFrame.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 Person elements
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
23#include <netedit/GNEUndoList.h>
33
34#include "GNEPersonFrame.h"
35
36// ===========================================================================
37// method definitions
38// ===========================================================================
39
41 GNEFrame(viewParent, viewNet, TL("Persons")),
42 myPersonBaseObject(new CommonXMLStructure::SumoBaseObject(nullptr)) {
43
44 // create tag Selector module for persons
46
47 // create person types selector module and set DEFAULT_PEDTYPE_ID as default element
49
50 // create person attributes
52
53 // create plan selector module for person plans
55
56 // create person plan attributes
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 person is valid
103 if (personTag == SUMO_TAG_NOTHING) {
104 myViewNet->setStatusBarText(TL("Current selected person 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 person type isn't valid."));
110 return false;
111 }
112 // finally check that person plan selected is valid
113 if (myPlanSelector->getCurrentPlanTemplate() == nullptr) {
114 myViewNet->setStatusBarText(TL("Current selected person 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 person is valid
171 // show PType selector and person plan selector
173 // check if current person type selected is valid
175 // show person attributes depending of myPlanSelector
177 // show person plan tag selector
179 // check current plan template
181 // show person plan attributes
183 // show edge path creator module
185 // show path legend
187 } else {
188 // hide modules
192 }
193 } else {
194 // hide modules
200 }
201 } else {
202 // hide all modules if person isn't valid
209 }
210}
211
212
213void
216 // show person attributes
218 // show person plan tag selector
220 // now check if person plan selected is valid
222 // show person plan attributes
224 // show edge path creator module
226 // show legend
228 } else {
229 // hide modules
232 }
233 } else {
234 // hide modules
239 }
240}
241
242
243bool
244GNEPersonFrame::createPath(const bool /*useLastRoute*/) {
245 // first check that all attributes are valid
247 return false;
249 // begin undo-redo operation
253 // create person
254 GNEDemandElement* person = buildPerson();
255 // declare route handler
258 // check if person and person plan can be created
261 // end undo-redo operation
263 // abort path creation
265 // refresh person and personPlan attributes
268 // compute person
269 person->computePathElement();
270 // enable show all person plans
272 return true;
273 } else {
274 // abort person creation
276 return false;
277 }
278 } else {
279 return false;
280 }
281}
282
283// ---------------------------------------------------------------------------
284// GNEPersonFrame - private methods
285// ---------------------------------------------------------------------------
286
289 // first person base object
291 // obtain person tag (only for improve code legibility)
293 // set tag
294 myPersonBaseObject->setTag(personTag);
295 // get attribute ad values
297 // add pType parameter
299 // declare route handler
303 // check if we're creating a person or personFlow
304 if (personTag == SUMO_TAG_PERSON) {
305 // Add parameter departure
308 }
309 // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
311 // obtain person parameters
312 SUMOVehicleParameter* personParameters = SUMOVehicleParserHelper::parseVehicleAttributes(SUMO_TAG_PERSON, SUMOSAXAttrs, false, false, false);
313 // check personParameters
314 if (personParameters) {
315 myPersonBaseObject->setVehicleParameter(personParameters);
316 // parse vehicle
317 routeHandler.parseSumoBaseObject(myPersonBaseObject);
318 // delete personParameters
319 delete personParameters;
320 }
321 } else {
322 // set begin and end attributes
325 }
326 // adjust poisson value
329 }
330 // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
332 // obtain personFlow parameters
333 SUMOVehicleParameter* personFlowParameters = SUMOVehicleParserHelper::parseFlowAttributes(SUMO_TAG_PERSONFLOW, SUMOSAXAttrs, false, true, 0, SUMOTime_MAX);
334 // check personParameters
335 if (personFlowParameters) {
336 myPersonBaseObject->setVehicleParameter(personFlowParameters);
337 // parse vehicle
338 routeHandler.parseSumoBaseObject(myPersonBaseObject);
339 // delete personParameters
340 delete personFlowParameters;
341 }
342 }
343 // refresh person and personPlan attributes
346 // return created person
348}
349
350/****************************************************************************/
#define TL(string)
Definition MsgHandler.h:305
#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_ROUTE
description of a route
@ SUMO_TAG_PERSON
@ SUMO_TAG_PERSONFLOW
@ 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
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:120
virtual void hide()
hide Frame
Definition GNEFrame.cpp:129
const std::vector< std::string > & getPredefinedTagsMML() const
get predefinedTagsMML
Definition GNEFrame.cpp:315
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:177
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:147
GNEPlanCreator * myPlanCreator
plan creator
GNEPlanSelector * myPlanSelector
personPlan selector
GNEDemandElementSelector * myTypeSelector
Person Type selectors.
GNEAttributesEditor * myPersonAttributesEditor
person attributes editor
~GNEPersonFrame()
Destructor.
GNEDemandElementSelector * getTypeSelector() const
get Type selectors
GNEAttributesEditor * getPersonAttributesEditor() const
get attributes creator
GNEPersonFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
void show()
show Frame
void demandElementSelected()
selected demand element in DemandElementSelector
GNEPlanCreator * getPlanCreator() const
get plan creator module
void tagSelected()
Tag selected in GNETagSelector.
GNEDemandElement * buildPerson()
build person and return it (note: function includes a call to begin(...), but NOT a call to end(....
GNEPlanSelector * getPlanSelector() const
get personPlan selector
CommonXMLStructure::SumoBaseObject * myPersonBaseObject
person base object
void hide()
hide Frame
GNEPlanCreatorLegend * myPlanCreatorLegend
plan creator legend
GNEAttributesEditor * myPersonPlanAttributesEditor
person plan attributes editor
bool createPath(const bool useLastRoute)
create path
bool addPerson(const GNEViewNetHelper::ViewObjectsSelector &viewObjects)
add vehicle element
GNETagSelector * myPersonTagSelector
person tag selector (used to select diffent kind of persons)
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 buildPersonPlan(const GNEDemandElement *planTemplate, GNEDemandElement *personParent, GNEAttributesEditor *personPlanAttributesEditor, GNEPlanCreator *planCreator, const bool centerAfterCreation)
build person 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 * menuCheckShowAllPersonPlans
show all person plans