74 FXIMPLEMENT(
GNESelectorFrame, FXVerticalFrame, GNESelectorFrameMap, ARRAYNUMBER(GNESelectorFrameMap))
83 locked =
new FXMenuCheck(parent, (
"lock\t\tLock " + label2 +
" selection").c_str(), 0, 0, LAYOUT_FILL_X | LAYOUT_RIGHT);
88 GNEFrame(horizontalFrameParent, viewNet,
"Selection"),
89 mySetOperation(SET_ADD),
94 FXMatrix* mSelectedItems =
new FXMatrix(mySelectedItemsComboBox, 3, (LAYOUT_FILL_X | LAYOUT_BOTTOM | LAYOUT_LEFT | MATRIX_BY_COLUMNS), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
107 myAddRadioButton =
new FXRadioButton(selBox,
"add\t\tSelected objects are added to the previous selection",
109 myRemoveRadioButton =
new FXRadioButton(selBox,
"remove\t\tSelected objects are removed from the previous selection",
111 myKeepRadioButton =
new FXRadioButton(selBox,
"keep\t\tRestrict previous selection by the current selection",
113 myReplaceRadioButton =
new FXRadioButton(selBox,
"replace\t\tReplace previous selection by the current selection",
160 new FXButton(additionalButtons,
"Load\t\tLoad ids from a file according to the current modfication mode.", 0,
this,
MID_CHOOSEN_LOAD,
GUIDesignButton);
164 new FXLabel(selectionHintGroupBox,
" - Hold <SHIFT> for \n rectangle selection.\n - Press <DEL> to\n delete selected items.", 0,
GUIDesignLabelFrameInformation);
269 FXFileDialog opendialog(
this,
"Open List of Selected Items");
271 opendialog.setSelectMode(SELECTFILE_EXISTING);
272 opendialog.setPatternList(
"Selection files (*.txt)\nAll files (*)");
276 if (opendialog.execute()) {
278 std::string file = opendialog.getFilename().text();
282 handleIDs(std::vector<GUIGlID>(ids.begin(), ids.end()),
false);
286 WRITE_WARNING(
"Opening FXMessageBox 'error loading selection'");
289 FXMessageBox::error(
this, MBOX_OK,
"Errors while loading Selection",
"%s", errors.c_str());
292 WRITE_WARNING(
"Closed FXMessageBox 'error loading selection' with 'OK'");
313 WRITE_WARNING(
"Opening FXMessageBox 'error storing selection'");
316 FXMessageBox::error(
this, MBOX_OK,
"Storing Selection failed",
"%s", e.what());
319 WRITE_WARNING(
"Closed FXMessageBox 'error storing selection' with 'OK'");
339 std::set<GUIGlID> unselectedElements;
342 for (
auto it : ids) {
344 unselectedElements.insert(it);
351 for (
auto it : ids) {
353 unselectedElements.insert(it);
359 for (
auto it : ids) {
361 unselectedElements.insert(it);
366 for (
auto it : ids) {
368 unselectedElements.insert(it);
373 for (
auto it : ids) {
375 unselectedElements.insert(it);
382 unselectedElements.insert(poly->
getGlID());
389 unselectedElements.insert(POI->
getGlID());
456 for (
auto i : attrs) {
485 char compOp = expr[0];
486 if (compOp ==
'<' || compOp ==
'>' || compOp ==
'=') {
487 expr = expr.substr(1);
505 char compOp = expr[0];
506 if (compOp ==
'=' || compOp ==
'!' || compOp ==
'^') {
507 expr = expr.substr(1);
525 FXDialogBox* helpDialog =
new FXDialogBox(
this,
"Match Attribute Help",
GUIDesignDialogBox);
526 std::ostringstream help;
528 <<
"The 'Match Attribute' controls allow to specify a set of objects which are then applied to the current selection " 529 <<
"according to the current 'Modification Mode'.\n" 530 <<
"1. Select an object type from the first input box\n" 531 <<
"2. Select an attribute from the second input box\n" 532 <<
"3. Enter a 'match expression' in the third input box and press <return>\n" 534 <<
"The empty expression matches all objects\n" 535 <<
"For numerical attributes the match expression must consist of a comparison operator ('<', '>', '=') and a number.\n" 536 <<
"An object matches if the comparison between its attribute and the given number by the given operator evaluates to 'true'\n" 538 <<
"For string attributes the match expression must consist of a comparison operator ('', '=', '!', '^') and a string.\n" 539 <<
" '' (no operator) matches if string is a substring of that object'ts attribute.\n" 540 <<
" '=' matches if string is an exact match.\n" 541 <<
" '!' matches if string is not a substring.\n" 542 <<
" '^' matches if string is not an exact match.\n" 545 <<
"junction; id; 'foo' -> match all junctions that have 'foo' in their id\n" 546 <<
"junction; type; '=priority' -> match all junctions of type 'priority', but not of type 'priority_stop'\n" 547 <<
"edge; speed; '>10' -> match all edges with a speed above 10\n";
551 helpDialog->create();
615 std::set<GUIGlID> previousSelection;
626 std::set<GUIGlID> idsSet(ids.begin(), ids.end());
627 std::set<GUIGlID> selected;
628 std::set<GUIGlID> deselected;
630 for (
auto it : ids) {
634 const GNEEdge& edge = (
static_cast<GNELane*
>(object))->getParentEdge();
642 for (
auto it : idsSet) {
652 type =
object->getType();
653 if (type ==
GLO_LANE && selectEdgesEnabled) {
655 it = (
dynamic_cast<GNELane*
>(object))->getParentEdge().getGlID();
662 switch (setOperation) {
668 deselected.insert(it);
671 if (previousSelection.count(it)) {
689 std::vector<GUIGlID> result;
692 for (
auto it : allIDs) {
696 if (ac->
getTag() == ACTag) {
698 result.push_back(it);
699 }
else if (numerical) {
706 result.push_back(it);
711 result.push_back(it);
716 result.push_back(it);
725 if (acVal.find(expr) != std::string::npos) {
726 result.push_back(it);
730 if (acVal.find(expr) == std::string::npos) {
731 result.push_back(it);
736 result.push_back(it);
741 result.push_back(it);
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
select tag in selector frame
SetOperation
FOX-declaration.
FXDEFMAP(GNESelectorFrame) GNESelectorFrameMap[]
long onCmdSave(FXObject *, FXSelector, void *)
Called when the user presses the Save-button.
const Polygons & getPolygons() const
Returns all polygons.
static const std::vector< SumoXMLTag > & allowedShapeTags()
get all editable for tag shape elements
GUIGlID getGlID() const
Returns the numerical id of the object.
GNEAttributeCarrier * retrieveAttributeCarrier(const GUIGlID id, bool failHard=true)
get a single attribute carrier based on a GLID
std::set< GUIGlID > getGlIDs(GUIGlObjectType type=GLO_MAX)
get ids of currently active objects
static const std::vector< SumoXMLTag > & allowedNetElementsTags()
get all editable for tag net elements
std::vector< GUIGlID > getMatches(SumoXMLTag ACTag, SumoXMLAttr ACAttr, char compOp, double val, const std::string &expr)
return objects of the given type with matching attrs
SumoXMLAttr myCurrentAttribute
current SumoXMLTag Attribute
FXTextField * myMatchString
string of the match
FXRealSpinDial * mySelectionScaling
selection scaling
virtual void setValue(FXdouble value)
Change current value.
void setNumberFormat(FXint prec, FXbool bExp=FALSE)
SumoXMLTag myCurrentTag
current SumoXMLTag tag
void remove2Update()
Removes the dialog to be updated.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
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,
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
GNESelectorFrame()
FOX needs this.
virtual std::string getAttribute(SumoXMLAttr key) const =0
This functions has to be implemented in all GNEAttributeCarriers.
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)
static OptionsCont & getOptions()
Retrieves the options.
#define GUIDesignComboBox
GNEViewNet * myViewNet
View Net for changes.
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.
select attribute in selector frame
void setRange(FXdouble lo, FXdouble hi)
Change the spinner's range.
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)
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
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.
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
bool autoSelectNodes()
whether to autoselect nodes or to lanes
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
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
static const std::vector< SumoXMLTag > & allowedAdditionalTags()
get all editable for tag additional elements
void add2Update(UpdateTarget *updateTarget)
Adds a dialog to be updated.
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
virtual std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
GUIGlID getGlID() const
Returns the numerical id of the object.
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.
changes the visual scaling of selected items
virtual void hide()
hide Frame
void setHelpText(const FXString &text)
Set the status line help text for this spinner.
GNENet * getNet() const
get the net object
GUIGlID getGlID() const
Returns the numerical id of the object.
#define GUIDesignButtonOK
void setIncrements(FXdouble fine, FXdouble norm, FXdouble coarse)
Change all spinner increment.
#define GUIDesignSpinDial
void unblockObject(GUIGlID id)
Marks an object as unblocked.
#define GUIDesignLabelLeft
static bool isNumerical(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is numerical (int or float)
FXRadioButton * myAddRadioButton
add radio button
bool locked(GUIGlObjectType type)
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.
C++ TraCI client API implementation.
FXComboBox * mySetComboBox
tag of the sets of elements
GUISelectedStorage gSelected
A global holder of selected objects.
std::map< GUIGlObjectType, ObjectTypeEntry > myTypeEntries
check boxes for type-based selection locking and selected object counts
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.
SumoXMLTag getTag() const
get XML Tag assigned to this object
const POIs & getPOIs() const
Returns all pois.