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-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 tags
19/****************************************************************************/
20
21#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
27
28#include "GNETagSelector.h"
29
30// ===========================================================================
31// FOX callback mapping
32// ===========================================================================
33
34FXDEFMAP(GNETagSelector) TagSelectorMap[] = {
36};
37
38// Object implementation
39FXIMPLEMENT(GNETagSelector, MFXGroupBoxModule, TagSelectorMap, ARRAYNUMBER(TagSelectorMap))
40
41// ===========================================================================
42// method definitions
43// ===========================================================================
44
45GNETagSelector::GNETagSelector(GNEFrame* frameParent, const GNETagProperties::Type type, const SumoXMLTag tag) :
46 MFXGroupBoxModule(frameParent, TL("Element")),
47 myFrameParent(frameParent),
48 myCurrentTemplateAC(nullptr) {
49 // Create MFXComboBoxIcon
50 myTagsMatchBox = new MFXComboBoxIcon(getCollapsableFrame(), GUIDesignComboBoxNCol, true, GUIDesignComboBoxVisibleItems,
52 // update tag types without informing parent (because we're in the creator
53 updateTagTypes(type, tag, false);
54 // GNETagSelector is always shown
55 show();
56}
57
58
60
61
62void
66
67
68void
72
73
78
79
80void
81GNETagSelector::updateTagTypes(const GNETagProperties::Type type, const SumoXMLTag newTag, const bool informParent) {
82 // check if net has proj
83 const bool proj = (GeoConvHelper::getFinal().getProjString() != "!");
84 // change GNETagSelector text
85 switch (type) {
87 setText(TL("network elements"));
88 break;
90 setText(TL("Additional elements"));
91 break;
93 setText(TL("Shape elements"));
94 break;
96 setText(TL("TAZ elements"));
97 break;
99 setText(TL("Wire elements"));
100 break;
102 setText(TL("Vehicles"));
103 break;
105 setText(TL("Stops"));
106 break;
108 setText(TL("Persons"));
109 break;
111 setText(TL("Person plans"));
112 break;
114 setText(TL("Container"));
115 break;
117 setText(TL("Container plans"));
118 break;
120 setText(TL("Person trips"));
121 break;
123 setText(TL("Walks"));
124 break;
126 setText(TL("Rides"));
127 break;
129 setText(TL("Person stops"));
130 break;
131 default:
132 throw ProcessError("invalid tag property");
133 }
135 // get tag properties
136 const auto tagPropertiesByType = myFrameParent->getViewNet()->getNet()->getTagPropertiesDatabase()->getTagPropertiesByType(type);
137 // fill myACTemplates and myTagsMatchBox
138 for (const auto tagProperty : tagPropertiesByType) {
139 if (!tagProperty->requireProj() || proj) {
140 myTagsMatchBox->appendIconItem(tagProperty->getSelectorText().c_str(), GUIIconSubSys::getIcon(tagProperty->getGUIIcon()), tagProperty->getBackGroundColor());
141 }
142 }
143 if (myTagsMatchBox->getNumItems() > 0) {
145 setCurrentTag(newTag, informParent);
146 } else {
148 }
149}
150
151
152void
153GNETagSelector::setCurrentTag(SumoXMLTag newTag, const bool informParent) {
154 // first reset myCurrentTemplateAC
156 // iterate over all myTagsMatchBox
157 for (int i = 0; i < myTagsMatchBox->getNumItems(); i++) {
160 // set color of myTypeMatchBox to black (valid)
161 myTagsMatchBox->setTextColor(FXRGB(0, 0, 0));
162 myTagsMatchBox->killFocus();
163 }
164 }
165 // inform to frame parent that a tag was selected
166 if (informParent) {
168 }
169}
170
171
172void
174 // call tag selected function
176}
177
178
179long
180GNETagSelector::onCmdSelectTag(FXObject*, FXSelector, void*) {
183 // set color of myTypeMatchBox to black (valid)
184 myTagsMatchBox->setTextColor(FXRGB(0, 0, 0));
185 myTagsMatchBox->killFocus();
186 } else {
187 // set color of myTypeMatchBox to red (invalid)
188 myTagsMatchBox->setTextColor(FXRGB(255, 0, 0));
189 }
190 // inform to frame parent that a tag was selected
192 return 1;
193}
194
195/****************************************************************************/
FXDEFMAP(GNETagSelector) 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
#define TL(string)
Definition MsgHandler.h:305
SumoXMLTag
Numbers representing SUMO-XML - element names.
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
virtual void tagSelected()
Tag selected in GNETagSelector.
Definition GNEFrame.cpp:277
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:155
GNEAttributeCarrier * getTemplateAC(const SumoXMLTag tag) const
get template AC by tag
GNENetHelper::ACTemplate * getACTemplates() const
get all attribute carriers templates used in this net
Definition GNENet.cpp:153
const GNETagPropertiesDatabase * getTagPropertiesDatabase() const
get tag properties database
Definition GNENet.cpp:141
const std::vector< const GNETagProperties * > getTagPropertiesByType(const GNETagProperties::Type type) const
get tagProperties associated to the given GNETagProperties::Type (NETWORKELEMENT, ADDITIONALELEMENT,...
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
MFXComboBoxIcon * myTagsMatchBox
comboBox with the tags
GNEAttributeCarrier * myCurrentTemplateAC
current templateAC;
void updateTagTypes(const GNETagProperties::Type type, const SumoXMLTag tag, const bool informParent)
update tag types to select
void refreshTagSelector()
refresh tagSelector (used when frameParent is show)
void showTagSelector()
show item selector
void setCurrentTag(SumoXMLTag newTag, const bool informParent=true)
set current type manually
long onCmdSelectTag(FXObject *, FXSelector, void *ptr)
GNEFrame * myFrameParent
FOX need this.
GNEAttributeCarrier * getCurrentTemplateAC() const
get current templateAC
void hideTagSelector()
hide item selector
~GNETagSelector()
destructor
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.
long setCurrentItem(const 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.
virtual void clearItems()
Remove all items from the list.
std::string getItemText(FXint index) const
Get text for specified item.
void disable()
Disable combo box.
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon item in the last position
void enable()
Enable combo box.
MFXGroupBoxModule (based on FXGroupBox)
void setText(const std::string &text)
set text