Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEPersonPlanFrame.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-2023 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 PersonPlan elements
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
26
27#include "GNEPersonPlanFrame.h"
28
29
30// ===========================================================================
31// method definitions
32// ===========================================================================
33
34// ---------------------------------------------------------------------------
35// GNEPersonPlanFrame - methods
36// ---------------------------------------------------------------------------
37
39 GNEFrame(viewParent, viewNet, "PersonPlans"),
40 myRouteHandler("", viewNet->getNet(), true, false) {
41
42 // create person types selector modul
44
45 // Create tag selector for person plan
47
48 // Create person parameters
50
51 // create myPathCreator Module
52 myPathCreator = new GNEPathCreator(this);
53
54 // Create GNEElementTree modul
56
57 // create legend label
59}
60
61
63
64
65void
67 // get persons maps
69 const auto& personFlows = myViewNet->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_PERSONFLOW);
70 // Only show moduls if there is at least one person
71 if ((persons.size() > 0) || (personFlows.size() > 0)) {
72 // show person selector
74 // refresh tag selector
76 // set first person as demand element (this will call demandElementSelected() function)
78 GNEDemandElement* personFound = nullptr;
79 // search person
80 for (const auto& person : persons) {
81 if (myViewNet->getFrontAttributeCarrier()->getID() == person->getID()) {
82 personFound = person;
83 }
84 }
85 // search personFlow
86 for (const auto& personFlow : personFlows) {
87 if (myViewNet->getFrontAttributeCarrier()->getID() == personFlow->getID()) {
88 personFound = personFlow;
89 }
90 }
91 // check personFound
92 if (personFound) {
94 }
95 } else {
97 }
98 } else {
99 // hide all moduls
106 }
107 // show frame
109}
110
111
112void
114 // reset candidate edges
115 for (const auto& edge : myViewNet->getNet()->getAttributeCarriers()->getEdges()) {
116 edge.second->resetCandidateFlags();
117 }
118 // enable undo/redo
120 // hide frame
122}
123
124
125bool
127 // check if we have to select a new person
128 if (myPersonSelector->getCurrentDemandElement() == nullptr) {
129 if (objectsUnderCursor.getDemandElementFront() && objectsUnderCursor.getDemandElementFront()->getTagProperty().isPerson()) {
130 // continue depending of number of demand elements under cursor
131 if (objectsUnderCursor.getClickedDemandElements().size() > 1) {
132 // Filter persons
134 } else {
135 // select new person
137 }
138 return true;
139 } else {
140 myViewNet->setStatusBarText(TL("Current selected person isn't valid."));
141 return false;
142 }
143 }
144 // finally check that person plan selected is valid
146 myViewNet->setStatusBarText(TL("Current selected person plan isn't valid."));
147 return false;
148 }
149 // Obtain current person plan tag (only for improve code legibility)
151 // declare flags for requirements
152 const bool requireBusStop = ((personPlanTag == GNE_TAG_PERSONTRIP_BUSSTOP) || (personPlanTag == GNE_TAG_WALK_BUSSTOP) ||
153 (personPlanTag == GNE_TAG_RIDE_BUSSTOP) || (personPlanTag == GNE_TAG_STOPPERSON_BUSSTOP));
154 const bool requireTrainStop = ((personPlanTag == GNE_TAG_PERSONTRIP_TRAINSTOP) || (personPlanTag == GNE_TAG_WALK_TRAINSTOP) ||
155 (personPlanTag == GNE_TAG_RIDE_TRAINSTOP) || (personPlanTag == GNE_TAG_STOPPERSON_TRAINSTOP));
156 const bool requireEdge = ((personPlanTag == GNE_TAG_PERSONTRIP_EDGE) || (personPlanTag == GNE_TAG_WALK_EDGE) ||
157 (personPlanTag == GNE_TAG_RIDE_EDGE) || (personPlanTag == GNE_TAG_WALK_EDGES) ||
158 (personPlanTag == GNE_TAG_STOPPERSON_EDGE));
159 const bool requireJunction = ((personPlanTag == GNE_TAG_PERSONTRIP_JUNCTIONS) || (personPlanTag == GNE_TAG_WALK_JUNCTIONS));
160 // continue depending of tag
161 if ((personPlanTag == GNE_TAG_WALK_ROUTE) && objectsUnderCursor.getDemandElementFront() && (objectsUnderCursor.getDemandElementFront()->getTagProperty().getTag() == SUMO_TAG_ROUTE)) {
162 return myPathCreator->addRoute(objectsUnderCursor.getDemandElementFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed());
163 } else if (requireBusStop && objectsUnderCursor.getAdditionalFront() && (objectsUnderCursor.getAdditionalFront()->getTagProperty().getTag() == SUMO_TAG_BUS_STOP)) {
164 return myPathCreator->addStoppingPlace(objectsUnderCursor.getAdditionalFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed());
165 } else if (requireTrainStop && objectsUnderCursor.getAdditionalFront() && (objectsUnderCursor.getAdditionalFront()->getTagProperty().getTag() == SUMO_TAG_TRAIN_STOP)) {
166 return myPathCreator->addStoppingPlace(objectsUnderCursor.getAdditionalFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed());
167 } else if (requireEdge && objectsUnderCursor.getEdgeFront()) {
168 return myPathCreator->addEdge(objectsUnderCursor.getEdgeFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed());
169 } else if (requireJunction && objectsUnderCursor.getJunctionFront()) {
170 return myPathCreator->addJunction(objectsUnderCursor.getJunctionFront());
171 } else {
172 return false;
173 }
174}
175
176
177void
181
182
187
188
193
194
199
200// ===========================================================================
201// protected
202// ===========================================================================
203
204void
206 // first check if person is valid
208 // Obtain current person plan tag (only for improve code legibility)
210 // show person attributes
212 // get previous person plan
214 // update VClass of myPathCreator depending if person is a ride
217 } else {
219 }
220 // set path creator mode depending if previousEdge exist
221 if (previousEdge) {
222 // set path creator mode
223 myPathCreator->showPathCreatorModule(personPlanTag, true, false);
224 // show legend
226 // add previous edge or junction
228 myPathCreator->addJunction(previousEdge->getToJunction());
230 myPathCreator->addEdge(previousEdge, true, true);
231 }
232 } else {
233 // set path creator mode
234 myPathCreator->showPathCreatorModule(personPlanTag, false, false);
235 // show legend
237 }
238 // show person hierarchy
240 } else {
241 // hide moduls if tag selecte isn't valid
246 }
247}
248
249
250void
252 // check if a valid person was selected
254 // show person plan tag selector
256 // now check if person plan selected is valid
258 // call tag selected
259 tagSelected();
260 } else {
265 }
266 } else {
267 // hide moduls if person selected isn't valid
273 }
274}
275
276
277bool
278GNEPersonPlanFrame::createPath(const bool /*useLastRoute*/) {
279 // first check that all attributes are valid
282 return false;
283 } else {
284 // check if person plan can be created
289 // refresh GNEElementTree
291 // abort path creation
293 // refresh using tagSelected
294 tagSelected();
295 // refresh personPlan attributes
297 // enable show all person plans
299 return true;
300 } else {
301 return false;
302 }
303 }
304}
305
306/****************************************************************************/
#define TL(string)
Definition MsgHandler.h:287
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_PEDESTRIAN
pedestrian
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_PERSONTRIP_JUNCTIONS
@ GNE_TAG_PERSONTRIP_BUSSTOP
@ GNE_TAG_WALK_EDGES
@ SUMO_TAG_BUS_STOP
A bus stop.
@ GNE_TAG_STOPPERSON_BUSSTOP
@ GNE_TAG_PERSONTRIP_TRAINSTOP
@ GNE_TAG_WALK_BUSSTOP
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ GNE_TAG_RIDE_EDGE
@ GNE_TAG_WALK_JUNCTIONS
@ SUMO_TAG_PERSON
@ GNE_TAG_WALK_TRAINSTOP
@ GNE_TAG_STOPPERSON_TRAINSTOP
@ GNE_TAG_RIDE_TRAINSTOP
@ GNE_TAG_WALK_EDGE
@ GNE_TAG_PERSONTRIP_EDGE
@ GNE_TAG_RIDE_BUSSTOP
@ GNE_TAG_STOPPERSON_EDGE
@ GNE_TAG_WALK_ROUTE
@ SUMO_TAG_PERSONFLOW
@ SUMO_ATTR_FROMJUNCTION
GNEDemandElement * getCurrentDemandElement() const
get current demand element
GNEEdge * getPersonPlanPreviousEdge() const
get previous edge for the current person plan
void setDemandElement(GNEDemandElement *demandElement)
set current demand element
void showDemandElementSelector()
show demand element selector
void setDemandElements(const std::vector< GNEDemandElement * > &demandElements)
set multiple demand elements to filter
void hideDemandElementSelector()
hide demand element selector
void enableUndoRedo()
disable undo-redo
const std::string getID() const
get ID (all Attribute Carriers have one)
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
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 refreshAttributesCreator()
refresh attribute creator
An Element which don't belong to GNENet but has influence in the simulation.
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:82
void hideHierarchicalElementTree()
hide GNEElementTree
void refreshHierarchicalElementTree()
refresh GNEElementTree
void showHierarchicalElementTree(GNEAttributeCarrier *AC)
show GNEElementTree
GNEViewNet * myViewNet
FOX need this.
Definition GNEFrame.h:117
virtual void show()
show Frame
Definition GNEFrame.cpp:115
virtual void hide()
hide Frame
Definition GNEFrame.cpp:124
const std::map< SumoXMLTag, std::set< GNEDemandElement * > > & getDemandElements() const
get demand elements
const std::map< std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:120
bool addStoppingPlace(GNEAdditional *stoppingPlace, const bool shiftKeyPressed, const bool controlKeyPressed)
add stoppingPlace
bool addRoute(GNEDemandElement *route, const bool shiftKeyPressed, const bool controlKeyPressed)
add route
void abortPathCreation()
abort path creation
bool addEdge(GNEEdge *edge, const bool shiftKeyPressed, const bool controlKeyPressed)
add edge
bool addJunction(GNEJunction *junction)
add junction
void setVClass(SUMOVehicleClass vClass)
set vClass
void hidePathCreatorModule()
show GNEPathCreator
void showPathCreatorModule(SumoXMLTag element, const bool firstElement, const bool consecutives)
show GNEPathCreator for the given tag
void hidePathLegendModule()
hide Legend modul
void showPathLegendModule()
show Legend modul
GNEElementTree * getPersonHierarchy() const
get Person Hierarchy
GNETagSelector * myPersonPlanTagSelector
personPlan selector
bool addPersonPlanElement(const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor, const GNEViewNetHelper::MouseButtonKeyPressed &mouseButtonKeyPressed)
add person plan element
bool createPath(const bool useLastRoute)
create path
GNEElementTree * myPersonHierarchy
Person Hierarchy.
~GNEPersonPlanFrame()
Destructor.
GNERouteHandler myRouteHandler
route handler
GNEPersonPlanFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
void tagSelected()
Tag selected in GNETagSelector.
GNEPathCreator * myPathCreator
Path Creator.
GNEPathCreator * getPathCreator() const
get path creator module
GNEPathLegendModule * myPathLegend
path legend modul
void demandElementSelected()
selected demand element in DemandElementSelector
GNEAttributesCreator * myPersonPlanAttributes
internal vehicle attributes
DemandElementSelector * getPersonSelector() const
get person selectors
void resetSelectedPerson()
reset selected person
DemandElementSelector * myPersonSelector
Person selectors.
bool buildPersonPlan(SumoXMLTag tag, GNEDemandElement *personParent, GNEAttributesCreator *personPlanAttributes, GNEPathCreator *pathCreator, 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
bool isRide() const
return true if tag correspond to a ride element
bool isStopPerson() const
return true if tag correspond to a person stop element
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
bool isPerson() const
return true if tag correspond to a person element
void refreshTagSelector()
refresh tagSelector (used when frameParent is show)
void showTagSelector()
show item selector
GNEAttributeCarrier * getCurrentTemplateAC() const
get current templateAC
void hideTagSelector()
hide item selector
class used to group all variables related with objects under cursor after a click over view
const std::vector< GNEDemandElement * > & getClickedDemandElements() const
get vector with clicked Demand Elements
GNEAdditional * getAdditionalFront() const
get front additional element or a pointer to nullptr
GNEJunction * getJunctionFront() const
get front junction or a pointer to nullptr
GNEDemandElement * getDemandElementFront() const
get front demand element or a pointer to nullptr
GNEEdge * getEdgeFront() const
get front edge or a pointer to nullptr
GNENet * getNet() const
get the net object
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
GNEViewParent * getViewParent() const
get the net 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
MFXCheckableButton * menuCheckShowAllPersonPlans
show all person plans
class used to group all variables related with mouse buttons and key pressed after certain events
bool shiftKeyPressed() const
check if SHIFT is pressed during current event
bool controlKeyPressed() const
check if CONTROL is pressed during current event