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-2024 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
23#include <netedit/GNENet.h>
24#include <netedit/GNEViewNet.h>
27
28#include "GNEPersonPlanFrame.h"
29
30
31// ===========================================================================
32// method definitions
33// ===========================================================================
34
35// ---------------------------------------------------------------------------
36// GNEPersonPlanFrame - methods
37// ---------------------------------------------------------------------------
38
40 GNEFrame(viewParent, viewNet, TL("PersonPlans")),
41 myRouteHandler("", viewNet->getNet(), myViewNet->getViewParent()->getGNEAppWindows()->isUndoRedoAllowed(), false) {
42
43 // create person types selector module
45
46 // Create plan selector
48
49 // Create person parameters
51
52 // create plan creator Module
54
55 // Create GNEElementTree module
57
58 // create plan creator legend
60}
61
62
64
65
66void
68 // get persons maps
70 const auto& personFlows = myViewNet->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_PERSONFLOW);
71 // Only show modules if there is at least one person
72 if ((persons.size() > 0) || (personFlows.size() > 0)) {
73 // show person selector
75 // refresh tag selector
77 } else {
78 // hide all modules
85 }
86 // show frame
88}
89
90
91void
93 // reset candidate edges
94 for (const auto& edge : myViewNet->getNet()->getAttributeCarriers()->getEdges()) {
95 edge.second->resetCandidateFlags();
96 }
97 // enable undo/redo
99 // hide frame
101}
102
103
104bool
106 // first check that we clicked over an AC
107 if (viewObjects.getAttributeCarrierFront() == nullptr) {
108 return false;
109 }
110 // check if we have to select a new person
111 if (myPersonSelector->getCurrentDemandElement() == nullptr) {
112 if (viewObjects.getDemandElementFront() && viewObjects.getDemandElementFront()->getTagProperty().isPerson()) {
113 // continue depending of number of demand elements under cursor
114 if (viewObjects.getDemandElements().size() > 1) {
115 // Filter persons
117 } else {
118 // select new person
120 }
121 return true;
122 } else {
123 myViewNet->setStatusBarText(TL("Current selected person isn't valid."));
124 return false;
125 }
126 }
127 // finally check that person plan selected is valid
129 myViewNet->setStatusBarText(TL("Current selected person plan isn't valid."));
130 return false;
131 }
132 // continue depending of marked elements
133 if (myPlanSelector->markRoutes() && viewObjects.getDemandElementFront() &&
135 return myPlanCreator->addRoute(viewObjects.getDemandElementFront());
136 } else if (myPlanSelector->markStoppingPlaces() && viewObjects.getAdditionalFront() &&
139 } else if (myPlanSelector->markJunctions() && viewObjects.getJunctionFront()) {
140 return myPlanCreator->addJunction(viewObjects.getJunctionFront());
141 } else if (myPlanSelector->markEdges() && viewObjects.getLaneFront()) {
142 return myPlanCreator->addEdge(viewObjects.getLaneFront());
143 } else if (myPlanSelector->markTAZs() && viewObjects.getTAZFront()) {
144 return myPlanCreator->addTAZ(viewObjects.getTAZFront());
145 } else {
146 return false;
147 }
148}
149
150
151void
155
156
161
162
167
168
173
174
179
180// ===========================================================================
181// protected
182// ===========================================================================
183
184void
186 // first check if person is valid
188 // show person attributes
190 // set path creator mode depending if previousEdge exist
191 if (myPersonSelector) {
192 // show path creator mode
194 // show legend
196 // show person hierarchy
198 } else {
199 // hide modules
203 }
204 } else {
205 // hide modules if tag selected isn't valid
210 }
211}
212
213
214void
216 // check if a valid person was selected
218 // show person plan tag selector
220 // now check if person plan selected is valid
222 // call tag selected
223 tagSelected();
224 } else {
229 }
230 } else {
231 // hide modules if person selected isn't valid
237 }
238}
239
240
241bool
242GNEPersonPlanFrame::createPath(const bool /*useLastRoute*/) {
243 // first check that all attributes are valid
246 return false;
247 } else {
248 // check if person plan can be created
251 // refresh GNEElementTree
253 // abort path creation
255 // refresh using tagSelected
256 tagSelected();
257 // refresh personPlan attributes
259 // enable show all person plans
261 return true;
262 } else {
263 return false;
264 }
265 }
266}
267
268/****************************************************************************/
#define TL(string)
Definition MsgHandler.h:315
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_PERSON
@ SUMO_TAG_PERSONFLOW
void enableUndoRedoTemporally()
enable undo-redo temporally (for example, after creating an edge)
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
void setDemandElements(const std::vector< GNEDemandElement * > &demandElements)
set multiple demand elements to filter
GNEDemandElement * getPreviousPlanElement() const
get previous plan element
void showDemandElementSelector()
show demand element selector
void setDemandElement(GNEDemandElement *demandElement)
set current demand element
GNEDemandElement * getCurrentDemandElement() const
get current demand element
void hideDemandElementSelector()
hide demand element selector
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< std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
const std::map< SumoXMLTag, std::map< const GUIGlObject *, GNEDemandElement * > > & getDemandElements() const
get demand elements
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:142
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:125
GNEElementTree * getPersonHierarchy() const
get Person Hierarchy
bool createPath(const bool useLastRoute)
create path
GNEDemandElementSelector * getPersonSelector() const
get person selectors
GNEElementTree * myPersonHierarchy
Person Hierarchy.
~GNEPersonPlanFrame()
Destructor.
GNERouteHandler myRouteHandler
route handler
GNEPlanSelector * myPlanSelector
personPlan selector
GNEPlanCreator * myPlanCreator
plan Creator
GNEPersonPlanFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
GNEDemandElementSelector * myPersonSelector
Person selectors.
void tagSelected()
Tag selected in GNETagSelector.
bool addPersonPlanElement(const GNEViewNetHelper::ViewObjectsSelector &viewObjects)
add person plan element
GNEPlanCreator * getPlanCreator() const
get plan creator module
void demandElementSelected()
selected demand element in DemandElementSelector
GNEAttributesCreator * myPersonPlanAttributes
internal vehicle attributes
void resetSelectedPerson()
reset selected person
GNEPlanCreatorLegend * myPlanCreatorLegend
plan creator legend
GNEPlanSelector * getPlanSelector() const
get personPlan selector
bool addStoppingPlace(GNEAdditional *stoppingPlace)
add from to stoppingPlace
bool addRoute(GNEDemandElement *route)
add route
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
bool markJunctions() const
check if mark junctions with dotted contours
void showPlanSelector()
show plan selector
bool markRoutes() const
check if mark routes with dotted contours
const GNETagProperties & getCurrentPlanTagProperties() const
get current plan tag properties
void hidePlanSelector()
plan item selector
bool markTAZs() const
check if mark TAZs with dotted contours
bool markStoppingPlaces() const
check if mark stoppingPlaces with dotted contours
bool markEdges() const
check if mark edges with dotted contours
void refreshPlanSelector()
refresh plan selector (used when frameParent is show)
bool buildPersonPlan(const GNEDemandElement *planTemplate, GNEDemandElement *personParent, GNEAttributesCreator *personPlanAttributes, 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...
bool isStoppingPlace() const
additional elements
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool isPerson() const
return true if tag correspond to a person element
class used to group all variables related with objects under cursor after a click over view
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
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
GNENet * getNet() const
get the net object
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