Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEPlanSelector.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// Frame for select person/container plans
19/****************************************************************************/
20
21#include <netedit/GNEViewNet.h>
22#include <netedit/GNENet.h>
69
70#include "GNEPlanSelector.h"
71
72// ===========================================================================
73// FOX callback mapping
74// ===========================================================================
75
76FXDEFMAP(GNEPlanSelector) TagSelectorMap[] = {
78};
79
80// Object implementation
81FXIMPLEMENT(GNEPlanSelector, MFXGroupBoxModule, TagSelectorMap, ARRAYNUMBER(TagSelectorMap))
82
83// ===========================================================================
84// method definitions
85// ===========================================================================
86
88 MFXGroupBoxModule(frameParent, TL("Plan type")),
89 myFrameParent(frameParent) {
90 // Create MFXComboBoxIcon
91 myPlansComboBox = new MFXComboBoxIcon(getCollapsableFrame(), GUIDesignComboBoxNCol, false, GUIDesignComboBoxVisibleItems,
93 // get net
94 const auto net = myFrameParent->getViewNet()->getNet();
95 // continue depending of plan type
96 if (planType == SUMO_TAG_PERSON) {
97 fillPersonPlanTemplates(net);
98 } else if (planType == SUMO_TAG_CONTAINER) {
99 fillContainerPlanTemplates(net);
100 } else {
101 throw ProcessError("Invalid plan");
102 }
103 // add person plan elements
104 for (const auto& planTemplate : myPlanTemplates) {
105 planTemplate.second->resetDefaultValues(false);
106 myPlansComboBox->appendIconItem(planTemplate.first->getTooltipText().c_str(),
107 GUIIconSubSys::getIcon(planTemplate.second->getTagProperty()->getGUIIcon()),
108 planTemplate.second->getTagProperty()->getBackGroundColor());
109 }
110 // set myCurrentPlanTemplate
111 myCurrentPlanTemplate = myPlanTemplates.front();
112 // set color of myTypeMatchBox to black (valid)
113 myPlansComboBox->setTextColor(FXRGB(0, 0, 0));
114 myPlansComboBox->killFocus();
115 // GNEPlanSelector is always shown
116 show();
117}
118
119
121 for (auto& planTemplate : myPlanTemplates) {
122 delete planTemplate.first;
123 delete planTemplate.second;
124 }
125 myPlanTemplates.clear();
126}
127
128
129void
135
136
137void
143
144
145const GNETagProperties*
149
150
155
156
157void
159 if (isPlanValid()) {
160 // call tag selected function
162 } else {
163 // set first item
165 }
166}
167
168
169bool
171 // first check if this modul is shown and selected plan is valid
172 if (isPlanValid()) {
173 return myCurrentPlanTemplate.first->planRoute();
174 } else {
175 return false;
176 }
177}
178
179
180bool
182 // first check if this modul is shown and selected plan is valid
183 if (isPlanValid()) {
184 return myCurrentPlanTemplate.first->planConsecutiveEdges() ||
185 myCurrentPlanTemplate.first->planEdge() ||
186 myCurrentPlanTemplate.first->planFromEdge() ||
187 myCurrentPlanTemplate.first->planToEdge();
188 } else {
189 return false;
190 }
191}
192
193
194bool
196 // first check if this modul is shown and selected plan is valid
197 if (isPlanValid()) {
198 return myCurrentPlanTemplate.first->planFromJunction() ||
199 myCurrentPlanTemplate.first->planToJunction();
200 } else {
201 return false;
202 }
203}
204
205
206bool
208 // first check if this modul is shown and selected plan is valid
209 if (isPlanValid()) {
210 return myCurrentPlanTemplate.first->planStoppingPlace() ||
211 myCurrentPlanTemplate.first->planFromStoppingPlace() ||
212 myCurrentPlanTemplate.first->planToStoppingPlace();
213 } else {
214 return false;
215 }
216}
217
218
219bool
221 // first check if this modul is shown and selected plan is valid
222 if (isPlanValid()) {
223 return myCurrentPlanTemplate.first->planFromTAZ() ||
224 myCurrentPlanTemplate.first->planToTAZ();
225 } else {
226 return false;
227 }
228}
229
230
231void
233 // clear junction colors
235 // we assume that all junctions don't support pedestrians
236 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
237 junction.second->setInvalidCandidate(true);
238 }
239 // mark junctions that supports pedestrian as candidates
240 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
241 for (int i = 0; i < (int)edge.second->getChildLanes().size(); i++) {
242 if (edge.second->getNBEdge()->getLanes().at(i).permissions & SVC_PEDESTRIAN) {
243 edge.second->getFromJunction()->setPossibleCandidate(true);
244 edge.second->getToJunction()->setPossibleCandidate(true);
245 }
246 }
247 }
248 // update view net
250}
251
252
253void
255 // clear edge colors
257 // mark edges that supports pedestrian as candidates
258 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
259 bool allowPedestrian = false;
260 for (int i = 0; i < (int)edge.second->getChildLanes().size(); i++) {
261 if (edge.second->getNBEdge()->getLanes().at(i).permissions & SVC_PEDESTRIAN) {
262 allowPedestrian = true;
263 }
264 }
265 if (allowPedestrian) {
266 edge.second->setPossibleCandidate(true);
267 } else {
268 edge.second->setInvalidCandidate(true);
269 }
270 }
271 // update view net
273}
274
275
276void
278 // reset all junction flags
279 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
280 junction.second->resetCandidateFlags();
281 }
282}
283
284
285void
287 // reset all junction flags
288 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
289 edge.second->resetCandidateFlags();
290 }
291}
292
293
294long
295GNEPlanSelector::onCmdSelectPlan(FXObject*, FXSelector, void*) {
296 // check if selected plan of comboBox exists in plans
297 for (const auto& planTemplate : myPlanTemplates) {
298 if (planTemplate.first->getTooltipText().c_str() == myPlansComboBox->getText()) {
299 // update myCurrentPlanTemplate
300 myCurrentPlanTemplate = planTemplate;
301 // set color of myTypeMatchBox to black (valid)
302 myPlansComboBox->setTextColor(FXRGB(0, 0, 0));
303 myPlansComboBox->killFocus();
304 // call tag selected function
306 return 1;
307 }
308 }
309 // reset myCurrentPlanTemplate
310 myCurrentPlanTemplate = std::make_pair(nullptr, nullptr);
311 // set color of myTypeMatchBox to red (invalid)
312 myPlansComboBox->setTextColor(FXRGB(255, 0, 0));
313 // call tag selected function
315 return 1;
316}
317
318
319bool
321 if (myCurrentPlanTemplate.second) {
322 return myPlansComboBox->getTextColor() == FXRGB(0, 0, 0);
323 } else {
324 return false;
325 }
326}
327
328
329void
331 GNETagProperties* tagProperty = nullptr;
332 // person trip
333 tagProperty = new GNETagProperties(SUMO_TAG_PERSONTRIP, nullptr,
346 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEPersonTrip(GNE_TAG_PERSONTRIP_EDGE_EDGE, net)));
347 // ride
348 tagProperty = new GNETagProperties(SUMO_TAG_RIDE, nullptr,
361 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNERide(GNE_TAG_RIDE_EDGE_EDGE, net)));
362 // walk
363 tagProperty = new GNETagProperties(SUMO_TAG_WALK, nullptr,
376 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGE_EDGE, net)));
377 // walk (edges)
378 tagProperty = new GNETagProperties(GNE_TAG_WALK_EDGES, nullptr,
384 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGES, net)));
385 // walk (route)
386 tagProperty = new GNETagProperties(GNE_TAG_WALK_ROUTE, nullptr,
392 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_ROUTE, net)));
393 // stop
394 tagProperty = new GNETagProperties(GNE_TAG_PERSONSTOPS, nullptr,
402 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPPERSON_EDGE, net)));
403}
404
405
406void
408 GNETagProperties* tagProperty = nullptr;
409 // transport
410 tagProperty = new GNETagProperties(SUMO_TAG_TRANSPORT, nullptr,
414 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
415 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
416 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
417 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
419 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
420 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
423 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNETransport(GNE_TAG_TRANSPORT_EDGE_EDGE, net)));
424 // tranship
425 tagProperty = new GNETagProperties(SUMO_TAG_TRANSHIP, nullptr,
429 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
430 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
431 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
432 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
434 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
435 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
438 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGE_EDGE, net)));
439 // tranship (edges)
440 tagProperty = new GNETagProperties(GNE_TAG_TRANSHIP_EDGES, nullptr,
446 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGES, net)));
447 // stop
448 tagProperty = new GNETagProperties(GNE_TAG_CONTAINERSTOPS, nullptr,
456 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPCONTAINER_EDGE, net)));
457}
458
459/****************************************************************************/
FXDEFMAP(GNEPlanSelector) TagSelectorMap[]
@ MID_GNE_TAG_SELECTED
tag selected in ComboBox
#define GUIDesignComboBox
Definition GUIDesigns.h:293
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition GUIDesigns.h:311
#define GUIDesignComboBoxVisibleItems
Definition GUIDesigns.h:49
@ GLO_TRANSHIP
a container tranship
@ GLO_WALK
a walk
@ GLO_CONTAINER_STOP
a containerStop
@ GLO_RIDE
a ride
@ GLO_PERSONTRIP
a person trip
@ GLO_TRANSPORT
a container transport
@ GLO_STOP
a stop
#define TL(string)
Definition MsgHandler.h:305
@ SVC_PEDESTRIAN
pedestrian
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_PERSONTRIP_EDGE_EDGE
@ SUMO_TAG_WALK
@ GNE_TAG_TRANSHIP_EDGE_EDGE
@ SUMO_TAG_TRANSHIP
@ GNE_TAG_WALK_EDGES
@ GNE_TAG_STOPCONTAINER_EDGE
@ SUMO_TAG_STOP
stop for vehicles
@ GNE_TAG_TRANSHIP_EDGES
@ SUMO_TAG_TRANSPORT
@ GNE_TAG_RIDE_EDGE_EDGE
@ GNE_TAG_TRANSPORT_EDGE_EDGE
@ SUMO_TAG_CONTAINER
@ GNE_TAG_WALK_EDGE_EDGE
@ SUMO_TAG_RIDE
@ SUMO_TAG_PERSON
@ SUMO_TAG_PERSONTRIP
@ GNE_TAG_CONTAINERSTOPS
@ GNE_TAG_PERSONSTOPS
@ GNE_TAG_STOPPERSON_EDGE
@ GNE_TAG_WALK_ROUTE
virtual void tagSelected()
Tag selected in GNETagSelector.
Definition GNEFrame.cpp:277
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:155
const std::map< std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
const std::map< std::string, GNEJunction * > & getJunctions() const
get junctions
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:147
void updateJunctionColors()
update junction colors
GNEDemandElement * getCurrentPlanTemplate() const
get current plan template
bool markJunctions() const
check if mark junctions with dotted contours
std::pair< GNETagProperties *, GNEDemandElement * > myCurrentPlanTemplate
current plan template;
void showPlanSelector()
show plan selector
void fillPersonPlanTemplates(GNENet *net)
fill person templates
bool markRoutes() const
check if mark routes with dotted contours
void hidePlanSelector()
plan item selector
void updateEdgeColors()
update edge colors
bool markTAZs() const
check if mark TAZs with dotted contours
~GNEPlanSelector()
destructor
GNEFrame * myFrameParent
pointer to Frame Parent
const GNETagProperties * getCurrentPlanTagProperties() const
get current plan tag properties
void clearEdgeColors()
clear edge colors
bool markStoppingPlaces() const
check if mark stoppingPlaces with dotted contours
std::vector< std::pair< GNETagProperties *, GNEDemandElement * > > myPlanTemplates
list with demand templates
MFXComboBoxIcon * myPlansComboBox
comboBox with the tags
long onCmdSelectPlan(FXObject *, FXSelector, void *)
Called when the user select an element in ComboBox.
bool markEdges() const
check if mark edges with dotted contours
void refreshPlanSelector()
refresh plan selector (used when frameParent is show)
void fillContainerPlanTemplates(GNENet *net)
fill container templates
void clearJunctionColors()
clear junction colors
bool isPlanValid() const
FOX need this.
GNENet * getNet() const
get the net object
void updateViewNet(const bool ignoreViewUpdater=true) const
Mark the entire GNEViewNet to be repainted later.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
long setCurrentItem(const FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
FXString getText() const
Get the text.
void setTextColor(FXColor clr)
Change text color.
FXColor getTextColor() const
Return text color.
MFXGroupBoxModule (based on FXGroupBox)