73 FXIMPLEMENT(
GNESelectorFrame, FXVerticalFrame, GNESelectorFrameMap, ARRAYNUMBER(GNESelectorFrameMap))
79 GNEFrame(horizontalFrameParent, viewNet, getStats().c_str()),
80 mySetOperation(SET_ADD),
87 myAddRadioButton =
new FXRadioButton(selBox,
"add\t\tSelected objects are added to the previous selection",
89 myRemoveRadioButton =
new FXRadioButton(selBox,
"remove\t\tSelected objects are removed from the previous selection",
91 myKeepRadioButton =
new FXRadioButton(selBox,
"keep\t\tRestrict previous selection by the current selection",
93 myReplaceRadioButton =
new FXRadioButton(selBox,
"replace\t\tReplace previous selection by the current selection",
95 myAddRadioButton->setCheck(
true);
100 mySetComboBox->appendItem(
"Net Element");
101 mySetComboBox->appendItem(
"Additional");
102 mySetComboBox->setNumVisible(mySetComboBox->getNumItems());
112 onCmdSubset(0, 0, 0);
115 myMatchAttrComboBox->setCurrentItem(3);
118 myMatchString->setText(
">10.0");
125 mySelectionScaling->setNumberFormat(1);
126 mySelectionScaling->setIncrements(0.1, .5, 1);
127 mySelectionScaling->setRange(1, 100);
128 mySelectionScaling->setValue(1);
129 mySelectionScaling->setHelpText(
"Enlarge selected objects");
131 FXGroupBox* additionalButtons =
new FXGroupBox(myContentFrame,
"Operations for selections",
GUIDesignGroupBoxFrame);
139 new FXButton(additionalButtons,
"Load\t\tLoad ids from a file according to the current modfication mode.", 0,
this,
MID_CHOOSEN_LOAD,
GUIDesignButton);
141 FXGroupBox* selectionHintGroupBox =
new FXGroupBox(myContentFrame,
"Information",
GUIDesignGroupBoxFrame);
143 new FXLabel(selectionHintGroupBox,
" - Hold <SHIFT> for \n rectangle selection.\n - Press <DEL> to\n delete selected items.", 0,
GUIDesignLabelLeft);
198 const bool netElements =
mySetComboBox->getText() ==
"Net Element";
200 for (std::vector<SumoXMLTag>::const_iterator it = tags.begin(); it != tags.end(); it++) {
221 FXFileDialog opendialog(
this,
"Open List of Selected Items");
223 opendialog.setSelectMode(SELECTFILE_EXISTING);
224 opendialog.setPatternList(
"Selection files (*.txt)\nAll files (*)");
228 if (opendialog.execute()) {
230 std::string file = opendialog.getFilename().text();
234 handleIDs(std::vector<GUIGlID>(ids.begin(), ids.end()),
false);
241 FXMessageBox::error(
this, MBOX_OK,
"Errors while loading Selection",
"%s", errors.c_str());
244 WRITE_WARNING(
"Closed FXMessageBox of type 'error' with 'OK'");
268 FXMessageBox::error(
this, MBOX_OK,
"Storing Selection failed",
"%s", e.what());
271 WRITE_WARNING(
"Closed FXMessageBox of type 'error' with 'OK'");
289 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
293 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
297 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
301 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
311 const bool netElements =
mySetComboBox->getText() ==
"Net Element";
327 for (std::vector<std::pair <SumoXMLAttr, std::string> >::const_iterator it = attrs.begin(); it != attrs.end(); it++) {
376 char compOp = expr[0];
377 if (compOp ==
'<' || compOp ==
'>' || compOp ==
'=') {
378 expr = expr.substr(1);
396 char compOp = expr[0];
397 if (compOp ==
'=' || compOp ==
'!' || compOp ==
'^') {
398 expr = expr.substr(1);
416 FXDialogBox* helpDialog =
new FXDialogBox(
this,
"Match Attribute Help",
GUIDesignDialogBox);
417 std::ostringstream help;
419 <<
"The 'Match Attribute' controls allow to specify a set of objects which are then applied to the current selection " 420 <<
"according to the current 'Modification Mode'.\n" 421 <<
"1. Select an object type from the first input box\n" 422 <<
"2. Select an attribute from the second input box\n" 423 <<
"3. Enter a 'match expression' in the third input box and press <return>\n" 425 <<
"The empty expression matches all objects\n" 426 <<
"For numerical attributes the match expression must consist of a comparison operator ('<', '>', '=') and a number.\n" 427 <<
"An object matches if the comparison between its attribute and the given number by the given operator evaluates to 'true'\n" 429 <<
"For string attributes the match expression must consist of a comparison operator ('', '=', '!', '^') and a string.\n" 430 <<
" '' (no operator) matches if string is a substring of that object'ts attribute.\n" 431 <<
" '=' matches if string is an exact match.\n" 432 <<
" '!' matches if string is not a substring.\n" 433 <<
" '^' matches if string is not an exact match.\n" 436 <<
"junction; id; 'foo' -> match all junctions that have 'foo' in their id\n" 437 <<
"junction; type; '=priority' -> match all junctions of type 'priority', but not of type 'priority_stop'\n" 438 <<
"edge; speed; '>10' -> match all edges with a speed above 10\n";
442 helpDialog->create();
477 return "Selection:\n" +
497 std::set<GUIGlID> previousSelection;
508 std::set<GUIGlID> idsSet(ids.begin(), ids.end());
509 std::set<GUIGlID> selected;
510 std::set<GUIGlID> deselected;
512 for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
517 const GNEEdge& edge = (
static_cast<GNELane*
>(object))->getParentEdge();
525 for (std::set<GUIGlID>::const_iterator it = idsSet.begin(); it != idsSet.end(); it++) {
536 type =
object->getType();
538 if ((type ==
GLO_LANE) && (selectEdgesEnabled ==
true)) {
541 id = (
static_cast<GNELane*
>(object))->getParentEdge().getGlID();
544 switch (setOperation) {
550 deselected.insert(
id);
553 if (previousSelection.count(
id)) {
572 std::vector<GUIGlID> result;
575 for (std::set<GUIGlID>::const_iterator it = allIDs.begin(); it != allIDs.end(); it++) {
579 throw ProcessError(
"Unkown object passed to GNESelectorFrame::getMatches (id=" +
toString(
id) +
").");
582 if (ac && ac->
getTag() == tag) {
584 result.push_back(
id);
585 }
else if (numerical) {
592 result.push_back(
id);
597 result.push_back(
id);
602 result.push_back(
id);
614 if (acVal.find(expr) != std::string::npos) {
615 result.push_back(
id);
619 if (acVal.find(expr) == std::string::npos) {
620 result.push_back(
id);
625 result.push_back(
id);
630 result.push_back(
id);
FXRadioButton * myReplaceRadioButton
replace radio button
SumoXMLTag
Numbers representing SUMO-XML - element names.
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
bool selectEdges()
whether inspection, selection and inversion should apply to edges or to lanes
void selectionUpdated()
called if currently registered for updates for changes of global selection
#define GUIDesignComboBoxNCol
number of column of every combo box
long onCmdSelMBString(FXObject *, FXSelector, void *)
Called when the user enters a new selection expression.
FXComboBox * myMatchAttrComboBox
attributes of the match box
SetOperation
FOX-declaration.
FXDEFMAP(GNESelectorFrame) GNESelectorFrameMap[]
long onCmdSave(FXObject *, FXSelector, void *)
Called when the user presses the Save-button.
void toggleSelection(GUIGlID id)
Toggles selection of an object.
std::vector< GUIGlID > getMatches(SumoXMLTag tag, SumoXMLAttr attr, char compOp, double val, const std::string &expr)
return objects of the given type with matching attrs
std::set< GUIGlID > getGlIDs(GUIGlObjectType type=GLO_MAX)
SumoXMLAttr myCurrentAttribute
current SumoXMLTag Attribute
FXTextField * myMatchString
string of the match
FXRealSpinDial * mySelectionScaling
selection scaling
SumoXMLTag myCurrentTag
current SumoXMLTag tag
void remove2Update()
Removes the dialog to be updated.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
long onCmdLoad(FXObject *, FXSelector, void *)
Called when the user presses the Load-button.
FXString gCurrentFolder
The folder used as last.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void handleIDs(std::vector< GUIGlID > ids, bool selectEdgesEnabled, SetOperation setop=SET_DEFAULT)
apply list of ids to the current selection according to SetOperation,
virtual std::string getAttribute(SumoXMLAttr key) const =0
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString ¤tFolder)
Returns the file name to write.
static const std::vector< std::pair< SumoXMLAttr, std::string > > & allowedAttributes(SumoXMLTag tag)
get all editable attributes for tag and their default values.
long onCmdHelp(FXObject *, FXSelector, void *)
Called when the user clicks the help button.
#define WRITE_WARNING(msg)
bool isTestingModeEnabled() const
check if netedit is running in testing mode
#define GUIDesignComboBox
GNEViewNet * myViewNet
the window to inform when the tls is modfied
std::set< GUIGlID > loadIDs(const std::string &filename, std::string &msgOut, GUIGlObjectType type=GLO_MAX, int maxErrors=16)
Loads a selection list (optionally with restricted type) and returns the ids of all active objects...
~GNESelectorFrame()
Destructor.
long onCmdScaleSelection(FXObject *, FXSelector, void *)
Called when the user changes visual scaling.
GNEUndoList * getUndoList() const
get the undoList object
long onCmdClear(FXObject *, FXSelector, void *)
Called when the user presses the Clear-button.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
#define GUIDesignTextField
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
SetOperation mySetOperation
how to modify selection
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
FXLabel * myFrameHeaderLabel
the label for the frame's header
long onCmdSelMBAttribute(FXObject *, FXSelector, void *)
Called when the user selectes a tag in the match box.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
static const std::vector< SumoXMLTag > & allowedTags(bool net)
get all editable for tag (net or additional).
bool autoSelectNodes()
whether to autoselect nodes or to lanes
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
const std::string ALL_VCLASS_NAMES_MATCH_STRING
the string that should be matched against if attr 'allowed' or 'disallowed' are set to "all" ...
GNEJunction * getGNEJunctionSource() const
returns the source-junction
FXRadioButton * myKeepRadioButton
keep button
#define GUIDesignButtonRectangular
little button rectangular (46x23) used in frames (For example, in "help" buttons) ...
long onCmdSelectOperation(FXObject *, FXSelector, void *)
begin/end of the description of an edge
void setSelectionScaling(double selectionScale)
set selection scaling
A road/street connecting two junctions (netedit-version)
#define GUIDesignTextFieldNCol
Num of column of text field.
long onCmdSubset(FXObject *, FXSelector, void *)
Called when the user change the type of element to search (netElement or Additional) ...
virtual void show()
show Frame
#define GUIDesignDialogBox
FXRadioButton * myRemoveRadioButton
remove radio button
void add2Update(UpdateTarget *updateTarget)
Adds a dialog to be updated.
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
FXComboBox * myMatchTagComboBox
tag of the match box
long onCmdInvert(FXObject *, FXSelector, void *)
Called when the user presses the Invert-button.
FXdouble getValue() const
Return current value.
virtual void hide()
hide Frame
GNENet * getNet() const
get the net object
GUIGlID getGlID() const
Returns the numerical id of the object.
#define GUIDesignButtonOK
selector match box messages
#define GUIDesignSpinDial
void unblockObject(GUIGlID id)
Marks an object as unblocked.
std::string getStats() const
get stats
#define GUIDesignLabelLeft
static bool isNumerical(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is numerical (int or float)
FXRadioButton * myAddRadioButton
add radio button
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
#define GUIDesignRadioButton
long onCmdSelMBTag(FXObject *, FXSelector, void *)
Called when the user selectes a tag in the match box.
FXComboBox * mySetComboBox
tag of the sets of elements
GUISelectedStorage gSelected
A global holder of selected objects.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.
changes the visual scaling of selected items
SumoXMLTag getTag() const
get XML Tag assigned to this object