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-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 ContainerPlan elements
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
31
33
34// ===========================================================================
35// method definitions
36// ===========================================================================
37
39 GNEFrame(viewParent, viewNet, TL("ContainerPlans")) {
40
41 // create container types selector module
43
44 // Create plan selector
46
47 // Create attributes editor
49
50 // create plan creator Module
52
53 // Create GNEElementTree module
55
56 // create plan creator legend
58}
59
60
62
63
64void
66 // get containers maps
67 const auto& containers = myViewNet->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_CONTAINER);
68 const auto& containerFlows = myViewNet->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_CONTAINERFLOW);
69 // Only show modules if there is at least one container
70 if ((containers.size() > 0) || (containerFlows.size() > 0)) {
71 // show container selector
72 myContainerSelector->showDemandElementSelector();
73 // refresh tag selector
74 myPlanSelector->refreshPlanSelector();
75 } else {
76 // hide all modules
77 myContainerSelector->hideDemandElementSelector();
78 myPlanSelector->hidePlanSelector();
79 myContainerPlanAttributesEditor->hideAttributesEditor();
80 myPlanCreator->hidePathCreatorModule();
81 myContainerHierarchy->hideHierarchicalElementTree();
82 myPlanCreatorLegend->hidePlanCreatorLegend();
83 }
84 // show frame
86}
87
88
89void
91 // reset candidate edges
92 for (const auto& edge : myViewNet->getNet()->getAttributeCarriers()->getEdges()) {
93 edge.second->resetCandidateFlags();
94 }
95 // enable undo/redo
96 myViewNet->getViewParent()->getGNEAppWindows()->enableUndoRedoTemporally();
97 // hide frame
99}
100
101
102bool
104 // first check that we clicked over an AC
105 if (viewObjects.getAttributeCarrierFront() == nullptr) {
106 return false;
107 }
108 // check if we have to select a new container
109 if (myContainerSelector->getCurrentDemandElement() == nullptr) {
110 if (viewObjects.getDemandElementFront() && viewObjects.getDemandElementFront()->getTagProperty()->isContainer()) {
111 // continue depending of number of demand elements under cursor
112 if (viewObjects.getDemandElements().size() > 1) {
113 // Filter containers
114 myContainerSelector->setDemandElements(viewObjects.getDemandElements());
115 } else {
116 // select new container
117 myContainerSelector->setDemandElement(viewObjects.getDemandElementFront());
118 }
119 return true;
120 } else {
121 myViewNet->setStatusBarText(TL("Current selected container isn't valid."));
122 return false;
123 }
124 }
125 // finally check that container plan selected is valid
126 if (!myPlanSelector->getCurrentPlanTemplate()) {
127 myViewNet->setStatusBarText(TL("Current selected container plan isn't valid."));
128 return false;
129 }
130 // continue depending of marked elements
131 if (myPlanSelector->markRoutes() && viewObjects.getDemandElementFront() &&
133 return myPlanCreator->addRoute(viewObjects.getDemandElementFront());
134 } else if (myPlanSelector->markStoppingPlaces() && viewObjects.getAdditionalFront() &&
135 (viewObjects.getAdditionalFront()->getTagProperty()->isStoppingPlace())) {
136 return myPlanCreator->addStoppingPlace(viewObjects.getAdditionalFront());
137 } else if (myPlanSelector->markJunctions() && viewObjects.getJunctionFront()) {
138 return myPlanCreator->addJunction(viewObjects.getJunctionFront());
139 } else if (myPlanSelector->markEdges() && viewObjects.getLaneFront()) {
140 return myPlanCreator->addEdge(viewObjects.getLaneFront());
141 } else if (myPlanSelector->markTAZs() && viewObjects.getTAZFront()) {
142 return myPlanCreator->addTAZ(viewObjects.getTAZFront());
143 } else {
144 return false;
145 }
146}
147
148
149void
153
154
159
160
165
166
171
172
177
178// ===========================================================================
179// protected
180// ===========================================================================
181
182void
184 // first check if container is valid
185 if (myPlanSelector->getCurrentPlanTemplate()) {
186 // show container attributes
187 myContainerPlanAttributesEditor->showAttributesEditor(myPlanSelector->getCurrentPlanTemplate(), true);
188 // set path creator mode depending if previousEdge exist
190 // show path creator mode
191 myPlanCreator->showPlanCreatorModule(myPlanSelector, myContainerSelector->getPreviousPlanElement());
192 // show legend
193 myPlanCreatorLegend->showPlanCreatorLegend();
194 // show container hierarchy
195 myContainerHierarchy->showHierarchicalElementTree(myContainerSelector->getCurrentDemandElement());
196 } else {
197 // hide modules
198 myPlanCreator->hidePathCreatorModule();
199 myContainerHierarchy->hideHierarchicalElementTree();
200 myPlanCreatorLegend->hidePlanCreatorLegend();
201 }
202 } else {
203 // hide modules if tag selected isn't valid
204 myContainerPlanAttributesEditor->hideAttributesEditor();
205 myPlanCreator->hidePathCreatorModule();
206 myContainerHierarchy->hideHierarchicalElementTree();
207 myPlanCreatorLegend->hidePlanCreatorLegend();
208 }
209}
210
211
212void
214 // check if a valid container was selected
215 if (myContainerSelector->getCurrentDemandElement()) {
216 // show container plan tag selector
217 myPlanSelector->showPlanSelector();
218 // now check if container plan selected is valid
219 if (myPlanSelector->getCurrentPlanTemplate()) {
220 // call tag selected
221 tagSelected();
222 } else {
223 myContainerPlanAttributesEditor->hideAttributesEditor();
224 myPlanCreator->hidePathCreatorModule();
225 myContainerHierarchy->hideHierarchicalElementTree();
226 myPlanCreatorLegend->hidePlanCreatorLegend();
227 }
228 } else {
229 // hide modules if container selected isn't valid
230 myPlanSelector->hidePlanSelector();
231 myContainerPlanAttributesEditor->hideAttributesEditor();
232 myPlanCreator->hidePathCreatorModule();
233 myContainerHierarchy->hideHierarchicalElementTree();
234 myPlanCreatorLegend->hidePlanCreatorLegend();
235 }
236}
237
238
239bool
240GNEContainerPlanFrame::createPath(const bool /*useLastRoute*/) {
241 // first check that all attributes are valid
242 if (!myContainerPlanAttributesEditor->checkAttributes(true)) {
243 return false;
244 } else {
245 // declare route handler
246 GNERouteHandler routeHandler(myViewNet->getNet(), myContainerSelector->getCurrentDemandElement()->getAttribute(GNE_ATTR_DEMAND_FILE),
247 myViewNet->getViewParent()->getGNEAppWindows()->isUndoRedoAllowed());
248 // check if container plan can be created
249 if (routeHandler.buildContainerPlan(myPlanSelector->getCurrentPlanTemplate(), myContainerSelector->getCurrentDemandElement(),
251 // refresh GNEElementTree
252 myContainerHierarchy->refreshHierarchicalElementTree();
253 // abort path creation
254 myPlanCreator->abortPathCreation();
255 // refresh using tagSelected
256 tagSelected();
257 // refresh containerPlan attributes
258 myContainerPlanAttributesEditor->refreshAttributesEditor();
259 // enable show all container plans
260 myViewNet->getDemandViewOptions().menuCheckShowAllContainerPlans->setChecked(TRUE);
261 return true;
262 } else {
263 return false;
264 }
265 }
266}
267
268/****************************************************************************/
#define TL(string)
Definition MsgHandler.h:304
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_ROUTE
description of a route
@ GNE_ATTR_DEMAND_FILE
demand demand file
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNEElementTree * myContainerHierarchy
Container Hierarchy.
GNEContainerPlanFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
GNEElementTree * getContainerHierarchy() const
get Container Hierarchy
GNEDemandElementSelector * getContainerSelector() const
get container selectors
void resetSelectedContainer()
reset selected container
GNEPlanCreator * getPlanCreator() const
get plan creator module
GNEPlanCreatorLegend * myPlanCreatorLegend
plan creator legend
GNEPlanSelector * getPlanSelector() const
get containerPlan selector
void demandElementSelected()
selected demand element in DemandElementSelector
GNEDemandElementSelector * myContainerSelector
Container selectors.
GNEPlanSelector * myPlanSelector
containerPlan selector
bool addContainerPlanElement(const GNEViewNetHelper::ViewObjectsSelector &viewObjects)
add container plan element
GNEAttributesEditor * myContainerPlanAttributesEditor
container plan attributes editor
void tagSelected()
Tag selected in GNETagSelector.
GNEPlanCreator * myPlanCreator
plan Creator
bool createPath(const bool useLastRoute)
create path
GNEViewNet * myViewNet
FOX need this.
Definition GNEFrame.h:122
virtual void show()
show Frame
Definition GNEFrame.cpp:110
virtual void hide()
hide Frame
Definition GNEFrame.cpp:119
GNEFrame(GNEViewParent *viewParent, GNEViewNet *viewNet, const std::string &frameLabel)
Constructor.
Definition GNEFrame.cpp:42
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:174
bool buildContainerPlan(const GNEDemandElement *planTemplate, GNEDemandElement *containerParent, GNEAttributesEditor *containerPlanAttributesEditor, GNEPlanCreator *planCreator, const bool centerAfterCreation)
build container plan
bool isContainer() const
return true if tag correspond to a container element
bool isStoppingPlace() const
additional elements
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
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
A single child window which contains a view of the simulation area.