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
66#include <netedit/GNENet.h>
67#include <netedit/GNEViewNet.h>
71
72#include "GNEPlanSelector.h"
73
74// ===========================================================================
75// FOX callback mapping
76// ===========================================================================
77
78FXDEFMAP(GNEPlanSelector) TagSelectorMap[] = {
80};
81
82// Object implementation
83FXIMPLEMENT(GNEPlanSelector, MFXGroupBoxModule, TagSelectorMap, ARRAYNUMBER(TagSelectorMap))
84
85// ===========================================================================
86// method definitions
87// ===========================================================================
88
90 MFXGroupBoxModule(frameParent, TL("Plan type")),
91 myFrameParent(frameParent) {
92 // Create MFXComboBoxIcon
93 myPlansComboBox = new MFXComboBoxIcon(getCollapsableFrame(), frameParent->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
95 // get net
96 const auto net = myFrameParent->getViewNet()->getNet();
97 // continue depending of plan type
98 if (planType == SUMO_TAG_PERSON) {
99 fillPersonPlanTemplates(net);
100 } else if (planType == SUMO_TAG_CONTAINER) {
101 fillContainerPlanTemplates(net);
102 } else {
103 throw ProcessError("Invalid plan");
104 }
105 // add person plan elements
106 for (const auto& planTemplate : myPlanTemplates) {
107 planTemplate.second->resetDefaultValues(false);
108 myPlansComboBox->appendIconItem(planTemplate.first->getTooltipText().c_str(),
109 GUIIconSubSys::getIcon(planTemplate.second->getTagProperty()->getGUIIcon()),
110 planTemplate.second->getTagProperty()->getBackGroundColor());
111 }
112 // set myCurrentPlanTemplate
113 myCurrentPlanTemplate = myPlanTemplates.front();
114 // set color of myTypeMatchBox to black (valid)
115 myPlansComboBox->setTextColor(GUIDesignTextColorBlack);
116 myPlansComboBox->killFocus();
117 // GNEPlanSelector is always shown
118 show();
119}
120
121
123 for (auto& planTemplate : myPlanTemplates) {
124 delete planTemplate.first;
125 delete planTemplate.second;
126 }
127 myPlanTemplates.clear();
128}
129
130
131void
137
138
139void
145
146
147const GNETagProperties*
151
152
157
158
159void
161 if (isPlanValid()) {
162 // call tag selected function
164 } else {
165 // set first item
167 }
168}
169
170
171bool
173 // first check if this modul is shown and selected plan is valid
174 if (isPlanValid()) {
175 return myCurrentPlanTemplate.first->planRoute();
176 } else {
177 return false;
178 }
179}
180
181
182bool
184 // first check if this modul is shown and selected plan is valid
185 if (isPlanValid()) {
186 return myCurrentPlanTemplate.first->planConsecutiveEdges() ||
187 myCurrentPlanTemplate.first->planEdge() ||
188 myCurrentPlanTemplate.first->planFromEdge() ||
189 myCurrentPlanTemplate.first->planToEdge();
190 } else {
191 return false;
192 }
193}
194
195
196bool
198 // first check if this modul is shown and selected plan is valid
199 if (isPlanValid()) {
200 return myCurrentPlanTemplate.first->planFromJunction() ||
201 myCurrentPlanTemplate.first->planToJunction();
202 } else {
203 return false;
204 }
205}
206
207
208bool
210 // first check if this modul is shown and selected plan is valid
211 if (isPlanValid()) {
212 return myCurrentPlanTemplate.first->planStoppingPlace() ||
213 myCurrentPlanTemplate.first->planFromStoppingPlace() ||
214 myCurrentPlanTemplate.first->planToStoppingPlace();
215 } else {
216 return false;
217 }
218}
219
220
221bool
223 // first check if this modul is shown and selected plan is valid
224 if (isPlanValid()) {
225 return myCurrentPlanTemplate.first->planFromTAZ() ||
226 myCurrentPlanTemplate.first->planToTAZ();
227 } else {
228 return false;
229 }
230}
231
232
233void
235 // clear junction colors
237 // we assume that all junctions don't support pedestrians
238 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
239 junction.second->setInvalidCandidate(true);
240 }
241 // mark junctions that supports pedestrian as candidates
242 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
243 for (int i = 0; i < (int)edge.second->getChildLanes().size(); i++) {
244 if (edge.second->getNBEdge()->getLanes().at(i).permissions & SVC_PEDESTRIAN) {
245 edge.second->getFromJunction()->setPossibleCandidate(true);
246 edge.second->getToJunction()->setPossibleCandidate(true);
247 }
248 }
249 }
250 // update view net
252}
253
254
255void
257 // clear edge colors
259 // mark edges that supports pedestrian as candidates
260 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
261 bool allowPedestrian = false;
262 for (int i = 0; i < (int)edge.second->getChildLanes().size(); i++) {
263 if (edge.second->getNBEdge()->getLanes().at(i).permissions & SVC_PEDESTRIAN) {
264 allowPedestrian = true;
265 }
266 }
267 if (allowPedestrian) {
268 edge.second->setPossibleCandidate(true);
269 } else {
270 edge.second->setInvalidCandidate(true);
271 }
272 }
273 // update view net
275}
276
277
278void
280 // reset all junction flags
281 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
282 junction.second->resetCandidateFlags();
283 }
284}
285
286
287void
289 // reset all junction flags
290 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
291 edge.second->resetCandidateFlags();
292 }
293}
294
295
296long
297GNEPlanSelector::onCmdSelectPlan(FXObject*, FXSelector, void*) {
298 // check if selected plan of comboBox exists in plans
299 for (const auto& planTemplate : myPlanTemplates) {
300 if (planTemplate.first->getTooltipText().c_str() == myPlansComboBox->getText()) {
301 // update myCurrentPlanTemplate
302 myCurrentPlanTemplate = planTemplate;
303 // set color of myTypeMatchBox to black (valid)
305 myPlansComboBox->killFocus();
306 // call tag selected function
308 return 1;
309 }
310 }
311 // reset myCurrentPlanTemplate
312 myCurrentPlanTemplate = std::make_pair(nullptr, nullptr);
313 // set color of myTypeMatchBox to red (invalid)
315 // call tag selected function
317 return 1;
318}
319
320
321bool
323 if (myCurrentPlanTemplate.second) {
325 } else {
326 return false;
327 }
328}
329
330
331void
333 GNETagProperties* tagProperty = nullptr;
334 // person trip
335 tagProperty = new GNETagProperties(SUMO_TAG_PERSONTRIP, nullptr,
348 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEPersonTrip(GNE_TAG_PERSONTRIP_EDGE_EDGE, net)));
349 // ride
350 tagProperty = new GNETagProperties(SUMO_TAG_RIDE, nullptr,
363 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNERide(GNE_TAG_RIDE_EDGE_EDGE, net)));
364 // walk
365 tagProperty = new GNETagProperties(SUMO_TAG_WALK, nullptr,
378 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGE_EDGE, net)));
379 // walk (edges)
380 tagProperty = new GNETagProperties(GNE_TAG_WALK_EDGES, nullptr,
386 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_EDGES, net)));
387 // walk (route)
388 tagProperty = new GNETagProperties(GNE_TAG_WALK_ROUTE, nullptr,
394 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEWalk(GNE_TAG_WALK_ROUTE, net)));
395 // stop
396 tagProperty = new GNETagProperties(GNE_TAG_PERSONSTOPS, nullptr,
404 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPPERSON_EDGE, net)));
405}
406
407
408void
410 GNETagProperties* tagProperty = nullptr;
411 // transport
412 tagProperty = new GNETagProperties(SUMO_TAG_TRANSPORT, nullptr,
416 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
417 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
418 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
419 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
421 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
422 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
425 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNETransport(GNE_TAG_TRANSPORT_EDGE_EDGE, net)));
426 // tranship
427 tagProperty = new GNETagProperties(SUMO_TAG_TRANSHIP, nullptr,
431 //GNETagProperties::Over::FROM_TAZ | GNETagProperties::Over::TO_TAZ |
432 //GNETagProperties::Over::FROM_JUNCTION | GNETagProperties::Over::TO_JUNCTION |
433 //GNETagProperties::Over::FROM_BUSSTOP | GNETagProperties::Over::TO_BUSSTOP |
434 //GNETagProperties::Over::FROM_TRAINSTOP | GNETagProperties::Over::TO_TRAINSTOP |
436 //GNETagProperties::Over::FROM_CHARGINGSTATION | GNETagProperties::Over::TO_CHARGINGSTATION |
437 //GNETagProperties::Over::FROM_PARKINGAREA | GNETagProperties::Over::TO_PARKINGAREA,
440 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGE_EDGE, net)));
441 // tranship (edges)
442 tagProperty = new GNETagProperties(GNE_TAG_TRANSHIP_EDGES, nullptr,
448 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNETranship(GNE_TAG_TRANSHIP_EDGES, net)));
449 // stop
450 tagProperty = new GNETagProperties(GNE_TAG_CONTAINERSTOPS, nullptr,
458 myPlanTemplates.push_back(std::make_pair(tagProperty, new GNEStopPlan(GNE_TAG_STOPCONTAINER_EDGE, net)));
459}
460
461/****************************************************************************/
FXDEFMAP(GNEPlanSelector) TagSelectorMap[]
@ MID_GNE_TAG_SELECTED
tag selected in ComboBox
#define GUIDesignTextColorRed
red color (for invalid text)
Definition GUIDesigns.h:44
#define GUIDesignComboBox
Definition GUIDesigns.h:295
#define GUIDesignComboBoxVisibleItems
Definition GUIDesigns.h:64
#define GUIDesignTextColorBlack
black color (for correct text)
Definition GUIDesigns.h:38
@ 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:208
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:152
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:144
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)