Eclipse SUMO - Simulation of Urban MObility
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-2024 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 #include <config.h>
21 
22 #include <netedit/GNEViewNet.h>
26 
27 #include "GNEElementSet.h"
28 #include "GNEMatchAttribute.h"
30 
31 
32 // ===========================================================================
33 // FOX callback mapping
34 // ===========================================================================
35 
36 FXDEFMAP(GNEElementSet) GNEElementSetMap[] = {
38 };
39 
40 // Object implementation
41 FXIMPLEMENT(GNEElementSet, MFXGroupBoxModule, GNEElementSetMap, ARRAYNUMBER(GNEElementSetMap))
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
46 
47 GNEElementSet::GNEElementSet(GNESelectorFrame* selectorFrameParent, Supermode supermode,
48  SumoXMLTag defaultTag, SumoXMLAttr defaultAttr, const std::string& defaultValue) :
49  MFXGroupBoxModule(selectorFrameParent, TL("Element Set")),
50  mySelectorFrameParent(selectorFrameParent),
51  myMatchAttribute(nullptr),
52  myMatchGenericDataAttribute(nullptr),
53  myCurrentSet(Type::INVALID) {
54  // Create MatchTagBox for tags and fill it
55  mySetComboBox = new MFXComboBoxIcon(getCollapsableFrame(), GUIDesignComboBoxNCol, false, GUIDesignComboBoxVisibleItemsMedium,
57  // continue depending of supermode
58  if (supermode == Supermode::NETWORK) {
59  // append elements
60  mySetComboBox->appendIconItem(TL("Network"), GUIIconSubSys::getIcon(GUIIcon::MODECREATEEDGE));
61  mySetComboBox->appendIconItem(TL("Additional"), GUIIconSubSys::getIcon(GUIIcon::MODEADDITIONAL));
62  mySetComboBox->appendIconItem(TL("Shape"), GUIIconSubSys::getIcon(GUIIcon::MODESHAPE));
63  mySetComboBox->appendIconItem(TL("TAZ"), GUIIconSubSys::getIcon(GUIIcon::MODETAZ));
64  // set default set
65  myCurrentSet = Type::NETWORK;
66  } else if (supermode == Supermode::DEMAND) {
67  // append elements
68  mySetComboBox->appendIconItem(TL("Demand"), GUIIconSubSys::getIcon(GUIIcon::SUPERMODEDEMAND));
69  // set default set
70  myCurrentSet = Type::DEMAND;
71  } else if (supermode == Supermode::DATA) {
72  // append elements
73  mySetComboBox->appendIconItem(TL("GenericDatas"), GUIIconSubSys::getIcon(GUIIcon::SUPERMODEDATA));
74  // set default set
75  myCurrentSet = Type::GENERICDATA;
76  } else {
77  throw ProcessError(TL("Invalid supermode"));
78  }
79  // build MatchAttribute
80  myMatchAttribute = new GNEMatchAttribute(this, defaultTag, defaultAttr, defaultValue);
82  myMatchGenericDataAttribute = new GNEMatchGenericDataAttribute(this, defaultTag, defaultAttr, defaultValue);
83 }
84 
85 
87 
88 
91  return mySelectorFrameParent;
92 }
93 
94 
97  return myCurrentSet;
98 }
99 
100 
101 void
103  // show myMatchAttribute (if exist)
107  // first check if myCurrentSet is invalid
108  if (myCurrentSet == Type::INVALID) {
109  // disable match attribute
111  } else {
112  // enable match attribute
114  }
115  } else {
118  // first check if myCurrentSet is invalid
119  if (myCurrentSet == Type::INVALID) {
120  // disable match attribute
122  } else {
123  // enable match attribute
125  }
126  }
127  // first show group box
128  show();
129 }
130 
131 
132 void
134  // hide both match attribute
137  // hide group box
138  hide();
139 }
140 
141 
142 long
143 GNEElementSet::onCmdSelectElementSet(FXObject*, FXSelector, void*) {
144  // check depending of current supermode
146  if (mySetComboBox->getText() == TL("Network")) {
148  } else if (mySetComboBox->getText() == TL("Additional")) {
150  } else if (mySetComboBox->getText() == TL("TAZ")) {
152  mySetComboBox->setTextColor(FXRGB(0, 0, 0));
153  } else if (mySetComboBox->getText() == TL("Shape")) {
155  } else {
157  }
159  if (mySetComboBox->getText() == TL("Demand")) {
161  } else {
163  }
165  if (mySetComboBox->getText() == TL("GenericDatas")) {
167  } else {
169  }
170  }
171  // set color
172  if (myCurrentSet == Type::INVALID) {
173  // set invalid color
174  mySetComboBox->setTextColor(FXRGB(255, 0, 0));
175  // hide match attribute
178  } else {
179  // set default color
180  mySetComboBox->setTextColor(FXRGB(0, 0, 0));
181  // show match attribute
185  } else {
188  }
189  }
190  return 1;
191 }
192 
193 /****************************************************************************/
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:299
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition: GUIDesigns.h:317
#define GUIDesignComboBoxVisibleItemsMedium
combo box medium small
Definition: GUIDesigns.h:53
@ MODEADDITIONAL
@ SUPERMODEDEMAND
@ MODECREATEEDGE
@ SUPERMODEDATA
#define TL(string)
Definition: MsgHandler.h:315
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
Definition: GNEElementSet.h:89
Type myCurrentSet
current element set selected
Definition: GNEElementSet.h:98
MFXComboBoxIcon * mySetComboBox
Combo Box with the element sets.
Definition: GNEElementSet.h:95
GNESelectorFrame * mySelectorFrameParent
FOX need this.
Definition: GNEElementSet.h:86
Type
FOX-declaration.
Definition: GNEElementSet.h:42
GNESelectorFrame * getSelectorFrameParent() const
get Selector Frame Parent
void hideElementSet()
hide element set
GNEMatchGenericDataAttribute * myMatchGenericDataAttribute
Match generic data attribute.
Definition: GNEElementSet.h:92
void showElementSet()
show element set
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:150
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
Definition: GNEViewNet.cpp:723
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