56 #ifdef CHECK_MEMORY_LEAKS 58 #endif // CHECK_MEMORY_LEAKS 77 FXIMPLEMENT(
GNESelectorFrame, FXScrollWindow, GNESelectorFrameMap, ARRAYNUMBER(GNESelectorFrameMap))
83 GNEFrame(parent, viewNet, getStats().c_str()),
84 mySetOperation(SET_ADD),
85 mySetOperationTarget(mySetOperation),
88 FXGroupBox* selBox =
new FXGroupBox(myContentFrame,
"Modification Mode", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
90 new FXRadioButton(selBox,
"add\t\tSelected objects are added to the previous selection",
91 &mySetOperationTarget, FXDataTarget::ID_OPTION + SET_ADD);
92 new FXRadioButton(selBox,
"remove\t\tSelected objects are removed from the previous selection",
93 &mySetOperationTarget, FXDataTarget::ID_OPTION + SET_SUB);
94 new FXRadioButton(selBox,
"keep\t\tRestrict previous selection by the current selection",
95 &mySetOperationTarget, FXDataTarget::ID_OPTION + SET_RESTRICT);
96 new FXRadioButton(selBox,
"replace\t\tReplace previous selection by the current selection",
97 &mySetOperationTarget, FXDataTarget::ID_OPTION + SET_REPLACE);
99 FXGroupBox* elementBox =
new FXGroupBox(myContentFrame,
"type of element", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
102 mySetBox->appendItem(
"Net Element");
103 mySetBox->appendItem(
"Additional");
104 mySetBox->setNumVisible(mySetBox->getNumItems());
106 FXGroupBox* matchBox =
new FXGroupBox(myContentFrame,
"Match Attribute", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
108 myMatchTagBox =
new FXListBox(matchBox,
this,
MID_GNE_SELMB_TAG, FRAME_GROOVE | LAYOUT_FILL_X);
110 myMatchAttrBox =
new FXListBox(matchBox, NULL, 0, FRAME_GROOVE | LAYOUT_FILL_X);
112 mySetBox->setCurrentItem(0);
114 onCmdSubset(0, 0, 0);
116 myMatchAttrBox->setCurrentItem(3);
118 myMatchString =
new FXTextField(matchBox, 12,
this,
MID_GNE_SELMB_STRING, FRAME_THICK | LAYOUT_FILL_X);
120 myMatchString->setText(
">10.0");
122 new FXButton(matchBox,
"Help", 0,
this,
MID_HELP);
124 FXGroupBox* selSizeBox =
new FXGroupBox(myContentFrame,
"Visual Scaling", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
127 mySelectionScaling->setNumberFormat(1);
128 mySelectionScaling->setIncrements(0.1, .5, 1);
129 mySelectionScaling->setRange(1, 100);
130 mySelectionScaling->setValue(1);
131 mySelectionScaling->setHelpText(
"Enlarge selected objects");
133 FXGroupBox* additionalButtons =
new FXGroupBox(myContentFrame,
"Operations for selections", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
135 new FXButton(additionalButtons,
"Clear\t\t", 0,
this,
MID_CHOOSEN_CLEAR, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED);
137 new FXButton(additionalButtons,
"Invert\t\t", 0,
this,
MID_CHOOSEN_INVERT, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED);
139 new FXButton(additionalButtons,
"Save\t\tSave ids of currently selected objects to a file.", 0,
this,
MID_CHOOSEN_SAVE, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED);
141 new FXButton(additionalButtons,
"Load\t\tLoad ids from a file according to the current modfication mode.", 0,
this,
MID_CHOOSEN_LOAD, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED);
143 FXGroupBox* selectionHintGroupBox =
new FXGroupBox(myContentFrame,
"Information", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
145 new FXLabel(selectionHintGroupBox,
" - Hold <SHIFT> for \n rectangle selection.\n - Press <DEL> to\n delete selected items.", 0, JUSTIFY_LEFT);
159 if (
mySetBox->getCurrentItem() == 0) {
163 for (std::vector<SumoXMLTag>::const_iterator it = tags.begin(); it != tags.end(); it++) {
175 for (std::vector<SumoXMLTag>::const_iterator it = tags.begin(); it != tags.end(); it++) {
191 FXFileDialog opendialog(
this,
"Open List of Selected Items");
193 opendialog.setSelectMode(SELECTFILE_EXISTING);
194 opendialog.setPatternList(
"Selection files (*.txt)\nAll files (*)");
198 if (opendialog.execute()) {
200 std::string file = opendialog.getFilename().text();
204 handleIDs(std::vector<GUIGlID>(ids.begin(), ids.end()),
false);
206 FXMessageBox::error(
this, MBOX_OK,
"Errors while loading Selection",
"%s", errors.c_str());
224 FXMessageBox::error(
this, MBOX_OK,
"Storing Selection failed",
"%s", e.what());
241 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
245 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
249 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
253 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
267 for (std::vector<std::pair <SumoXMLAttr, std::string> >::const_iterator it = attrs.begin(); it != attrs.end(); it++) {
296 char compOp = expr[0];
297 if (compOp ==
'<' || compOp ==
'>' || compOp ==
'=') {
298 expr = expr.substr(1);
303 std::istringstream buf(expr);
305 if (!buf.fail() && (int)buf.tellg() == (int)expr.size()) {
317 char compOp = expr[0];
318 if (compOp ==
'=' || compOp ==
'!' || compOp ==
'^') {
319 expr = expr.substr(1);
338 FXDialogBox* helpDialog =
new FXDialogBox(
this,
"Match Attribute Help", DECOR_CLOSE | DECOR_TITLE);
339 std::ostringstream help;
341 <<
"The 'Match Attribute' controls allow to specify a set of objects which are then applied to the current selection " 342 <<
"according to the current 'Modification Mode'.\n" 343 <<
"1. Select an object type from the first input box\n" 344 <<
"2. Select an attribute from the second input box\n" 345 <<
"3. Enter a 'match expression' in the third input box and press <return>\n" 347 <<
"The empty expression matches all objects\n" 348 <<
"For numerical attributes the match expression must consist of a comparison operator ('<', '>', '=') and a number.\n" 349 <<
"An object matches if the comparison between its attribute and the given number by the given operator evaluates to 'true'\n" 351 <<
"For string attributes the match expression must consist of a comparison operator ('', '=', '!', '^') and a string.\n" 352 <<
" '' (no operator) matches if string is a substring of that object'ts attribute.\n" 353 <<
" '=' matches if string is an exact match.\n" 354 <<
" '!' matches if string is not a substring.\n" 355 <<
" '^' matches if string is not an exact match.\n" 358 <<
"junction; id; 'foo' -> match all junctions that have 'foo' in their id\n" 359 <<
"junction; type; '=priority' -> match all junctions of type 'priority', but not of type 'priority_stop'\n" 360 <<
"edge; speed; '>10' -> match all edges with a speed above 10\n";
361 new FXLabel(helpDialog, help.str().c_str(), 0, JUSTIFY_LEFT);
363 new FXButton(helpDialog,
"OK\t\tSave modifications", 0, helpDialog, FXDialogBox::ID_ACCEPT,
364 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
365 0, 0, 0, 0, 4, 4, 3, 3);
366 helpDialog->create();
384 FXScrollWindow::show();
393 FXScrollWindow::hide();
401 return "Selection:\n" +
420 std::set<GUIGlID> previousSelection;
431 std::set<GUIGlID> idsSet(ids.begin(), ids.end());
432 std::set<GUIGlID> selected;
433 std::set<GUIGlID> deselected;
435 for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
440 const GNEEdge& edge = (
static_cast<GNELane*
>(object))->getParentEdge();
448 for (std::set<GUIGlID>::const_iterator it = idsSet.begin(); it != idsSet.end(); it++) {
459 type =
object->getType();
461 if (type ==
GLO_LANE && selectEdges) {
464 id = (
static_cast<GNELane*
>(object))->getParentEdge().getGlID();
467 switch (setOperation) {
473 deselected.insert(
id);
476 if (previousSelection.count(
id)) {
495 std::vector<GUIGlID> result;
498 for (std::set<GUIGlID>::const_iterator it = allIDs.begin(); it != allIDs.end(); it++) {
502 throw ProcessError(
"Unkown object passed to GNESelectorFrame::getMatches (id=" +
toString(
id) +
").");
505 if (ac && ac->
getTag() == tag) {
507 result.push_back(
id);
508 }
else if (numerical) {
515 result.push_back(
id);
520 result.push_back(
id);
525 result.push_back(
id);
537 if (acVal.find(expr) != std::string::npos) {
538 result.push_back(
id);
542 if (acVal.find(expr) == std::string::npos) {
543 result.push_back(
id);
548 result.push_back(
id);
553 result.push_back(
id);
SumoXMLTag
Numbers representing SUMO-XML - element names.
const std::set< GUIGlID > & getSelected() const
Returns the list 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
void hideFramesArea()
hide frames area if all GNEFrames are hidden
FXuint mySetOperation
how to modify selection
static bool isNumerical(SumoXMLAttr attr)
whether an attribute is numerical (int or float)
long onCmdSelMBString(FXObject *, FXSelector, void *)
Called when the user enters a new selection expression.
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::set< GUIGlID > getGlIDs(GUIGlObjectType type=GLO_MAX)
GNEViewParent * getViewParent() const
get the net object
FXTextField * myMatchString
string of the match
FXRealSpinDial * mySelectionScaling
selection scaling
void showFramesArea()
show frames area if at least a GNEFrame is showed
FXListBox * myMatchTagBox
tag of the match box
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.
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.
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.
selector match box messages
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
static const std::vector< SumoXMLTag > & allowedTags()
get all editable for tag.
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.
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" ...
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
GNEJunction * getGNEJunctionSource() const
returns the source-junction
A road/street connecting two junctions (netedit-version)
GNEJunction * getGNEJunctionDest() const
returns the destination-junction
long onCmdSubset(FXObject *, FXSelector, void *)
static const std::vector< SumoXMLTag > & allowedAdditionalTags()
get all editable tags for additionals
void add2Update(UpdateTarget *updateTarget)
Adds a dialog to be updated.
long onCmdInvert(FXObject *, FXSelector, void *)
Called when the user presses the Invert-button.
static const std::vector< SumoXMLTag > & allowedNetElementTags()
get all editable tags for netElements
FXListBox * myMatchAttrBox
attributes of the match box
FXdouble getValue() const
Return current value.
void handleIDs(std::vector< GUIGlID > ids, bool selectEdges, SetOperation setop=SET_DEFAULT)
apply list of ids to the current selection according to SetOperation,
GNENet * getNet() const
get the net object
GUIGlID getGlID() const
Returns the numerical id of the object.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=OUTPUT_ACCURACY)
void unblockObject(GUIGlID id)
Marks an object as unblocked.
std::string getStats() const
get stats
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
long onCmdSelMBTag(FXObject *, FXSelector, void *)
Called when the user selectes a tag in the match box.
FXListBox * mySetBox
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
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.
SumoXMLTag getTag() const
get Tag assigned to this object