Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEContainerPlanFrame.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 ContainerPlan elements
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
27
29
30
31// ===========================================================================
32// method definitions
33// ===========================================================================
34
35// ---------------------------------------------------------------------------
36// GNEContainerPlanFrame - methods
37// ---------------------------------------------------------------------------
38
40 GNEFrame(viewParent, viewNet, "ContainerPlans"),
41 myRouteHandler("", viewNet->getNet(), true, false) {
42
43 // create container types selector modul
45
46 // Create tag selector for container plan
48
49 // Create container parameters
51
52 // create myPathCreator Module
53 myPathCreator = new GNEPathCreator(this);
54
55 // Create GNEElementTree modul
57
58 // create legend label
60}
61
62
64
65
66void
68 // get containers maps
69 const auto& containers = myViewNet->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_CONTAINER);
70 const auto& containerFlows = myViewNet->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_CONTAINERFLOW);
71 // Only show moduls if there is at least one container
72 if ((containers.size() > 0) || (containerFlows.size() > 0)) {
73 // show container selector
75 // refresh tag selector
77 // set first container as demand element (this will call demandElementSelected() function)
78 if (containers.size() > 0) {
79 myContainerSelector->setDemandElement(*containers.begin());
80 } else {
81 myContainerSelector->setDemandElement(*containerFlows.begin());
82 }
83 } else {
84 // hide all moduls
91 }
92 // show frame
94}
95
96
97void
99 // reset candidate edges
100 for (const auto& edge : myViewNet->getNet()->getAttributeCarriers()->getEdges()) {
101 edge.second->resetCandidateFlags();
102 }
103 // enable undo/redo
105 // hide frame
107}
108
109
110bool
112 // first check if container selected is valid
114 myViewNet->setStatusBarText(TL("Current selected container isn't valid."));
115 return false;
116 }
117 // finally check that container plan selected is valid
119 myViewNet->setStatusBarText(TL("Current selected container plan isn't valid."));
120 return false;
121 }
122 // Obtain current container plan tag (only for improve code legibility)
124 // declare flags for requirements
125 const bool requireContainerStop = ((containerPlanTag == GNE_TAG_TRANSPORT_CONTAINERSTOP) || (containerPlanTag == GNE_TAG_TRANSHIP_CONTAINERSTOP) ||
126 (containerPlanTag == GNE_TAG_STOPCONTAINER_CONTAINERSTOP));
127 const bool requireEdge = ((containerPlanTag == GNE_TAG_TRANSPORT_EDGE) || (containerPlanTag == GNE_TAG_TRANSHIP_EDGE) ||
128 (containerPlanTag == GNE_TAG_TRANSHIP_EDGES) || (containerPlanTag == GNE_TAG_STOPCONTAINER_EDGE));
129 // continue depending of tag
130 if (requireContainerStop && objectsUnderCursor.getAdditionalFront() && (objectsUnderCursor.getAdditionalFront()->getTagProperty().getTag() == SUMO_TAG_CONTAINER_STOP)) {
131 return myPathCreator->addStoppingPlace(objectsUnderCursor.getAdditionalFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed());
132 } else if (requireEdge && objectsUnderCursor.getEdgeFront()) {
133 return myPathCreator->addEdge(objectsUnderCursor.getEdgeFront(), mouseButtonKeyPressed.shiftKeyPressed(), mouseButtonKeyPressed.controlKeyPressed());
134 } else {
135 return false;
136 }
137}
138
139
144
145
150
151
156
157// ===========================================================================
158// protected
159// ===========================================================================
160
161void
163 // first check if container is valid
165 // Obtain current container plan tag (only for improve code legibility)
167 // show container attributes
169 // get previous container plan
171 // set path creator mode depending if previousEdge exist
172 if (previousEdge) {
173 // set path creator mode
174 myPathCreator->showPathCreatorModule(containerPlanTag, true, false);
175 // show legend
177 // check if add previous edge
179 myPathCreator->addEdge(previousEdge, true, true);
180 }
181 } else {
182 // set path creator mode
183 myPathCreator->showPathCreatorModule(containerPlanTag, false, false);
184 // show legend
186 }
187 // show container hierarchy
189 } else {
190 // hide moduls if tag selecte isn't valid
196 }
197}
198
199
200void
202 // check if a valid container was selected
204 // show container plan tag selector
206 // now check if container plan selected is valid
208 // call tag selected
209 tagSelected();
210 } else {
215 }
216 } else {
217 // hide moduls if container selected isn't valid
223 }
224}
225
226
227bool
228GNEContainerPlanFrame::createPath(const bool /*useLastRoute*/) {
229 // first check that all attributes are valid
232 } else {
233 // check if container plan can be created
238 myPathCreator, true)) {
239 // refresh GNEElementTree
241 // abort path creation
243 // refresh using tagSelected
244 tagSelected();
245 // refresh containerPlan attributes
247 // enable show all person plans
249 return true;
250 }
251 }
252 return false;
253}
254
255/****************************************************************************/
#define TL(string)
Definition MsgHandler.h:287
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRANSPORT_CONTAINERSTOP
@ SUMO_TAG_NOTHING
invalid tag
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_CONTAINERFLOW
@ GNE_TAG_STOPCONTAINER_EDGE
@ GNE_TAG_TRANSHIP_EDGES
@ GNE_TAG_STOPCONTAINER_CONTAINERSTOP
@ SUMO_TAG_CONTAINER
@ GNE_TAG_TRANSHIP_EDGE
@ GNE_TAG_TRANSHIP_CONTAINERSTOP
@ GNE_TAG_TRANSPORT_EDGE
GNEDemandElement * getCurrentDemandElement() const
get current demand element
void setDemandElement(GNEDemandElement *demandElement)
set current demand element
GNEEdge * getContainerPlanPreviousEdge() const
get previous edge for the current container plan
void showDemandElementSelector()
show demand element selector
void hideDemandElementSelector()
hide demand element selector
void enableUndoRedo()
disable undo-redo
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
GNEElementTree * myContainerHierarchy
Container Hierarchy.
GNERouteHandler myRouteHandler
route handler
GNEAttributesCreator * myContainerPlanAttributes
internal vehicle attributes
DemandElementSelector * myContainerSelector
Container selectors.
GNEContainerPlanFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
GNEElementTree * getContainerHierarchy() const
get container Hierarchy
GNEPathCreator * myPathCreator
Path Creator.
GNETagSelector * myContainerPlanTagSelector
containerPlan selector
GNEPathCreator * getPathCreator() const
get path creator modul
bool addContainerPlanElement(const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor, const GNEViewNetHelper::MouseButtonKeyPressed &mouseButtonKeyPressed)
add container plan element
void demandElementSelected()
selected demand element in DemandElementSelector
GNEPathLegendModule * myPathLegend
path legend modul
void tagSelected()
Tag selected in GNETagSelector.
bool createPath(const bool useLastRoute)
create path
DemandElementSelector * getContainerSelector() const
get container selectors
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
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
void abortPathCreation()
abort path creation
bool addEdge(GNEEdge *edge, const bool shiftKeyPressed, const bool controlKeyPressed)
add edge
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
bool buildContainerPlan(SumoXMLTag tag, GNEDemandElement *containerParent, GNEAttributesCreator *containerPlanAttributes, GNEPathCreator *pathCreator, 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
bool isStopContainer() const
return true if tag correspond to a container stop 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
GNEAdditional * getAdditionalFront() const
get front additional element or a pointer to nullptr
GNEEdge * getEdgeFront() const
get front edge 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
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