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.org/sumo
3 // Copyright (C) 2001-2022 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>
25 
26 #include "GNEElementSet.h"
27 #include "GNEMatchAttribute.h"
29 
30 
31 // ===========================================================================
32 // FOX callback mapping
33 // ===========================================================================
34 
35 FXDEFMAP(GNEElementSet) GNEElementSetMap[] = {
37 };
38 
39 // Object implementation
40 FXIMPLEMENT(GNEElementSet, FXGroupBoxModule, GNEElementSetMap, ARRAYNUMBER(GNEElementSetMap))
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
45 
46 GNEElementSet::GNEElementSet(GNESelectorFrame* selectorFrameParent, Supermode supermode,
47  SumoXMLTag defaultTag, SumoXMLAttr defaultAttr, const std::string& defaultValue) :
48  FXGroupBoxModule(selectorFrameParent->getContentFrame(), "Element Set"),
49  mySelectorFrameParent(selectorFrameParent),
50  myMatchAttribute(nullptr),
51  myMatchGenericDataAttribute(nullptr),
52  myCurrentSet(Type::INVALID) {
53  // Create MatchTagBox for tags and fill it
54  mySetComboBox = new MFXIconComboBox(getCollapsableFrame(), GUIDesignComboBoxNCol, this, MID_CHOOSEN_ELEMENTS, GUIDesignComboBox);
55  // continue depending of supermode
56  if (supermode == Supermode::NETWORK) {
57  // append elements
58  mySetComboBox->appendIconItem("Network", GUIIconSubSys::getIcon(GUIIcon::MODECREATEEDGE));
59  mySetComboBox->appendIconItem("Additional", GUIIconSubSys::getIcon(GUIIcon::MODEADDITIONAL));
60  mySetComboBox->appendIconItem("Shape", GUIIconSubSys::getIcon(GUIIcon::MODEPOLYGON));
61  mySetComboBox->appendIconItem("TAZ", GUIIconSubSys::getIcon(GUIIcon::MODETAZ));
62  // set default set
63  myCurrentSet = Type::NETWORK;
64  // build MatchAttribute
65  myMatchAttribute = new GNEMatchAttribute(this, defaultTag, defaultAttr, defaultValue);
66  } else if (supermode == Supermode::DEMAND) {
67  // append elements
68  mySetComboBox->appendIconItem("Demand", GUIIconSubSys::getIcon(GUIIcon::SUPERMODEDEMAND));
69  // set default set
70  myCurrentSet = Type::DEMAND;
71  // build MatchAttribute
72  myMatchAttribute = new GNEMatchAttribute(this, defaultTag, defaultAttr, defaultValue);
73  } else if (supermode == Supermode::DATA) {
74  // append elements
75  mySetComboBox->appendIconItem("Data", GUIIconSubSys::getIcon(GUIIcon::SUPERMODEDATA));
76  // set default set
77  myCurrentSet = Type::DATA;
79  myMatchGenericDataAttribute = new GNEMatchGenericDataAttribute(this, defaultTag, defaultAttr, defaultValue);
80  } else {
81  throw ProcessError("Invalid supermode");
82  }
83  // set visible items
84  mySetComboBox->setNumVisible(mySetComboBox->getNumItems());
85 }
86 
87 
89 
90 
93  return mySelectorFrameParent;
94 }
95 
96 
99  return myCurrentSet;
100 }
101 
102 
103 void
105  // first show group box
106  show();
107  // show myMatchAttribute (if exist)
108  if (myMatchAttribute) {
110  // first check if myCurrentSet is invalid
111  if (myCurrentSet == Type::INVALID) {
112  // disable macht attribute
114  } else {
115  // enable match attribute
117  }
118  }
119  // show myMatchGenericDataAttribute (if exist)
122  // first check if myCurrentSet is invalid
123  if (myCurrentSet == Type::INVALID) {
124  // disable macht attribute
126  } else {
127  // enable match attribute
129  }
130  }
131 }
132 
133 
134 void
136  // hide match attribute (if exist)
137  if (myMatchAttribute) {
139  }
140  // hide match generic data attribute (if exist)
143  }
144  // hide group box
145  hide();
146 }
147 
148 
149 long
150 GNEElementSet::onCmdSelectElementSet(FXObject*, FXSelector, void*) {
151  // check depending of current supermode
153  if (mySetComboBox->getText() == "Network") {
155  } else if (mySetComboBox->getText() == "Additional") {
157  } else if (mySetComboBox->getText() == "TAZ") {
159  mySetComboBox->setTextColor(FXRGB(0, 0, 0));
160  } else if (mySetComboBox->getText() == "Shape") {
162  } else {
164  }
166  if (mySetComboBox->getText() == "Demand") {
168  } else {
170  }
172  if (mySetComboBox->getText() == "Data") {
174  } else {
176  }
177  }
178  // set color
179  if (myCurrentSet == Type::INVALID) {
180  // set invalid color
181  mySetComboBox->setTextColor(FXRGB(255, 0, 0));
182  // hide match attribute
183  if (myMatchAttribute) {
185  }
188  }
189  } else {
190  // set default color
191  mySetComboBox->setTextColor(FXRGB(0, 0, 0));
192  // set current set
193  if (myMatchAttribute) {
195  }
198  }
199  }
200  return 1;
201 }
202 
203 /****************************************************************************/
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:553
#define GUIDesignComboBox
Definition: GUIDesigns.h:267
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition: GUIDesigns.h:285
@ MODEADDITIONAL
@ SUPERMODEDEMAND
@ MODECREATEEDGE
@ SUPERMODEDATA
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
FXGroupBoxModule (based on FXGroupBox)
~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
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
MFXIconComboBox * mySetComboBox
Combo Box with the element sets.
Definition: GNEElementSet.h:95
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:133
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:513
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.
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