58 #ifdef CHECK_MEMORY_LEAKS 60 #endif // CHECK_MEMORY_LEAKS 79 FXIMPLEMENT(
GNESelectorFrame, FXVerticalFrame, GNESelectorFrameMap, ARRAYNUMBER(GNESelectorFrameMap))
85 GNEFrame(horizontalFrameParent, viewNet, getStats().c_str()),
86 mySetOperation(SET_ADD),
87 mySetOperationTarget(mySetOperation),
92 new FXRadioButton(selBox,
"add\t\tSelected objects are added to the previous selection",
94 new FXRadioButton(selBox,
"remove\t\tSelected objects are removed from the previous selection",
96 new FXRadioButton(selBox,
"keep\t\tRestrict previous selection by the current selection",
98 new FXRadioButton(selBox,
"replace\t\tReplace previous selection by the current selection",
104 mySetComboBox->appendItem(
"Net Element");
105 mySetComboBox->appendItem(
"Additional");
106 mySetComboBox->setNumVisible(mySetComboBox->getNumItems());
114 mySetComboBox->setCurrentItem(0);
116 onCmdSubset(0, 0, 0);
118 myMatchAttrComboBox->setCurrentItem(3);
122 myMatchString->setText(
">10.0");
129 mySelectionScaling->setNumberFormat(1);
130 mySelectionScaling->setIncrements(0.1, .5, 1);
131 mySelectionScaling->setRange(1, 100);
132 mySelectionScaling->setValue(1);
133 mySelectionScaling->setHelpText(
"Enlarge selected objects");
135 FXGroupBox* additionalButtons =
new FXGroupBox(myContentFrame,
"Operations for selections",
GUIDesignGroupBoxFrame);
143 new FXButton(additionalButtons,
"Load\t\tLoad ids from a file according to the current modfication mode.", 0,
this,
MID_CHOOSEN_LOAD,
GUIDesignButton);
145 FXGroupBox* selectionHintGroupBox =
new FXGroupBox(myContentFrame,
"Information",
GUIDesignGroupBoxFrame);
147 new FXLabel(selectionHintGroupBox,
" - Hold <SHIFT> for \n rectangle selection.\n - Press <DEL> to\n delete selected items.", 0,
GUIDesignLabelLeft);
161 const bool netElements =
mySetComboBox->getCurrentItem() == 0;
163 for (std::vector<SumoXMLTag>::const_iterator it = tags.begin(); it != tags.end(); it++) {
177 FXFileDialog opendialog(
this,
"Open List of Selected Items");
179 opendialog.setSelectMode(SELECTFILE_EXISTING);
180 opendialog.setPatternList(
"Selection files (*.txt)\nAll files (*)");
184 if (opendialog.execute()) {
186 std::string file = opendialog.getFilename().text();
190 handleIDs(std::vector<GUIGlID>(ids.begin(), ids.end()),
false);
192 FXMessageBox::error(
this, MBOX_OK,
"Errors while loading Selection",
"%s", errors.c_str());
210 FXMessageBox::error(
this, MBOX_OK,
"Storing Selection failed",
"%s", e.what());
227 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
231 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
235 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
239 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
249 const bool netElements =
mySetComboBox->getCurrentItem() == 0;
254 for (std::vector<std::pair <SumoXMLAttr, std::string> >::const_iterator it = attrs.begin(); it != attrs.end(); it++) {
267 const bool netElements =
mySetComboBox->getCurrentItem() == 0;
284 char compOp = expr[0];
285 if (compOp ==
'<' || compOp ==
'>' || compOp ==
'=') {
286 expr = expr.substr(1);
304 char compOp = expr[0];
305 if (compOp ==
'=' || compOp ==
'!' || compOp ==
'^') {
306 expr = expr.substr(1);
325 FXDialogBox* helpDialog =
new FXDialogBox(
this,
"Match Attribute Help",
GUIDesignDialogBox);
326 std::ostringstream help;
328 <<
"The 'Match Attribute' controls allow to specify a set of objects which are then applied to the current selection " 329 <<
"according to the current 'Modification Mode'.\n" 330 <<
"1. Select an object type from the first input box\n" 331 <<
"2. Select an attribute from the second input box\n" 332 <<
"3. Enter a 'match expression' in the third input box and press <return>\n" 334 <<
"The empty expression matches all objects\n" 335 <<
"For numerical attributes the match expression must consist of a comparison operator ('<', '>', '=') and a number.\n" 336 <<
"An object matches if the comparison between its attribute and the given number by the given operator evaluates to 'true'\n" 338 <<
"For string attributes the match expression must consist of a comparison operator ('', '=', '!', '^') and a string.\n" 339 <<
" '' (no operator) matches if string is a substring of that object'ts attribute.\n" 340 <<
" '=' matches if string is an exact match.\n" 341 <<
" '!' matches if string is not a substring.\n" 342 <<
" '^' matches if string is not an exact match.\n" 345 <<
"junction; id; 'foo' -> match all junctions that have 'foo' in their id\n" 346 <<
"junction; type; '=priority' -> match all junctions of type 'priority', but not of type 'priority_stop'\n" 347 <<
"edge; speed; '>10' -> match all edges with a speed above 10\n";
350 new FXButton(helpDialog,
"OK\t\tSave modifications",
GUIIconSubSys::getIcon(
ICON_ACCEPT), helpDialog, FXDialogBox::ID_ACCEPT,
GUIDesignButtonDialog, 0, 0, 0, 0, 4, 4, 3, 3);
351 helpDialog->create();
386 return "Selection:\n" +
405 std::set<GUIGlID> previousSelection;
416 std::set<GUIGlID> idsSet(ids.begin(), ids.end());
417 std::set<GUIGlID> selected;
418 std::set<GUIGlID> deselected;
420 for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
425 const GNEEdge& edge = (
static_cast<GNELane*
>(object))->getParentEdge();
433 for (std::set<GUIGlID>::const_iterator it = idsSet.begin(); it != idsSet.end(); it++) {
444 type =
object->getType();
446 if (type ==
GLO_LANE && selectEdges) {
449 id = (
static_cast<GNELane*
>(object))->getParentEdge().getGlID();
452 switch (setOperation) {
458 deselected.insert(
id);
461 if (previousSelection.count(
id)) {
480 std::vector<GUIGlID> result;
483 for (std::set<GUIGlID>::const_iterator it = allIDs.begin(); it != allIDs.end(); it++) {
487 throw ProcessError(
"Unkown object passed to GNESelectorFrame::getMatches (id=" +
toString(
id) +
").");
490 if (ac && ac->
getTag() == tag) {
492 result.push_back(
id);
493 }
else if (numerical) {
500 result.push_back(
id);
505 result.push_back(
id);
510 result.push_back(
id);
522 if (acVal.find(expr) != std::string::npos) {
523 result.push_back(
id);
527 if (acVal.find(expr) == std::string::npos) {
528 result.push_back(
id);
533 result.push_back(
id);
538 result.push_back(
id);
SumoXMLTag
Numbers representing SUMO-XML - element names.
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
FXuint mySetOperation
how to modify selection
GNEJunction * getGNEJunctionSource() const
returns the source-junction
long onCmdSelMBString(FXObject *, FXSelector, void *)
Called when the user enters a new selection expression.
FXComboBox * myMatchAttrComboBox
attributes of the match box
std::string getStats() const
get stats
SetOperation
FOX-declaration.
FXDEFMAP(GNESelectorFrame) GNESelectorFrameMap[]
static SUMOReal _2SUMOReal(const E *const data)
converts a char-type array into the SUMOReal value described by it
long onCmdSave(FXObject *, FXSelector, void *)
Called when the user presses the Save-button.
void toggleSelection(GUIGlID id)
Toggles selection of an object.
std::set< GUIGlID > getGlIDs(GUIGlObjectType type=GLO_MAX)
FXTextField * myMatchString
string of the match
FXRealSpinDial * mySelectionScaling
selection scaling
changes the visual scaling of selected items
void setSelectionScaling(SUMOReal selectionScale)
set selection scaling
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.
std::vector< GUIGlID > getMatches(SumoXMLTag tag, SumoXMLAttr attr, char compOp, SUMOReal val, const std::string &expr)
return objects of the given type with matching attrs
FXString gCurrentFolder
The folder used as last.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString ¤tFolder)
Returns the file name to write.
GUIGlID getGlID() const
Returns the numerical id of the object.
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.
GNEUndoList * getUndoList() const
get the undoList object
#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.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
long onCmdScaleSelection(FXObject *, FXSelector, void *)
Called when the user changes visual scaling.
long onCmdClear(FXObject *, FXSelector, void *)
Called when the user presses the Clear-button.
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
#define GUIDesignButtonDialog
button with size limited by text, centered over Frame with thick and raise frame
#define GUIDesignTextField
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
FXdouble getValue() const
Return current value.
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
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
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 'disalloed' are set to "all" ...
A road/street connecting two junctions (netedit-version)
#define GUIDesignTextFieldNCol
Num of column of text field.
long onCmdSubset(FXObject *, FXSelector, void *)
#define GUIDesignButtonHelp
little button for help in frames
virtual void show()
show Frame
#define GUIDesignDialogBox
void add2Update(UpdateTarget *updateTarget)
Adds a dialog to be updated.
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
virtual std::string getAttribute(SumoXMLAttr key) const =0
FXComboBox * myMatchTagComboBox
tag of the match box
long onCmdInvert(FXObject *, FXSelector, void *)
Called when the user presses the Invert-button.
GNENet * getNet() const
get the net object
virtual void hide()
hide Frame
void handleIDs(std::vector< GUIGlID > ids, bool selectEdges, SetOperation setop=SET_DEFAULT)
apply list of ids to the current selection according to SetOperation,
selector match box messages
SumoXMLTag getTag() const
get XML Tag assigned to this object
#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)
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.
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction