Eclipse SUMO - Simulation of Urban MObility
GNETAZFrame.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-2024 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 add TAZ elements
19 /****************************************************************************/
20 #include <config.h>
21 
25 #include <netedit/GNENet.h>
26 #include <netedit/GNEViewNet.h>
31 #include <netedit/GNEUndoList.h>
33 
34 #include "GNETAZFrame.h"
35 
36 
37 // ===========================================================================
38 // FOX callback mapping
39 // ===========================================================================
40 
41 FXDEFMAP(GNETAZFrame::TAZParameters) TAZParametersMap[] = {
44  FXMAPFUNC(SEL_COMMAND, MID_HELP, GNETAZFrame::TAZParameters::onCmdHelp),
45 };
46 
47 FXDEFMAP(GNETAZFrame::TAZSaveChanges) TAZSaveChangesMap[] = {
50 };
51 
52 FXDEFMAP(GNETAZFrame::TAZChildDefaultParameters) TAZChildDefaultParametersMap[] = {
56 };
57 
58 FXDEFMAP(GNETAZFrame::TAZSelectionStatistics) TAZSelectionStatisticsMap[] = {
60 };
61 
62 FXDEFMAP(GNETAZFrame::TAZEdgesGraphic) TAZEdgesGraphicMap[] = {
64 };
65 
66 // Object implementation
67 FXIMPLEMENT(GNETAZFrame::TAZParameters, MFXGroupBoxModule, TAZParametersMap, ARRAYNUMBER(TAZParametersMap))
68 FXIMPLEMENT(GNETAZFrame::TAZSaveChanges, MFXGroupBoxModule, TAZSaveChangesMap, ARRAYNUMBER(TAZSaveChangesMap))
69 FXIMPLEMENT(GNETAZFrame::TAZChildDefaultParameters, MFXGroupBoxModule, TAZChildDefaultParametersMap, ARRAYNUMBER(TAZChildDefaultParametersMap))
70 FXIMPLEMENT(GNETAZFrame::TAZSelectionStatistics, MFXGroupBoxModule, TAZSelectionStatisticsMap, ARRAYNUMBER(TAZSelectionStatisticsMap))
71 FXIMPLEMENT(GNETAZFrame::TAZEdgesGraphic, MFXGroupBoxModule, TAZEdgesGraphicMap, ARRAYNUMBER(TAZEdgesGraphicMap))
72 
73 
74 // ===========================================================================
75 // method definitions
76 // ===========================================================================
77 
78 // ---------------------------------------------------------------------------
79 // GNETAZFrame::CurrentTAZ - methods
80 // ---------------------------------------------------------------------------
81 
83  edge(_edge),
84  source(_source),
85  sink(_sink),
86  sourceColor(0),
87  sinkColor(0),
88  sourcePlusSinkColor(0),
89  sourceMinusSinkColor(0),
90  myCurrentTAZParent(CurrentTAZParent) {
91 }
92 
93 
95 
96 
97 void
99  sourceColor = GNEAttributeCarrier::parse<int>(source->getAttribute(GNE_ATTR_TAZCOLOR));
100  sinkColor = GNEAttributeCarrier::parse<int>(sink->getAttribute(GNE_ATTR_TAZCOLOR));
101  // Obtain Source+Sink needs more steps. First obtain Source+Sink Weight
102  double sourcePlusSinkWeight = source->getDepartWeight() + sink->getDepartWeight();
103  // avoid division between zero
104  if ((myCurrentTAZParent->myMaxSourcePlusSinkWeight - myCurrentTAZParent->myMinSourcePlusSinkWeight) == 0) {
105  sourcePlusSinkColor = 0;
106  } else {
107  // calculate percentage relative to the max and min Source+Sink weight
108  double percentage = (sourcePlusSinkWeight - myCurrentTAZParent->myMinSourcePlusSinkWeight) /
109  (myCurrentTAZParent->myMaxSourcePlusSinkWeight - myCurrentTAZParent->myMinSourcePlusSinkWeight);
110  // convert percentage to a value between [0-9] (because we have only 10 colors)
111  if (percentage >= 1) {
112  sourcePlusSinkColor = 9;
113  } else if (percentage < 0) {
114  sourcePlusSinkColor = 0;
115  } else {
116  sourcePlusSinkColor = (int)(percentage * 10);
117  }
118  }
119  // Obtain Source+Sink needs more steps. First obtain Source-Sink Weight
120  double sourceMinusSinkWeight = source->getDepartWeight() - sink->getDepartWeight();
121  // avoid division between zero
122  if ((myCurrentTAZParent->myMaxSourceMinusSinkWeight - myCurrentTAZParent->myMinSourceMinusSinkWeight) == 0) {
123  sourceMinusSinkColor = 0;
124  } else {
125  // calculate percentage relative to the max and min Source-Sink weight
126  double percentage = (sourceMinusSinkWeight - myCurrentTAZParent->myMinSourceMinusSinkWeight) /
127  (myCurrentTAZParent->myMaxSourceMinusSinkWeight - myCurrentTAZParent->myMinSourceMinusSinkWeight);
128  // convert percentage to a value between [0-9] (because we have only 10 colors)
129  if (percentage >= 1) {
130  sourceMinusSinkColor = 9;
131  } else if (percentage < 0) {
132  sourceMinusSinkColor = 0;
133  } else {
134  sourceMinusSinkColor = (int)(percentage * 10);
135  }
136  }
137 }
138 
139 
141  edge(nullptr),
142  source(nullptr),
143  sink(nullptr),
144  sourceColor(0),
145  sinkColor(0),
146  sourcePlusSinkColor(0),
147  sourceMinusSinkColor(0),
148  myCurrentTAZParent(nullptr) {
149 }
150 
151 
153  MFXGroupBoxModule(TAZFrameParent, TL("TAZ")),
154  myTAZFrameParent(TAZFrameParent),
155  myEditedTAZ(nullptr),
160  // create TAZ label
161  myCurrentTAZLabel = new FXLabel(getCollapsableFrame(), TL("No TAZ selected"), 0, GUIDesignLabel(JUSTIFY_LEFT));
162 }
163 
164 
166 
167 
168 void
170  // set new current TAZ
171  myEditedTAZ = editedTAZ;
172  // update label and moduls
173  if (myEditedTAZ != nullptr) {
174  myCurrentTAZLabel->setText((TL("Current TAZ: ") + myEditedTAZ->getID()).c_str());
175  // obtain a copy of all SELECTED edges of the net (to avoid slowdown during manipulations)
176  mySelectedEdges = myTAZFrameParent->myViewNet->getNet()->getAttributeCarriers()->getSelectedEdges();
177  // refresh TAZ Edges
178  refreshTAZEdges();
179  // hide TAZ parameters
180  myTAZFrameParent->myTAZParameters->hideTAZParametersModule();
181  // hide drawing shape
182  myTAZFrameParent->myDrawingShape->hideDrawingShape();
183  // show edge common parameters
184  myTAZFrameParent->myTAZCommonStatistics->showTAZCommonStatisticsModule();
185  // show save TAZ Edges
186  myTAZFrameParent->myTAZSaveChanges->showTAZSaveChangesModule();
187  // show edge common parameters
188  myTAZFrameParent->myTAZChildDefaultParameters->extendTAZChildDefaultParameters();
189  // show Edges graphics
190  myTAZFrameParent->myTAZEdgesGraphic->showTAZEdgesGraphicModule();
191  } else {
192  // show TAZ parameters
193  myTAZFrameParent->myTAZParameters->showTAZParametersModule();
194  // show drawing shape
195  myTAZFrameParent->myDrawingShape->showDrawingShape();
196  // hide edge common parameters
197  myTAZFrameParent->myTAZCommonStatistics->hideTAZCommonStatisticsModule();
198  // hide edge common parameters
199  myTAZFrameParent->myTAZChildDefaultParameters->collapseTAZChildDefaultParameters();
200  // hide Edges graphics
201  myTAZFrameParent->myTAZEdgesGraphic->hideTAZEdgesGraphicModule();
202  // hide save TAZ Edges
203  myTAZFrameParent->myTAZSaveChanges->hideTAZSaveChangesModule();
204  // restore label
205  myCurrentTAZLabel->setText(TL("No TAZ selected"));
206  // clear selected edges
207  mySelectedEdges.clear();
208  // reset all weight values
209  myMaxSourcePlusSinkWeight = 0;
210  myMinSourcePlusSinkWeight = -1;
211  myMaxSourceMinusSinkWeight = 0;
212  myMinSourceMinusSinkWeight = -1;
213  }
214 }
215 
216 
217 GNETAZ*
219  return myEditedTAZ;
220 }
221 
222 
223 bool
225  // simply iterate over edges and check edge parameter
226  for (const auto& TAZEdgeColor : myTAZEdgeColors) {
227  if (TAZEdgeColor.edge == edge) {
228  return true;
229  }
230  }
231  // not found, then return false
232  return false;
233 }
234 
235 
236 const std::vector<GNEEdge*>&
238  return mySelectedEdges;
239 }
240 
241 
242 const std::vector<GNETAZFrame::CurrentTAZ::TAZEdgeColor>&
244  return myTAZEdgeColors;
245 }
246 
247 
248 void
250  // clear all curren TAZEdges
251  myTAZEdgeColors.clear();
252  // clear weight values
253  myMaxSourcePlusSinkWeight = 0;
254  myMinSourcePlusSinkWeight = -1;
255  myMaxSourceMinusSinkWeight = 0;
256  myMinSourceMinusSinkWeight = -1;
257  // only refresh if we're editing an TAZ
258  if (myEditedTAZ) {
259  // first update TAZ Statistics
260  myEditedTAZ->updateTAZStatistic();
261  myTAZFrameParent->myTAZCommonStatistics->updateStatistics();
262  // iterate over child TAZElements and create TAZEdges
263  for (const auto& TAZElement : myEditedTAZ->getChildAdditionals()) {
264  addTAZChild(dynamic_cast<GNETAZSourceSink*>(TAZElement));
265  }
266  // update colors after add all edges
267  for (auto& TAZEdgeColor : myTAZEdgeColors) {
269  }
270  // update edge colors
271  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
272  }
273 }
274 
275 
276 void
278  // first make sure that TAZElements is an TAZ Source or Sink
279  if (sourceSink && ((sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) || (sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSINK))) {
280  GNEEdge* edge = myTAZFrameParent->myViewNet->getNet()->getAttributeCarriers()->retrieveEdge(sourceSink->getAttribute(SUMO_ATTR_EDGE));
281  // first check if TAZEdgeColor has to be created
282  bool createTAZEdge = true;
283  for (auto& TAZEdgeColor : myTAZEdgeColors) {
284  if (TAZEdgeColor.edge == edge) {
285  createTAZEdge = false;
286  // update TAZ Source or Sink
287  if (sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
288  TAZEdgeColor.source = sourceSink;
289  } else {
290  TAZEdgeColor.sink = sourceSink;
291  }
292  }
293  }
294  // check if TAZElements has to be created
295  if (createTAZEdge) {
296  if (sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
297  myTAZEdgeColors.push_back(TAZEdgeColor(this, edge, sourceSink, nullptr));
298  } else {
299  myTAZEdgeColors.push_back(TAZEdgeColor(this, edge, nullptr, sourceSink));
300  }
301  }
302  // recalculate weights
303  myMaxSourcePlusSinkWeight = 0;
304  myMinSourcePlusSinkWeight = -1;
305  myMaxSourceMinusSinkWeight = 0;
306  myMinSourceMinusSinkWeight = -1;
307  for (const auto& TAZEdgeColor : myTAZEdgeColors) {
308  // make sure that both TAZ Source and Sink exist
310  // obtain source plus sink
311  double sourcePlusSink = TAZEdgeColor.source->getDepartWeight() + TAZEdgeColor.sink->getDepartWeight();
312  // check myMaxSourcePlusSinkWeight
313  if (sourcePlusSink > myMaxSourcePlusSinkWeight) {
314  myMaxSourcePlusSinkWeight = sourcePlusSink;
315  }
316  // check myMinSourcePlusSinkWeight
317  if ((myMinSourcePlusSinkWeight == -1) || (sourcePlusSink < myMinSourcePlusSinkWeight)) {
318  myMinSourcePlusSinkWeight = sourcePlusSink;
319  }
320  // obtain source minus sink
321  double sourceMinusSink = TAZEdgeColor.source->getDepartWeight() - TAZEdgeColor.sink->getDepartWeight();
322  // use valor absolute
323  if (sourceMinusSink < 0) {
324  sourceMinusSink *= -1;
325  }
326  // check myMaxSourcePlusSinkWeight
327  if (sourceMinusSink > myMaxSourceMinusSinkWeight) {
328  myMaxSourceMinusSinkWeight = sourceMinusSink;
329  }
330  // check myMinSourcePlusSinkWeight
331  if ((myMinSourceMinusSinkWeight == -1) || (sourceMinusSink < myMinSourceMinusSinkWeight)) {
332  myMinSourceMinusSinkWeight = sourceMinusSink;
333  }
334  }
335  }
336  } else {
337  throw ProcessError(TL("Invalid TAZ Child"));
338  }
339 }
340 
341 // ---------------------------------------------------------------------------
342 // GNETAZFrame::TAZCommonStatistics - methods
343 // ---------------------------------------------------------------------------
344 
346  MFXGroupBoxModule(TAZFrameParent, TL("TAZ Statistics")),
347  myTAZFrameParent(TAZFrameParent) {
348  // create label for statistics
349  myStatisticsLabel = new FXLabel(getCollapsableFrame(), TL("Statistics"), 0, GUIDesignLabelFrameInformation);
350 }
351 
352 
354 
355 
356 void
358  // always update statistics after show
359  updateStatistics();
360  show();
361 }
362 
363 
364 void
366  hide();
367 }
368 
369 
370 void
372  if (myTAZFrameParent->myCurrentTAZ->getTAZ()) {
373  // declare ostringstream for statistics
374  std::ostringstream information;
375  information
376  << TL("- Number of edges: ") << toString(myTAZFrameParent->myCurrentTAZ->getTAZ()->getChildAdditionals().size() / 2) << "\n"
377  << TL("- Min source: ") << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_MIN_SOURCE) << "\n"
378  << TL("- Max source: ") << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_MAX_SOURCE) << "\n"
379  << TL("- Average source: ") << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_AVERAGE_SOURCE) << "\n"
380  << "\n"
381  << TL("- Min sink: ") << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_MIN_SINK) << "\n"
382  << TL("- Max sink: ") << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_MAX_SINK) << "\n"
383  << TL("- Average sink: ") << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_AVERAGE_SINK);
384  // set new label
385  myStatisticsLabel->setText(information.str().c_str());
386  } else {
387  myStatisticsLabel->setText(TL("No TAZ Selected"));
388  }
389 }
390 
391 // ---------------------------------------------------------------------------
392 // GNETAZFrame::TAZSaveChanges - methods
393 // ---------------------------------------------------------------------------
394 
396  MFXGroupBoxModule(TAZFrameParent, TL("Modifications")),
397  myTAZFrameParent(TAZFrameParent) {
398  // Create groupbox for save changes
400  mySaveChangesButton->disable();
401  // Create groupbox cancel changes
403  myCancelChangesButton->disable();
404 }
405 
406 
408 
409 
410 void
412  show();
413 }
414 
415 
416 void
418  // cancel changes before hiding module
419  onCmdCancelChanges(0, 0, 0);
420  hide();
421 }
422 
423 
424 void
426  // check that save changes is disabled
427  if (!mySaveChangesButton->isEnabled()) {
428  // enable mySaveChangesButton and myCancelChangesButton
429  mySaveChangesButton->enable();
430  myCancelChangesButton->enable();
431  // start undo list set
432  myTAZFrameParent->myViewNet->getUndoList()->begin(GUIIcon::TAZ, TL("TAZ changes"));
433  }
434 }
435 
436 
437 bool
439  // simply check if save Changes Button is enabled
440  return myTAZFrameParent->shown() && mySaveChangesButton->isEnabled();
441 }
442 
443 
444 long
445 GNETAZFrame::TAZSaveChanges::onCmdSaveChanges(FXObject*, FXSelector, void*) {
446  // check that save changes is enabled
447  if (mySaveChangesButton->isEnabled()) {
448  // disable mySaveChangesButton and myCancelChangesButton
449  mySaveChangesButton->disable();
450  myCancelChangesButton->disable();
451  // finish undo list set
452  myTAZFrameParent->myViewNet->getUndoList()->end();
453  // always refresh TAZ Edges after removing TAZSources/Sinks
454  myTAZFrameParent->myCurrentTAZ->refreshTAZEdges();
455  // update use edges button
456  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
457 
458  }
459  return 1;
460 }
461 
462 
463 long
464 GNETAZFrame::TAZSaveChanges::onCmdCancelChanges(FXObject*, FXSelector, void*) {
465  // check that save changes is enabled
466  if (mySaveChangesButton->isEnabled()) {
467  // disable buttons
468  mySaveChangesButton->disable();
469  myCancelChangesButton->disable();
470  // abort undo list
471  myTAZFrameParent->myViewNet->getUndoList()->abortAllChangeGroups();
472  // always refresh TAZ Edges after removing TAZSources/Sinks
473  myTAZFrameParent->myCurrentTAZ->refreshTAZEdges();
474  // update use edges button
475  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
476  }
477  return 1;
478 }
479 
480 // ---------------------------------------------------------------------------
481 // GNETAZFrame::TAZChildDefaultParameters - methods
482 // ---------------------------------------------------------------------------
483 
485  MFXGroupBoxModule(TAZFrameParent, TL("TAZ Sources/Sinks")),
486  myTAZFrameParent(TAZFrameParent),
487  myDefaultTAZSourceWeight(1),
488  myDefaultTAZSinkWeight(1) {
489  // create checkbox for toggle membership
491  new FXLabel(myToggleMembershipFrame, TL("Membership"), 0, GUIDesignLabelThickedFixed(100));
493  // by default enabled
494  myToggleMembership->setCheck(TRUE);
495  // create default TAZ Source weight
497  new FXLabel(myDefaultTAZSourceFrame, TL("New source"), 0, GUIDesignLabelThickedFixed(100));
499  myTextFieldDefaultValueTAZSources->setText("1");
500  // create default TAZ Sink weight
502  new FXLabel(myDefaultTAZSinkFrame, TL("New sink"), 0, GUIDesignLabelThickedFixed(100));
504  myTextFieldDefaultValueTAZSinks->setText("1");
505  // Create button for use selected edges
506  myUseSelectedEdges = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Use selected edges"), "", "", nullptr, this, MID_GNE_SELECT, GUIDesignButton);
507  // Create button for zero fringe probabilities
509  // Create information label
510  std::ostringstream information;
511  information
512  << std::string("- ") << TL("Toggle Membership:") << "\n"
513  << std::string(" ") << TL("Create new Sources/Sinks with given weights.");
515  // always show
516  show();
517 }
518 
519 
521 
522 
523 void
525  // check if TAZ selection Statistics Module has to be shown
526  if (myToggleMembership->getCheck() == FALSE) {
527  myTAZFrameParent->myTAZSelectionStatistics->showTAZSelectionStatisticsModule();
528  } else {
529  myTAZFrameParent->myTAZSelectionStatistics->hideTAZSelectionStatisticsModule();
530  }
531  // update selected button
532  updateSelectEdgesButton();
533  // show items edges button
534  myToggleMembershipFrame->show();
535  myDefaultTAZSourceFrame->show();
536  myDefaultTAZSinkFrame->show();
537  myUseSelectedEdges->show();
538  myInformationLabel->show();
539 }
540 
541 
542 void
544  // hide TAZ Selection Statistics Module
545  myTAZFrameParent->myTAZSelectionStatistics->hideTAZSelectionStatisticsModule();
546  // hide items
547  myToggleMembershipFrame->hide();
548  myDefaultTAZSourceFrame->hide();
549  myDefaultTAZSinkFrame->hide();
550  myUseSelectedEdges->hide();
551  myInformationLabel->hide();
552 }
553 
554 
555 void
557  if (myToggleMembership->getCheck() == TRUE) {
558  // check if use selected edges has to be enabled
559  if (myTAZFrameParent->myCurrentTAZ->getSelectedEdges().size() > 0) {
560  myUseSelectedEdges->setText(TL("Use selected edges"));
561  myUseSelectedEdges->enable();
562  } else if (myTAZFrameParent->myCurrentTAZ->getTAZEdges().size() > 0) {
563  myUseSelectedEdges->setText(TL("Remove all edges"));
564  myUseSelectedEdges->enable();
565  } else {
566  myUseSelectedEdges->setText(TL("Use selected edges"));
567  myUseSelectedEdges->disable();
568  }
569  } else if (myTAZFrameParent->getCurrentTAZModule()->getTAZEdges().size() > 0) {
570  // enable myUseSelectedEdges button
571  myUseSelectedEdges->enable();
572  // update mySelectEdgesOfSelection label
573  if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size() == 0) {
574  // check if all edges of TAZChildren are selected
575  bool allSelected = true;
576  for (const auto& TAZEdgeColor : myTAZFrameParent->getCurrentTAZModule()->getTAZEdges()) {
577  if (!TAZEdgeColor.edge->isAttributeCarrierSelected()) {
578  allSelected = false;
579  }
580  }
581  if (allSelected) {
582  myUseSelectedEdges->setText(TL("Remove all edges from selection"));
583  } else {
584  myUseSelectedEdges->setText(TL("Add all edges to selection"));
585  }
586  } else if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size() == 1) {
587  if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().front().edge->isAttributeCarrierSelected()) {
588  myUseSelectedEdges->setText(TL("Remove edge from selection"));
589  } else {
590  myUseSelectedEdges->setText(TL("Add edge to selection"));
591  }
592  } else {
593  // check if all edges of TAZChildren selected are selected
594  bool allSelected = true;
595  for (const auto& selectedEdge : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
596  if (!selectedEdge.edge->isAttributeCarrierSelected()) {
597  allSelected = false;
598  }
599  }
600  if (allSelected) {
601  myUseSelectedEdges->setText((TL("Remove ") + toString(myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size()) + TL(" edges from to selection")).c_str());
602  } else {
603  myUseSelectedEdges->setText((TL("Add ") + toString(myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size()) + TL(" edges to selection")).c_str());
604  }
605  }
606  } else {
607  // TAZ doesn't have children, then disable button
608  myUseSelectedEdges->disable();
609  }
610 }
611 
612 
613 double
615  return myDefaultTAZSourceWeight;
616 }
617 
618 
619 double
621  return myDefaultTAZSinkWeight;
622 }
623 
624 
625 bool
627  return (myToggleMembership->getCheck() == TRUE);
628 }
629 
630 
631 long
633  // find edited object
634  if (obj == myToggleMembership) {
635  // first clear selected edges
636  myTAZFrameParent->myTAZSelectionStatistics->clearSelectedEdges();
637  // set text of myToggleMembership
638  if (myToggleMembership->getCheck() == TRUE) {
639  myToggleMembership->setText(TL("toggle"));
640  // show source/Sink Frames
641  myDefaultTAZSourceFrame->show();
642  myDefaultTAZSinkFrame->show();
643  // update information label
644  std::ostringstream information;
645  information
646  << std::string("- ") << TL("Toggle Membership:") << "\n"
647  << std::string(" ") << TL("Create new Sources/Sinks with given weights.");
648  myInformationLabel->setText(information.str().c_str());
649  // hide TAZSelectionStatistics
650  myTAZFrameParent->myTAZSelectionStatistics->hideTAZSelectionStatisticsModule();
651  // check if use selected edges has to be enabled
652  if (myTAZFrameParent->myCurrentTAZ->getSelectedEdges().size() > 0) {
653  myUseSelectedEdges->setText(TL("Use selected edges"));
654  } else if (myTAZFrameParent->myCurrentTAZ->getTAZEdges().size() > 0) {
655  myUseSelectedEdges->setText(TL("Remove all edges"));
656  } else {
657  myUseSelectedEdges->setText(TL("Use selected edges"));
658  myUseSelectedEdges->disable();
659  }
660  } else {
661  myToggleMembership->setText(TL("keep"));
662  // hide source/Sink Frames
663  myDefaultTAZSourceFrame->hide();
664  myDefaultTAZSinkFrame->hide();
665  // update information label
666  std::ostringstream information;
667  information
668  << std::string("- ") << TL("Keep Membership:") << TL(" Select Sources/Sinks.") << "\n"
669  << std::string("- ") << TL("Press ESC to clear the current selection.");
670  myInformationLabel->setText(information.str().c_str());
671  // show TAZSelectionStatistics
672  myTAZFrameParent->myTAZSelectionStatistics->showTAZSelectionStatisticsModule();
673  }
674  // update button
675  updateSelectEdgesButton();
676  } else if (obj == myTextFieldDefaultValueTAZSources) {
677  // check if given value is valid
678  if (GNEAttributeCarrier::canParse<double>(myTextFieldDefaultValueTAZSources->getText().text())) {
679  myDefaultTAZSourceWeight = GNEAttributeCarrier::parse<double>(myTextFieldDefaultValueTAZSources->getText().text());
680  // check if myDefaultTAZSourceWeight is greater than 0
681  if (myDefaultTAZSourceWeight >= 0) {
682  // set valid color
683  myTextFieldDefaultValueTAZSources->setTextColor(FXRGB(0, 0, 0));
684  } else {
685  // set invalid color
686  myTextFieldDefaultValueTAZSources->setTextColor(FXRGB(255, 0, 0));
687  myDefaultTAZSourceWeight = 1;
688  }
689  } else {
690  // set invalid color
691  myTextFieldDefaultValueTAZSources->setTextColor(FXRGB(255, 0, 0));
692  myDefaultTAZSourceWeight = 1;
693  }
694  } else if (obj == myTextFieldDefaultValueTAZSinks) {
695  // check if given value is valid
696  if (GNEAttributeCarrier::canParse<double>(myTextFieldDefaultValueTAZSinks->getText().text())) {
697  myDefaultTAZSinkWeight = GNEAttributeCarrier::parse<double>(myTextFieldDefaultValueTAZSinks->getText().text());
698  // check if myDefaultTAZSinkWeight is greater than 0
699  if (myDefaultTAZSinkWeight >= 0) {
700  // set valid color
701  myTextFieldDefaultValueTAZSinks->setTextColor(FXRGB(0, 0, 0));
702  } else {
703  // set invalid color
704  myTextFieldDefaultValueTAZSinks->setTextColor(FXRGB(255, 0, 0));
705  myDefaultTAZSinkWeight = 1;
706  }
707  } else {
708  // set invalid color
709  myTextFieldDefaultValueTAZSinks->setTextColor(FXRGB(255, 0, 0));
710  myDefaultTAZSinkWeight = 1;
711  }
712  }
713  return 1;
714 }
715 
716 
717 long
719  // select edge or create new TAZ Source/Child, depending of myToggleMembership
720  if (myToggleMembership->getCheck() == TRUE) {
721  // first drop all edges
722  myTAZFrameParent->dropTAZMembers();
723  // iterate over selected edges and add it as TAZMember
724  for (const auto& selectedEdge : myTAZFrameParent->myCurrentTAZ->getSelectedEdges()) {
725  myTAZFrameParent->addOrRemoveTAZMember(selectedEdge);
726  }
727  // update selected button
728  updateSelectEdgesButton();
729  } else {
730  if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size() == 0) {
731  // first check if all TAZEdges are selected
732  bool allSelected = true;
733  for (const auto& TAZEdgeColor : myTAZFrameParent->getCurrentTAZModule()->getTAZEdges()) {
734  if (!TAZEdgeColor.edge->isAttributeCarrierSelected()) {
735  allSelected = false;
736  }
737  }
738  // select or unselect all depending of allSelected
739  if (allSelected) {
740  // remove form selection all TAZEdges
741  for (const auto& TAZEdgeColor : myTAZFrameParent->getCurrentTAZModule()->getTAZEdges()) {
742  // change attribute selected (without undo-redo)
743  TAZEdgeColor.edge->unselectAttributeCarrier();
744  }
745  } else {
746  // add to selection all TAZEdges
747  for (const auto& TAZEdgeColor : myTAZFrameParent->getCurrentTAZModule()->getTAZEdges()) {
748  // change attribute selected (without undo-redo)
749  TAZEdgeColor.edge->selectAttributeCarrier();
750  }
751  }
752  } else {
753  // first check if all TAZEdges are selected
754  bool allSelected = true;
755  for (const auto& selectedEdge : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
756  if (!selectedEdge.edge->isAttributeCarrierSelected()) {
757  allSelected = false;
758  }
759  }
760  // select or unselect all depending of allSelected
761  if (allSelected) {
762  // only remove from selection selected TAZEdges
763  for (const auto& selectedEdge : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
764  if (selectedEdge.edge->isAttributeCarrierSelected()) {
765  // change attribute selected (without undo-redo)
766  selectedEdge.edge->unselectAttributeCarrier();
767  }
768  }
769  } else {
770  // only add to selection selected TAZEdges
771  for (const auto& selectedEdge : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
772  if (!selectedEdge.edge->isAttributeCarrierSelected()) {
773  // change attribute selected (without undo-redo)
774  selectedEdge.edge->selectAttributeCarrier();
775  }
776  }
777  }
778  }
779  }
780  // update selection button
781  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
782  // update view net
783  myTAZFrameParent->myViewNet->updateViewNet();
784  return 1;
785 }
786 
787 
788 long
790  // compute and update
791  auto& neteditOptions = OptionsCont::getOptions();
792  myTAZFrameParent->getViewNet()->getNet()->computeAndUpdate(neteditOptions, false);
793  myTAZFrameParent->getViewNet()->update();
794  // find all edges with TAZSource/sinks and without successors/predecessors
795  std::vector<GNEAdditional*> sources;
796  std::vector<GNEAdditional*> sinks;
797  std::set<GNEAdditional*> TAZs;
798  // check if we're editing a single TAZ or all TAZs
799  if (myTAZFrameParent->myCurrentTAZ->getTAZ() != nullptr) {
800  // iterate over source/sinks
801  for (const auto& TAZSourceSink : myTAZFrameParent->myCurrentTAZ->getTAZ()->getChildAdditionals()) {
802  if (TAZSourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
803  // set sink probability to 0 for all edges that have no predecessor
804  if (!TAZSourceSink->getParentEdges().front()->hasSuccessors() &&
805  (TAZSourceSink->getAttributeDouble(SUMO_ATTR_WEIGHT) != 0)) {
806  sources.push_back(TAZSourceSink);
807  TAZs.insert(myTAZFrameParent->myCurrentTAZ->getTAZ());
808  }
809  } else {
810  // set source probability to 0 for all edges that have no successor
811  if (!TAZSourceSink->getParentEdges().front()->hasPredecessors() &&
812  (TAZSourceSink->getAttributeDouble(SUMO_ATTR_WEIGHT) != 0)) {
813  sinks.push_back(TAZSourceSink);
814  TAZs.insert(myTAZFrameParent->myCurrentTAZ->getTAZ());
815  }
816  }
817  }
818  } else {
819  // iterate over all TAZs
820  for (const auto& TAZ : myTAZFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getAdditionals().at(SUMO_TAG_TAZ)) {
821  // iterate over source/sinks
822  for (const auto& TAZSourceSink : TAZ.second->getChildAdditionals()) {
823  if (TAZSourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
824  // set sink probability to 0 for all edges that have no predecessor
825  if (!TAZSourceSink->getParentEdges().front()->hasSuccessors() &&
826  (TAZSourceSink->getAttributeDouble(SUMO_ATTR_WEIGHT) != 0)) {
827  sources.push_back(TAZSourceSink);
828  TAZs.insert(TAZ.second);
829  }
830  } else {
831  // set source probability to 0 for all edges that have no successor
832  if (!TAZSourceSink->getParentEdges().front()->hasPredecessors() &&
833  (TAZSourceSink->getAttributeDouble(SUMO_ATTR_WEIGHT) != 0)) {
834  sinks.push_back(TAZSourceSink);
835  TAZs.insert(TAZ.second);
836  }
837  }
838  }
839  }
840  }
841  // check if there is sources/sinks
842  if ((sources.size() + sinks.size()) > 0) {
843  // build the text
844  const std::string text = (TAZs.size() == 1) ?
845  // single TAZ
846  TL("Set weight 0 in ") + toString(sources.size()) + TL(" sources and ") +
847  toString(sinks.size()) + TL(" sinks from TAZ '") + (*TAZs.begin())->getID() + "'?" :
848  // multiple TAZs
849  TL("Set weight 0 in ") + toString(sources.size()) + TL(" sources and ") +
850  toString(sinks.size()) + TL(" sinks from ") + toString(TAZs.size()) + TL(" TAZs?");
851  // ask if continue
852  const FXuint answer = FXMessageBox::question(this, MBOX_YES_NO, TL("Set zero fringe probabilities"), "%s", text.c_str());
853  if (answer == 1) { // 1:yes, 2:no, 4:esc
854  myTAZFrameParent->myViewNet->getUndoList()->begin(GUIIcon::TAZ, TL("set zero fringe probabilities"));
855  for (const auto& source : sources) {
856  source->setAttribute(SUMO_ATTR_WEIGHT, "0", myTAZFrameParent->myViewNet->getUndoList());
857  }
858  for (const auto& sink : sinks) {
859  sink->setAttribute(SUMO_ATTR_WEIGHT, "0", myTAZFrameParent->myViewNet->getUndoList());
860  }
861  myTAZFrameParent->myViewNet->getUndoList()->end();
862  }
863  } else {
864  // show information box
865  FXMessageBox::information(this, MBOX_OK, TL("Set zero fringe probabilities"), TL("No source/sinks to update."));
866  }
867  return 1;
868 }
869 
870 // ---------------------------------------------------------------------------
871 // GNETAZFrame::TAZSelectionStatistics - methods
872 // ---------------------------------------------------------------------------
873 
875  MFXGroupBoxModule(TAZFrameParent, TL("Selection Statistics")),
876  myTAZFrameParent(TAZFrameParent) {
877  // create default TAZ Source weight
879  new FXLabel(myTAZSourceFrame, TL("Source"), 0, GUIDesignLabelThickedFixed(100));
881  myTAZSourceFrame->hide();
882  // create default TAZ Sink weight
884  new FXLabel(myTAZSinkFrame, TL("Sink"), 0, GUIDesignLabelThickedFixed(100));
886  myTAZSinkFrame->hide();
887  // create label for statistics
888  myStatisticsLabel = new FXLabel(getCollapsableFrame(), TL("Statistics"), 0, GUIDesignLabelFrameInformation);
889 }
890 
891 
893 
894 
895 void
897  // update Statistics before show
898  updateStatistics();
899  show();
900 }
901 
902 
903 void
905  // clear children before hide
906  clearSelectedEdges();
907  hide();
908 }
909 
910 
911 bool
913  // find TAZEdgeColor using edge as criterium wasn't previously selected
914  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
915  if (selectedEdge.edge == TAZEdgeColor.edge) {
916  throw ProcessError(TL("TAZEdgeColor already selected"));
917  }
918  }
919  // add edge and their TAZ Children into myTAZChildSelected
920  myEdgeAndTAZChildrenSelected.push_back(TAZEdgeColor);
921  // always update statistics after insertion
922  updateStatistics();
923  // update edge colors
924  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
925  // update selection button
926  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
927  return true;
928 }
929 
930 
931 bool
933  if (edge) {
934  // find TAZEdgeColor using edge as criterium
935  for (auto it = myEdgeAndTAZChildrenSelected.begin(); it != myEdgeAndTAZChildrenSelected.end(); it++) {
936  if (it->edge == edge) {
937  myEdgeAndTAZChildrenSelected.erase(it);
938  // always update statistics after insertion
939  updateStatistics();
940  // update edge colors
941  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
942  // update selection button
943  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
944  return true;
945  }
946  }
947  // throw exception if edge wasn't found
948  throw ProcessError(TL("edge wasn't found"));
949  } else {
950  throw ProcessError(TL("Invalid edge"));
951  }
952 }
953 
954 
955 bool
957  // find TAZEdgeColor using edge as criterium
958  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
959  if (selectedEdge.edge == edge) {
960  return true;
961  }
962  }
963  // edge wasn't found, then return false
964  return false;
965 }
966 
967 
968 void
970  // clear all selected edges (and the TAZ Children)
971  myEdgeAndTAZChildrenSelected.clear();
972  // always update statistics after clear edges
973  updateStatistics();
974  // update edge colors
975  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
976  // update selection button
977  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
978 }
979 
980 
981 const std::vector<GNETAZFrame::CurrentTAZ::TAZEdgeColor>&
983  return myEdgeAndTAZChildrenSelected;
984 }
985 
986 
987 long
989  if (obj == myTextFieldTAZSourceWeight) {
990  // check if given value is valid
991  if (GNEAttributeCarrier::canParse<double>(myTextFieldTAZSourceWeight->getText().text())) {
992  double newTAZSourceWeight = GNEAttributeCarrier::parse<double>(myTextFieldTAZSourceWeight->getText().text());
993  // check if myDefaultTAZSourceWeight is greater than 0
994  if (newTAZSourceWeight >= 0) {
995  // set valid color in TextField
996  myTextFieldTAZSourceWeight->setTextColor(FXRGB(0, 0, 0));
997  // enable save button
998  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
999  // update weight of all TAZSources
1000  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
1001  selectedEdge.source->setAttribute(SUMO_ATTR_WEIGHT, myTextFieldTAZSourceWeight->getText().text(), myTAZFrameParent->myViewNet->getUndoList());
1002  }
1003  // refresh TAZ Edges
1004  myTAZFrameParent->getCurrentTAZModule()->refreshTAZEdges();
1005  } else {
1006  // set invalid color
1007  myTextFieldTAZSourceWeight->setTextColor(FXRGB(255, 0, 0));
1008  }
1009  } else {
1010  // set invalid color
1011  myTextFieldTAZSourceWeight->setTextColor(FXRGB(255, 0, 0));
1012  }
1013  } else if (obj == myTextFieldTAZSinkWeight) {
1014  // check if given value is valid
1015  if (GNEAttributeCarrier::canParse<double>(myTextFieldTAZSinkWeight->getText().text())) {
1016  double newTAZSinkWeight = GNEAttributeCarrier::parse<double>(myTextFieldTAZSinkWeight->getText().text());
1017  // check if myDefaultTAZSinkWeight is greater than 0
1018  if (newTAZSinkWeight >= 0) {
1019  // set valid color in TextField
1020  myTextFieldTAZSinkWeight->setTextColor(FXRGB(0, 0, 0));
1021  // enable save button
1022  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
1023  // update weight of all TAZSources
1024  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
1025  selectedEdge.sink->setAttribute(SUMO_ATTR_WEIGHT, myTextFieldTAZSinkWeight->getText().text(), myTAZFrameParent->myViewNet->getUndoList());
1026  }
1027  // refresh TAZ Edges
1028  myTAZFrameParent->getCurrentTAZModule()->refreshTAZEdges();
1029  } else {
1030  // set invalid color
1031  myTextFieldTAZSinkWeight->setTextColor(FXRGB(255, 0, 0));
1032  }
1033  } else {
1034  // set invalid color
1035  myTextFieldTAZSinkWeight->setTextColor(FXRGB(255, 0, 0));
1036  }
1037  }
1038  return 1;
1039 }
1040 
1041 
1042 long
1044  if (myEdgeAndTAZChildrenSelected.size() == 0) {
1045  // add to selection all TAZEdges
1046  for (const auto& TAZEdgeColor : myTAZFrameParent->getCurrentTAZModule()->getTAZEdges()) {
1047  // avoid empty undolists
1048  if (!TAZEdgeColor.edge->isAttributeCarrierSelected()) {
1049  // enable save button
1050  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
1051  // change attribute selected
1052  TAZEdgeColor.edge->setAttribute(GNE_ATTR_SELECTED, "true", myTAZFrameParent->myViewNet->getUndoList());
1053  }
1054  }
1055  } else {
1056  // only add to selection selected TAZEdges
1057  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
1058  // avoid empty undolists
1059  if (!selectedEdge.edge->isAttributeCarrierSelected()) {
1060  // enable save button
1061  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
1062  // change attribute selected
1063  selectedEdge.edge->setAttribute(GNE_ATTR_SELECTED, "true", myTAZFrameParent->myViewNet->getUndoList());
1064  }
1065  }
1066  }
1067  return 1;
1068 }
1069 
1070 
1071 void
1073  if (myEdgeAndTAZChildrenSelected.size() > 0) {
1074  // show TAZSources/Sinks frames
1075  myTAZSourceFrame->show();
1076  myTAZSinkFrame->show();
1077  // declare string sets for TextFields (to avoid duplicated values)
1078  std::set<std::string> weightSourceSet;
1079  std::set<std::string> weightSinkSet;
1080  // declare statistic variables
1081  double weight = 0;
1082  double maxWeightSource = 0;
1083  double minWeightSource = -1;
1084  double averageWeightSource = 0;
1085  double maxWeightSink = 0;
1086  double minWeightSink = -1;
1087  double averageWeightSink = 0;
1088  // iterate over child TAZElements
1089  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
1090  //start with sources
1091  weight = selectedEdge.source->getDepartWeight();
1092  // insert source weight in weightSinkTextField
1093  weightSourceSet.insert(toString(weight));
1094  // check max Weight
1095  if (maxWeightSource < weight) {
1096  maxWeightSource = weight;
1097  }
1098  // check min Weight
1099  if (minWeightSource == -1 || (maxWeightSource < weight)) {
1100  minWeightSource = weight;
1101  }
1102  // update Average
1103  averageWeightSource += weight;
1104  // continue with sinks
1105  weight = selectedEdge.sink->getDepartWeight();
1106  // save sink weight in weightSinkTextField
1107  weightSinkSet.insert(toString(weight));
1108  // check max Weight
1109  if (maxWeightSink < weight) {
1110  maxWeightSink = weight;
1111  }
1112  // check min Weight
1113  if (minWeightSink == -1 || (maxWeightSink < weight)) {
1114  minWeightSink = weight;
1115  }
1116  // update Average
1117  averageWeightSink += weight;
1118  }
1119  // calculate average
1120  averageWeightSource /= (double)myEdgeAndTAZChildrenSelected.size();
1121  averageWeightSink /= (double)myEdgeAndTAZChildrenSelected.size();
1122  // declare ostringstream for statistics
1123  std::ostringstream information;
1124  std::string edgeInformation;
1125  // first fill edgeInformation
1126  if (myEdgeAndTAZChildrenSelected.size() == 1) {
1127  edgeInformation = TL("- Edge ID: ") + myEdgeAndTAZChildrenSelected.begin()->edge->getID();
1128  } else {
1129  edgeInformation = TL("- Number of edges: ") + toString(myEdgeAndTAZChildrenSelected.size());
1130  }
1131  // fill rest of information
1132  information
1133  << edgeInformation << "\n"
1134  << TL("- Min source: ") << toString(minWeightSource) << "\n"
1135  << TL("- Max source: ") << toString(maxWeightSource) << "\n"
1136  << TL("- Average source: ") << toString(averageWeightSource) << "\n"
1137  << "\n"
1138  << TL("- Min sink: ") << toString(minWeightSink) << "\n"
1139  << TL("- Max sink: ") << toString(maxWeightSink) << "\n"
1140  << TL("- Average sink: ") << toString(averageWeightSink);
1141  // set new label
1142  myStatisticsLabel->setText(information.str().c_str());
1143  // set TextFields (Text and color)
1144  myTextFieldTAZSourceWeight->setText(joinToString(weightSourceSet, " ").c_str());
1145  myTextFieldTAZSourceWeight->setTextColor(FXRGB(0, 0, 0));
1146  myTextFieldTAZSinkWeight->setText(joinToString(weightSinkSet, " ").c_str());
1147  myTextFieldTAZSinkWeight->setTextColor(FXRGB(0, 0, 0));
1148  } else {
1149  // hide TAZSources/Sinks frames
1150  myTAZSourceFrame->hide();
1151  myTAZSinkFrame->hide();
1152  // hide myStatisticsLabel
1153  myStatisticsLabel->setText(TL("No edges selected"));
1154  }
1155 }
1156 
1157 // ---------------------------------------------------------------------------
1158 // GNETAZFrame::TAZParameters- methods
1159 // ---------------------------------------------------------------------------
1160 
1162  MFXGroupBoxModule(TAZFrameParent, TL("TAZ parameters")),
1163  myTAZFrameParent(TAZFrameParent),
1164  myTAZTemplate(nullptr) {
1165  // create TAZ Template
1166  myTAZTemplate = new GNETAZ(TAZFrameParent->getViewNet()->getNet());
1167  // create Button and string textField for center (by default, empty)
1168  FXHorizontalFrame* centerParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
1169  new FXLabel(centerParameter, toString(SUMO_ATTR_CENTER).c_str(), 0, GUIDesignLabelThickedFixed(100));
1170  myTextFieldCenter = new FXTextField(centerParameter, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
1171  // create Button and string textField for color and set blue as default color
1172  FXHorizontalFrame* fillParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
1173  new FXLabel(fillParameter, toString(SUMO_ATTR_FILL).c_str(), 0, GUIDesignLabelThickedFixed(100));
1174  myCheckButtonFill = new FXCheckButton(fillParameter, "false", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
1175  myCheckButtonFill->setCheck(FALSE);
1176  // create Button and string textField for color and set blue as default color
1177  FXHorizontalFrame* colorParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
1180  myTextFieldColor = new FXTextField(colorParameter, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
1181  myTextFieldColor->setText("blue");
1182  // create Button and string textField for name and set blue as default name
1183  FXHorizontalFrame* nameParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
1184  new FXLabel(nameParameter, toString(SUMO_ATTR_NAME).c_str(), 0, GUIDesignLabelThickedFixed(100));
1185  myTextFieldName = new FXTextField(nameParameter, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
1186  // create Label and CheckButton for use inner edges with true as default value
1187  FXHorizontalFrame* useInnenEdges = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
1188  new FXLabel(useInnenEdges, TL("Edges within"), 0, GUIDesignLabelThickedFixed(100));
1189  myAddEdgesWithinCheckButton = new FXCheckButton(useInnenEdges, TL("use"), this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
1190  myAddEdgesWithinCheckButton->setCheck(true);
1191  // Create help button
1193 }
1194 
1195 
1197  delete myTAZTemplate;
1198 }
1199 
1200 
1201 void
1203  MFXGroupBoxModule::show();
1204 }
1205 
1206 
1207 void
1209  MFXGroupBoxModule::hide();
1210 }
1211 
1212 
1213 bool
1215  const bool validColor = GNEAttributeCarrier::canParse<RGBColor>(myTextFieldColor->getText().text());
1216  const bool validCenter = myTextFieldCenter->getText().empty() || GNEAttributeCarrier::canParse<Position>(myTextFieldCenter->getText().text());
1217  const bool validName = SUMOXMLDefinitions::isValidAttribute(myTextFieldName->getText().text());
1218  return (validColor && validCenter && validName);
1219 }
1220 
1221 
1222 bool
1224  return (myAddEdgesWithinCheckButton->getCheck() == TRUE);
1225 }
1226 
1227 
1228 void
1230  // check if baseTAZ exist, and if yes, delete it
1231  if (myTAZFrameParent->myBaseTAZ) {
1232  // delete baseTAZ (and all children)
1233  delete myTAZFrameParent->myBaseTAZ;
1234  }
1235  // create a base TAZ
1236  myTAZFrameParent->myBaseTAZ = new CommonXMLStructure::SumoBaseObject(nullptr);
1237  // set tag
1238  myTAZFrameParent->myBaseTAZ->setTag(SUMO_TAG_TAZ);
1239  // get attributes
1240  myTAZFrameParent->myBaseTAZ->addPositionAttribute(SUMO_ATTR_CENTER, myTextFieldCenter->getText().empty() ? Position::INVALID : GNEAttributeCarrier::parse<Position>(myTextFieldCenter->getText().text()));
1241  myTAZFrameParent->myBaseTAZ->addBoolAttribute(SUMO_ATTR_FILL, (myCheckButtonFill->getCheck() == TRUE));
1242  myTAZFrameParent->myBaseTAZ->addColorAttribute(SUMO_ATTR_COLOR, GNEAttributeCarrier::parse<RGBColor>(myTextFieldColor->getText().text()));
1243  myTAZFrameParent->myBaseTAZ->addStringAttribute(SUMO_ATTR_NAME, myTextFieldName->getText().text());
1244 }
1245 
1246 
1247 long
1249  // create FXColorDialog
1250  FXColorDialog colordialog(getCollapsableFrame(), TL("Color Dialog"));
1251  colordialog.setTarget(this);
1252  colordialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::COLORWHEEL));
1253  // If previous attribute wasn't correct, set black as default color
1254  if (GNEAttributeCarrier::canParse<RGBColor>(myTextFieldColor->getText().text())) {
1255  colordialog.setRGBA(MFXUtils::getFXColor(GNEAttributeCarrier::parse<RGBColor>(myTextFieldColor->getText().text())));
1256  } else {
1257  colordialog.setRGBA(MFXUtils::getFXColor(RGBColor::BLUE));
1258  }
1259  // execute dialog to get a new color
1260  if (colordialog.execute()) {
1261  myTextFieldColor->setText(toString(MFXUtils::getRGBColor(colordialog.getRGBA())).c_str());
1262  onCmdSetAttribute(0, 0, 0);
1263  }
1264  return 0;
1265 }
1266 
1267 
1268 long
1269 GNETAZFrame::TAZParameters::onCmdSetAttribute(FXObject* obj, FXSelector, void*) {
1270  if (obj == myTextFieldColor) {
1271  // check color
1272  if (GNEAttributeCarrier::canParse<RGBColor>(myTextFieldColor->getText().text())) {
1273  myTextFieldColor->setTextColor(FXRGB(0, 0, 0));
1274  myTextFieldColor->killFocus();
1275  } else {
1276  myTextFieldColor->setTextColor(FXRGB(255, 0, 0));
1277  }
1278  } else if (obj == myTextFieldCenter) {
1279  // check center
1280  if (myTextFieldCenter->getText().empty() || GNEAttributeCarrier::canParse<RGBColor>(myTextFieldCenter->getText().text())) {
1281  myTextFieldCenter->setTextColor(FXRGB(0, 0, 0));
1282  myTextFieldCenter->killFocus();
1283  } else {
1284  myTextFieldCenter->setTextColor(FXRGB(255, 0, 0));
1285  }
1286  } else if (obj == myTextFieldName) {
1287  // check name
1288  if (SUMOXMLDefinitions::isValidAttribute(myTextFieldName->getText().text())) {
1289  myTextFieldName->setTextColor(FXRGB(0, 0, 0));
1290  myTextFieldName->killFocus();
1291  } else {
1292  myTextFieldName->setTextColor(FXRGB(255, 0, 0));
1293  }
1294  } else if (obj == myAddEdgesWithinCheckButton) {
1295  // change useInnenEdgesCheckButton text
1296  if (myAddEdgesWithinCheckButton->getCheck() == TRUE) {
1297  myAddEdgesWithinCheckButton->setText(TL("use"));
1298  } else {
1299  myAddEdgesWithinCheckButton->setText(TL("not use"));
1300  }
1301  } else if (obj == myCheckButtonFill) {
1302  // change myCheckButtonFill text
1303  if (myCheckButtonFill->getCheck() == TRUE) {
1304  myCheckButtonFill->setText("true");
1305  } else {
1306  myCheckButtonFill->setText("false");
1307  }
1308  }
1309  return 0;
1310 }
1311 
1312 
1313 long
1314 GNETAZFrame::TAZParameters::onCmdHelp(FXObject*, FXSelector, void*) {
1315  myTAZFrameParent->openHelpAttributesDialog(myTAZTemplate);
1316  return 1;
1317 }
1318 
1319 // ---------------------------------------------------------------------------
1320 // GNETAZFrame::TAZEdgesGraphic - methods
1321 // ---------------------------------------------------------------------------
1322 
1324  MFXGroupBoxModule(TAZFrameParent, TL("Edges")),
1325  myTAZFrameParent(TAZFrameParent),
1326  myEdgeDefaultColor(RGBColor::GREY),
1327  myEdgeSelectedColor(RGBColor::MAGENTA) {
1328  // create label for non taz edge color information
1329  FXLabel* NonTAZEdgeLabel = new FXLabel(getCollapsableFrame(), TL("Non TAZ Edge"), nullptr, GUIDesignLabel(JUSTIFY_NORMAL));
1330  NonTAZEdgeLabel->setBackColor(MFXUtils::getFXColor(myEdgeDefaultColor));
1331  NonTAZEdgeLabel->setTextColor(MFXUtils::getFXColor(RGBColor::WHITE));
1332  // create label for selected TAZEdgeColor color information
1333  FXLabel* selectedTAZEdgeLabel = new FXLabel(getCollapsableFrame(), TL("Selected TAZ Edge"), nullptr, GUIDesignLabel(JUSTIFY_NORMAL));
1334  selectedTAZEdgeLabel->setBackColor(MFXUtils::getFXColor(myEdgeSelectedColor));
1335  // build rainbow
1336  GNEFrame::buildRainbow(this);
1337  // create Radio button for show edges by source weight
1338  myColorBySourceWeight = new FXRadioButton(getCollapsableFrame(), TL("Color by Source"), this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1339  // create Radio button for show edges by sink weight
1340  myColorBySinkWeight = new FXRadioButton(getCollapsableFrame(), TL("Color by Sink"), this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1341  // create Radio button for show edges by source + sink weight
1342  myColorBySourcePlusSinkWeight = new FXRadioButton(getCollapsableFrame(), TL("Color by Source + Sink"), this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1343  // create Radio button for show edges by source - sink weight
1344  myColorBySourceMinusSinkWeight = new FXRadioButton(getCollapsableFrame(), TL("Color by Source - Sink"), this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1345  // show by source as default
1346  myColorBySourceWeight->setCheck(true);
1347 }
1348 
1349 
1351 
1352 
1353 void
1355  // update edge colors
1356  updateEdgeColors();
1357  show();
1358 }
1359 
1360 
1361 void
1363  // iterate over all edges and restore color
1364  for (const auto& edge : myTAZFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
1365  for (const auto& lane : edge.second.second->getLanes()) {
1366  lane->setSpecialColor(nullptr);
1367  }
1368  }
1369  hide();
1370 }
1371 
1372 
1373 void
1375  const std::vector<RGBColor>& scaledColors = GNEViewNetHelper::getRainbowScaledColors();
1376  // start painting all edges in gray
1377  for (const auto& edge : myTAZFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
1378  if (!edge.second.second->isAttributeCarrierSelected()) {
1379  // set candidate color (in this case, gray)
1380  for (const auto lane : edge.second.second->getLanes()) {
1381  lane->setSpecialColor(&myEdgeDefaultColor);
1382  }
1383  }
1384  }
1385  // now paint Source/sinks colors
1386  for (const auto& TAZEdgeColor : myTAZFrameParent->myCurrentTAZ->getTAZEdges()) {
1387  if (!TAZEdgeColor.edge->isAttributeCarrierSelected()) {
1388  // set candidate color (in this case,
1389  for (const auto& lane : TAZEdgeColor.edge->getLanes()) {
1390  // check what will be painted (source, sink or both)
1391  if (myColorBySourceWeight->getCheck() == TRUE) {
1392  lane->setSpecialColor(&scaledColors.at(TAZEdgeColor.sourceColor), TAZEdgeColor.source->getDepartWeight());
1393  } else if (myColorBySinkWeight->getCheck() == TRUE) {
1394  lane->setSpecialColor(&scaledColors.at(TAZEdgeColor.sinkColor), TAZEdgeColor.sink->getDepartWeight());
1395  } else if (myColorBySourcePlusSinkWeight->getCheck() == TRUE) {
1396  lane->setSpecialColor(&scaledColors.at(TAZEdgeColor.sourcePlusSinkColor), TAZEdgeColor.source->getDepartWeight() + TAZEdgeColor.sink->getDepartWeight());
1397  } else {
1398  lane->setSpecialColor(&scaledColors.at(TAZEdgeColor.sourceMinusSinkColor), TAZEdgeColor.source->getDepartWeight() - TAZEdgeColor.sink->getDepartWeight());
1399  }
1400  }
1401  }
1402  }
1403  // as last step paint candidate colors
1404  for (const auto& selectedEdge : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
1405  if (!selectedEdge.edge->isAttributeCarrierSelected()) {
1406  // set candidate selected color
1407  for (const auto& lane : selectedEdge.edge->getLanes()) {
1408  lane->setSpecialColor(&myEdgeSelectedColor);
1409  }
1410  }
1411  }
1412  // always update view after setting new colors
1413  myTAZFrameParent->myViewNet->updateViewNet();
1414 }
1415 
1416 
1417 long
1418 GNETAZFrame::TAZEdgesGraphic::onCmdChoosenBy(FXObject* obj, FXSelector, void*) {
1419  // check what radio was pressed and disable the others
1420  if (obj == myColorBySourceWeight) {
1421  myColorBySinkWeight->setCheck(FALSE);
1422  myColorBySourcePlusSinkWeight->setCheck(FALSE);
1423  myColorBySourceMinusSinkWeight->setCheck(FALSE);
1424  } else if (obj == myColorBySinkWeight) {
1425  myColorBySourceWeight->setCheck(FALSE);
1426  myColorBySourcePlusSinkWeight->setCheck(FALSE);
1427  myColorBySourceMinusSinkWeight->setCheck(FALSE);
1428  } else if (obj == myColorBySourcePlusSinkWeight) {
1429  myColorBySourceWeight->setCheck(FALSE);
1430  myColorBySinkWeight->setCheck(FALSE);
1431  myColorBySourceMinusSinkWeight->setCheck(FALSE);
1432  } else if (obj == myColorBySourceMinusSinkWeight) {
1433  myColorBySourceWeight->setCheck(FALSE);
1434  myColorBySinkWeight->setCheck(FALSE);
1435  myColorBySourcePlusSinkWeight->setCheck(FALSE);
1436  }
1437  // update edge colors
1438  updateEdgeColors();
1439  return 1;
1440 }
1441 
1442 // ---------------------------------------------------------------------------
1443 // GNETAZFrame - methods
1444 // ---------------------------------------------------------------------------
1445 
1447  GNEFrame(viewParent, viewNet, TL("TAZs")),
1448  myBaseTAZ(nullptr) {
1449 
1450  // create current TAZ module
1451  myCurrentTAZ = new CurrentTAZ(this);
1452 
1453  // Create TAZ Parameters module
1454  myTAZParameters = new TAZParameters(this);
1455 
1456  // Create drawing controls module
1457  myDrawingShape = new GNEDrawingShape(this);
1458 
1459  // Create TAZ Edges Common Statistics module
1461 
1462  // Create save TAZ Edges module
1463  myTAZSaveChanges = new TAZSaveChanges(this);
1464 
1465  // Create TAZ Edges Common Parameters module
1467 
1468  // Create TAZ Edges Selection Statistics module
1470 
1471  // Create TAZ Edges Common Parameters module
1472  myTAZEdgesGraphic = new TAZEdgesGraphic(this);
1473 
1474  // by default there isn't a TAZ
1475  myCurrentTAZ->setTAZ(nullptr);
1476 }
1477 
1478 
1480  // check if we have to delete base TAZ object
1481  if (myBaseTAZ) {
1482  delete myBaseTAZ;
1483  }
1484 }
1485 
1486 
1487 void
1489  // hide frame
1490  GNEFrame::hide();
1491 }
1492 
1493 
1494 bool
1495 GNETAZFrame::processClick(const Position& clickedPosition, const GNEViewNetHelper::ViewObjectsSelector& viewObjects) {
1496  // Declare map to keep values
1497  std::map<SumoXMLAttr, std::string> valuesOfElement;
1498  if (myDrawingShape->isDrawing()) {
1499  // add or delete a new point depending of flag "delete last created point"
1502  } else {
1503  myDrawingShape->addNewPoint(clickedPosition);
1504  }
1505  return true;
1506  } else if ((myCurrentTAZ->getTAZ() == nullptr) || (viewObjects.getTAZFront() && myCurrentTAZ->getTAZ() && !myTAZSaveChanges->isChangesPending())) {
1507  // if user click over an TAZ and there isn't changes pending, then select a new TAZ
1508  if (viewObjects.getTAZFront()) {
1509  // avoid reset of Frame if user doesn't click over an TAZ
1510  myCurrentTAZ->setTAZ(viewObjects.getTAZFront());
1511  // update TAZStatistics
1514  return true;
1515  } else {
1516  return false;
1517  }
1518  } else if (viewObjects.getEdgeFront()) {
1519  // if toggle Edge is enabled, select edge. In other case create two new source/Sinks
1521  // create new source/Sinks or delete it
1522  return addOrRemoveTAZMember(viewObjects.getEdgeFront());
1523  } else {
1524  // first check if clicked edge was previously selected
1526  // clear selected edges
1528  } else {
1529  // iterate over TAZEdges saved in CurrentTAZ (it contains the Edge and Source/sinks)
1530  for (const auto& TAZEdgeColor : myCurrentTAZ->getTAZEdges()) {
1531  if (TAZEdgeColor.edge == viewObjects.getEdgeFront()) {
1532  // clear current selection (to avoid having two or more edges selected at the same time using mouse clicks)
1534  // now select edge
1535  myTAZSelectionStatistics->selectEdge(TAZEdgeColor);
1536  // edge selected, then return true
1537  return true;
1538  }
1539  }
1540  }
1541  // edge wasn't selected, then return false
1542  return false;
1543  }
1544  } else {
1545  // nothing to do
1546  return false;
1547  }
1548 }
1549 
1550 
1551 void
1552 GNETAZFrame::processEdgeSelection(const std::vector<GNEEdge*>& edges) {
1553  // first check that a TAZ is selected
1554  if (myCurrentTAZ->getTAZ()) {
1555  // if "toggle Membership" is enabled, create new TAZSources/sinks. In other case simply select edges
1557  // iterate over edges
1558  for (const auto& edge : edges) {
1559  // first check if edge owns a TAZEge
1560  if (!myCurrentTAZ->isTAZEdge(edge)) {
1561  // create new TAZ Sources/Sinks
1562  addOrRemoveTAZMember(edge);
1563  }
1564  }
1565  } else {
1566  // iterate over edges
1567  for (const auto& edge : edges) {
1568  // first check that selected edge isn't already selected
1570  // iterate over TAZEdges saved in CurrentTAZ (it contains the Edge and Source/sinks)
1571  for (const auto& TAZEdgeColor : myCurrentTAZ->getTAZEdges()) {
1572  if (TAZEdgeColor.edge == edge) {
1573  myTAZSelectionStatistics->selectEdge(TAZEdgeColor);
1574  }
1575  }
1576  }
1577  }
1578  }
1579  }
1580 }
1581 
1582 
1585  return myDrawingShape;
1586 }
1587 
1588 
1591  return myCurrentTAZ;
1592 }
1593 
1594 
1597  return myTAZSelectionStatistics;
1598 }
1599 
1600 
1603  return myTAZSaveChanges;
1604 }
1605 
1606 
1607 bool
1609  // show warning dialogbox and stop check if input parameters are valid
1611  return false;
1612  } else if (myDrawingShape->getTemporalShape().size() < 3) {
1613  WRITE_WARNING(TL("TAZ shape needs at least three points"));
1614  return false;
1615  } else {
1616  // get attributes and values
1618  // generate new ID
1620  // obtain shape and close it
1622  shape.closePolygon();
1624  // set center if is invalid
1627  }
1628  // check if TAZ has to be created with edges
1630  // update objects in boundary
1632  // get all edge IDs
1633  std::vector<std::string> edgeIDs;
1634  // get only edges with geometry around shape
1635  for (const auto& edge : myViewNet->getViewObjectsSelector().getEdges()) {
1637  edgeIDs.push_back(edge->getID());
1638  }
1639  }
1641  } else {
1642  // TAZ is created without edges
1643  myBaseTAZ->addStringListAttribute(SUMO_ATTR_EDGES, std::vector<std::string>());
1644  }
1645  // declare additional handler
1646  GNEAdditionalHandler additionalHandler(myViewNet->getNet(), true, false);
1647  // build TAZ
1648  additionalHandler.parseSumoBaseObject(myBaseTAZ);
1649  // TAZ created, then return true
1650  return true;
1651  }
1652 }
1653 
1654 
1655 bool
1657  // first check if edge exist;
1658  if (edge) {
1659  // first check if already exist (in this case, remove it)
1660  for (const auto& TAZEdgeColor : myCurrentTAZ->getTAZEdges()) {
1661  if (TAZEdgeColor.edge == edge) {
1662  // enable save changes button
1664  // remove Source and Sinks using GNEChange_TAZElement
1665  if (myViewNet->getNet()->getAttributeCarriers()->retrieveAdditional(TAZEdgeColor.source->getGUIGlObject(), false)) {
1666  myViewNet->getUndoList()->add(new GNEChange_Additional(TAZEdgeColor.source, false), true);
1667  }
1668  if (myViewNet->getNet()->getAttributeCarriers()->retrieveAdditional(TAZEdgeColor.sink->getGUIGlObject(), false)) {
1669  myViewNet->getUndoList()->add(new GNEChange_Additional(TAZEdgeColor.sink, false), true);
1670  }
1671  // always refresh TAZ Edges after removing TAZSources/Sinks
1673  // update select edges button
1675  return true;
1676  }
1677  }
1678  // if wasn't found, then add it
1680  // create TAZ Sink using GNEChange_TAZElement and value of TAZChild default parameters
1682  myViewNet->getUndoList()->add(new GNEChange_Additional(source, true), true);
1683  // create TAZ Sink using GNEChange_TAZElement and value of TAZChild default parameters
1685  myViewNet->getUndoList()->add(new GNEChange_Additional(sink, true), true);
1686  // always refresh TAZ Edges after adding TAZSources/Sinks
1688  // update selected button
1690  return true;
1691  } else {
1692  throw ProcessError("Edge cannot be null");
1693  }
1694 }
1695 
1696 
1697 void
1699  // iterate over all TAZEdges
1700  for (const auto& TAZEdgeColor : myCurrentTAZ->getTAZEdges()) {
1701  // enable save changes button
1703  // remove Source and Sinks using GNEChange_TAZElement
1704  if (myViewNet->getNet()->getAttributeCarriers()->retrieveAdditional(TAZEdgeColor.source, false)) {
1705  myViewNet->getUndoList()->add(new GNEChange_Additional(TAZEdgeColor.source, false), true);
1706  }
1707  if (myViewNet->getNet()->getAttributeCarriers()->retrieveAdditional(TAZEdgeColor.sink, false)) {
1708  myViewNet->getUndoList()->add(new GNEChange_Additional(TAZEdgeColor.sink, false), true);
1709  }
1710  }
1711  // always refresh TAZ Edges after removing TAZSources/Sinks
1713 }
1714 
1715 
1716 /****************************************************************************/
FXDEFMAP(GNETAZFrame::TAZParameters) TAZParametersMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
Definition: GUIAppEnum.h:930
@ MID_CANCEL
Cancel-button pressed.
Definition: GUIAppEnum.h:306
@ MID_GNE_SET_ATTRIBUTE_DIALOG
attribute edited trough dialog
Definition: GUIAppEnum.h:966
@ MID_CHOOSEN_OPERATION
set type of selection
Definition: GUIAppEnum.h:593
@ MID_HELP
help button
Definition: GUIAppEnum.h:648
@ MID_OK
Ok-button pressed.
Definition: GUIAppEnum.h:304
@ MID_GNE_SELECT
select element
Definition: GUIAppEnum.h:948
@ MID_GNE_SET_ZEROFRINGEPROB
set zero fringe probabilities (used in TAZ Frame)
Definition: GUIAppEnum.h:1022
#define GUIDesignButtonAttribute
button extended over over column with thick and raise frame
Definition: GUIDesigns.h:94
#define GUIDesignButton
Definition: GUIDesigns.h:88
#define GUIDesignTextField
Definition: GUIDesigns.h:65
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:405
#define GUIDesignButtonRectangular
little rectangular button used in frames (For example, in "help" buttons)
Definition: GUIDesigns.h:100
#define GUIDesignLabel(justify)
Definition: GUIDesigns.h:249
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition: GUIDesigns.h:80
#define GUIDesignCheckButton
checkButton placed in left position
Definition: GUIDesigns.h:198
#define GUIDesignRadioButton
Definition: GUIDesigns.h:235
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
Definition: GUIDesigns.h:258
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:285
@ SAVE
save icons
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:295
#define TL(string)
Definition: MsgHandler.h:315
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
@ GNE_ATTR_MAX_SOURCE
max source (used only by TAZs)
@ SUMO_ATTR_EDGE
@ GNE_ATTR_TAZCOLOR
Color of TAZSources/TAZSinks.
@ GNE_ATTR_MAX_SINK
max sink (used only by TAZs)
@ GNE_ATTR_AVERAGE_SINK
average sink (used only by TAZs)
@ GNE_ATTR_SELECTED
element is selected
@ GNE_ATTR_MIN_SINK
min sink (used only by TAZs)
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_WEIGHT
@ SUMO_ATTR_FILL
Fill the polygon.
@ SUMO_ATTR_NAME
@ SUMO_ATTR_CENTER
@ GNE_ATTR_AVERAGE_SOURCE
average source (used only by TAZs)
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ GNE_ATTR_MIN_SOURCE
min source (used only by TAZs)
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:283
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
void parseSumoBaseObject(CommonXMLStructure::SumoBaseObject *obj)
parse SumoBaseObject (it's called recursivelly)
const Position & getPositionAttribute(const SumoXMLAttr attr) const
get Position attribute
void addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector &value)
add PositionVector attribute into current SumoBaseObject node
void addStringListAttribute(const SumoXMLAttr attr, const std::vector< std::string > &value)
add string list attribute into current SumoBaseObject node
void addPositionAttribute(const SumoXMLAttr attr, const Position &value)
add Position attribute into current SumoBaseObject node
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
add string attribute into current SumoBaseObject node
Builds additional objects for GNENet (busStops, chargingStations, detectors, etc.....
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:49
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * getNet() const
get pointer to net
bool isDrawing() const
return true if currently a shape is drawed
void addNewPoint(const Position &P)
add new point to temporal shape
bool getDeleteLastCreatedPoint()
get flag delete last created point
void removeLastPoint()
remove last added point
const PositionVector & getTemporalShape() const
get Temporal shape
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
static FXLabel * buildRainbow(FXComposite *parent)
build rainbow in frame modul
Definition: GNEFrame.cpp:317
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:150
GNEViewNet * myViewNet
FOX need this.
Definition: GNEFrame.h:117
virtual void show()
show Frame
Definition: GNEFrame.cpp:115
virtual void hide()
hide Frame
Definition: GNEFrame.cpp:124
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
bool isNetworkElementAroundShape(GNEAttributeCarrier *AC, const PositionVector &shape) const
check if shape of given AC (network element) is around the given shape
std::string generateAdditionalID(SumoXMLTag type) const
generate additional id
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
std::vector< GNEEdge * > getSelectedEdges() const
return all edges
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:121
struct for edges and the source/sink colors
Definition: GNETAZFrame.h:52
GNETAZSourceSink * sink
@brif sink TAZ
Definition: GNETAZFrame.h:71
GNETAZSourceSink * source
source TAZ
Definition: GNETAZFrame.h:68
~TAZEdgeColor()
destructor (needed because RGBColors has to be deleted)
Definition: GNETAZFrame.cpp:94
void refreshTAZEdges()
refresh TAZEdges
double myMinSourceMinusSinkWeight
minimum source minus sink value of current TAZ Edges
Definition: GNETAZFrame.h:147
bool isTAZEdge(GNEEdge *edge) const
check if given edge belongs to current TAZ
GNETAZFrame * myTAZFrameParent
pointer to TAZ Frame
Definition: GNETAZFrame.h:123
GNETAZ * myEditedTAZ
current edited TAZ
Definition: GNETAZFrame.h:126
const std::vector< CurrentTAZ::TAZEdgeColor > & getTAZEdges() const
get TAZEdges
void setTAZ(GNETAZ *editedTAZ)
set current TAZ
void addTAZChild(GNETAZSourceSink *additional)
add TAZChild
const std::vector< GNEEdge * > & getSelectedEdges() const
get current selected edges
double myMaxSourceMinusSinkWeight
maximum source minus sink value of current TAZ Edges
Definition: GNETAZFrame.h:144
FXLabel * myCurrentTAZLabel
Label for current TAZ.
Definition: GNETAZFrame.h:135
CurrentTAZ(GNETAZFrame *TAZFrameParent)
constructor
double myMaxSourcePlusSinkWeight
maximum source plus sink value of current TAZ Edges
Definition: GNETAZFrame.h:138
double myMinSourcePlusSinkWeight
minimum source plus sink value of current TAZ Edges
Definition: GNETAZFrame.h:141
GNETAZ * getTAZ() const
get current TAZ
bool getToggleMembership() const
check if toggle membership is enabled
FXButton * myUseSelectedEdges
button for use selected edges
Definition: GNETAZFrame.h:302
TAZChildDefaultParameters(GNETAZFrame *TAZFrameParent)
FOX-declaration.
FXCheckButton * myToggleMembership
CheckButton to enable or disable Toggle edge Membership.
Definition: GNETAZFrame.h:284
void collapseTAZChildDefaultParameters()
collapse TAZ child default parameters Module (if we have selected a TAZ)
FXTextField * myTextFieldDefaultValueTAZSources
textField to set a default value for TAZ Sources
Definition: GNETAZFrame.h:293
long onCmdUseSelectedEdges(FXObject *obj, FXSelector, void *)
Called when the user press "use selected edges" button.
void updateSelectEdgesButton()
update "select edges button"
double getDefaultTAZSourceWeight() const
get default source weight
void extendTAZChildDefaultParameters()
extend TAZ child default parameters Module (if we have selected a TAZ)
FXLabel * myInformationLabel
information label
Definition: GNETAZFrame.h:308
FXHorizontalFrame * myDefaultTAZSinkFrame
Horizontal Frame for default TAZ Sink Weight.
Definition: GNETAZFrame.h:296
FXHorizontalFrame * myDefaultTAZSourceFrame
Horizontal Frame for default TAZ Source Weight.
Definition: GNETAZFrame.h:290
FXHorizontalFrame * myToggleMembershipFrame
Horizontal Frame toggle membership.
Definition: GNETAZFrame.h:287
long onCmdSetZeroFringeProbabilities(FXObject *obj, FXSelector, void *)
Called when the user press "zero fringe probabilities" button.
FXTextField * myTextFieldDefaultValueTAZSinks
textField to set a default value for TAZ Sinks
Definition: GNETAZFrame.h:299
long onCmdSetDefaultValues(FXObject *obj, FXSelector, void *)
double getDefaultTAZSinkWeight() const
default sink weight
FXButton * myZeroFringeProbabilities
button for setting zero fringe probabilities
Definition: GNETAZFrame.h:305
void showTAZCommonStatisticsModule()
show TAZ Common Statistics Module
TAZCommonStatistics(GNETAZFrame *TAZFrameParent)
constructor
FXLabel * myStatisticsLabel
Statistics labels.
Definition: GNETAZFrame.h:177
void hideTAZCommonStatisticsModule()
hide TAZ Common Statistics Module
void updateStatistics()
update Statistics label
FXRadioButton * myColorBySourcePlusSinkWeight
add radio button "color source + sink"
Definition: GNETAZFrame.h:509
RGBColor myEdgeSelectedColor
RGBColor color for selected egdes.
Definition: GNETAZFrame.h:518
FXRadioButton * myColorBySinkWeight
add radio button "color by sink"
Definition: GNETAZFrame.h:506
void showTAZEdgesGraphicModule()
show TAZ Edges Graphic Module
void updateEdgeColors()
update edge colors;
FXRadioButton * myColorBySourceWeight
add radio button "color by source"
Definition: GNETAZFrame.h:503
FXRadioButton * myColorBySourceMinusSinkWeight
add radio button "color source - Sink"
Definition: GNETAZFrame.h:512
RGBColor myEdgeDefaultColor
default RGBColor for all edges
Definition: GNETAZFrame.h:515
long onCmdChoosenBy(FXObject *obj, FXSelector, void *)
void hideTAZEdgesGraphicModule()
hide TAZ Edges Graphic Module
TAZEdgesGraphic(GNETAZFrame *TAZFrameParent)
FOX-declaration.
FXTextField * myTextFieldName
textField to modify the default value of name parameter
Definition: GNETAZFrame.h:456
void getAttributesAndValues() const
get a map with attributes and their values
bool isAddEdgesWithinEnabled() const
check if edges within has to be used after TAZ Creation
void showTAZParametersModule()
show TAZ parameters and set the default value of parameters
TAZParameters(GNETAZFrame *TAZFrameParent)
FOX-declaration.
FXButton * myHelpTAZAttribute
button for help
Definition: GNETAZFrame.h:462
FXCheckButton * myAddEdgesWithinCheckButton
CheckButton to enable or disable use edges within TAZ after creation.
Definition: GNETAZFrame.h:459
long onCmdSetAttribute(FXObject *, FXSelector, void *)
Called when user set a value.
long onCmdHelp(FXObject *, FXSelector, void *)
Called when help button is pressed.
void hideTAZParametersModule()
hide TAZ parameters
long onCmdSetColorAttribute(FXObject *, FXSelector, void *)
FXButton * myColorEditor
Button for open color editor.
Definition: GNETAZFrame.h:444
FXTextField * myTextFieldCenter
text field center
Definition: GNETAZFrame.h:447
FXTextField * myTextFieldColor
textField to modify the default value of color parameter
Definition: GNETAZFrame.h:453
FXCheckButton * myCheckButtonFill
CheckButton to enable or disable fill.
Definition: GNETAZFrame.h:450
bool isCurrentParametersValid() const
check if current parameters are valid
bool isChangesPending() const
return true if there is changes to save
FXButton * mySaveChangesButton
@field FXButton for save changes in TAZEdges
Definition: GNETAZFrame.h:224
void showTAZSaveChangesModule()
show TAZ Save Changes Module
FXButton * myCancelChangesButton
@field FXButton for cancel changes in TAZEdges
Definition: GNETAZFrame.h:227
long onCmdCancelChanges(FXObject *, FXSelector, void *)
Called when the user press the button cancel changes.
TAZSaveChanges(GNETAZFrame *TAZFrameParent)
FOX-declaration.
void hideTAZSaveChangesModule()
hide TAZ Save Changes Module
long onCmdSaveChanges(FXObject *, FXSelector, void *)
void enableButtonsAndBeginUndoList()
enable buttons save and cancel changes (And begin Undo List)
long onCmdSelectEdges(FXObject *obj, FXSelector, void *)
Called when the user press select edges.
TAZSelectionStatistics(GNETAZFrame *TAZFrameParent)
FOX-declaration.
FXHorizontalFrame * myTAZSourceFrame
Horizontal Frame for default TAZ Source Weight.
Definition: GNETAZFrame.h:373
void hideTAZSelectionStatisticsModule()
hide TAZ Selection Statistics Module
bool isEdgeSelected(GNEEdge *edge)
check if an edge is selected
FXHorizontalFrame * myTAZSinkFrame
Horizontal Frame for default TAZ Sink Weight.
Definition: GNETAZFrame.h:379
const std::vector< CurrentTAZ::TAZEdgeColor > & getEdgeAndTAZChildrenSelected() const
get map with edge and TAZChildren
void showTAZSelectionStatisticsModule()
show TAZ Selection Statistics Module
long onCmdSetNewValues(FXObject *obj, FXSelector, void *)
void clearSelectedEdges()
clear current TAZ children
FXTextField * myTextFieldTAZSourceWeight
textField for TAZ Source weight
Definition: GNETAZFrame.h:376
void updateStatistics()
update TAZSelectionStatistics
FXTextField * myTextFieldTAZSinkWeight
textField for TAZ Sink weight
Definition: GNETAZFrame.h:382
bool selectEdge(const CurrentTAZ::TAZEdgeColor &edge)
add an edge and their TAZ Children in the list of selected items
bool unselectEdge(GNEEdge *edge)
un select an edge (and their TAZ Children)
FXLabel * myStatisticsLabel
Statistics labels.
Definition: GNETAZFrame.h:385
TAZSelectionStatistics * myTAZSelectionStatistics
TAZ Edges selection parameters.
Definition: GNETAZFrame.h:591
TAZSelectionStatistics * getTAZSelectionStatisticsModule() const
get TAZ Selection Statistics modul
TAZSaveChanges * getTAZSaveChangesModule() const
get TAZ Save Changes modul
CurrentTAZ * myCurrentTAZ
current TAZ
Definition: GNETAZFrame.h:573
TAZEdgesGraphic * myTAZEdgesGraphic
TAZ Edges Graphic.
Definition: GNETAZFrame.h:594
TAZParameters * myTAZParameters
TAZ parameters.
Definition: GNETAZFrame.h:579
bool addOrRemoveTAZMember(GNEEdge *edge)
add or remove a source and a sink, or remove it if edge is in the list of TAZ Children
void dropTAZMembers()
drop all TAZSources and TAZ Sinks of current TAZ
GNEDrawingShape * getDrawingShapeModule() const
get drawing mode modul
CurrentTAZ * getCurrentTAZModule() const
get Current TAZ modul
TAZCommonStatistics * myTAZCommonStatistics
TAZ Edges common parameters.
Definition: GNETAZFrame.h:576
GNEDrawingShape * myDrawingShape
Drawing shape.
Definition: GNETAZFrame.h:582
bool shapeDrawed()
build a shaped element using the drawed shape return true if was successfully created
~GNETAZFrame()
Destructor.
TAZSaveChanges * myTAZSaveChanges
save TAZ Edges
Definition: GNETAZFrame.h:585
CommonXMLStructure::SumoBaseObject * myBaseTAZ
SumoBaseObject used for creating TAZ.
Definition: GNETAZFrame.h:557
void hide()
hide TAZ frame
void processEdgeSelection(const std::vector< GNEEdge * > &edges)
process selection of edges in view net
bool processClick(const Position &clickedPosition, const GNEViewNetHelper::ViewObjectsSelector &viewObjects)
process click over Viewnet
TAZChildDefaultParameters * myTAZChildDefaultParameters
TAZ child defaults parameters.
Definition: GNETAZFrame.h:588
GNETAZFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
Definition: GNETAZ.h:34
void updateTAZStatistic()
update TAZ Statistic
Definition: GNETAZ.cpp:599
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
double getDepartWeight() const
get depart weight
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
class used to group all variables related with objects under cursor after a click over view
GNEEdge * getEdgeFront() const
get front edge or a pointer to nullptr
GNETAZ * getTAZFront() const
get front TAZ or a pointer to nullptr
const std::vector< GNEEdge * > & getEdges() const
get vector with edges
GNENet * getNet() const
get the net object
void updateObjectsInBoundary(const Boundary &boundary)
get objects in the given boundary
Definition: GNEViewNet.cpp:474
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
Definition: GNEViewNet.cpp:468
A single child window which contains a view of the simulation area.
Definition: GNEViewParent.h:88
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
Definition: GUIDesigns.cpp:128
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
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)
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:112
static RGBColor getRGBColor(FXColor col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:106
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:317
A list of positions.
void closePolygon()
ensures that the last position equals the first
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
static const RGBColor WHITE
Definition: RGBColor.h:192
static const RGBColor BLUE
Definition: RGBColor.h:187
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
static const std::vector< RGBColor > & getRainbowScaledColors()
get scaled rainbow colors