Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNETagSelector.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// Frame for select tags
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNEViewNet.h>
68
69#include "GNETagSelector.h"
70
71
72// ===========================================================================
73// FOX callback mapping
74// ===========================================================================
75
76FXDEFMAP(GNETagSelector) TagSelectorMap[] = {
78};
79
80// Object implementation
81FXIMPLEMENT(GNETagSelector, MFXGroupBoxModule, TagSelectorMap, ARRAYNUMBER(TagSelectorMap))
82
83
84// ===========================================================================
85// method definitions
86// ===========================================================================
87
88GNETagSelector::GNETagSelector(GNEFrame* frameParent, GNETagProperties::TagType type, SumoXMLTag tag, bool onlyDrawables) :
89 MFXGroupBoxModule(frameParent, TL("Element")),
90 myFrameParent(frameParent),
91 myTagType(type),
92 myCurrentTemplateAC(nullptr) {
93 // Create MFXComboBoxIcon
94 myTagsMatchBox = new MFXComboBoxIcon(getCollapsableFrame(), GUIDesignComboBoxNCol, true, this, MID_GNE_TAG_SELECTED, GUIDesignComboBox);
95 // set current tag type without notifying
96 setCurrentTagType(myTagType, onlyDrawables, false);
97 // set current tag without notifying
98 setCurrentTag(tag, false);
99 // GNETagSelector is always shown
100 show();
101}
102
103
105 // clear myACTemplates and myTagsMatchBox
106 for (const auto& ACTemplate : myACTemplates) {
107 delete ACTemplate;
108 }
109 myACTemplates.clear();
110}
111
112
113void
117
118
119void
123
124
127 // clear myACTemplates and myTagsMatchBox
128 for (const auto& ACTemplate : myACTemplates) {
129 if (ACTemplate->getAC()->getTagProperty().getTag() == ACTag) {
130 return ACTemplate->getAC();
131 }
132 }
133 return nullptr;
134}
135
136
141
142
143void
144GNETagSelector::setCurrentTagType(GNETagProperties::TagType tagType, const bool onlyDrawables, const bool notifyFrameParent) {
145 // check if net has proj
146 const bool proj = (GeoConvHelper::getFinal().getProjString() != "!");
147 // set new tagType
148 myTagType = tagType;
149 // change GNETagSelector text
150 switch (myTagType) {
152 setText(TL("network elements"));
153 break;
155 setText(TL("Additional elements"));
156 break;
158 setText(TL("Shape elements"));
159 break;
161 setText(TL("TAZ elements"));
162 break;
164 setText(TL("Wire elements"));
165 break;
167 setText(TL("Vehicles"));
168 break;
170 setText(TL("Stops"));
171 break;
173 setText(TL("Persons"));
174 break;
176 setText(TL("Person plans"));
177 break;
179 setText(TL("Container"));
180 break;
182 setText(TL("Container plans"));
183 break;
185 setText(TL("Person trips"));
186 break;
188 setText(TL("Walks"));
189 break;
191 setText(TL("Rides"));
192 break;
194 setText(TL("Person stops"));
195 break;
196 default:
197 throw ProcessError("invalid tag property");
198 }
199 // clear myACTemplates and myTagsMatchBox
200 for (const auto& ACTemplate : myACTemplates) {
201 delete ACTemplate;
202 }
203 myACTemplates.clear();
205 // get tag properties
206 const auto tagProperties = GNEAttributeCarrier::getTagPropertiesByType(myTagType);
207 // fill myACTemplates and myTagsMatchBox
208 for (const auto& tagProperty : tagProperties) {
209 if ((!onlyDrawables || tagProperty.isDrawable()) && (!tagProperty.requireProj() || proj)) {
210 myACTemplates.push_back(new ACTemplate(myFrameParent->getViewNet()->getNet(), tagProperty));
211 myTagsMatchBox->appendIconItem(tagProperty.getFieldString().c_str(), GUIIconSubSys::getIcon(tagProperty.getGUIIcon()), tagProperty.getBackGroundColor());
212 }
213 }
214 // set color of myTypeMatchBox to black (valid)
215 myTagsMatchBox->setTextColor(FXRGB(0, 0, 0));
216 myTagsMatchBox->killFocus();
217 // Set visible items
219 // set first myACTemplate as edited AC
220 myCurrentTemplateAC = myACTemplates.front()->getAC();
221 // call tag selected function
222 if (notifyFrameParent) {
224 }
225}
226
227
228void
229GNETagSelector::setCurrentTag(SumoXMLTag newTag, const bool notifyFrameParent) {
230 // first reset myCurrentTemplateAC
231 myCurrentTemplateAC = nullptr;
232 // iterate over all myTagsMatchBox
233 for (int i = 0; i < (int)myACTemplates.size(); i++) {
234 if (myACTemplates.at(i)->getAC() && (myACTemplates.at(i)->getAC()->getTagProperty().getTag() == newTag)) {
235 // set current template and currentItem
236 myCurrentTemplateAC = myACTemplates.at(i)->getAC();
238 // set color of myTypeMatchBox to black (valid)
239 myTagsMatchBox->setTextColor(FXRGB(0, 0, 0));
240 myTagsMatchBox->killFocus();
241 }
242 }
243 // call tag selected function
244 if (notifyFrameParent) {
246 }
247}
248
249
250void
252 // call tag selected function
254}
255
256
257long
258GNETagSelector::onCmdSelectTag(FXObject*, FXSelector, void*) {
259 // iterate over all myTagsMatchBox
260 for (int i = 0; i < (int)myACTemplates.size(); i++) {
261 if (myACTemplates.at(i)->getAC() && myACTemplates.at(i)->getAC()->getTagProperty().getFieldString() == myTagsMatchBox->getText().text()) {
262 // set templateAC and currentItem
263 myCurrentTemplateAC = myACTemplates.at(i)->getAC();
265 // set color of myTypeMatchBox to black (valid)
266 myTagsMatchBox->setTextColor(FXRGB(0, 0, 0));
267 myTagsMatchBox->killFocus();
268 // call tag selected function
270 // Write Warning in console if we're in testing mode
271 WRITE_DEBUG(("Selected item '" + myTagsMatchBox->getText() + "' in GNETagSelector").text());
272 return 1;
273 }
274 }
275 // reset templateAC
276 myCurrentTemplateAC = nullptr;
277 // set color of myTypeMatchBox to red (invalid)
278 myTagsMatchBox->setTextColor(FXRGB(255, 0, 0));
279 // Write Warning in console if we're in testing mode
280 WRITE_DEBUG("Selected invalid item in GNETagSelector");
281 // call tag selected function
283 return 1;
284}
285
286
289 return myAC;
290}
291
292
294 myAC(nullptr) {
295 // create attribute carrier depending of
296 switch (tagProperty.getTag()) {
297 // additional elements
300 myAC = new GNEBusStop(tagProperty.getTag(), net);
301 break;
302 case SUMO_TAG_ACCESS:
303 myAC = new GNEAccess(net);
304 break;
306 myAC = new GNEContainerStop(net);
307 break;
309 myAC = new GNEChargingStation(net);
310 break;
312 myAC = new GNEParkingArea(net);
313 break;
315 myAC = new GNEParkingSpace(net);
316 break;
319 break;
322 myAC = new GNELaneAreaDetector(tagProperty.getTag(), net);
323 break;
326 break;
329 myAC = new GNEEntryExitDetector(tagProperty.getTag(), net);
330 break;
333 break;
334 case SUMO_TAG_VSS:
335 myAC = new GNEVariableSpeedSign(net);
336 break;
337 case SUMO_TAG_STEP:
339 break;
342 myAC = new GNECalibrator(tagProperty.getTag(), net);
343 break;
345 myAC = new GNECalibratorFlow(net);
346 break;
348 myAC = new GNERerouter(net);
349 break;
351 myAC = new GNERerouterInterval(net);
352 break;
354 myAC = new GNEClosingReroute(net);
355 break;
357 myAC = new GNEClosingLaneReroute(net);
358 break;
360 myAC = new GNEDestProbReroute(net);
361 break;
363 myAC = new GNEParkingAreaReroute(net);
364 break;
366 myAC = new GNERouteProbReroute(net);
367 break;
369 myAC = new GNERouteProbe(net);
370 break;
372 myAC = new GNEVaporizer(net);
373 break;
374 // shapes
375 case SUMO_TAG_POLY:
376 myAC = new GNEPoly(net);
377 break;
378 case SUMO_TAG_POI:
379 case GNE_TAG_POILANE:
380 case GNE_TAG_POIGEO:
381 myAC = new GNEPOI(tagProperty.getTag(), net);
382 break;
383 // TAZs
384 case SUMO_TAG_TAZ:
385 myAC = new GNETAZ(net);
386 break;
388 case SUMO_TAG_TAZSINK:
389 myAC = new GNETAZSourceSink(tagProperty.getTag(), net);
390 break;
391 // wires
393 myAC = new GNETractionSubstation(net);
394 break;
396 myAC = new GNEOverheadWire(net);
397 break;
399 myAC = nullptr; // TMP
400 break;
401 // Demand elements
402 case SUMO_TAG_ROUTE:
404 myAC = new GNERoute(tagProperty.getTag(), net);
405 break;
406 case SUMO_TAG_VTYPE:
407 myAC = new GNEVType(net);
408 break;
410 myAC = new GNEVTypeDistribution(net);
411 break;
412 case SUMO_TAG_TRIP:
413 case SUMO_TAG_VEHICLE:
417 case SUMO_TAG_FLOW:
422 myAC = new GNEVehicle(tagProperty.getTag(), net);
423 break;
424 // stops
436 // waypoints
443 myAC = new GNEStop(tagProperty.getTag(), net);
444 break;
445 case SUMO_TAG_PERSON:
447 myAC = new GNEPerson(tagProperty.getTag(), net);
448 break;
451 myAC = new GNEContainer(tagProperty.getTag(), net);
452 break;
455 myAC = new GNETransport(tagProperty.getTag(), net);
456 break;
460 myAC = new GNETranship(tagProperty.getTag(), net);
461 break;
466 myAC = new GNEPersonTrip(tagProperty.getTag(), net);
467 break;
474 myAC = new GNEWalk(tagProperty.getTag(), net);
475 break;
479 myAC = new GNERide(tagProperty.getTag(), net);
480 break;
481 default:
482 throw ProcessError("Non-supported tagProperty in ACTemplate");
483 break;
484 }
485}
486
487
491
492/****************************************************************************/
FXDEFMAP(GNETagSelector) TagSelectorMap[]
@ MID_GNE_TAG_SELECTED
tag selected in ComboBox
Definition GUIAppEnum.h:931
#define GUIDesignComboBox
Definition GUIDesigns.h:288
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition GUIDesigns.h:306
#define WRITE_DEBUG(msg)
Definition MsgHandler.h:281
#define TL(string)
Definition MsgHandler.h:287
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions
@ SUMO_TAG_TRACTION_SUBSTATION
A traction substation.
@ GNE_TAG_TRIP_TAZS
a single trip definition that uses TAZs
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ GNE_TAG_PERSONTRIP_JUNCTIONS
@ SUMO_TAG_REROUTER
A rerouter.
@ GNE_TAG_WAYPOINT_PARKINGAREA
waypoint placed over a parking area
@ GNE_TAG_MULTI_LANE_AREA_DETECTOR
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ SUMO_TAG_ROUTEPROBE
a routeprobe detector
@ GNE_TAG_TRANSPORT_CONTAINERSTOP
@ GNE_TAG_STOP_PARKINGAREA
stop placed over a parking area
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_ACCESS
An access point for a train stop.
@ GNE_TAG_PERSONTRIP_BUSSTOP
@ GNE_TAG_WALK_EDGES
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ GNE_TAG_STOP_BUSSTOP
stop placed over a busStop
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ GNE_TAG_WAYPOINT_TRAINSTOP
waypoint placed over a busStop
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ GNE_TAG_WAYPOINT_CONTAINERSTOP
waypoint placed over a containerStop
@ GNE_TAG_STOPCONTAINER_EDGE
@ GNE_TAG_WAYPOINT_BUSSTOP
waypoint placed over a busStop
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ GNE_TAG_WAYPOINT_CHARGINGSTATION
waypoint placed over a charging station
@ GNE_TAG_STOPPERSON_BUSSTOP
@ SUMO_TAG_STEP
trigger: a step description
@ SUMO_TAG_VEHICLE
description of a vehicle
@ GNE_TAG_FLOW_ROUTE
a flow definition using a route instead of a from-to edges route
@ SUMO_TAG_OVERHEAD_WIRE_CLAMP
An overhead wire clamp (connection of wires in opposite directions)
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions
@ GNE_TAG_POIGEO
Point of interest over view with GEO attributes.
@ GNE_TAG_TRANSHIP_EDGES
@ GNE_TAG_STOP_CONTAINERSTOP
stop placed over a containerStop
@ GNE_TAG_STOPCONTAINER_CONTAINERSTOP
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_PARKING_AREA
A parking area.
@ GNE_TAG_PERSONTRIP_TRAINSTOP
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ GNE_TAG_FLOW_TAZS
a flow between TAZs
@ GNE_TAG_CALIBRATOR_LANE
A calibrator placed over lane.
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_PARKING_SPACE
A parking space for a single vehicle within a parking area.
@ SUMO_TAG_CONTAINER
@ GNE_TAG_WALK_BUSSTOP
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ SUMO_TAG_OVERHEAD_WIRE_SECTION
An overhead wire section.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ GNE_TAG_RIDE_EDGE
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ GNE_TAG_TRANSHIP_EDGE
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ GNE_TAG_WALK_JUNCTIONS
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route
@ GNE_TAG_CALIBRATOR_FLOW
a flow definition within in Calibrator
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ GNE_TAG_POILANE
Point of interest over Lane.
@ GNE_TAG_WAYPOINT_LANE
waypoint placed over a lane
@ SUMO_TAG_PERSON
@ SUMO_TAG_DET_EXIT
an e3 exit point
@ GNE_TAG_WALK_TRAINSTOP
@ SUMO_TAG_VAPORIZER
vaporizer of vehicles
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ GNE_TAG_STOP_LANE
stop placed over a lane
@ GNE_TAG_STOPPERSON_TRAINSTOP
@ GNE_TAG_RIDE_TRAINSTOP
@ GNE_TAG_WALK_EDGE
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
@ GNE_TAG_STOP_TRAINSTOP
stop placed over a trainStop
@ GNE_TAG_STOP_CHARGINGSTATION
stop placed over a charging station
@ GNE_TAG_PERSONTRIP_EDGE
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
@ GNE_TAG_RIDE_BUSSTOP
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_ENTRY_EXIT_DETECTOR
alternative tag for e3 detector
@ SUMO_TAG_VSS
A variable speed sign.
@ GNE_TAG_STOPPERSON_EDGE
@ GNE_TAG_WALK_ROUTE
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ GNE_TAG_TRANSHIP_CONTAINERSTOP
@ GNE_TAG_TRANSPORT_EDGE
static const std::vector< GNETagProperties > getTagPropertiesByType(const int tagPropertyCategory)
get tagProperties associated to the given GNETagProperties::TagType (NETWORKELEMENT,...
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
A lane area vehicles can halt at (netedit-version)
Definition GNEBusStop.h:33
A lane area vehicles can halt at (netedit-version)
virtual void tagSelected()
Tag selected in GNETagSelector.
Definition GNEFrame.cpp:267
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:150
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
A lane area vehicles can park at (netedit-version)
vehicle space used by GNEParkingAreas
Representation of a RouteProbe in netedit.
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
ACTemplate(GNENet *net, const GNETagProperties tagProperty)
constructor
GNEAttributeCarrier * myAC
editedAC
GNEAttributeCarrier * getAC() const
get template AC
GNETagProperties::TagType myTagType
current tagType
MFXComboBoxIcon * myTagsMatchBox
comboBox with the tags
GNEAttributeCarrier * myCurrentTemplateAC
current templateAC;
void refreshTagSelector()
refresh tagSelector (used when frameParent is show)
void showTagSelector()
show item selector
GNEAttributeCarrier * getTemplateAC(SumoXMLTag ACTag) const
get templateAC
long onCmdSelectTag(FXObject *, FXSelector, void *)
GNEFrame * myFrameParent
pointer to Frame Parent
GNEAttributeCarrier * getCurrentTemplateAC() const
get current templateAC
void setCurrentTagType(GNETagProperties::TagType tagType, const bool onlyDrawables, const bool notifyFrameParent=true)
set current type manually
void hideTagSelector()
hide item selector
std::vector< ACTemplate * > myACTemplates
list with ACTemplates
~GNETagSelector()
destructor
void setCurrentTag(SumoXMLTag newTag, const bool notifyFrameParent=true)
set current type manually
Representation of a vaporizer in netedit.
GNENet * getNet() const
get the net object
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
const std::string & getProjString() const
Returns the original projection definition.
ComboBox with icon.
void setCurrentItem(FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
FXint getNumItems() const
Return the number of items in the list.
FXString getText() const
Get the text.
void setTextColor(FXColor clr)
Change text color.
void setNumVisible(FXint nvis)
Set the number of visible items in the drop down list.
void clearItems()
Remove all items from the list.
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon
MFXGroupBoxModule (based on FXGroupBox)
void setText(const std::string &text)
set text