Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEElementSet.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// The Widget for modifying selections of network-elements
19/****************************************************************************/
20
21#include <netedit/GNEViewNet.h>
24
25#include "GNEElementSet.h"
26#include "GNEMatchAttribute.h"
28
29// ===========================================================================
30// FOX callback mapping
31// ===========================================================================
32
33FXDEFMAP(GNEElementSet) GNEElementSetMap[] = {
35};
36
37// Object implementation
38FXIMPLEMENT(GNEElementSet, MFXGroupBoxModule, GNEElementSetMap, ARRAYNUMBER(GNEElementSetMap))
39
40// ===========================================================================
41// method definitions
42// ===========================================================================
43
44GNEElementSet::GNEElementSet(GNESelectorFrame* selectorFrameParent, Supermode supermode,
45 SumoXMLTag defaultTag, SumoXMLAttr defaultAttr, const std::string& defaultValue) :
46 MFXGroupBoxModule(selectorFrameParent, TL("Element Set")),
47 mySelectorFrameParent(selectorFrameParent),
48 myMatchAttribute(nullptr),
49 myMatchGenericDataAttribute(nullptr),
50 myCurrentSet(Type::INVALID) {
51 // Create MatchTagBox for tags and fill it
52 mySetComboBox = new MFXComboBoxIcon(getCollapsableFrame(), GUIDesignComboBoxNCol, false, GUIDesignComboBoxVisibleItems,
54 // continue depending of supermode
55 if (supermode == Supermode::NETWORK) {
56 // append elements
57 mySetComboBox->appendIconItem(TL("Network"), GUIIconSubSys::getIcon(GUIIcon::MODECREATEEDGE));
58 mySetComboBox->appendIconItem(TL("Additional"), GUIIconSubSys::getIcon(GUIIcon::MODEADDITIONAL));
59 mySetComboBox->appendIconItem(TL("Shape"), GUIIconSubSys::getIcon(GUIIcon::MODESHAPE));
60 mySetComboBox->appendIconItem(TL("TAZ"), GUIIconSubSys::getIcon(GUIIcon::MODETAZ));
61 // set default set
62 myCurrentSet = Type::NETWORK;
63 } else if (supermode == Supermode::DEMAND) {
64 // append elements
65 mySetComboBox->appendIconItem(TL("Demand"), GUIIconSubSys::getIcon(GUIIcon::SUPERMODEDEMAND));
66 // set default set
67 myCurrentSet = Type::DEMAND;
68 } else if (supermode == Supermode::DATA) {
69 // append elements
70 mySetComboBox->appendIconItem(TL("GenericDatas"), GUIIconSubSys::getIcon(GUIIcon::SUPERMODEDATA));
71 // set default set
72 myCurrentSet = Type::GENERICDATA;
73 } else {
74 throw ProcessError(TL("Invalid supermode"));
75 }
76 // build MatchAttribute
77 myMatchAttribute = new GNEMatchAttribute(this, defaultTag, defaultAttr, defaultValue);
79 myMatchGenericDataAttribute = new GNEMatchGenericDataAttribute(this, defaultTag, defaultAttr, defaultValue);
80}
81
82
84
85
90
91
96
97
98void
100 // show myMatchAttribute (if exist)
104 // first check if myCurrentSet is invalid
106 // disable match attribute
108 } else {
109 // enable match attribute
111 }
112 } else {
115 // first check if myCurrentSet is invalid
117 // disable match attribute
119 } else {
120 // enable match attribute
122 }
123 }
124 // first show group box
125 show();
126}
127
128
129void
131 // hide both match attribute
134 // hide group box
135 hide();
136}
137
138
139long
140GNEElementSet::onCmdSelectElementSet(FXObject*, FXSelector, void*) {
141 // check depending of current supermode
143 if (mySetComboBox->getText() == TL("Network")) {
145 } else if (mySetComboBox->getText() == TL("Additional")) {
147 } else if (mySetComboBox->getText() == TL("TAZ")) {
149 mySetComboBox->setTextColor(FXRGB(0, 0, 0));
150 } else if (mySetComboBox->getText() == TL("Shape")) {
152 } else {
154 }
156 if (mySetComboBox->getText() == TL("Demand")) {
158 } else {
160 }
162 if (mySetComboBox->getText() == TL("GenericDatas")) {
164 } else {
166 }
167 }
168 // set color
170 // set invalid color
171 mySetComboBox->setTextColor(FXRGB(255, 0, 0));
172 // hide match attribute
175 } else {
176 // set default color
177 mySetComboBox->setTextColor(FXRGB(0, 0, 0));
178 // show match attribute
182 } else {
185 }
186 }
187 return 1;
188}
189
190/****************************************************************************/
FXDEFMAP(GNEElementSet) GNEElementSetMap[]
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
@ DATA
Data mode (edgeData, LaneData etc..)
@ DEMAND
Demand mode (Routes, Vehicles etc..)
@ MID_CHOOSEN_ELEMENTS
set subset of elements
Definition GUIAppEnum.h:599
#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
@ MODEADDITIONAL
@ SUPERMODEDEMAND
@ MODECREATEEDGE
@ SUPERMODEDATA
#define TL(string)
Definition MsgHandler.h:301
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
~GNEElementSet()
destructor
long onCmdSelectElementSet(FXObject *, FXSelector, void *)
Called when the user change the set of element to search (networkElement, Additional or shape)
Type getElementSet() const
get current selected element set
GNEMatchAttribute * myMatchAttribute
modul for match attribute
Type myCurrentSet
current element set selected
MFXComboBoxIcon * mySetComboBox
Combo Box with the element sets.
GNESelectorFrame * mySelectorFrameParent
FOX need this.
Type
FOX-declaration.
GNESelectorFrame * getSelectorFrameParent() const
get Selector Frame Parent
void hideElementSet()
hide element set
GNEMatchGenericDataAttribute * myMatchGenericDataAttribute
Match generic data attribute.
void showElementSet()
show element set
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:154
void showMatchAttribute(const GNEElementSet::Type type)
show match attributes
void hideMatchAttribute()
hide match attributes
void enableMatchAttribute()
enable match attributes
void disableMatchAttribute()
disable match attributes
void disableMatchGenericDataAttribute()
disable match attributes
void enableMatchGenericDataAttribute()
enable match attributes
void hideMatchGenericDataAttribute()
hide match attributes
void showMatchGenericDataAttribute()
show match attributes
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
ComboBox with icon.
FXString getText() const
Get the text.
void setTextColor(FXColor clr)
Change text color.
MFXGroupBoxModule (based on FXGroupBox)
Definition json.hpp:4471
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeData() const
@check if current supermode is Data
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network