56 #ifdef CHECK_MEMORY_LEAKS 58 #endif // CHECK_MEMORY_LEAKS 76 FXIMPLEMENT(
GNESelectorFrame, FXScrollWindow, GNESelectorFrameMap, ARRAYNUMBER(GNESelectorFrameMap))
82 GNEFrame(parent, viewNet, getStats().c_str()),
83 mySetOperation(SET_ADD),
84 mySetOperationTarget(mySetOperation),
87 FXGroupBox* selBox =
new FXGroupBox(myContentFrame,
"Modification Mode",
88 GROUPBOX_NORMAL | FRAME_GROOVE | LAYOUT_FILL_X, 2, 0, 0, 0, 4, 2, 2, 2);
89 new FXRadioButton(selBox,
"add\t\tSelected objects are added to the previous selection",
90 &mySetOperationTarget, FXDataTarget::ID_OPTION + SET_ADD);
91 new FXRadioButton(selBox,
"remove\t\tSelected objects are removed from the previous selection",
92 &mySetOperationTarget, FXDataTarget::ID_OPTION + SET_SUB);
93 new FXRadioButton(selBox,
"keep\t\tRestrict previous selection by the current selection",
94 &mySetOperationTarget, FXDataTarget::ID_OPTION + SET_RESTRICT);
95 new FXRadioButton(selBox,
"replace\t\tReplace previous selection by the current selection",
96 &mySetOperationTarget, FXDataTarget::ID_OPTION + SET_REPLACE);
99 FXGroupBox* matchBox =
new FXGroupBox(myContentFrame,
"Match Attribute",
100 GROUPBOX_NORMAL | FRAME_GROOVE | LAYOUT_FILL_X, 2, 0, 0, 0, 4, 2, 2, 2);
103 for (std::vector<SumoXMLTag>::const_iterator it = tags.begin(); it != tags.end(); it++) {
104 myMatchTagBox->appendItem(
toString(*it).c_str());
106 myMatchTagBox->setCurrentItem(1);
107 myMatchTagBox->setNumVisible(myMatchTagBox->getNumItems());
108 myMatchAttrBox =
new FXListBox(matchBox);
109 onCmdSelMBTag(0, 0, 0);
110 myMatchAttrBox->setCurrentItem(3);
111 myMatchString =
new FXTextField(matchBox, 12,
this,
MID_GNE_SELMB_STRING, TEXTFIELD_NORMAL, 0, 0, 0, 0, 4, 2, 0, 2);
112 myMatchString->setText(
">10.0");
113 new FXButton(matchBox,
"Help", 0,
this,
MID_HELP);
115 FXGroupBox* selSizeBox =
new FXGroupBox(myContentFrame,
"Visual Scaling",
116 GROUPBOX_NORMAL | FRAME_GROOVE | LAYOUT_FILL_X, 2, 0, 0, 0, 4, 2, 2, 2);
119 LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FILL_Y);
120 mySelectionScaling->setNumberFormat(1);
121 mySelectionScaling->setIncrements(0.1, .5, 1);
122 mySelectionScaling->setRange(1, 100);
123 mySelectionScaling->setValue(1);
124 mySelectionScaling->setHelpText(
"Enlarge selected objects");
130 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
131 0, 0, 0, 0, 4, 4, 3, 3);
134 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
135 0, 0, 0, 0, 4, 4, 3, 3);
137 new FXButton(myContentFrame,
"Save\t\tSave ids of currently selected objects to a file.", 0,
this,
MID_CHOOSEN_SAVE,
138 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
139 0, 0, 0, 0, 4, 4, 3, 3);
142 new FXButton(myContentFrame,
"Load\t\tLoad ids from a file according to the current modfication mode.", 0,
this,
MID_CHOOSEN_LOAD,
143 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
144 0, 0, 0, 0, 4, 4, 3, 3);
148 new FXLabel(myContentFrame,
"Hold <SHIFT> for\nrectangle selection.\nPress <DEL> to\ndelete selected items.", 0, JUSTIFY_LEFT);
159 FXFileDialog opendialog(
this,
"Open List of Selected Items");
161 opendialog.setSelectMode(SELECTFILE_EXISTING);
162 opendialog.setPatternList(
"Selection files (*.txt)\nAll files (*)");
166 if (opendialog.execute()) {
168 std::string file = opendialog.getFilename().text();
172 handleIDs(std::vector<GUIGlID>(ids.begin(), ids.end()),
false);
174 FXMessageBox::error(
this, MBOX_OK,
"Errors while loading Selection",
"%s", errors.c_str());
192 FXMessageBox::error(
this, MBOX_OK,
"Storing Selection failed",
"%s", e.what());
209 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
213 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
217 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
231 for (std::vector<std::pair <SumoXMLAttr, std::string> >::const_iterator it = attrs.begin(); it != attrs.end(); it++) {
260 char compOp = expr[0];
261 if (compOp ==
'<' || compOp ==
'>' || compOp ==
'=') {
262 expr = expr.substr(1);
267 std::istringstream buf(expr);
269 if (!buf.fail() && (int)buf.tellg() == (int)expr.size()) {
281 char compOp = expr[0];
282 if (compOp ==
'=' || compOp ==
'!' || compOp ==
'^') {
283 expr = expr.substr(1);
302 FXDialogBox* helpDialog =
new FXDialogBox(
this,
"Match Attribute Help", DECOR_CLOSE | DECOR_TITLE);
303 std::ostringstream help;
305 <<
"The 'Match Attribute' controls allow to specify a set of objects which are then applied to the current selection " 306 <<
"according to the current 'Modification Mode'.\n" 307 <<
"1. Select an object type from the first input box\n" 308 <<
"2. Select an attribute from the second input box\n" 309 <<
"3. Enter a 'match expression' in the third input box and press <return>\n" 311 <<
"The empty expression matches all objects\n" 312 <<
"For numerical attributes the match expression must consist of a comparison operator ('<', '>', '=') and a number.\n" 313 <<
"An object matches if the comparison between its attribute and the given number by the given operator evaluates to 'true'\n" 315 <<
"For string attributes the match expression must consist of a comparison operator ('', '=', '!', '^') and a string.\n" 316 <<
" '' (no operator) matches if string is a substring of that object'ts attribute.\n" 317 <<
" '=' matches if string is an exact match.\n" 318 <<
" '!' matches if string is not a substring.\n" 319 <<
" '^' matches if string is not an exact match.\n" 322 <<
"junction; id; 'foo' -> match all junctions that have 'foo' in their id\n" 323 <<
"junction; type; '=priority' -> match all junctions of type 'priority', but not of type 'priority_stop'\n" 324 <<
"edge; speed; '>10' -> match all edges with a speed above 10\n";
325 new FXLabel(helpDialog, help.str().c_str(), 0, JUSTIFY_LEFT);
327 new FXButton(helpDialog,
"OK\t\tSave modifications", 0, helpDialog, FXDialogBox::ID_ACCEPT,
328 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
329 0, 0, 0, 0, 4, 4, 3, 3);
330 helpDialog->create();
348 FXScrollWindow::show();
357 FXScrollWindow::hide();
365 return "Selection:\n" +
383 std::set<GUIGlID> previousSelection;
394 std::set<GUIGlID> idsSet(ids.begin(), ids.end());
395 std::set<GUIGlID> selected;
396 std::set<GUIGlID> deselected;
398 for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
403 const GNEEdge& edge = (
static_cast<GNELane*
>(object))->getParentEdge();
411 for (std::set<GUIGlID>::const_iterator it = idsSet.begin(); it != idsSet.end(); it++) {
422 type =
object->getType();
424 if (type ==
GLO_LANE && selectEdges) {
427 id = (
static_cast<GNELane*
>(object))->getParentEdge().getGlID();
430 switch (setOperation) {
436 deselected.insert(
id);
439 if (previousSelection.count(
id)) {
458 std::vector<GUIGlID> result;
461 for (std::set<GUIGlID>::const_iterator it = allIDs.begin(); it != allIDs.end(); it++) {
465 throw ProcessError(
"Unkown object passed to GNESelectorFrame::getMatches (id=" +
toString(
id) +
").");
468 if (ac && ac->
getTag() == tag) {
470 result.push_back(
id);
471 }
else if (numerical) {
478 result.push_back(
id);
483 result.push_back(
id);
488 result.push_back(
id);
500 if (acVal.find(expr) != std::string::npos) {
501 result.push_back(
id);
505 if (acVal.find(expr) == std::string::npos) {
506 result.push_back(
id);
511 result.push_back(
id);
516 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
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.
std::string getStats() const
get stats
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)
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 *)
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.
GNEViewParent * getViewParent() const
get the net object
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.
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
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.
selector match box messages
const std::set< GUIGlID > & getSelected() const
Returns the list of ids of all selected objects.
static const std::vector< SumoXMLTag > & allowedTags()
get all editable for tag.
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.
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)
A road/street connecting two junctions (netedit-version)
void add2Update(UpdateTarget *updateTarget)
Adds a dialog to be updated.
long onCmdInvert(FXObject *, FXSelector, void *)
Called when the user presses the Invert-button.
FXListBox * myMatchAttrBox
attributes of the match box
GNEJunction * getDest() const
returns the destination-junction
GNENet * getNet() const
get the net object
void handleIDs(std::vector< GUIGlID > ids, bool selectEdges, SetOperation setop=SET_DEFAULT)
apply list of ids to the current selection according to SetOperation,
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=OUTPUT_ACCURACY)
SumoXMLTag getTag() const
get Tag assigned to this object
void unblockObject(GUIGlID id)
Marks an object as unblocked.
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.
GUISelectedStorage gSelected
A global holder of selected objects.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
GNEJunction * getSource() const
returns the source-junction
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.