Eclipse SUMO - Simulation of Urban MObility
GNEFixDemandElements.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 // Dialog used to fix demand elements during saving
19 /****************************************************************************/
20 #include <config.h>
21 
24 #include <netedit/GNENet.h>
25 #include <netedit/GNEViewNet.h>
26 #include <netedit/GNEUndoList.h>
27 
28 #include "GNEFixDemandElements.h"
29 
30 
31 // ===========================================================================
32 // FOX callback mapping
33 // ===========================================================================
34 
35 FXDEFMAP(GNEFixDemandElements) GNEFixDemandElementsMap[] = {
39 };
40 
41 // Object implementation
42 FXIMPLEMENT(GNEFixDemandElements, FXDialogBox, GNEFixDemandElementsMap, ARRAYNUMBER(GNEFixDemandElementsMap))
43 
44 // ===========================================================================
45 // member method definitions
46 // ===========================================================================
47 
48 // ---------------------------------------------------------------------------
49 // GNEFixDemandElements - methods
50 // ---------------------------------------------------------------------------
51 
52 GNEFixDemandElements::GNEFixDemandElements(GNEViewNet* viewNet, const std::vector<GNEDemandElement*>& invalidDemandElements) :
53  FXDialogBox(viewNet->getApp(), "Fix demand elements problems", GUIDesignDialogBoxExplicit(800, 620)),
54  myViewNet(viewNet) {
55  // set busStop icon for this dialog
57  // create main frame
58  myMainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
59  // create frames for options
60  FXHorizontalFrame* optionsFrame = new FXHorizontalFrame(myMainFrame, GUIDesignAuxiliarFrame);
61  myLeftFrame = new FXVerticalFrame(optionsFrame, GUIDesignAuxiliarFrame);
62  myRightFrame = new FXVerticalFrame(optionsFrame, GUIDesignAuxiliarFrame);
63  // create fix route options
64  myFixRouteOptions = new FixRouteOptions(this, viewNet);
65  // create fix vehicle options
66  myFixVehicleOptions = new FixVehicleOptions(this, viewNet);
67  // create fix stops options
68  myFixStopPositionOptions = new FixStopPositionOptions(this, viewNet);
69  // create fix person plans options
70  myFixPersonPlanOptions = new FixPersonPlanOptions(this, viewNet);
71  // create buttons
72  myButtons = new Buttons(this);
73  // split invalidDemandElements in four groups
74  std::vector<GNEDemandElement*> invalidRoutes, invalidVehicles, invalidStops, invalidPlans;
75  // fill groups
76  for (const auto& invalidDemandElement : invalidDemandElements) {
77  if (invalidDemandElement->getTagProperty().isRoute()) {
78  invalidRoutes.push_back(invalidDemandElement);
79  } else if (invalidDemandElement->getTagProperty().isVehicle()) {
80  invalidVehicles.push_back(invalidDemandElement);
81  } else if (invalidDemandElement->getTagProperty().isStop()) {
82  invalidStops.push_back(invalidDemandElement);
83  } else {
84  invalidPlans.push_back(invalidDemandElement);
85  }
86  }
87  // fill options
88  myFixRouteOptions->setInvalidElements(invalidRoutes);
89  myFixVehicleOptions->setInvalidElements(invalidVehicles);
90  myFixStopPositionOptions->setInvalidElements(invalidStops);
91  myFixPersonPlanOptions->setInvalidElements(invalidPlans);
92 }
93 
94 
96 }
97 
98 
99 long
100 GNEFixDemandElements::onCmdSelectOption(FXObject* obj, FXSelector, void*) {
101  // select options
106  return 1;
107 }
108 
109 
110 long
111 GNEFixDemandElements::onCmdAccept(FXObject*, FXSelector, void*) {
112  bool abortSaving = false;
113  // fix elements
114  myFixRouteOptions->fixElements(abortSaving);
115  myFixVehicleOptions->fixElements(abortSaving);
117  myFixPersonPlanOptions->fixElements(abortSaving);
118  // check if abort saving
119  if (abortSaving) {
120  // stop modal with TRUE (abort saving)
121  getApp()->stopModal(this, FALSE);
122  } else {
123  // stop modal with TRUE (continue saving)
124  getApp()->stopModal(this, TRUE);
125  }
126  return 1;
127 }
128 
129 
130 long
131 GNEFixDemandElements::onCmdCancel(FXObject*, FXSelector, void*) {
132  // Stop Modal (abort saving)
133  getApp()->stopModal(this, FALSE);
134  return 1;
135 }
136 
137 // ---------------------------------------------------------------------------
138 // GNEFixDemandElements::FixOptions - methods
139 // ---------------------------------------------------------------------------
140 
141 GNEFixDemandElements::FixOptions::FixOptions(FXVerticalFrame* frameParent, const std::string& title, GNEViewNet* viewNet) :
142  FXGroupBoxModule(frameParent, title, FXGroupBoxModule::Options::SAVE),
143  myViewNet(viewNet) {
144  // Create table
145  myTable = new FXTable(this, this, MID_TABLE, GUIDesignTableFixElements);
146  // create horizontal frame
147  FXHorizontalFrame* horizontalFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
148  // create vertical frames
149  myLeftFrame = new FXVerticalFrame(horizontalFrame, GUIDesignAuxiliarVerticalFrame);
150  myRightFrame = new FXVerticalFrame(horizontalFrame, GUIDesignAuxiliarVerticalFrame);
151 }
152 
153 
154 void
155 GNEFixDemandElements::FixOptions::setInvalidElements(const std::vector<GNEDemandElement*>& invalidElements) {
156  // update invalid elements
157  myInvalidElements = invalidElements;
158  // configure table
159  myTable->setTableSize((int)(myInvalidElements.size()), 3);
160  myTable->setSelBackColor(FXRGBA(255, 255, 255, 255));
161  myTable->setSelTextColor(FXRGBA(0, 0, 0, 255));
162  myTable->setEditable(false);
163  // configure header
164  myTable->setVisibleColumns(4);
165  myTable->setColumnWidth(0, GUIDesignHeight);
166  myTable->setColumnWidth(1, 150);
167  myTable->setColumnWidth(2, 200);
168  myTable->setColumnText(0, "");
169  myTable->setColumnText(1, toString(SUMO_ATTR_ID).c_str());
170  myTable->setColumnText(2, "Conflict");
171  myTable->getRowHeader()->setWidth(0);
172  // Declare pointer to FXTableItem
173  FXTableItem* item = nullptr;
174  // iterate over invalid routes
175  for (int i = 0; i < (int)myInvalidElements.size(); i++) {
176  // Set icon
177  item = new FXTableItem("", myInvalidElements.at(i)->getIcon());
178  item->setIconPosition(FXTableItem::CENTER_X);
179  myTable->setItem(i, 0, item);
180  // Set ID
181  item = new FXTableItem(myInvalidElements.at(i)->getID().c_str());
182  item->setJustify(FXTableItem::LEFT | FXTableItem::CENTER_Y);
183  myTable->setItem(i, 1, item);
184  // Set conflict
185  item = new FXTableItem(myInvalidElements.at(i)->getDemandElementProblem().c_str());
186  item->setJustify(FXTableItem::LEFT | FXTableItem::CENTER_Y);
187  myTable->setItem(i, 2, item);
188  }
189  // check if enable or disable options
190  if (invalidElements.size() > 0) {
191  enableOptions();
192  toogleSaveButton(true);
193  } else {
194  disableOptions();
195  toogleSaveButton(false);
196  }
197 }
198 
199 bool
201  const FXString file = MFXUtils::getFilename2Write(myTable,
202  "Save list of conflicted items", ".txt",
204  if (file == "") {
205  return false;
206  }
207  try {
208  // open output device
209  OutputDevice& dev = OutputDevice::getDevice(file.text());
210  // get invalid element ID and problem
211  for (const auto& invalidElement : myInvalidElements) {
212  dev << invalidElement->getID() << ":" << invalidElement->getDemandElementProblem() << "\n";
213  }
214  // close output device
215  dev.close();
216  // write warning if netedit is running in testing mode
217  WRITE_DEBUG("Opening FXMessageBox 'Saving list of conflicted items sucesfully'");
218  // open message box error
219  FXMessageBox::information(myTable, MBOX_OK, "Saving sucesfully", "%s", "List of conflicted items was sucesfully saved");
220  // write warning if netedit is running in testing mode
221  WRITE_DEBUG("Closed FXMessageBox 'Saving list of conflicted items sucesfully' with 'OK'");
222  } catch (IOError& e) {
223  // write warning if netedit is running in testing mode
224  WRITE_DEBUG("Opening FXMessageBox 'error saving list of conflicted items'");
225  // open message box error
226  FXMessageBox::error(myTable, MBOX_OK, "Saving list of conflicted items failed", "%s", e.what());
227  // write warning if netedit is running in testing mode
228  WRITE_DEBUG("Closed FXMessageBox 'error saving list of conflicted items' with 'OK'");
229  }
230  return true;
231 }
232 
233 // ---------------------------------------------------------------------------
234 // GNEFixDemandElements::FixRouteOptions - methods
235 // ---------------------------------------------------------------------------
236 
238  FixOptions(fixDemandElementsParent->myLeftFrame, "Routes", viewNet) {
239  // Remove invalid routes
240  removeInvalidRoutes = new FXRadioButton(myLeftFrame, "Remove invalid routes",
241  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
242  // Save invalid routes
243  saveInvalidRoutes = new FXRadioButton(myLeftFrame, "Save invalid routes",
244  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
245  // Select invalid routes
246  selectInvalidRoutesAndCancel = new FXRadioButton(myRightFrame, "Select conflicted routes",
247  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
248  // Remove stops out of route
249  removeStopsOutOfRoute = new FXCheckButton(myRightFrame, "Remove stops out of route",
250  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignCheckButtonFix);
251  // leave option "removeInvalidRoutes" as default
252  removeInvalidRoutes->setCheck(true);
253  // ... and remove stops out of route
254  removeStopsOutOfRoute->setCheck(TRUE);
255 }
256 
257 
258 void
260  if (option == removeInvalidRoutes) {
261  removeInvalidRoutes->setCheck(true);
262  saveInvalidRoutes->setCheck(false);
263  selectInvalidRoutesAndCancel->setCheck(false);
264  } else if (option == saveInvalidRoutes) {
265  removeInvalidRoutes->setCheck(false);
266  saveInvalidRoutes->setCheck(true);
267  selectInvalidRoutesAndCancel->setCheck(false);
268  } else if (option == selectInvalidRoutesAndCancel) {
269  removeInvalidRoutes->setCheck(false);
270  saveInvalidRoutes->setCheck(false);
271  selectInvalidRoutesAndCancel->setCheck(true);
272  }
273 }
274 
275 
276 void
278  if (myInvalidElements.size() > 0) {
279  if (removeInvalidRoutes->getCheck() == TRUE) {
280  // begin undo list
281  myViewNet->getUndoList()->begin(GUIIcon::ROUTE, "delete invalid routes");
282  // iterate over invalid routes to delete it
283  for (const auto& invalidRoute : myInvalidElements) {
285  }
286  // end undo list
287  myViewNet->getUndoList()->end();
288  } else if (selectInvalidRoutesAndCancel->getCheck() == TRUE) {
289  // begin undo list
290  myViewNet->getUndoList()->begin(GUIIcon::ROUTE, "select invalid routes");
291  // iterate over invalid single lane elements to select all elements
292  for (const auto& invalidRoute : myInvalidElements) {
293  invalidRoute->setAttribute(GNE_ATTR_SELECTED, "true", myViewNet->getUndoList());
294  }
295  // end undo list
296  myViewNet->getUndoList()->end();
297  // abort saving
298  abortSaving = true;
299  }
300  // check if remove stops
301  if (removeStopsOutOfRoute->getCheck() == TRUE) {
302  // get all stops to remove
303  std::vector<GNEDemandElement*> stopsToRemove;
304  for (const auto& invalidRoute : myInvalidElements) {
305  const auto invaldstops = invalidRoute->getInvalidStops();
306  // append to stopsToRemove
307  stopsToRemove.insert(stopsToRemove.end(), invaldstops.begin(), invaldstops.end());
308  }
309  // begin undo list
310  myViewNet->getUndoList()->begin(GUIIcon::ROUTE, "delete invalid stops");
311  // remove all
312  for (const auto& stopToRemove : stopsToRemove) {
314  }
315  // end undo list
316  myViewNet->getUndoList()->end();
317  }
318  }
319 }
320 
321 
322 void
324  removeInvalidRoutes->enable();
325  saveInvalidRoutes->enable();
326  selectInvalidRoutesAndCancel->enable();
327  removeStopsOutOfRoute->enable();
328 }
329 
330 
331 void
333  removeInvalidRoutes->disable();
334  saveInvalidRoutes->disable();
335  selectInvalidRoutesAndCancel->disable();
336  removeStopsOutOfRoute->disable();
337 }
338 
339 // ---------------------------------------------------------------------------
340 // GNEFixDemandElements::FixVehicleOptions - methods
341 // ---------------------------------------------------------------------------
342 
344  FixOptions(fixDemandElementsParent->myLeftFrame, "Vehicles", viewNet) {
345  // Remove invalid vehicles
346  removeInvalidVehicles = new FXRadioButton(myLeftFrame, "Remove invalid vehicles",
347  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
348  // Save invalid vehicles
349  saveInvalidVehicles = new FXRadioButton(myLeftFrame, "Save invalid vehicles",
350  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
351  // Select invalid vehicle
352  selectInvalidVehiclesAndCancel = new FXRadioButton(myRightFrame, "Select conflicted vehicle",
353  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
354  // Remove stops out of route
355  removeStopsOutOfVehicle = new FXCheckButton(myRightFrame, "Remove stops out of vehicle's route",
356  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignCheckButtonFix);
357  // by default remove invalid vehicles
358  removeInvalidVehicles->setCheck(TRUE);
359  // ... and remove stops out of route
360  removeStopsOutOfVehicle->setCheck(TRUE);
361 }
362 
363 
364 void
366  if (option == removeInvalidVehicles) {
367  removeInvalidVehicles->setCheck(true);
368  saveInvalidVehicles->setCheck(false);
369  selectInvalidVehiclesAndCancel->setCheck(false);
370  } else if (option == saveInvalidVehicles) {
371  removeInvalidVehicles->setCheck(false);
372  saveInvalidVehicles->setCheck(true);
373  selectInvalidVehiclesAndCancel->setCheck(false);
374  } else if (option == selectInvalidVehiclesAndCancel) {
375  removeInvalidVehicles->setCheck(false);
376  saveInvalidVehicles->setCheck(false);
377  selectInvalidVehiclesAndCancel->setCheck(true);
378  }
379 }
380 
381 
382 void
384  if (myInvalidElements.size() > 0) {
385  if (removeInvalidVehicles->getCheck() == TRUE) {
386  // begin undo list
387  myViewNet->getUndoList()->begin(GUIIcon::ROUTE, "delete invalid routes");
388  // iterate over invalid routes to delete it
389  for (const auto& invalidVehicle : myInvalidElements) {
390  myViewNet->getNet()->deleteDemandElement(invalidVehicle, myViewNet->getUndoList());
391  }
392  // end undo list
393  myViewNet->getUndoList()->end();
394  } else if (selectInvalidVehiclesAndCancel->getCheck() == TRUE) {
395  // begin undo list
396  myViewNet->getUndoList()->begin(GUIIcon::ROUTE, "select invalid routes");
397  // iterate over invalid single lane elements to select all elements
398  for (const auto& invalidVehicle : myInvalidElements) {
399  invalidVehicle->setAttribute(GNE_ATTR_SELECTED, "true", myViewNet->getUndoList());
400  }
401  // end undo list
402  myViewNet->getUndoList()->end();
403  // abort saving
404  abortSaving = true;
405  }
406  // check if remove stops
407  if (removeStopsOutOfVehicle->getCheck() == TRUE) {
408  // get all stops to remove
409  std::vector<GNEDemandElement*> stopsToRemove;
410  for (const auto& invalidVehicle : myInvalidElements) {
411  const auto invaldstops = invalidVehicle->getInvalidStops();
412  // append to stopsToRemove
413  stopsToRemove.insert(stopsToRemove.end(), invaldstops.begin(), invaldstops.end());
414  }
415  // begin undo list
416  myViewNet->getUndoList()->begin(GUIIcon::ROUTE, "delete invalid stops");
417  // remove all
418  for (const auto& stopToRemove : stopsToRemove) {
420  }
421  // end undo list
422  myViewNet->getUndoList()->end();
423  }
424  }
425 }
426 
427 
428 void
430  removeInvalidVehicles->enable();
431  saveInvalidVehicles->enable();
432  selectInvalidVehiclesAndCancel->enable();
433  removeStopsOutOfVehicle->enable();
434 }
435 
436 
437 void
439  removeInvalidVehicles->disable();
440  saveInvalidVehicles->disable();
441  selectInvalidVehiclesAndCancel->disable();
442  removeStopsOutOfVehicle->disable();
443 }
444 
445 // ---------------------------------------------------------------------------
446 // GNEFixDemandElements::FixStopPositionOptions - methods
447 // ---------------------------------------------------------------------------
448 
450  FixOptions(fixDemandElementsParent->myRightFrame, "Stop positions", viewNet) {
451  // Activate friendlyPos and save
452  activateFriendlyPositionAndSave = new FXRadioButton(myLeftFrame, "Activate friendlyPos and save",
453  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
454  // Save invalid position
455  saveInvalid = new FXRadioButton(myLeftFrame, "Save invalid positions",
456  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
457  // Select invalid Stops
458  selectInvalidStopsAndCancel = new FXRadioButton(myRightFrame, "Select conflicted Stops",
459  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
460  // Fix positions and save
461  fixPositionsAndSave = new FXRadioButton(myRightFrame, "Fix positions and save",
462  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
463  // leave option "activateFriendlyPositionAndSave" as default
464  activateFriendlyPositionAndSave->setCheck(true);
465 }
466 
467 
468 void
470  if (option == activateFriendlyPositionAndSave) {
471  activateFriendlyPositionAndSave->setCheck(true);
472  fixPositionsAndSave->setCheck(false);
473  saveInvalid->setCheck(false);
474  selectInvalidStopsAndCancel->setCheck(false);
475  } else if (option == fixPositionsAndSave) {
476  activateFriendlyPositionAndSave->setCheck(false);
477  fixPositionsAndSave->setCheck(true);
478  saveInvalid->setCheck(false);
479  selectInvalidStopsAndCancel->setCheck(false);
480  } else if (option == saveInvalid) {
481  activateFriendlyPositionAndSave->setCheck(false);
482  fixPositionsAndSave->setCheck(false);
483  saveInvalid->setCheck(true);
484  selectInvalidStopsAndCancel->setCheck(false);
485  } else if (option == selectInvalidStopsAndCancel) {
486  activateFriendlyPositionAndSave->setCheck(false);
487  fixPositionsAndSave->setCheck(false);
488  saveInvalid->setCheck(false);
489  selectInvalidStopsAndCancel->setCheck(true);
490  }
491 }
492 
493 
494 void
496  // check options for stops
497  if (myInvalidElements.size() > 0) {
498  if (activateFriendlyPositionAndSave->getCheck() == TRUE) {
499  // begin undo list
500  myViewNet->getUndoList()->begin(GUIIcon::STOP, "change " + toString(SUMO_ATTR_FRIENDLY_POS) + " of invalid stops");
501  // iterate over invalid stops to enable friendly position
502  for (const auto& stop : myInvalidElements) {
503  stop->setAttribute(SUMO_ATTR_FRIENDLY_POS, "true", myViewNet->getUndoList());
504  }
505  myViewNet->getUndoList()->end();
506  } else if (fixPositionsAndSave->getCheck() == TRUE) {
507  myViewNet->getUndoList()->begin(GUIIcon::STOP, "fix positions of invalid stops");
508  // iterate over invalid stops to fix positions
509  for (const auto& stop : myInvalidElements) {
510  stop->fixDemandElementProblem();
511  }
512  myViewNet->getUndoList()->end();
513  } else if (selectInvalidStopsAndCancel->getCheck() == TRUE) {
514  myViewNet->getUndoList()->begin(GUIIcon::STOP, "select invalid stops");
515  // iterate over invalid stops to select all elements
516  for (const auto& stop : myInvalidElements) {
517  stop->setAttribute(GNE_ATTR_SELECTED, "true", myViewNet->getUndoList());
518  }
519  // end undo list
520  myViewNet->getUndoList()->end();
521  // abort saving
522  abortSaving = true;
523  }
524  }
525 }
526 
527 
528 void
530  activateFriendlyPositionAndSave->enable();
531  fixPositionsAndSave->enable();
532  saveInvalid->enable();
533  selectInvalidStopsAndCancel->enable();
534 }
535 
536 
537 void
539  activateFriendlyPositionAndSave->disable();
540  fixPositionsAndSave->disable();
541  saveInvalid->disable();
542  selectInvalidStopsAndCancel->disable();
543 }
544 
545 // ---------------------------------------------------------------------------
546 // GNEFixDemandElements::FixPersonPlanOptions - methods
547 // ---------------------------------------------------------------------------
548 
550  FixOptions(fixDemandElementsParent->myRightFrame, "Person/container plans", viewNet) {
551  // Delete person plan
552  deletePersonPlan = new FXRadioButton(myLeftFrame, "Delete person plan",
553  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
554  // Save invalid person plans
555  saveInvalid = new FXRadioButton(myLeftFrame, "Save invalid person plans",
556  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
557  // Select invalid person plans
558  selectInvalidPersonPlansAndCancel = new FXRadioButton(myRightFrame, "Select conflicted person plans",
559  fixDemandElementsParent, MID_CHOOSEN_OPERATION, GUIDesignRadioButtonFix);
560  // leave option "activateFriendlyPositionAndSave" as default
561  deletePersonPlan->setCheck(true);
562 }
563 
564 
565 void
567  if (option == deletePersonPlan) {
568  deletePersonPlan->setCheck(true);
569  saveInvalid->setCheck(false);
570  selectInvalidPersonPlansAndCancel->setCheck(false);
571  selectInvalidPersonPlansAndCancel->setCheck(false);
572  } else if (option == saveInvalid) {
573  deletePersonPlan->setCheck(false);
574  saveInvalid->setCheck(true);
575  selectInvalidPersonPlansAndCancel->setCheck(false);
576  } else if (option == selectInvalidPersonPlansAndCancel) {
577  deletePersonPlan->setCheck(false);
578  saveInvalid->setCheck(false);
579  selectInvalidPersonPlansAndCancel->setCheck(true);
580  }
581 }
582 
583 
584 void
586  // check options for person plans
587  if (myInvalidElements.size() > 0) {
588  if (deletePersonPlan->getCheck() == TRUE) {
589  // begin undo list
590  myViewNet->getUndoList()->begin(GUIIcon::MODEPERSONPLAN, "delete invalid person plans");
591  // remove all invalid person plans
592  for (const auto& personPlan : myInvalidElements) {
594  }
595  myViewNet->getUndoList()->end();
596  } else if (selectInvalidPersonPlansAndCancel->getCheck() == TRUE) {
597  myViewNet->getUndoList()->begin(GUIIcon::MODEPERSONPLAN, "select invalid person plans");
598  // iterate over invalid person plans to select all elements
599  for (const auto& personPlan : myInvalidElements) {
600  personPlan->setAttribute(GNE_ATTR_SELECTED, "true", myViewNet->getUndoList());
601  }
602  // end undo list
603  myViewNet->getUndoList()->end();
604  // abort saving
605  abortSaving = false;
606  }
607  }
608 }
609 
610 
611 void
613  deletePersonPlan->enable();
614  saveInvalid->enable();
615  selectInvalidPersonPlansAndCancel->enable();
616 }
617 
618 
619 void
621  deletePersonPlan->disable();
622  saveInvalid->disable();
623  selectInvalidPersonPlansAndCancel->disable();
624 }
625 
626 // ---------------------------------------------------------------------------
627 // GNEFixDemandElements::Buttons - methods
628 // ---------------------------------------------------------------------------
629 
631  FXHorizontalFrame(fixDemandElementsParent->myMainFrame, GUIDesignHorizontalFrame) {
632  new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
633  myAcceptButton = new FXButton(this, FXWindow::tr("&Accept"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), fixDemandElementsParent, MID_GNE_BUTTON_ACCEPT, GUIDesignButtonAccept);
634  myCancelButton = new FXButton(this, FXWindow::tr("&Cancel"), GUIIconSubSys::getIcon(GUIIcon::CANCEL), fixDemandElementsParent, MID_GNE_BUTTON_CANCEL, GUIDesignButtonCancel);
635  new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
636  // set focus in accept button
637  myAcceptButton->setFocus();
638 }
639 
640 /****************************************************************************/
FXDEFMAP(GNEFixDemandElements) GNEFixDemandElementsMap[]
@ MID_GNE_BUTTON_CANCEL
cancel button
Definition: GUIAppEnum.h:1193
@ MID_TABLE
The Table.
Definition: GUIAppEnum.h:493
@ MID_CHOOSEN_OPERATION
set type of selection
Definition: GUIAppEnum.h:551
@ MID_GNE_BUTTON_ACCEPT
accept button
Definition: GUIAppEnum.h:1191
#define GUIDesignDialogBoxExplicit(width, height)
design for dialog box with specift width and height (for example, additional dialogs)
Definition: GUIDesigns.h:539
#define GUIDesignRadioButtonFix
design for radio button with fixed height (used in fix elements dialogs)
Definition: GUIDesigns.h:185
#define GUIDesignButtonAccept
Accept Button.
Definition: GUIDesigns.h:127
#define GUIDesignButtonCancel
Cancel Button.
Definition: GUIDesigns.h:130
#define GUIDesignHeight
define a standard height for all elements (Change it carefully)
Definition: GUIDesigns.h:37
#define GUIDesignCheckButtonFix
design for check button with fixed height (used in fix elements dialogs)
Definition: GUIDesigns.h:160
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:343
#define GUIDesignAuxiliarVerticalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:346
#define GUIDesignTableFixElements
design for tables used in GNEFixDemandElements dialogs
Definition: GUIDesigns.h:562
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
Definition: GUIDesigns.h:340
#define GUIDesignHorizontalFrame
Definition: GUIDesigns.h:293
FXString gCurrentFolder
The folder used as last.
@ MODEPERSONPLAN
@ SUPERMODEDEMAND
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:290
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
FXGroupBoxModule (based on FXGroupBox)
Options
GroupBoxModule options.
An Element which don't belongs to GNENet but has influency in the simulation.
horizontal frame for buttons
FXButton * myAcceptButton
accept button
FXButton * myCancelButton
cancel button
Buttons(GNEFixDemandElements *fixDemandElementsParent)
build Position Options
bool saveContents() const
save contents
FXVerticalFrame * myRightFrame
vertical right frame
FXTable * myTable
Table with the demand elements.
void setInvalidElements(const std::vector< GNEDemandElement * > &invalidElements)
set invalid demand elements
FXVerticalFrame * myLeftFrame
vertical left frame
FixOptions(FXVerticalFrame *frameParent, const std::string &title, GNEViewNet *viewNet)
constructor
groupbox for all radio buttons related with fix person plan options
FXRadioButton * deletePersonPlan
Option "delete person plan".
FixPersonPlanOptions(GNEFixDemandElements *fixDemandElementsParent, GNEViewNet *viewNet)
build Position Options
void disableOptions()
disable personPlan options
void selectOption(FXObject *option)
select option
FXRadioButton * selectInvalidPersonPlansAndCancel
Option "Select invalid person plans and cancel".
void enableOptions()
enable personPlan options
void fixElements(bool &abortSaving)
fix elements
FXRadioButton * saveInvalid
Option "Save invalid".
groupbox for all radio buttons related with fix route options
void selectOption(FXObject *option)
select option
void fixElements(bool &abortSaving)
fix elements
FXRadioButton * removeInvalidRoutes
Option "Remove invalid routes".
FXRadioButton * saveInvalidRoutes
Option "Save invalid routes".
FXRadioButton * selectInvalidRoutesAndCancel
Option "Select invalid routes and cancel".
FXCheckButton * removeStopsOutOfRoute
Option "Remove stops out of route".
void disableOptions()
disable route options
FixRouteOptions(GNEFixDemandElements *fixDemandElementsParent, GNEViewNet *viewNet)
constructor
groupbox for all radio buttons related with fix stop options
FXRadioButton * saveInvalid
Option "Save invalid".
void fixElements(bool &abortSaving)
fix elements
FixStopPositionOptions(GNEFixDemandElements *fixDemandElementsParent, GNEViewNet *viewNet)
build Position Options
FXRadioButton * fixPositionsAndSave
Option "Fix Positions and save".
FXRadioButton * selectInvalidStopsAndCancel
Option "Select invalid stops and cancel".
void selectOption(FXObject *option)
select option
FXRadioButton * activateFriendlyPositionAndSave
Option "Activate friendlyPos and save".
groupbox for all radio buttons related with fix vehicle options
FXRadioButton * saveInvalidVehicles
Option "save invalid vehicles".
FXCheckButton * removeStopsOutOfVehicle
Option "Remove stops out of vehicle".
void selectOption(FXObject *option)
select option
FXRadioButton * selectInvalidVehiclesAndCancel
Option "Select invalid vehicles and cancel".
void fixElements(bool &abortSaving)
fix elements
FXRadioButton * removeInvalidVehicles
Option "remove invalid elements".
FixVehicleOptions(GNEFixDemandElements *fixDemandElementsParent, GNEViewNet *viewNet)
constructor
void disableOptions()
disable vehicle options
Dialog for edit rerouters.
FixStopPositionOptions * myFixStopPositionOptions
fix stop options
long onCmdSelectOption(FXObject *obj, FXSelector, void *)
FixRouteOptions * myFixRouteOptions
fix route options
FXVerticalFrame * myRightFrame
vertical right frame
FXVerticalFrame * myMainFrame
main frame
FixVehicleOptions * myFixVehicleOptions
fix vehicle options
GNEViewNet * myViewNet
view net
long onCmdCancel(FXObject *, FXSelector, void *)
event after press cancel button
FixPersonPlanOptions * myFixPersonPlanOptions
fix person plan options
long onCmdAccept(FXObject *, FXSelector, void *)
event after press accept button
FXVerticalFrame * myLeftFrame
vertical left frame
void deleteDemandElement(GNEDemandElement *demandElement, GNEUndoList *undoList)
remove demand element
Definition: GNENet.cpp:630
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...
GNENet * getNet() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition: MFXUtils.cpp:82
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
void close()
Closes the device and removes it from the dictionary.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.