Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNESelectorFrame.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// The Widget for modifying selections of network-elements
19/****************************************************************************/
20
21#include <netedit/GNENet.h>
23#include <netedit/GNEUndoList.h>
32
33#include "GNESelectorFrame.h"
34
35// ===========================================================================
36// FOX callback mapping
37// ===========================================================================
38
42
46
55
61
62// Object implementation
63FXIMPLEMENT(GNESelectorFrame::ModificationMode, MFXGroupBoxModule, ModificationModeMap, ARRAYNUMBER(ModificationModeMap))
64FXIMPLEMENT(GNESelectorFrame::VisualScaling, MFXGroupBoxModule, VisualScalingMap, ARRAYNUMBER(VisualScalingMap))
65FXIMPLEMENT(GNESelectorFrame::SelectionOperation, MFXGroupBoxModule, SelectionOperationMap, ARRAYNUMBER(SelectionOperationMap))
66FXIMPLEMENT(GNESelectorFrame::SelectionHierarchy, MFXGroupBoxModule, SelectionHierarchyMap, ARRAYNUMBER(SelectionHierarchyMap))
67
68// ===========================================================================
69// method definitions
70// ===========================================================================
71
72// ---------------------------------------------------------------------------
73// ModificationMode::SelectionInformation - methods
74// ---------------------------------------------------------------------------
75
77 MFXGroupBoxModule(selectorFrameParent, TL("Selection information")),
78 mySelectorFrameParent(selectorFrameParent) {
79 // information label
80 myInformationLabel = new FXLabel(getCollapsableFrame(), "", nullptr, GUIDesignLabelFrameInformation);
81}
82
83
85
86
87void
89 // first clear information
90 myInformation.clear();
91 // get attribute carriers
92 const auto ACs = mySelectorFrameParent->getViewNet()->getNet()->getAttributeCarriers();
93 // continue depending of supermode
94 if (mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
95 updateInformationLabel(TL("Junctions"), ACs->getNumberOfSelectedJunctions());
96 updateInformationLabel(TL("Edges"), ACs->getNumberOfSelectedEdges());
97 updateInformationLabel(TL("Lanes"), ACs->getNumberOfSelectedLanes());
98 updateInformationLabel(TL("Connections"), ACs->getNumberOfSelectedConnections());
99 updateInformationLabel(TL("Crossings"), ACs->getNumberOfSelectedCrossings());
100 updateInformationLabel(TL("WalkingAreas"), ACs->getNumberOfSelectedWalkingAreas());
101 updateInformationLabel(TL("Additionals"), ACs->getNumberOfSelectedPureAdditionals());
102 updateInformationLabel(TL("Wires"), ACs->getNumberOfSelectedWires());
103 updateInformationLabel(TL("TAZs"), ACs->getNumberOfSelectedTAZs());
104 updateInformationLabel(TL("Polygons"), ACs->getNumberOfSelectedPolygons());
105 updateInformationLabel(TL("POIs"), ACs->getNumberOfSelectedPOIs());
106 updateInformationLabel(TL("JuPedSim elements"),
107 ACs->getNumberOfSelectedJpsWalkableAreas() +
108 ACs->getNumberOfSelectedJpsObstacles());
109 } else if (mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
110 updateInformationLabel(TL("Routes"), ACs->getNumberOfSelectedRoutes());
111 updateInformationLabel(TL("Vehicles"), ACs->getNumberOfSelectedVehicles());
112 updateInformationLabel(TL("Persons"), ACs->getNumberOfSelectedPersons());
113 updateInformationLabel(TL("Person trips"), ACs->getNumberOfSelectedPersonTrips());
114 updateInformationLabel(TL("Walks"), ACs->getNumberOfSelectedWalks());
115 updateInformationLabel(TL("Rides"), ACs->getNumberOfSelectedRides());
116 updateInformationLabel(TL("Containers"), ACs->getNumberOfSelectedContainers());
117 updateInformationLabel(TL("Transport"), ACs->getNumberOfSelectedTransport());
118 updateInformationLabel(TL("Tranships"), ACs->getNumberOfSelectedTranships());
119 updateInformationLabel(TL("Stops"), ACs->getNumberOfSelectedStops());
120 } else if (mySelectorFrameParent->getViewNet()->getEditModes().isCurrentSupermodeData()) {
121 updateInformationLabel(TL("EdgeDatas"), ACs->getNumberOfSelectedEdgeDatas());
122 updateInformationLabel(TL("EdgeRelDatas"), ACs->getNumberOfSelectedEdgeRelDatas());
123 updateInformationLabel(TL("EdgeTAZRel"), ACs->getNumberOfSelectedEdgeTAZRel());
124 }
125 // adjust format
126 const auto numberLines = std::count(myInformation.begin(), myInformation.end(), ':');
127 if (numberLines == 0) {
128 myInformation.append(" \n \n");
129 } else if (numberLines > 1) {
130 myInformation.pop_back();
131 }
132 // set label
133 myInformationLabel->setText(myInformation.c_str());
134}
135
136
137void
139 // check number
140 if (number > 0) {
141 myInformation.append(element + ": " + toString(number) + "\n");
142 }
143}
144
145// ---------------------------------------------------------------------------
146// ModificationMode::ModificationMode - methods
147// ---------------------------------------------------------------------------
148
150 MFXGroupBoxModule(selectorFrameParent, TL("Modification Mode")),
151 myModificationModeType(Operation::ADD) {
152 // Create all options buttons
153 myAddRadioButton = GUIDesigns::buildFXRadioButton(getCollapsableFrame(), TL("add"), "", TL("Selected objects are added to the previous selection"),
155 myRemoveRadioButton = GUIDesigns::buildFXRadioButton(getCollapsableFrame(), TL("remove"), "", TL("Selected objects are removed from the previous selection"),
157 myKeepRadioButton = GUIDesigns::buildFXRadioButton(getCollapsableFrame(), TL("keep"), "", TL("Restrict previous selection by the current selection"),
159 myReplaceRadioButton = GUIDesigns::buildFXRadioButton(getCollapsableFrame(), TL("replace"), "", TL("Replace previous selection by the current selection"),
161 myAddRadioButton->setCheck(true);
162}
163
164
166
167
170 return myModificationModeType;
171}
172
173
174long
176 if (obj == myAddRadioButton) {
177 myModificationModeType = Operation::ADD;
178 myAddRadioButton->setCheck(true);
179 myRemoveRadioButton->setCheck(false);
180 myKeepRadioButton->setCheck(false);
181 myReplaceRadioButton->setCheck(false);
182 return 1;
183 } else if (obj == myRemoveRadioButton) {
184 myModificationModeType = Operation::SUB;
185 myAddRadioButton->setCheck(false);
186 myRemoveRadioButton->setCheck(true);
187 myKeepRadioButton->setCheck(false);
188 myReplaceRadioButton->setCheck(false);
189 return 1;
190 } else if (obj == myKeepRadioButton) {
191 myModificationModeType = Operation::RESTRICT;
192 myAddRadioButton->setCheck(false);
193 myRemoveRadioButton->setCheck(false);
194 myKeepRadioButton->setCheck(true);
195 myReplaceRadioButton->setCheck(false);
196 return 1;
197 } else if (obj == myReplaceRadioButton) {
198 myModificationModeType = Operation::REPLACE;
199 myAddRadioButton->setCheck(false);
200 myRemoveRadioButton->setCheck(false);
201 myKeepRadioButton->setCheck(false);
202 myReplaceRadioButton->setCheck(true);
203 return 1;
204 } else {
205 return 0;
206 }
207}
208
209// ---------------------------------------------------------------------------
210// ModificationMode::VisualScaling - methods
211// ---------------------------------------------------------------------------
212
214 MFXGroupBoxModule(selectorFrameParent, TL("Visual Scaling")),
215 mySelectorFrameParent(selectorFrameParent) {
216 // Create spin button and configure it
218 //mySelectionScaling->setNumberFormat(1);
219 //mySelectionScaling->setIncrements(0.1, .5, 1);
220 mySelectionScaling->setIncrement(0.5);
221 mySelectionScaling->setRange(1, 100000);
222 mySelectionScaling->setValue(1);
223 mySelectionScaling->setHelpText(TL("Enlarge selected objects"));
224}
225
226
228
229
230long
232 // set scale in viewnet
233 mySelectorFrameParent->myViewNet->setSelectorFrameScale(mySelectionScaling->getValue());
234 mySelectorFrameParent->myViewNet->updateViewNet();
235 return 1;
236}
237
238// ---------------------------------------------------------------------------
239// ModificationMode::SelectionHierarchy - methods
240// ---------------------------------------------------------------------------
241
243 MFXGroupBoxModule(selectorFrameParent, TL("Selection operations")),
244 mySelectorFrameParent(selectorFrameParent) {
245 // tabular buttons, see GNETLSEditorFrame
246
247 FXHorizontalFrame* selectionButtons = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
248 FXVerticalFrame* col1 = new FXVerticalFrame(selectionButtons, LAYOUT_FILL_X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); // left button columm
249 FXVerticalFrame* col2 = new FXVerticalFrame(selectionButtons, LAYOUT_FILL_X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); // right button column
250
251 // Create "Clear List" Button
252 GUIDesigns::buildFXButton(col1, TL("Clear"), "", TL("Deselect all objects (hotkey: ESC)"), nullptr, this, MID_CHOOSEN_CLEAR, GUIDesignButton);
253 // Create "Invert" Button
254 GUIDesigns::buildFXButton(col2, TL("Invert"), "", TL("Invert selection status of all objects"), nullptr, this, MID_CHOOSEN_INVERT, GUIDesignButton);
255 // Create "Save" Button
256 GUIDesigns::buildFXButton(col1, TL("Save"), "", TL("Save ids of currently selected objects to a file."), nullptr, this, MID_CHOOSEN_SAVE, GUIDesignButton);
257 // Create "Load" Button
258 GUIDesigns::buildFXButton(col2, TL("Load"), "", TL("Load ids from a file according to the current modification mode."), nullptr, this, MID_CHOOSEN_LOAD, GUIDesignButton);
259 // Create "Delete" Button
260 GUIDesigns::buildFXButton(col1, TL("Delete"), "", TL("Delete all selected objects (hotkey: DEL)"), nullptr, this, MID_CHOOSEN_DELETE, GUIDesignButton);
261 // Create "reduce" Button
262 GUIDesigns::buildFXButton(col2, TL("Reduce"), "", TL("Reduce network to current selection."), nullptr, this, MID_CHOOSEN_REDUCE, GUIDesignButton);
263}
264
265
267
268
269void
271 std::vector<GNEAttributeCarrier*> loadedACs;
272 std::ifstream strm(file.c_str());
273 // check if file can be opened
274 if (!strm.good()) {
275 WRITE_ERRORF(TL("Could not open '%'."), file);
276 } else {
277 // convert all glObjects into GNEAttributeCarriers
278 std::map<const std::string, GNEAttributeCarrier*> GLFUllNameAC;
279 const auto GLObjects = GUIGlObjectStorage::gIDStorage.getAllGLObjects();
280 for (const auto& GLObject : GLObjects) {
281 // try to parse GLObject to AC
282 GNEAttributeCarrier* AC = dynamic_cast<GNEAttributeCarrier*>(GLObject);
283 // if was successfully parsed and is NOT a template, add into GLFUllNameAC using fullName
284 if (AC && !AC->isTemplate()) {
285 GLFUllNameAC[GUIGlObject::TypeNames.getString(GLObject->getType()) + ":" + AC->getID()] = AC;
286 }
287 }
288 // continue while stream exist
289 while (strm.good()) {
290 std::string line;
291 strm >> line;
292 // check if line isn't empty
293 if (line.length() != 0) {
294 // obtain AC from GLFUllNameAC
295 if (StringUtils::startsWith(line, "node:")) {
296 line = StringUtils::replace(line, "node:", "junction:");
297 }
298 GNEAttributeCarrier* AC = GLFUllNameAC.count(line) > 0 ? GLFUllNameAC.at(line) : nullptr;
299 // check if AC exist, is selectable, and isn't locked
300 if (AC && AC->getTagProperty()->isSelectable() && !mySelectorFrameParent->getViewNet()->getLockManager().isObjectLocked(AC->getGUIGlObject()->getType(), false)) {
301 // now check if we're in the correct supermode to load this element
302 if (((mySelectorFrameParent->myViewNet->getEditModes().isCurrentSupermodeNetwork()) && !AC->getTagProperty()->isDemandElement()) ||
303 ((mySelectorFrameParent->myViewNet->getEditModes().isCurrentSupermodeDemand()) && AC->getTagProperty()->isDemandElement()) ||
304 ((mySelectorFrameParent->myViewNet->getEditModes().isCurrentSupermodeData()) && AC->getTagProperty()->isDataElement())) {
305 loadedACs.push_back(AC);
306 }
307 }
308 }
309 }
310 // change selected attribute in loaded ACs allowing undo/redo
311 if (loadedACs.size() > 0) {
312 mySelectorFrameParent->myViewNet->getUndoList()->begin(GUIIcon::MODESELECT, TL("load selection"));
313 mySelectorFrameParent->handleIDs(loadedACs);
314 mySelectorFrameParent->myViewNet->getUndoList()->end();
315 }
316 }
317}
318
319
320long
322 // get the new file name
323 FXFileDialog opendialog(getCollapsableFrame(), TL("Open List of Selected Items"));
324 opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::OPEN));
325 opendialog.setSelectMode(SELECTFILE_EXISTING);
326 opendialog.setPatternList(SUMOXMLDefinitions::TXTFileExtensions.getMultilineString().c_str());
327 if (gCurrentFolder.length() != 0) {
328 opendialog.setDirectory(gCurrentFolder);
329 }
330 if (opendialog.execute()) {
331 gCurrentFolder = opendialog.getDirectory();
332 loadFromFile(opendialog.getFilename().text());
333 }
334 return 1;
335}
336
337
338long
340 FXString file = MFXUtils::getFilename2Write(this, TL("Save List of selected Items"),
341 SUMOXMLDefinitions::TXTFileExtensions.getMultilineString().c_str(),
343 if (file == "") {
344 return 1;
345 }
346 try {
347 OutputDevice& dev = OutputDevice::getDevice(file.text());
348 // get selected attribute carriers
349 const auto selectedACs = mySelectorFrameParent->myViewNet->getNet()->getAttributeCarriers()->getSelectedAttributeCarriers(false);
350 for (const auto& selectedAC : selectedACs) {
351 GUIGlObject* object = dynamic_cast<GUIGlObject*>(selectedAC);
352 if (object) {
353 dev << GUIGlObject::TypeNames.getString(object->getType()) << ":" << selectedAC->getID() << "\n";
354 }
355 }
356 dev.close();
357 } catch (IOError& e) {
358 // open message box error
359 FXMessageBox::error(getCollapsableFrame(), MBOX_OK, "Storing Selection failed", "%s", e.what());
360 }
361 return 1;
362}
363
364
365long
367 const auto& editModes = mySelectorFrameParent->myViewNet->getEditModes();
368 GNEUndoList* undoList = mySelectorFrameParent->myViewNet->getUndoList();
369 // declare massive selection
370 MassiveSelection massiveSelection =
371 editModes.isCurrentSupermodeNetwork() ? processMassiveNetworkElementSelection(false) :
372 editModes.isCurrentSupermodeDemand() ? processMassiveDemandElementSelection() :
373 processMassiveDataElementSelection();
374 // only continue if there are elements to unselect
375 if (massiveSelection.isElementToProcess()) {
376 // check if add locked elements
377 bool askedContinueIfLock = false;
378 bool addLockedElements = false;
379 bool unlockedElements = false;
380 for (const auto& ACToUnselect : massiveSelection.ACsToUnselect) {
381 if (ACToUnselect.second == false) {
382 // there are unlocked elements
383 unlockedElements = true;
384 } else if (!askedContinueIfLock) {
385 addLockedElements = askContinueIfLock();
386 // only ask one time for locking
387 askedContinueIfLock = true;
388 }
389 }
390 if (unlockedElements || addLockedElements) {
391 mySelectorFrameParent->myViewNet->getUndoList()->begin(GUIIcon::MODESELECT, TL("clear selection"));
392 for (const auto& ACToUnselect : massiveSelection.ACsToUnselect) {
393 if (addLockedElements || !ACToUnselect.second) {
394 ACToUnselect.first->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
395 }
396 }
397 mySelectorFrameParent->myViewNet->getUndoList()->end();
398 }
399 }
400 mySelectorFrameParent->myViewNet->updateViewNet();
401 return 1;
402}
403
404long
406 // acts like the 'del' hotkey
407 mySelectorFrameParent->getViewNet()->hotkeyDel();
408 return 1;
409}
410
411
412long
414 const auto& editModes = mySelectorFrameParent->myViewNet->getEditModes();
415 GNEUndoList* undoList = mySelectorFrameParent->myViewNet->getUndoList();
416 // declare massive selection
417 MassiveSelection massiveSelection =
418 editModes.isCurrentSupermodeNetwork() ? processMassiveNetworkElementSelection(true) :
419 editModes.isCurrentSupermodeDemand() ? processMassiveDemandElementSelection() :
420 processMassiveDataElementSelection();
421 // only continue if there are elements to select and unselect
422 if (massiveSelection.isElementToProcess()) {
423 // check if add locked elements
424 bool askedContinueIfLock = false;
425 bool addLockedElements = false;
426 bool unlockedElements = false;
427 for (const auto& ACToSelect : massiveSelection.ACsToSelect) {
428 if (ACToSelect.second == false) {
429 // there are unlocked elements
430 unlockedElements = true;
431 } else if (!askedContinueIfLock) {
432 addLockedElements = askContinueIfLock();
433 // only ask one time for locking
434 askedContinueIfLock = true;
435 }
436 }
437 for (const auto& ACToUnselect : massiveSelection.ACsToUnselect) {
438 if (ACToUnselect.second == false) {
439 // there are unlocked elements
440 unlockedElements = true;
441 } else if (!askedContinueIfLock) {
442 addLockedElements = askContinueIfLock();
443 // only ask one time for locking
444 askedContinueIfLock = true;
445 }
446 }
447 if (unlockedElements || addLockedElements) {
448 mySelectorFrameParent->myViewNet->getUndoList()->begin(GUIIcon::MODESELECT, TL("invert selection"));
449 for (const auto& ACToSelect : massiveSelection.ACsToSelect) {
450 if (addLockedElements || !ACToSelect.second) {
451 ACToSelect.first->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
452 }
453 }
454 for (const auto& ACToUnselect : massiveSelection.ACsToUnselect) {
455 if (addLockedElements || !ACToUnselect.second) {
456 ACToUnselect.first->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
457 }
458 }
459 mySelectorFrameParent->myViewNet->getUndoList()->end();
460 }
461 }
462 return 1;
463}
464
465
466long
468 // begin undoList operation
469 mySelectorFrameParent->getViewNet()->getUndoList()->begin(Supermode::NETWORK, GUIIcon::SIMPLIFYNETWORK, TL("reduce network"));
470 // invert and clear
471 onCmdInvert(0, 0, 0);
472 onCmdDelete(0, 0, 0);
473 // end undoList operation
474 mySelectorFrameParent->getViewNet()->getUndoList()->end();
475 return 1;
476}
477
478
481 const auto& ACs = mySelectorFrameParent->myViewNet->getNet()->getAttributeCarriers();
482 const bool selectEdges = mySelectorFrameParent->getViewNet()->getNetworkViewOptions().selectEdges();
483 // extract all network elements
484 std::unordered_set<GNEAttributeCarrier*> networkACs;
485 // add junctions
486 for (const auto& junction : ACs->getJunctions()) {
487 networkACs.insert(junction.second);
488 // due we iterate over all junctions, only it's necessary iterate over incoming edges
489 for (const auto& incomingEdge : junction.second->getGNEIncomingEdges()) {
490 if (!filterLanes || selectEdges) {
491 networkACs.insert(incomingEdge);
492 }
493 // add lanes
494 if (!filterLanes || !selectEdges) {
495 for (const auto& lane : incomingEdge->getChildLanes()) {
496 networkACs.insert(lane);
497 }
498 }
499 // add connections
500 for (const auto& connection : incomingEdge->getGNEConnections()) {
501 networkACs.insert(connection);
502 }
503 }
504 // add crossings
505 for (const auto& crossing : junction.second->getGNECrossings()) {
506 networkACs.insert(crossing);
507 }
508 // add walkingArea
509 for (const auto& walkingArea : junction.second->getGNEWalkingAreas()) {
510 networkACs.insert(walkingArea);
511 }
512 }
513 // add additionals
514 for (const auto& additionalTags : ACs->getAdditionals()) {
515 for (const auto& additional : additionalTags.second) {
516 if (additional.second->getTagProperty()->isSelectable()) {
517 networkACs.insert(additional.second);
518 }
519 }
520 }
521 // declare massive selection
522 GNESelectorFrame::SelectionOperation::MassiveSelection massiveSelection(ACs->getNumberOfNetworkElements());
523 // iterate over network ACs
524 for (const auto& networkAC : networkACs) {
525 const auto networkACObjectType = networkAC->getGUIGlObject()->getType();
526 // save locking status in lockedTypes
527 if (massiveSelection.lockedTypes.find(networkACObjectType) == massiveSelection.lockedTypes.end()) {
528 massiveSelection.lockedTypes[networkACObjectType] = networkAC->getGUIGlObject()->isGLObjectLocked();
529 }
530 // save element and their locking status
531 if (networkAC->isAttributeCarrierSelected()) {
532 massiveSelection.ACsToUnselect[networkAC] = massiveSelection.lockedTypes.at(networkACObjectType);
533 } else {
534 massiveSelection.ACsToSelect[networkAC] = massiveSelection.lockedTypes.at(networkACObjectType);
535 }
536 }
537 return massiveSelection;
538}
539
540
543 const auto& ACs = mySelectorFrameParent->myViewNet->getNet()->getAttributeCarriers();
544 // declare massive selection
545 GNESelectorFrame::SelectionOperation::MassiveSelection massiveSelection(ACs->getNumberOfDemandElements());
546 // iterate over selectable demand elements
547 for (const auto& demandElementTag : ACs->getDemandElements()) {
548 for (const auto& demandElement : demandElementTag.second) {
549 if (demandElement.second->getTagProperty()->isSelectable()) {
550 const auto networkACObjectType = demandElement.first->getType();
551 // save locking status in lockedTypes
552 if (massiveSelection.lockedTypes.find(networkACObjectType) == massiveSelection.lockedTypes.end()) {
553 massiveSelection.lockedTypes[networkACObjectType] = demandElement.first->isGLObjectLocked();
554 }
555 // save element and their locking status
556 if (demandElement.second->isAttributeCarrierSelected()) {
557 massiveSelection.ACsToUnselect[demandElement.second] = massiveSelection.lockedTypes.at(networkACObjectType);
558 } else {
559 massiveSelection.ACsToSelect[demandElement.second] = massiveSelection.lockedTypes.at(networkACObjectType);
560 }
561 }
562 }
563 }
564 return massiveSelection;
565}
566
567
570 const auto& ACs = mySelectorFrameParent->myViewNet->getNet()->getAttributeCarriers();
571 // declare massive selection
572 GNESelectorFrame::SelectionOperation::MassiveSelection massiveSelection(ACs->getNumberOfDataElements());
573 // iterate over selectable demand elements
574 for (const auto& genericDataTag : mySelectorFrameParent->myViewNet->getNet()->getAttributeCarriers()->getGenericDatas()) {
575 for (const auto& genericData : genericDataTag.second) {
576 if (genericData.second->getTagProperty()->isSelectable()) {
577 const auto networkACObjectType = genericData.first->getType();
578 // save locking status in lockedTypes
579 if (massiveSelection.lockedTypes.find(networkACObjectType) == massiveSelection.lockedTypes.end()) {
580 massiveSelection.lockedTypes[networkACObjectType] = genericData.first->isGLObjectLocked();
581 }
582 // save element and their locking status
583 if (genericData.second->isAttributeCarrierSelected()) {
584 massiveSelection.ACsToUnselect[genericData.second] = massiveSelection.lockedTypes.at(networkACObjectType);
585 } else {
586 massiveSelection.ACsToSelect[genericData.second] = massiveSelection.lockedTypes.at(networkACObjectType);
587 }
588 }
589 }
590 }
591 return massiveSelection;
592}
593
594
595bool
597 // open question box
598 const FXuint answer = FXMessageBox::question(mySelectorFrameParent->getViewNet()->getApp(),
599 MBOX_YES_NO, "Confirm selection operation", "There are locked elements in the current selection.\nApply operation to locked elements?");
600 if (answer != 1) { //1:yes, 2:no, 4:esc
601 return false;
602 } else {
603 return true;
604 }
605}
606
607// ---------------------------------------------------------------------------
608// ModificationMode::SelectionOperation::SelectionHierarchy - methods
609// ---------------------------------------------------------------------------
610
612 ACsToSelect.reserve(bucketSize);
613 ACsToUnselect.reserve(bucketSize);
614}
615
616
618
619
621 return (ACsToSelect.size() + ACsToUnselect.size()) > 0;
622}
623
624
626
627// ---------------------------------------------------------------------------
628// ModificationMode::SelectionHierarchy - methods
629// ---------------------------------------------------------------------------
630
632 MFXGroupBoxModule(selectorFrameParent, TL("Hierarchy operations")),
633 mySelectorFrameParent(selectorFrameParent),
634 myCurrentSelectedParent(Selection::ALL),
635 myCurrentSelectedChild(Selection::ALL) {
636 // create label for parents
637 new FXLabel(getCollapsableFrame(), TL("Select parents"), nullptr, GUIDesignLabelThick(JUSTIFY_NORMAL));
638 // Create MFXComboBoxIcon for parent comboBox
641 // create parent buttons
642 FXHorizontalFrame* parentButtons = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
643 // Create "select" Button
645 // Create "unselect" Button
647 // create label for parents
648 new FXLabel(getCollapsableFrame(), TL("Select children"), nullptr, GUIDesignLabelThick(JUSTIFY_NORMAL));
649 // Create MFXComboBoxIcon for parent comboBox
652 // create children buttons
653 FXHorizontalFrame* childrenButtons = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
654 // Create "select" Button
656 // Create "unselect" Button
658 // fill comboBoxes
659 for (const auto& item : myItems) {
660 myParentsComboBox->appendIconItem(item.second.c_str());
661 myChildrenComboBox->appendIconItem(item.second.c_str());
662 }
663}
664
665
667
668
669long
671 if (obj == myParentsComboBox) {
672 for (const auto& item : myItems) {
673 if (item.second == myParentsComboBox->getText().text()) {
674 // enable buttons
675 mySelectParentsButton->enable();
676 myUnselectParentsButton->enable();
677 // change text color
678 myParentsComboBox->setTextColor(FXRGB(0, 0, 0));
679 // set current selected parent
680 myCurrentSelectedParent = item.first;
681 return 1;
682 }
683 }
684 // item not found
685 myCurrentSelectedParent = Selection::NOTHING;
686 // disable buttons
687 mySelectParentsButton->disable();
688 myUnselectParentsButton->disable();
689 myParentsComboBox->setTextColor(FXRGB(255, 0, 0));
690 return 1;
691 } else if (obj == myChildrenComboBox) {
692 for (const auto& item : myItems) {
693 if (item.second == myChildrenComboBox->getText().text()) {
694 // enable buttons
695 mySelectChildrenButton->enable();
696 myUnselectChildrenButton->enable();
697 // change text color
698 myChildrenComboBox->setTextColor(FXRGB(0, 0, 0));
699 // set current selected parent
700 myCurrentSelectedChild = item.first;
701 return 1;
702 }
703 }
704 // item not found
705 myCurrentSelectedChild = Selection::NOTHING;
706 // disable buttons
707 mySelectChildrenButton->disable();
708 myUnselectChildrenButton->disable();
709 myChildrenComboBox->setTextColor(FXRGB(255, 0, 0));
710 return 1;
711 }
712 return 0;
713}
714
715
716long
717GNESelectorFrame::SelectionHierarchy::onCmdParents(FXObject* obj, FXSelector, void*) {
718 const auto viewNet = mySelectorFrameParent->getViewNet();
719 // get selected elements
720 const auto selectedACs = viewNet->getNet()->getAttributeCarriers()->getSelectedAttributeCarriers(true);
721 // check if there is selected ACs
722 if ((selectedACs.size() > 0) && (myCurrentSelectedParent != Selection::NOTHING)) {
723 // vector of of element to select or unselect
724 std::vector<GNEAttributeCarrier*> editedParents;
725 for (const auto& selectedAC : selectedACs) {
726 if (selectedAC->getTagProperty()->getTag() == SUMO_TAG_CONNECTION) {
727 const auto connection = viewNet->getNet()->getAttributeCarriers()->retrieveConnection(selectedAC->getGUIGlObject());
728 editedParents.push_back(connection->getLaneFrom());
729 editedParents.push_back(connection->getLaneTo());
730 } else if (selectedAC->getTagProperty()->getTag() == SUMO_TAG_CROSSING) {
731 const auto crossing = viewNet->getNet()->getAttributeCarriers()->retrieveCrossing(selectedAC->getGUIGlObject());
732 editedParents.push_back(crossing->getParentJunctions().front());
733 } else {
734 // get hierarchical element
735 const auto hierarchicalElement = selectedAC->getHierarchicalElement();
736 // get parent junctions
737 if ((myCurrentSelectedParent == Selection::ALL) || (myCurrentSelectedParent == Selection::JUNCTION)) {
738 editedParents.insert(editedParents.end(), hierarchicalElement->getParentJunctions().begin(), hierarchicalElement->getParentJunctions().end());
739 }
740 // get parent edges
741 if ((myCurrentSelectedParent == Selection::ALL) || (myCurrentSelectedParent == Selection::EDGE)) {
742 if (selectedAC->getTagProperty()->getTag() == SUMO_TAG_LANE) {
743 // special case for lanes
744 editedParents.push_back(dynamic_cast<GNELane*>(selectedAC)->getParentEdge());
745 } else {
746 editedParents.insert(editedParents.end(), hierarchicalElement->getParentEdges().begin(), hierarchicalElement->getParentEdges().end());
747 }
748 }
749 // get parent lanes
750 if ((myCurrentSelectedParent == Selection::ALL) || (myCurrentSelectedParent == Selection::LANE)) {
751 editedParents.insert(editedParents.end(), hierarchicalElement->getParentLanes().begin(), hierarchicalElement->getParentLanes().end());
752 }
753 // get parent additional
754 if ((myCurrentSelectedParent == Selection::ALL) || (myCurrentSelectedParent == Selection::ADDITIONAL)) {
755 editedParents.insert(editedParents.end(), hierarchicalElement->getParentAdditionals().begin(), hierarchicalElement->getParentAdditionals().end());
756 }
757 // get parent wire
758 if ((myCurrentSelectedParent == Selection::ALL) || (myCurrentSelectedParent == Selection::WIRE)) {
759 editedParents.insert(editedParents.end(), hierarchicalElement->getParentAdditionals().begin(), hierarchicalElement->getParentAdditionals().end());
760 }
761 // get parent demand
762 if ((myCurrentSelectedParent == Selection::ALL) || (myCurrentSelectedParent == Selection::DEMAND)) {
763 editedParents.insert(editedParents.end(), hierarchicalElement->getParentDemandElements().begin(), hierarchicalElement->getParentDemandElements().end());
764 }
765 // get parent data
766 if ((myCurrentSelectedParent == Selection::ALL) || (myCurrentSelectedParent == Selection::DATA)) {
767 editedParents.insert(editedParents.end(), hierarchicalElement->getParentGenericDatas().begin(), hierarchicalElement->getParentGenericDatas().end());
768 }
769 }
770 }
771 // select HE
772 if (editedParents.size() > 0) {
773 if (editedParents.size() > 1) {
774 viewNet->getUndoList()->begin(GUIIcon::SELECT, TL("select parents"));
775 }
776 for (const auto& HE : editedParents) {
777 if (obj == mySelectParentsButton) {
778 HE->setAttribute(GNE_ATTR_SELECTED, "true", viewNet->getUndoList());
779 } else {
780 HE->setAttribute(GNE_ATTR_SELECTED, "false", viewNet->getUndoList());
781 }
782 }
783 if (editedParents.size() > 1) {
784 viewNet->getUndoList()->end();
785 }
786 }
787 // update information label
788 mySelectorFrameParent->mySelectionInformation->updateInformationLabel();
789 // update viewNet
790 viewNet->update();
791 }
792 return 1;
793}
794
795
796long
798 // get selected elements
799 const auto selectedACs = mySelectorFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getSelectedAttributeCarriers(true);
800 // check if there is selected ACs
801 if ((selectedACs.size() > 0) && (myCurrentSelectedChild != Selection::NOTHING)) {
802 // vector of of element to select or unselect
803 std::vector<GNEAttributeCarrier*> editedChildren;
804 for (const auto& selectedAC : selectedACs) {
805 // get hierarchical element
806 const auto hierarchicalElement = selectedAC->getHierarchicalElement();
807 // junctions
808 if ((myCurrentSelectedChild == Selection::ALL) || (myCurrentSelectedChild == Selection::JUNCTION)) {
809 if (selectedAC->getTagProperty()->getTag() == SUMO_TAG_JUNCTION) {
810 // special case for junction
811 const auto junction = dynamic_cast<GNEJunction*>(selectedAC);
812 // insert edges
813 editedChildren.insert(editedChildren.end(), junction->getGNEIncomingEdges().begin(), junction->getGNEIncomingEdges().end());
814 editedChildren.insert(editedChildren.end(), junction->getGNEOutgoingEdges().begin(), junction->getGNEOutgoingEdges().end());
815 } else {
816 editedChildren.insert(editedChildren.end(), hierarchicalElement->getChildJunctions().begin(), hierarchicalElement->getChildJunctions().end());
817 }
818 }
819 // edges
820 if ((myCurrentSelectedChild == Selection::ALL) || (myCurrentSelectedChild == Selection::EDGE)) {
821 if (selectedAC->getTagProperty()->getTag() == SUMO_TAG_EDGE) {
822 // special case for edges
823 const auto edge = dynamic_cast<GNEEdge*>(selectedAC);
824 // insert lanes
825 editedChildren.insert(editedChildren.end(), edge->getChildLanes().begin(), edge->getChildLanes().end());
826 } else {
827 editedChildren.insert(editedChildren.end(), hierarchicalElement->getChildEdges().begin(), hierarchicalElement->getChildEdges().end());
828 }
829 }
830 // connections
831 if ((myCurrentSelectedChild == Selection::ALL) || (myCurrentSelectedChild == Selection::CONNECTION)) {
832 if (selectedAC->getTagProperty()->getTag() == SUMO_TAG_EDGE) {
833 // case for edges
834 const auto edge = dynamic_cast<GNEEdge*>(selectedAC);
835 // insert connections
836 editedChildren.insert(editedChildren.end(), edge->getGNEConnections().begin(), edge->getGNEConnections().end());
837 } else if (selectedAC->getTagProperty()->getTag() == SUMO_TAG_LANE) {
838 // case for lanes
839 const auto lane = dynamic_cast<GNELane*>(selectedAC);
840 // insert connections
841 for (const auto& connection : lane->getParentEdge()->getGNEConnections()) {
842 if (connection->getAttribute(SUMO_ATTR_FROM_LANE) == lane->getAttribute(SUMO_ATTR_INDEX)) {
843 editedChildren.push_back(connection);
844 }
845 }
846 } else if (selectedAC->getTagProperty()->getTag() == SUMO_TAG_JUNCTION) {
847 // case for junction
848 const auto junction = dynamic_cast<GNEJunction*>(selectedAC);
849 // get connections
850 const auto connections = junction->getGNEConnections();
851 // insert connections
852 editedChildren.insert(editedChildren.end(), connections.begin(), connections.end());
853 }
854 }
855 // crossings
856 if ((myCurrentSelectedChild == Selection::ALL) || (myCurrentSelectedChild == Selection::CROSSING)) {
857 if (selectedAC->getTagProperty()->getTag() == SUMO_TAG_JUNCTION) {
858 // case for junction
859 const auto junction = dynamic_cast<GNEJunction*>(selectedAC);
860 // insert crossings
861 editedChildren.insert(editedChildren.end(), junction->getGNECrossings().begin(), junction->getGNECrossings().end());
862 }
863 }
864 // lanes
865 if ((myCurrentSelectedChild == Selection::ALL) || (myCurrentSelectedChild == Selection::LANE)) {
866 editedChildren.insert(editedChildren.end(), hierarchicalElement->getChildLanes().begin(), hierarchicalElement->getChildLanes().end());
867 }
868 // additional
869 if ((myCurrentSelectedChild == Selection::ALL) || (myCurrentSelectedChild == Selection::ADDITIONAL)) {
870 // avoid insert symbols
871 for (const auto& additionalChild : hierarchicalElement->getChildAdditionals()) {
872 if (!additionalChild->getTagProperty()->isWireElement() && !additionalChild->getTagProperty()->isSymbol()) {
873 editedChildren.push_back(additionalChild);
874 }
875 }
876 }
877 // wire
878 if ((myCurrentSelectedChild == Selection::ALL) || (myCurrentSelectedChild == Selection::WIRE)) {
879 // avoid insert symbols
880 for (const auto& wireChild : hierarchicalElement->getChildAdditionals()) {
881 if (wireChild->getTagProperty()->isWireElement() && !wireChild->getTagProperty()->isSymbol()) {
882 editedChildren.push_back(wireChild);
883 }
884 }
885 }
886 // demand
887 if ((myCurrentSelectedChild == Selection::ALL) || (myCurrentSelectedChild == Selection::DEMAND)) {
888 editedChildren.insert(editedChildren.end(), hierarchicalElement->getChildDemandElements().begin(), hierarchicalElement->getChildDemandElements().end());
889 }
890 // data
891 if ((myCurrentSelectedChild == Selection::ALL) || (myCurrentSelectedChild == Selection::DATA)) {
892 editedChildren.insert(editedChildren.end(), hierarchicalElement->getChildGenericDatas().begin(), hierarchicalElement->getChildGenericDatas().end());
893 }
894 }
895 // select HE
896 if (editedChildren.size() > 0) {
897 if (editedChildren.size() > 1) {
898 mySelectorFrameParent->getViewNet()->getUndoList()->begin(GUIIcon::SELECT, TL("select children"));
899 }
900 for (const auto& HE : editedChildren) {
901 if (obj == mySelectChildrenButton) {
902 HE->setAttribute(GNE_ATTR_SELECTED, "true", mySelectorFrameParent->getViewNet()->getUndoList());
903 } else {
904 HE->setAttribute(GNE_ATTR_SELECTED, "false", mySelectorFrameParent->getViewNet()->getUndoList());
905 }
906 }
907 if (editedChildren.size() > 1) {
908 mySelectorFrameParent->getViewNet()->getUndoList()->end();
909 }
910 }
911 // update information label
912 mySelectorFrameParent->mySelectionInformation->updateInformationLabel();
913 // update viewNet
914 mySelectorFrameParent->getViewNet()->update();
915 }
916 return 1;
917}
918
919// ---------------------------------------------------------------------------
920// GNECrossingFrame::Legend - methods
921// ---------------------------------------------------------------------------
922
924 MFXGroupBoxModule(selectorFrameParent, TL("Information")) {
925 // Create Selection Hint
926 new MFXDynamicLabel(getCollapsableFrame(), (std::string("- ") + TL("Hold <SHIFT> for rectangle selection.") + std::string("\n- ") + TL("Press <DEL> to delete selected objects.")).c_str(), nullptr, GUIDesignLabelFrameInformation);
927}
928
929
931
932// ---------------------------------------------------------------------------
933// GNESelectorFrame - methods
934// ---------------------------------------------------------------------------
935
937 GNEFrame(viewParent, viewNet, TL("Selection")) {
938 // create selection information
940 // create Modification Mode modul
942 // create ElementSet modul
944 // create VisualScaling modul
945 myVisualScaling = new VisualScaling(this);
946 // create SelectionOperation modul
948 // create SelectionHierarchy modul
950 // create Information modul
951 myInformation = new Information(this);
952}
953
954
956
957
958void
961 // update information label
963 // Show frame
965}
966
967
968void
970 // hide frame
972}
973
974
975void
980
981
982void
986
987
988bool
990 // get front AC
991 auto AC = viewObjects.getAttributeCarrierFront();
992 // check AC
993 if (AC == nullptr) {
994 return false;
995 }
996 // check locking
997 if (myViewNet->getLockManager().isObjectLocked(AC->getGUIGlObject()->getType(), AC->isAttributeCarrierSelected())) {
998 return false;
999 }
1000 // check modes
1001 if ((AC->getTagProperty()->isNetworkElement() || AC->getTagProperty()->isAdditionalElement()) &&
1003 return false;
1004 }
1005 if (AC->getTagProperty()->isDemandElement() && !myViewNet->getEditModes().isCurrentSupermodeDemand()) {
1006 return false;
1007 }
1008 if (AC->getTagProperty()->isDataElement() && !myViewNet->getEditModes().isCurrentSupermodeData()) {
1009 return false;
1010 }
1011 // filter GLObjects by layer
1012 auto filteredGLObjects = GNEViewNetHelper::filterElementsByLayer(viewObjects.getGLObjects());
1013 // check if we have to open dialog
1014 if (filteredGLObjects.size() > 1) {
1015 myViewNet->openSelectDialogAtCursor(filteredGLObjects);
1016 } else {
1017 // toggle selection
1018 if (AC->isAttributeCarrierSelected()) {
1019 AC->unselectAttributeCarrier();
1020 } else {
1021 AC->selectAttributeCarrier();
1022 }
1023 // update information label
1025 }
1026 return true;
1027}
1028
1029
1030void
1031GNESelectorFrame::handleIDs(const std::vector<GNEAttributeCarrier*>& ACs, const ModificationMode::Operation setop) {
1032 // declare set operation
1034 // declare two sets of attribute carriers, one for select and another for unselect
1035 std::set<std::pair<std::string, GNEAttributeCarrier*> > ACsToSelect, ACsToUnselect;
1036 // in restrict AND replace mode all current selected attribute carriers will be unselected
1037 if ((setOperation == ModificationMode::Operation::REPLACE) || (setOperation == ModificationMode::Operation::RESTRICT)) {
1038 // obtain selected ACs depending of current supermode
1039 auto selectedACs = myViewNet->getNet()->getAttributeCarriers()->getSelectedAttributeCarriers(false);
1040 // add id into ACs to unselect
1041 for (const auto& selectedAC : selectedACs) {
1042 ACsToUnselect.insert(std::make_pair(selectedAC->getID(), selectedAC));
1043 }
1044 }
1045 // handle ids
1046 for (const auto& AC : ACs) {
1047 // iterate over AttributeCarriers an place it in ACsToSelect or ACsToUnselect
1048 switch (setOperation) {
1050 ACsToUnselect.insert(std::make_pair(AC->getID(), AC));
1051 break;
1053 if (ACsToUnselect.find(std::make_pair(AC->getID(), AC)) != ACsToUnselect.end()) {
1054 ACsToSelect.insert(std::make_pair(AC->getID(), AC));
1055 }
1056 break;
1057 default:
1058 ACsToSelect.insert(std::make_pair(AC->getID(), AC));
1059 break;
1060 }
1061 }
1062 // select junctions and their connections if Auto select junctions is enabled (note: only for "add mode")
1064 std::set<GNEEdge*> edgesToSelect;
1065 // iterate over ACsToSelect and extract edges
1066 for (const auto& AC : ACsToSelect) {
1067 if (AC.second->getTagProperty()->getTag() == SUMO_TAG_EDGE) {
1068 edgesToSelect.insert(myViewNet->getNet()->getAttributeCarriers()->retrieveEdge(AC.second->getID()));
1069 }
1070 }
1071 // iterate over extracted edges
1072 for (const auto& edgeToSelect : edgesToSelect) {
1073 // select junction source and all connections, crossings and walkingAreas
1074 ACsToSelect.insert(std::make_pair(edgeToSelect->getFromJunction()->getID(), edgeToSelect->getFromJunction()));
1075 for (const auto& connectionToSelect : edgeToSelect->getFromJunction()->getGNEConnections()) {
1076 ACsToSelect.insert(std::make_pair(connectionToSelect->getID(), connectionToSelect));
1077 }
1078 for (const auto& fromCrossingToSelect : edgeToSelect->getFromJunction()->getGNECrossings()) {
1079 ACsToSelect.insert(std::make_pair(fromCrossingToSelect->getID(), fromCrossingToSelect));
1080 }
1081 for (const auto& fromWalkingAreaToSelect : edgeToSelect->getFromJunction()->getGNEWalkingAreas()) {
1082 ACsToSelect.insert(std::make_pair(fromWalkingAreaToSelect->getID(), fromWalkingAreaToSelect));
1083 }
1084 // select junction destination and all connections, crossings and walkingAreas
1085 ACsToSelect.insert(std::make_pair(edgeToSelect->getToJunction()->getID(), edgeToSelect->getToJunction()));
1086 for (const auto& connectionToSelect : edgeToSelect->getToJunction()->getGNEConnections()) {
1087 ACsToSelect.insert(std::make_pair(connectionToSelect->getID(), connectionToSelect));
1088 }
1089 for (const auto& toCrossingToSelect : edgeToSelect->getToJunction()->getGNECrossings()) {
1090 ACsToSelect.insert(std::make_pair(toCrossingToSelect->getID(), toCrossingToSelect));
1091 }
1092 for (const auto& toWalkingAreaToSelect : edgeToSelect->getToJunction()->getGNEWalkingAreas()) {
1093 ACsToSelect.insert(std::make_pair(toWalkingAreaToSelect->getID(), toWalkingAreaToSelect));
1094 }
1095 }
1096 }
1097 // only continue if there is ACs to select or unselect
1098 if ((ACsToSelect.size() + ACsToUnselect.size()) > 0) {
1099 // first unselect AC of ACsToUnselect and then selects AC of ACsToSelect
1101 for (const auto& ACToUnselect : ACsToUnselect) {
1102 if (ACToUnselect.second->getTagProperty()->isSelectable()) {
1103 ACToUnselect.second->setAttribute(GNE_ATTR_SELECTED, "false", myViewNet->getUndoList());
1104 }
1105 }
1106 for (const auto& ACToSelect : ACsToSelect) {
1107 if (ACToSelect.second->getTagProperty()->isSelectable()) {
1108 ACToSelect.second->setAttribute(GNE_ATTR_SELECTED, "true", myViewNet->getUndoList());
1109 }
1110 }
1111 // finish operation
1113 }
1114}
1115
1116
1117FXVerticalFrame*
1121
1122
1127
1128
1133
1134
1139
1140/****************************************************************************/
FXDEFMAP(GNESelectorFrame::ModificationMode) ModificationModeMap[]
@ NETWORK
Network mode (Edges, junctions, etc..)
@ MID_GNE_SELECTORFRAME_SELECTSCALE
changes the visual scaling of selected items
@ MID_GNE_SELECTORFRAME_CHILDREN
select/unselect children
@ MID_CHOOSEN_SAVE
Save set.
Definition GUIAppEnum.h:603
@ MID_CHOOSEN_INVERT
Deselect selected items.
Definition GUIAppEnum.h:615
@ MID_CHOOSEN_DELETE
delete set
Definition GUIAppEnum.h:607
@ MID_CHOOSEN_OPERATION
set type of selection
Definition GUIAppEnum.h:597
@ MID_CHOOSEN_LOAD
Load set.
Definition GUIAppEnum.h:601
@ MID_CHOOSEN_REDUCE
simplify network reduction
Definition GUIAppEnum.h:619
@ MID_CHOOSEN_CLEAR
Clear set.
Definition GUIAppEnum.h:605
@ MID_GNE_SELECT
select element
Definition GUIAppEnum.h:957
@ MID_GNE_SELECTORFRAME_PARENTS
select/unselect parents
#define GUIDesignSpinDial
Definition GUIDesigns.h:485
#define GUIDesignButton
Definition GUIDesigns.h:82
#define GUIDesignComboBox
Definition GUIDesigns.h:293
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition GUIDesigns.h:311
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:399
#define GUIDesignComboBoxVisibleItems
Definition GUIDesigns.h:49
#define GUIDesignLabelThick(justify)
label extended over frame with thick and with text justify to left
Definition GUIDesigns.h:249
#define GUIDesignRadioButton
Definition GUIDesigns.h:229
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition GUIDesigns.h:279
FXString gCurrentFolder
The folder used as last.
@ OPEN
open icons
@ SIMPLIFYNETWORK
@ SAVE
save icons
#define WRITE_ERRORF(...)
Definition MsgHandler.h:297
#define TL(string)
Definition MsgHandler.h:305
@ SUMO_TAG_CONNECTION
connectioon between two lanes
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_CROSSING
crossing between edges for pedestrians
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_FROM_LANE
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_INDEX
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isTemplate() const
check if this AC is template
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
virtual GUIGlObject * getGUIGlObject()=0
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
GNEViewNet * myViewNet
FOX need this.
Definition GNEFrame.h:121
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
Definition GNEFrame.h:124
virtual void show()
show Frame
Definition GNEFrame.cpp:119
virtual void hide()
hide Frame
Definition GNEFrame.cpp:128
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:202
void showMatchAttribute()
show match attributes
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
std::vector< GNEAttributeCarrier * > getSelectedAttributeCarriers(const bool ignoreCurrentSupermode)
get all selected attribute carriers (or only relative to current supermode
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:146
Information(GNESelectorFrame *selectorFrameParent)
constructor
FXRadioButton * myReplaceRadioButton
replace radio button
ModificationMode(GNESelectorFrame *selectorFrameParent)
constructor
long onCmdSelectModificationMode(FXObject *, FXSelector, void *)
FXRadioButton * myAddRadioButton
FOX need this.
Operation getModificationMode() const
get current modification mode
FXRadioButton * myRemoveRadioButton
remove radio button
FXRadioButton * myKeepRadioButton
keep button
SelectionHierarchy(GNESelectorFrame *selectorFrameParent)
FOX-declaration.
MFXComboBoxIcon * myChildrenComboBox
comboBox for children
FXButton * myUnselectParentsButton
unselect parents button
FXButton * mySelectParentsButton
select parents button
FXButton * myUnselectChildrenButton
unselect parents button
long onCmdParents(FXObject *obj, FXSelector, void *)
called when user press select/unselect parents button
long onCmdChildren(FXObject *obj, FXSelector, void *)
called when user press select/unselect children button
long onCmdSelectItem(FXObject *obj, FXSelector, void *)
called when user select an item in comboBox
MFXComboBoxIcon * myParentsComboBox
comboBox for parents
const std::vector< std::pair< Selection, std::string > > myItems
FXButton * mySelectChildrenButton
select children button
void updateInformationLabel()
update information label
SelectionOperation(GNESelectorFrame *selectorFrameParent)
FOX-declaration.
long onCmdSave(FXObject *, FXSelector, void *)
Called when the user presses the Save-button.
MassiveSelection processMassiveNetworkElementSelection(const bool filterLanes) const
process massive network element selection
bool askContinueIfLock() const
ask if continue due locking
long onCmdDelete(FXObject *, FXSelector, void *)
Called when the user presses the delete-button.
long onCmdReduce(FXObject *, FXSelector, void *)
Called when the user presses the Reduce-button.
long onCmdInvert(FXObject *, FXSelector, void *)
Called when the user presses the Invert-button.
long onCmdClear(FXObject *, FXSelector, void *)
Called when the user presses the Clear-button.
long onCmdLoad(FXObject *, FXSelector, void *)
Called when the user presses the Load-button.
void loadFromFile(const std::string &file) const
load from file
MassiveSelection processMassiveDataElementSelection() const
process massive dataelement selection
MassiveSelection processMassiveDemandElementSelection() const
process massive demand element selection
long onCmdScaleSelection(FXObject *, FXSelector, void *)
Called when the user changes visual scaling.
VisualScaling(GNESelectorFrame *selectorFrameParent)
FOX-declaration.
FXRealSpinner * mySelectionScaling
Spinner for selection scaling.
FXVerticalFrame * getContentFrame() const
get vertical frame that holds all widgets of frame
void updateFrameAfterUndoRedo()
function called after undo/redo in the current frame
ModificationMode * getModificationModeModul() const
get modification mode modul
void show()
show Frame
GNESelectorFrame::SelectionOperation * mySelectionOperation
modul for selection operations
~GNESelectorFrame()
Destructor.
GNESelectorFrame::SelectionInformation * mySelectionInformation
modul for selection information
GNESelectorFrame::VisualScaling * myVisualScaling
modul for visual scaling
GNESelectorFrame::Information * myInformation
information modul
GNESelectorFrame::SelectionHierarchy * mySelectionHierarchy
modul for selection hierarchy
GNESelectorFrame::ModificationMode * myModificationMode
modul for change modification mode
GNEMatchAttribute * myMatchAttribute
modul for match attribute
void clearCurrentSelection() const
clear current selection with possibility of undo/redo
void hide()
hide Frame
GNESelectorFrame::SelectionOperation * getSelectionOperationModul() const
get selection operation modul
void handleIDs(const std::vector< GNEAttributeCarrier * > &ACs, const ModificationMode::Operation setop=ModificationMode::Operation::DEFAULT)
apply list of ids to the current selection according to Operation,
GNESelectorFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
SelectionInformation * getSelectionInformation() const
get modul for selection information
bool selectAttributeCarrier(const GNEViewNetHelper::ViewObjectsSelector &viewObjects)
select attribute carrier (element)
bool isDataElement() const
return true if tag correspond to a data element
bool isSelectable() const
return true if tag correspond to a selectable element
bool isDemandElement() const
return true if tag correspond to a demand element
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
bool isObjectLocked(GUIGlObjectType objectType, const bool selected) const
check if given GLObject is locked for inspect, select, delete and move
class used to group all variables related with objects under cursor after a click over view
GNEAttributeCarrier * getAttributeCarrierFront() const
get front attribute carrier or a pointer to nullptr
const std::vector< GUIGlObject * > & getGLObjects() const
get vector with GL objects
GNENet * getNet() const
get the net object
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
void openSelectDialogAtCursor(const std::vector< GUIGlObject * > &GLObjects)
open select dialog at cursor
bool autoSelectNodes()
whether to autoselect nodes or to lanes
GNEUndoList * getUndoList() const
get the undoList object
GNEViewNetHelper::LockManager & getLockManager()
get lock manager
A single child window which contains a view of the simulation area.
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
static FXRadioButton * buildFXRadioButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXObject *tgt, FXSelector sel, FXuint opts=RADIOBUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build radio button
static StringBijection< GUIGlObjectType > TypeNames
associates object types with strings
Definition GUIGlObject.h:72
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
const std::vector< GUIGlObject * > & getAllGLObjects() const
Returns the set of all known objects.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon item in the last position
A list item which allows for custom coloring.
MFXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
void setText(const std::string &text)
set text
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extensions, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition MFXUtils.cpp:116
Static storage of an output device and its base (abstract) implementation.
void close()
Closes the device and removes it from the dictionary.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
static StringBijection< TXTFileExtension > TXTFileExtensions
TXT file Extensions.
const std::string & getString(const T key) const
get string
static std::string replace(std::string str, const std::string &what, const std::string &by)
Replaces all occurrences of the second string by the third string within the first string.
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
std::unordered_map< GNEAttributeCarrier *, bool > ACsToSelect
ACs to select (the bool flag shows if element is locked)
std::map< GUIGlObjectType, bool > lockedTypes
locked types
std::unordered_map< GNEAttributeCarrier *, bool > ACsToUnselect
ACs to select (the bool flag shows if element is locked)
bool isElementToProcess() const
check if there are element to process
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeData() const
@check if current supermode is Data
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static std::vector< GUIGlObject * > filterElementsByLayer(const std::vector< GUIGlObject * > &GLObjects)
filter elements based on the layer