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
23#include <netedit/GNENet.h>
25#include <netedit/GNEViewNet.h>
29
30#include "GNETagSelector.h"
31
32// ===========================================================================
33// FOX callback mapping
34// ===========================================================================
35
36FXDEFMAP(GNETagSelector) TagSelectorMap[] = {
38};
39
40// Object implementation
41FXIMPLEMENT(GNETagSelector, MFXGroupBoxModule, TagSelectorMap, ARRAYNUMBER(TagSelectorMap))
42
43// ===========================================================================
44// method definitions
45// ===========================================================================
46
47GNETagSelector::GNETagSelector(GNEFrame* frameParent, const GNETagProperties::Type type, const SumoXMLTag tag) :
48 MFXGroupBoxModule(frameParent, TL("Element")),
49 myFrameParent(frameParent),
50 myCurrentTemplateAC(nullptr) {
51 // Create MFXComboBoxIcon
52 myTagsMatchBox = new MFXComboBoxIcon(getCollapsableFrame(), frameParent->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
54 // update tag types without informing parent (because we're in the creator
55 updateTagTypes(type, tag, false);
56 // GNETagSelector is always shown
57 show();
58}
59
60
62
63
64void
68
69
70void
74
75
80
81
82void
83GNETagSelector::updateTagTypes(const GNETagProperties::Type type, const SumoXMLTag newTag, const bool informParent) {
84 // check if net has proj
85 const bool proj = (GeoConvHelper::getFinal().getProjString() != "!");
86 // change GNETagSelector text
87 switch (type) {
89 setText(TL("network elements"));
90 break;
92 setText(TL("Additional elements"));
93 break;
95 setText(TL("Shape elements"));
96 break;
98 setText(TL("TAZ elements"));
99 break;
101 setText(TL("Wire elements"));
102 break;
104 setText(TL("Vehicles"));
105 break;
107 setText(TL("Stops"));
108 break;
110 setText(TL("Persons"));
111 break;
113 setText(TL("Person plans"));
114 break;
116 setText(TL("Container"));
117 break;
119 setText(TL("Container plans"));
120 break;
122 setText(TL("Person trips"));
123 break;
125 setText(TL("Walks"));
126 break;
128 setText(TL("Rides"));
129 break;
131 setText(TL("Person stops"));
132 break;
133 default:
134 throw ProcessError("invalid tag property");
135 }
137 // get tag properties
138 const auto tagPropertiesByType = myFrameParent->getViewNet()->getNet()->getTagPropertiesDatabase()->getTagPropertiesByType(type);
139 // fill myACTemplates and myTagsMatchBox
140 for (const auto tagProperty : tagPropertiesByType) {
141 if ((!tagProperty->requireProj() || proj) && !tagProperty->isListedElement() && !tagProperty->isSymbol()) {
142 myTagsMatchBox->appendIconItem(tagProperty->getSelectorText().c_str(), GUIIconSubSys::getIcon(tagProperty->getGUIIcon()), tagProperty->getBackGroundColor());
143 }
144 }
145 if (myTagsMatchBox->getNumItems() > 0) {
147 setCurrentTag(newTag, informParent);
148 } else {
150 }
151}
152
153
154void
155GNETagSelector::setCurrentTag(SumoXMLTag newTag, const bool informParent) {
156 // first reset myCurrentTemplateAC
158 // iterate over all myTagsMatchBox
159 for (int i = 0; i < myTagsMatchBox->getNumItems(); i++) {
162 // set color of myTypeMatchBox to black (valid)
164 myTagsMatchBox->killFocus();
165 }
166 }
167 // inform to frame parent that a tag was selected
168 if (informParent) {
170 }
171}
172
173
174void
176 // call tag selected function
178}
179
180
181long
182GNETagSelector::onCmdSelectTag(FXObject*, FXSelector, void*) {
185 // set color of myTypeMatchBox to black (valid)
187 myTagsMatchBox->killFocus();
188 } else {
189 // set color of myTypeMatchBox to red (invalid)
191 }
192 // inform to frame parent that a tag was selected
194 return 1;
195}
196
197/****************************************************************************/
FXDEFMAP(GNETagSelector) 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
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:201
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:145
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:150
const GNETagPropertiesDatabase * getTagPropertiesDatabase() const
get tag properties database
Definition GNENet.cpp:138
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