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, GNEGroupBoxModule, TagSelectorMap, ARRAYNUMBER(TagSelectorMap))
84
85// ===========================================================================
86// method definitions
87// ===========================================================================
88
90 GNEGroupBoxModule(frameParent, TL("Plan type")),
91 myPlanType(planType),
92 myFrameParent(frameParent) {
93 // Create MFXComboBoxIcon
94 myPlansComboBox = new MFXComboBoxIcon(getCollapsableFrame(), frameParent->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
96 // add person plan elements
97 for (const auto& planTemplate : myFrameParent->getViewNet()->getNet()->getACTemplates()->getPlanTemplates(myPlanType)) {
98 planTemplate.second->resetDefaultValues(false);
99 myPlansComboBox->appendIconItem(planTemplate.first->getTooltipText().c_str(),
100 GUIIconSubSys::getIcon(planTemplate.second->getTagProperty()->getGUIIcon()),
101 planTemplate.second->getTagProperty()->getBackGroundColor());
102 }
103 // set myCurrentPlanTemplate
104 myCurrentPlanTemplate = myFrameParent->getViewNet()->getNet()->getACTemplates()->getPlanTemplates(myPlanType).front();
105 // set color of myTypeMatchBox to black (valid)
106 myPlansComboBox->setTextColor(GUIDesignTextColorBlack);
107 myPlansComboBox->killFocus();
108 // GNEPlanSelector is always shown
109 show();
110}
111
112
115
116
117void
123
124
125void
131
132
133const GNETagProperties*
137
138
143
144
145void
147 if (isPlanValid()) {
148 // call tag selected function
150 } else {
151 // set first item
153 }
154}
155
156
157bool
159 // first check if this modul is shown and selected plan is valid
160 if (isPlanValid()) {
161 return myCurrentPlanTemplate.first->planRoute();
162 } else {
163 return false;
164 }
165}
166
167
168bool
170 // first check if this modul is shown and selected plan is valid
171 if (isPlanValid()) {
172 return myCurrentPlanTemplate.first->planConsecutiveEdges() ||
173 myCurrentPlanTemplate.first->planEdge() ||
174 myCurrentPlanTemplate.first->planFromEdge() ||
175 myCurrentPlanTemplate.first->planToEdge();
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->planFromJunction() ||
187 myCurrentPlanTemplate.first->planToJunction();
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->planStoppingPlace() ||
199 myCurrentPlanTemplate.first->planFromStoppingPlace() ||
200 myCurrentPlanTemplate.first->planToStoppingPlace();
201 } else {
202 return false;
203 }
204}
205
206
207bool
209 // first check if this modul is shown and selected plan is valid
210 if (isPlanValid()) {
211 return myCurrentPlanTemplate.first->planFromTAZ() ||
212 myCurrentPlanTemplate.first->planToTAZ();
213 } else {
214 return false;
215 }
216}
217
218
219void
221 // clear junction colors
223 // we assume that all junctions don't support pedestrians
224 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
225 junction.second->setInvalidCandidate(true);
226 }
227 // mark junctions that supports pedestrian as candidates
228 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
229 for (int i = 0; i < (int)edge.second->getChildLanes().size(); i++) {
230 if (edge.second->getNBEdge()->getLanes().at(i).permissions & SVC_PEDESTRIAN) {
231 edge.second->getFromJunction()->setPossibleCandidate(true);
232 edge.second->getToJunction()->setPossibleCandidate(true);
233 }
234 }
235 }
236 // update view net
238}
239
240
241void
243 // clear edge colors
245 // mark edges that supports pedestrian as candidates
246 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
247 bool allowPedestrian = false;
248 for (int i = 0; i < (int)edge.second->getChildLanes().size(); i++) {
249 if (edge.second->getNBEdge()->getLanes().at(i).permissions & SVC_PEDESTRIAN) {
250 allowPedestrian = true;
251 }
252 }
253 if (allowPedestrian) {
254 edge.second->setPossibleCandidate(true);
255 } else {
256 edge.second->setInvalidCandidate(true);
257 }
258 }
259 // update view net
261}
262
263
264void
266 // reset all junction flags
267 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
268 junction.second->resetCandidateFlags();
269 }
270}
271
272
273void
275 // reset all junction flags
276 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
277 edge.second->resetCandidateFlags();
278 }
279}
280
281
282long
283GNEPlanSelector::onCmdSelectPlan(FXObject*, FXSelector, void*) {
284 // check if selected plan of comboBox exists in plans
285 for (const auto& planTemplate : myFrameParent->getViewNet()->getNet()->getACTemplates()->getPlanTemplates(myPlanType)) {
286 if (planTemplate.first->getTooltipText().c_str() == myPlansComboBox->getText()) {
287 // update myCurrentPlanTemplate
288 myCurrentPlanTemplate = planTemplate;
289 // set color of myTypeMatchBox to black (valid)
291 myPlansComboBox->killFocus();
292 // call tag selected function
294 return 1;
295 }
296 }
297 // reset myCurrentPlanTemplate
298 myCurrentPlanTemplate = std::make_pair(nullptr, nullptr);
299 // set color of myTypeMatchBox to red (invalid)
301 // call tag selected function
303 return 1;
304}
305
306
307bool
309 if (myCurrentPlanTemplate.second) {
311 } else {
312 return false;
313 }
314}
315
316/****************************************************************************/
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
#define TL(string)
Definition MsgHandler.h:304
@ SVC_PEDESTRIAN
pedestrian
SumoXMLTag
Numbers representing SUMO-XML - element names.
virtual void tagSelected()
Tag selected in GNETagSelector.
Definition GNEFrame.cpp:202
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:145
GNEGroupBoxModule (based on FXGroupBox)
const std::vector< std::pair< GNETagProperties *, GNEDemandElement * > > & getPlanTemplates(SumoXMLTag tag) const
get plan templates
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
GNENetHelper::ACTemplate * getACTemplates() const
get all attribute carriers templates used in this net
Definition GNENet.cpp:180
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:174
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
bool markRoutes() const
check if mark routes with dotted contours
SumoXMLTag myPlanType
plan type
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
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 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.