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.org/sumo
3 // Copyright (C) 2001-2020 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>
32 
33 #include "GNETAZFrame.h"
34 
35 
36 // ===========================================================================
37 // FOX callback mapping
38 // ===========================================================================
39 
40 FXDEFMAP(GNETAZFrame::TAZParameters) TAZParametersMap[] = {
43  FXMAPFUNC(SEL_COMMAND, MID_HELP, GNETAZFrame::TAZParameters::onCmdHelp),
44 };
45 
46 FXDEFMAP(GNETAZFrame::TAZSaveChanges) TAZSaveChangesMap[] = {
49 };
50 
51 FXDEFMAP(GNETAZFrame::TAZChildDefaultParameters) TAZChildDefaultParametersMap[] = {
54 };
55 
56 FXDEFMAP(GNETAZFrame::TAZSelectionStatistics) TAZSelectionStatisticsMap[] = {
58 };
59 
60 FXDEFMAP(GNETAZFrame::TAZEdgesGraphic) TAZEdgesGraphicMap[] = {
62 };
63 
64 // Object implementation
65 FXIMPLEMENT(GNETAZFrame::TAZParameters, FXGroupBox, TAZParametersMap, ARRAYNUMBER(TAZParametersMap))
66 FXIMPLEMENT(GNETAZFrame::TAZSaveChanges, FXGroupBox, TAZSaveChangesMap, ARRAYNUMBER(TAZSaveChangesMap))
67 FXIMPLEMENT(GNETAZFrame::TAZChildDefaultParameters, FXGroupBox, TAZChildDefaultParametersMap, ARRAYNUMBER(TAZChildDefaultParametersMap))
68 FXIMPLEMENT(GNETAZFrame::TAZSelectionStatistics, FXGroupBox, TAZSelectionStatisticsMap, ARRAYNUMBER(TAZSelectionStatisticsMap))
69 FXIMPLEMENT(GNETAZFrame::TAZEdgesGraphic, FXGroupBox, TAZEdgesGraphicMap, ARRAYNUMBER(TAZEdgesGraphicMap))
70 
71 
72 // ===========================================================================
73 // method definitions
74 // ===========================================================================
75 
76 // ---------------------------------------------------------------------------
77 // GNETAZFrame::TAZCurrent - methods
78 // ---------------------------------------------------------------------------
79 
80 GNETAZFrame::TAZCurrent::TAZEdge::TAZEdge(TAZCurrent* TAZCurrentParent, GNEEdge* _edge, GNETAZSourceSink* _TAZSource, GNETAZSourceSink* _TAZSink) :
81  edge(_edge),
82  TAZSource(_TAZSource),
83  TAZSink(_TAZSink),
84  sourceColor(0),
85  sinkColor(0),
86  sourcePlusSinkColor(0),
87  sourceMinusSinkColor(0),
88  myTAZCurrentParent(TAZCurrentParent)
89 { }
90 
91 
93 
94 
95 void
97  sourceColor = GNEAttributeCarrier::parse<int>(TAZSource->getAttribute(GNE_ATTR_TAZCOLOR));
98  sinkColor = GNEAttributeCarrier::parse<int>(TAZSink->getAttribute(GNE_ATTR_TAZCOLOR));
99  // Obtain Source+Sink needs more steps. First obtain Source+Sink Weight
100  double sourcePlusSinkWeight = TAZSource->getDepartWeight() + TAZSink->getDepartWeight();
101  // avoid division between zero
102  if ((myTAZCurrentParent->myMaxSourcePlusSinkWeight - myTAZCurrentParent->myMinSourcePlusSinkWeight) == 0) {
103  sourcePlusSinkColor = 0;
104  } else {
105  // calculate percentage relative to the max and min Source+Sink weight
106  double percentage = (sourcePlusSinkWeight - myTAZCurrentParent->myMinSourcePlusSinkWeight) /
107  (myTAZCurrentParent->myMaxSourcePlusSinkWeight - myTAZCurrentParent->myMinSourcePlusSinkWeight);
108  // convert percentage to a value between [0-9] (because we have only 10 colors)
109  if (percentage >= 1) {
110  sourcePlusSinkColor = 9;
111  } else if (percentage < 0) {
112  sourcePlusSinkColor = 0;
113  } else {
114  sourcePlusSinkColor = (int)(percentage * 10);
115  }
116  }
117  // Obtain Source+Sink needs more steps. First obtain Source-Sink Weight
118  double sourceMinusSinkWeight = TAZSource->getDepartWeight() - TAZSink->getDepartWeight();
119  // avoid division between zero
120  if ((myTAZCurrentParent->myMaxSourceMinusSinkWeight - myTAZCurrentParent->myMinSourceMinusSinkWeight) == 0) {
121  sourceMinusSinkColor = 0;
122  } else {
123  // calculate percentage relative to the max and min Source-Sink weight
124  double percentage = (sourceMinusSinkWeight - myTAZCurrentParent->myMinSourceMinusSinkWeight) /
125  (myTAZCurrentParent->myMaxSourceMinusSinkWeight - myTAZCurrentParent->myMinSourceMinusSinkWeight);
126  // convert percentage to a value between [0-9] (because we have only 10 colors)
127  if (percentage >= 1) {
128  sourceMinusSinkColor = 9;
129  } else if (percentage < 0) {
130  sourceMinusSinkColor = 0;
131  } else {
132  sourceMinusSinkColor = (int)(percentage * 10);
133  }
134  }
135 }
136 
137 
139  FXGroupBox(TAZFrameParent->myContentFrame, "TAZ", GUIDesignGroupBoxFrame),
140  myTAZFrameParent(TAZFrameParent),
141  myEditedTAZ(nullptr),
146  // create TAZ label
147  myTAZCurrentLabel = new FXLabel(this, "No TAZ selected", 0, GUIDesignLabelLeft);
148 }
149 
150 
152 
153 
154 void
156  // set new current TAZ
157  myEditedTAZ = editedTAZ;
158  // update label and moduls
159  if (myEditedTAZ != nullptr) {
160  myTAZCurrentLabel->setText(("Current TAZ: " + myEditedTAZ->getID()).c_str());
161  // obtain a copy of all edges of the net (to avoid slowdown during manipulations)
162  myNetEdges = myTAZFrameParent->myViewNet->getNet()->retrieveEdges();
163  // obtain a copy of all SELECTED edges of the net (to avoid slowdown during manipulations)
164  mySelectedEdges = myTAZFrameParent->myViewNet->getNet()->retrieveEdges(true);
165  // resfresh TAZ Edges
166  refreshTAZEdges();
167  // hide TAZ parameters
168  myTAZFrameParent->myTAZParameters->hideTAZParametersModul();
169  // hide Netedit parameters
170  myTAZFrameParent->myNeteditAttributes->hideNeteditAttributesModul();
171  // hide drawing shape
172  myTAZFrameParent->myDrawingShape->hideDrawingShape();
173  // show edge common parameters
174  myTAZFrameParent->myTAZCommonStatistics->showTAZCommonStatisticsModul();
175  // show save TAZ Edges
176  myTAZFrameParent->myTAZSaveChanges->showTAZSaveChangesModul();
177  // show edge common parameters
178  myTAZFrameParent->myTAZChildDefaultParameters->showTAZChildDefaultParametersModul();
179  // show Edges graphics
180  myTAZFrameParent->myTAZEdgesGraphic->showTAZEdgesGraphicModul();
181  } else {
182  // show TAZ parameters
183  myTAZFrameParent->myTAZParameters->showTAZParametersModul();
184  // show Netedit parameters
185  myTAZFrameParent->myNeteditAttributes->showNeteditAttributesModul(GNEAttributeCarrier::getTagProperties(SUMO_TAG_TAZ));
186  // show drawing shape
187  myTAZFrameParent->myDrawingShape->showDrawingShape();
188  // hide edge common parameters
189  myTAZFrameParent->myTAZCommonStatistics->hideTAZCommonStatisticsModul();
190  // hide edge common parameters
191  myTAZFrameParent->myTAZChildDefaultParameters->hideTAZChildDefaultParametersModul();
192  // hide Edges graphics
193  myTAZFrameParent->myTAZEdgesGraphic->hideTAZEdgesGraphicModul();
194  // hide save TAZ Edges
195  myTAZFrameParent->myTAZSaveChanges->hideTAZSaveChangesModul();
196  // restore label
197  myTAZCurrentLabel->setText("No TAZ selected");
198  // clear net edges (always the last step due hideTAZEdgesGraphicModul() function)
199  myNetEdges.clear();
200  // clear selected edges
201  mySelectedEdges.clear();
202  // reset all weight values
203  myMaxSourcePlusSinkWeight = 0;
204  myMinSourcePlusSinkWeight = -1;
205  myMaxSourceMinusSinkWeight = 0;
206  myMinSourceMinusSinkWeight = -1;
207  }
208 }
209 
210 
211 GNETAZ*
213  return myEditedTAZ;
214 }
215 
216 
217 bool
219  // simply iterate over edges and check edge parameter
220  for (const auto& i : myTAZEdges) {
221  if (i.edge == edge) {
222  return true;
223  }
224  }
225  // not found, then return false
226  return false;
227 }
228 
229 
230 const std::vector<GNEEdge*>&
232  return myNetEdges;
233 }
234 
235 
236 const std::vector<GNEEdge*>&
238  return mySelectedEdges;
239 }
240 
241 
242 const std::vector<GNETAZFrame::TAZCurrent::TAZEdge>&
244  return myTAZEdges;
245 }
246 
247 
248 void
250  // clear all curren TAZEdges
251  myTAZEdges.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  // iterate over child additional and create TAZEdges
260  for (const auto& TAZElement : myEditedTAZ->getChildTAZElements()) {
261  addTAZChild(dynamic_cast<GNETAZSourceSink*>(TAZElement));
262  }
263  // update colors after add all edges
264  for (auto& i : myTAZEdges) {
265  i.updateColors();
266  }
267  // update edge colors
268  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
269  }
270 }
271 
272 
273 void
275  // first make sure that additional is an TAZ Source or Sink
276  if (sourceSink && ((sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) || (sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSINK))) {
277  GNEEdge* edge = myTAZFrameParent->myViewNet->getNet()->retrieveEdge(sourceSink->getAttribute(SUMO_ATTR_EDGE));
278  // first check if TAZEdge has to be created
279  bool createTAZEdge = true;
280  for (auto& i : myTAZEdges) {
281  if (i.edge == edge) {
282  createTAZEdge = false;
283  // update TAZ Source or Sink
284  if (sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
285  i.TAZSource = sourceSink;
286  } else {
287  i.TAZSink = sourceSink;
288  }
289  }
290  }
291  // check if additional has to be created
292  if (createTAZEdge) {
293  if (sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
294  myTAZEdges.push_back(TAZEdge(this, edge, sourceSink, nullptr));
295  } else {
296  myTAZEdges.push_back(TAZEdge(this, edge, nullptr, sourceSink));
297  }
298  }
299  // recalculate weights
300  myMaxSourcePlusSinkWeight = 0;
301  myMinSourcePlusSinkWeight = -1;
302  myMaxSourceMinusSinkWeight = 0;
303  myMinSourceMinusSinkWeight = -1;
304  for (const auto& i : myTAZEdges) {
305  // make sure that both TAZ Source and Sink exist
306  if (i.TAZSource && i.TAZSink) {
307  // obtain source plus sink
308  double sourcePlusSink = i.TAZSource->getDepartWeight() + i.TAZSink->getDepartWeight();
309  // check myMaxSourcePlusSinkWeight
310  if (sourcePlusSink > myMaxSourcePlusSinkWeight) {
311  myMaxSourcePlusSinkWeight = sourcePlusSink;
312  }
313  // check myMinSourcePlusSinkWeight
314  if ((myMinSourcePlusSinkWeight == -1) || (sourcePlusSink < myMinSourcePlusSinkWeight)) {
315  myMinSourcePlusSinkWeight = sourcePlusSink;
316  }
317  // obtain source minus sink
318  double sourceMinusSink = i.TAZSource->getDepartWeight() - i.TAZSink->getDepartWeight();
319  // use valor absolute
320  if (sourceMinusSink < 0) {
321  sourceMinusSink *= -1;
322  }
323  // check myMaxSourcePlusSinkWeight
324  if (sourceMinusSink > myMaxSourceMinusSinkWeight) {
325  myMaxSourceMinusSinkWeight = sourceMinusSink;
326  }
327  // check myMinSourcePlusSinkWeight
328  if ((myMinSourceMinusSinkWeight == -1) || (sourceMinusSink < myMinSourceMinusSinkWeight)) {
329  myMinSourceMinusSinkWeight = sourceMinusSink;
330  }
331  }
332  }
333  } else {
334  throw ProcessError("Invalid TAZ Child");
335  }
336 }
337 
338 // ---------------------------------------------------------------------------
339 // GNETAZFrame::TAZCommonStatistics - methods
340 // ---------------------------------------------------------------------------
341 
343  FXGroupBox(TAZFrameParent->myContentFrame, "TAZ Statistics", GUIDesignGroupBoxFrame),
344  myTAZFrameParent(TAZFrameParent) {
345  // create label for statistics
346  myStatisticsLabel = new FXLabel(this, "Statistics", 0, GUIDesignLabelFrameInformation);
347 }
348 
349 
351 
352 
353 void
355  // always update statistics after show
356  updateStatistics();
357  show();
358 }
359 
360 
361 void
363  hide();
364 }
365 
366 
367 void
369  if (myTAZFrameParent->myTAZCurrent->getTAZ()) {
370  // declare ostringstream for statistics
371  std::ostringstream information;
372  information
373  << "- Number of Edges: " << toString(myTAZFrameParent->myTAZCurrent->getTAZ()->getChildAdditionals().size() / 2) << "\n"
374  << "- Min source: " << myTAZFrameParent->myTAZCurrent->getTAZ()->getAttribute(GNE_ATTR_MIN_SOURCE) << "\n"
375  << "- Max source: " << myTAZFrameParent->myTAZCurrent->getTAZ()->getAttribute(GNE_ATTR_MAX_SOURCE) << "\n"
376  << "- Average source: " << myTAZFrameParent->myTAZCurrent->getTAZ()->getAttribute(GNE_ATTR_AVERAGE_SOURCE) << "\n"
377  << "\n"
378  << "- Min sink: " << myTAZFrameParent->myTAZCurrent->getTAZ()->getAttribute(GNE_ATTR_MIN_SINK) << "\n"
379  << "- Max sink: " << myTAZFrameParent->myTAZCurrent->getTAZ()->getAttribute(GNE_ATTR_MAX_SINK) << "\n"
380  << "- Average sink: " << myTAZFrameParent->myTAZCurrent->getTAZ()->getAttribute(GNE_ATTR_AVERAGE_SINK);
381  // set new label
382  myStatisticsLabel->setText(information.str().c_str());
383  } else {
384  myStatisticsLabel->setText("No TAZ Selected");
385  }
386 }
387 
388 // ---------------------------------------------------------------------------
389 // GNETAZFrame::TAZSaveChanges - methods
390 // ---------------------------------------------------------------------------
391 
393  FXGroupBox(TAZFrameParent->myContentFrame, "Modifications", GUIDesignGroupBoxFrame),
394  myTAZFrameParent(TAZFrameParent) {
395  // Create groupbox for save changes
396  mySaveChangesButton = new FXButton(this, "Confirm changes", GUIIconSubSys::getIcon(GUIIcon::SAVE), this, MID_OK, GUIDesignButton);
397  mySaveChangesButton->disable();
398  // Create groupbox cancel changes
399  myCancelChangesButton = new FXButton(this, "Cancel changes", GUIIconSubSys::getIcon(GUIIcon::CANCEL), this, MID_CANCEL, GUIDesignButton);
400  myCancelChangesButton->disable();
401 }
402 
403 
405 
406 
407 void
409  show();
410 }
411 
412 
413 void
415  // cancel changes before hidding modul
416  onCmdCancelChanges(0, 0, 0);
417  hide();
418 }
419 
420 
421 void
423  // check that save changes is disabled
424  if (!mySaveChangesButton->isEnabled()) {
425  // enable mySaveChangesButton and myCancelChangesButton
426  mySaveChangesButton->enable();
427  myCancelChangesButton->enable();
428  // start undo list set
429  myTAZFrameParent->myViewNet->getUndoList()->p_begin("TAZ attributes");
430  }
431 }
432 
433 
434 bool
436  // simply check if save Changes Button is enabled
437  return mySaveChangesButton->isEnabled();
438 }
439 
440 
441 long
442 GNETAZFrame::TAZSaveChanges::onCmdSaveChanges(FXObject*, FXSelector, void*) {
443  // check that save changes is enabled
444  if (mySaveChangesButton->isEnabled()) {
445  // disable mySaveChangesButton and myCancelChangesButtonand
446  mySaveChangesButton->disable();
447  myCancelChangesButton->disable();
448  // finish undo list set
449  myTAZFrameParent->myViewNet->getUndoList()->p_end();
450  }
451  return 1;
452 }
453 
454 
455 long
456 GNETAZFrame::TAZSaveChanges::onCmdCancelChanges(FXObject*, FXSelector, void*) {
457  // check that save changes is enabled
458  if (mySaveChangesButton->isEnabled()) {
459  // disable buttons
460  mySaveChangesButton->disable();
461  myCancelChangesButton->disable();
462  // abort undo list
463  myTAZFrameParent->myViewNet->getUndoList()->p_abort();
464  // always refresh TAZ Edges after removing TAZSources/Sinks
465  myTAZFrameParent->myTAZCurrent->refreshTAZEdges();
466  // update use edges button
467  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
468  }
469  return 1;
470 }
471 
472 // ---------------------------------------------------------------------------
473 // GNETAZFrame::TAZChildDefaultParameters - methods
474 // ---------------------------------------------------------------------------
475 
477  FXGroupBox(TAZFrameParent->myContentFrame, "TAZ Sources/Sinks", GUIDesignGroupBoxFrame),
478  myTAZFrameParent(TAZFrameParent),
479  myDefaultTAZSourceWeight(1),
480  myDefaultTAZSinkWeight(1) {
481  // create checkbox for toogle membership
482  FXHorizontalFrame* toogleMembershipFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
483  new FXLabel(toogleMembershipFrame, "Membership", 0, GUIDesignLabelAttribute);
484  myToggleMembership = new FXCheckButton(toogleMembershipFrame, "Toggle", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
485  // by default enabled
486  myToggleMembership->setCheck(TRUE);
487  // create default TAZ Source weight
488  myDefaultTAZSourceFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
489  new FXLabel(myDefaultTAZSourceFrame, "New source", 0, GUIDesignLabelAttribute);
491  myTextFieldDefaultValueTAZSources->setText("1");
492  // create default TAZ Sink weight
493  myDefaultTAZSinkFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
494  new FXLabel(myDefaultTAZSinkFrame, "New sink", 0, GUIDesignLabelAttribute);
496  myTextFieldDefaultValueTAZSinks->setText("1");
497  // Create button for use selected edges
498  myUseSelectedEdges = new FXButton(this, "Use selected edges", nullptr, this, MID_GNE_SELECT, GUIDesignButton);
499  // Create information label
500  std::ostringstream information;
501  information
502  << "- Toogle Membership:\n"
503  << " Create new Sources/Sinks\n"
504  << " with given weights.";
505  myInformationLabel = new FXLabel(this, information.str().c_str(), 0, GUIDesignLabelFrameInformation);
506 }
507 
508 
510 
511 
512 void
514  // check if TAZ selection Statistics Modul has to be shown
515  if (myToggleMembership->getCheck() == FALSE) {
516  myTAZFrameParent->myTAZSelectionStatistics->showTAZSelectionStatisticsModul();
517  } else {
518  myTAZFrameParent->myTAZSelectionStatistics->hideTAZSelectionStatisticsModul();
519  }
520  // update selected button
521  updateSelectEdgesButton();
522  // show modul
523  show();
524 }
525 
526 
527 void
529  // hide TAZ Selection Statistics Modul
530  myTAZFrameParent->myTAZSelectionStatistics->hideTAZSelectionStatisticsModul();
531  // hide modul
532  hide();
533 }
534 
535 
536 void
538  if (myToggleMembership->getCheck() == TRUE) {
539  // check if use selected edges has to be enabled
540  if (myTAZFrameParent->myTAZCurrent->getSelectedEdges().size() > 0) {
541  myUseSelectedEdges->setText("Use selected edges");
542  myUseSelectedEdges->enable();
543  } else if (myTAZFrameParent->myTAZCurrent->getTAZEdges().size() > 0) {
544  myUseSelectedEdges->setText("Remove all edges");
545  myUseSelectedEdges->enable();
546  } else {
547  myUseSelectedEdges->setText("Use selected edges");
548  myUseSelectedEdges->disable();
549  }
550  } else if (myTAZFrameParent->getTAZCurrentModul()->getTAZEdges().size() > 0) {
551  // enable myUseSelectedEdges button
552  myUseSelectedEdges->enable();
553  // update mySelectEdgesOfSelection label
554  if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size() == 0) {
555  // check if all edges of TAZChildren are selected
556  bool allSelected = true;
557  for (const auto& i : myTAZFrameParent->getTAZCurrentModul()->getTAZEdges()) {
558  if (!i.edge->isAttributeCarrierSelected()) {
559  allSelected = false;
560  }
561  }
562  if (allSelected) {
563  myUseSelectedEdges->setText("Remove all edges from selection");
564  } else {
565  myUseSelectedEdges->setText("Add all edges to selection");
566  }
567  } else if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size() == 1) {
568  if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().front().edge->isAttributeCarrierSelected()) {
569  myUseSelectedEdges->setText("Remove edge from selection");
570  } else {
571  myUseSelectedEdges->setText("Add edge to selection");
572  }
573  } else {
574  // check if all edges of TAZChildren selected are selected
575  bool allSelected = true;
576  for (const auto& i : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
577  if (!i.edge->isAttributeCarrierSelected()) {
578  allSelected = false;
579  }
580  }
581  if (allSelected) {
582  myUseSelectedEdges->setText(("Remove " + toString(myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size()) + " from to selection").c_str());
583  } else {
584  myUseSelectedEdges->setText(("Add " + toString(myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size()) + " edges to selection").c_str());
585  }
586  }
587  } else {
588  // TAZ doesn't have children, then disable button
589  myUseSelectedEdges->disable();
590  }
591 }
592 
593 
594 double
596  return myDefaultTAZSourceWeight;
597 }
598 
599 
600 double
602  return myDefaultTAZSinkWeight;
603 }
604 
605 
606 bool
608  return (myToggleMembership->getCheck() == TRUE);
609 }
610 
611 
612 long
614  // find edited object
615  if (obj == myToggleMembership) {
616  // first clear selected edges
617  myTAZFrameParent->myTAZSelectionStatistics->clearSelectedEdges();
618  // set text of myToggleMembership
619  if (myToggleMembership->getCheck() == TRUE) {
620  myToggleMembership->setText("toogle");
621  // show TAZSource/Sink Frames
622  myDefaultTAZSourceFrame->show();
623  myDefaultTAZSinkFrame->show();
624  // update information label
625  std::ostringstream information;
626  information
627  << "- Toogle Membership:\n"
628  << " Create new Sources/Sinks\n"
629  << " with given weights.";
630  myInformationLabel->setText(information.str().c_str());
631  // hide TAZSelectionStatistics
632  myTAZFrameParent->myTAZSelectionStatistics->hideTAZSelectionStatisticsModul();
633  // check if use selected edges has to be enabled
634  if (myTAZFrameParent->myTAZCurrent->getSelectedEdges().size() > 0) {
635  myUseSelectedEdges->setText("Use selected edges");
636  } else if (myTAZFrameParent->myTAZCurrent->getTAZEdges().size() > 0) {
637  myUseSelectedEdges->setText("Remove all edges");
638  } else {
639  myUseSelectedEdges->setText("Use selected edges");
640  myUseSelectedEdges->disable();
641  }
642  } else {
643  myToggleMembership->setText("keep");
644  // hide TAZSource/Sink Frames
645  myDefaultTAZSourceFrame->hide();
646  myDefaultTAZSinkFrame->hide();
647  // update information label
648  std::ostringstream information;
649  information
650  << "- Keep Membership:\n"
651  << " Select Sources/Sinks.\n"
652  << "- Press ESC to clear\n"
653  << " current selection.";
654  myInformationLabel->setText(information.str().c_str());
655  // show TAZSelectionStatistics
656  myTAZFrameParent->myTAZSelectionStatistics->showTAZSelectionStatisticsModul();
657  }
658  // update button
659  updateSelectEdgesButton();
660  } else if (obj == myTextFieldDefaultValueTAZSources) {
661  // check if given value is valid
662  if (GNEAttributeCarrier::canParse<double>(myTextFieldDefaultValueTAZSources->getText().text())) {
663  myDefaultTAZSourceWeight = GNEAttributeCarrier::parse<double>(myTextFieldDefaultValueTAZSources->getText().text());
664  // check if myDefaultTAZSourceWeight is greather than 0
665  if (myDefaultTAZSourceWeight >= 0) {
666  // set valid color
667  myTextFieldDefaultValueTAZSources->setTextColor(FXRGB(0, 0, 0));
668  } else {
669  // set invalid color
670  myTextFieldDefaultValueTAZSources->setTextColor(FXRGB(255, 0, 0));
671  myDefaultTAZSourceWeight = 1;
672  }
673  } else {
674  // set invalid color
675  myTextFieldDefaultValueTAZSources->setTextColor(FXRGB(255, 0, 0));
676  myDefaultTAZSourceWeight = 1;
677  }
678  } else if (obj == myTextFieldDefaultValueTAZSinks) {
679  // check if given value is valid
680  if (GNEAttributeCarrier::canParse<double>(myTextFieldDefaultValueTAZSinks->getText().text())) {
681  myDefaultTAZSinkWeight = GNEAttributeCarrier::parse<double>(myTextFieldDefaultValueTAZSinks->getText().text());
682  // check if myDefaultTAZSinkWeight is greather than 0
683  if (myDefaultTAZSinkWeight >= 0) {
684  // set valid color
685  myTextFieldDefaultValueTAZSinks->setTextColor(FXRGB(0, 0, 0));
686  } else {
687  // set invalid color
688  myTextFieldDefaultValueTAZSinks->setTextColor(FXRGB(255, 0, 0));
689  myDefaultTAZSinkWeight = 1;
690  }
691  } else {
692  // set invalid color
693  myTextFieldDefaultValueTAZSinks->setTextColor(FXRGB(255, 0, 0));
694  myDefaultTAZSinkWeight = 1;
695  }
696  }
697  return 1;
698 }
699 
700 
701 long
703  // select edge or create new TAZ Source/Child, depending of myToggleMembership
704  if (myToggleMembership->getCheck() == TRUE) {
705  // first drop all edges
706  myTAZFrameParent->dropTAZMembers();
707  // iterate over selected edges and add it as TAZMember
708  for (const auto& i : myTAZFrameParent->myTAZCurrent->getSelectedEdges()) {
709  myTAZFrameParent->addOrRemoveTAZMember(i);
710  }
711  // update selected button
712  updateSelectEdgesButton();
713  } else {
714  if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size() == 0) {
715  // first check if all TAZEdges are selected
716  bool allSelected = true;
717  for (const auto& i : myTAZFrameParent->getTAZCurrentModul()->getTAZEdges()) {
718  if (!i.edge->isAttributeCarrierSelected()) {
719  allSelected = false;
720  }
721  }
722  // select or unselect all depending of allSelected
723  if (allSelected) {
724  // remove form selection all TAZEdges
725  for (const auto& i : myTAZFrameParent->getTAZCurrentModul()->getTAZEdges()) {
726  // enable save button
727  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
728  // change attribute selected
729  i.edge->setAttribute(GNE_ATTR_SELECTED, "false", myTAZFrameParent->myViewNet->getUndoList());
730  }
731  } else {
732  // add to selection all TAZEdges
733  for (const auto& i : myTAZFrameParent->getTAZCurrentModul()->getTAZEdges()) {
734  // enable save button
735  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
736  // change attribute selected
737  i.edge->setAttribute(GNE_ATTR_SELECTED, "true", myTAZFrameParent->myViewNet->getUndoList());
738  }
739  }
740  } else {
741  // first check if all TAZEdges are selected
742  bool allSelected = true;
743  for (const auto& i : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
744  if (!i.edge->isAttributeCarrierSelected()) {
745  allSelected = false;
746  }
747  }
748  // select or unselect all depending of allSelected
749  if (allSelected) {
750  // only remove from selection selected TAZEdges
751  for (const auto& i : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
752  if (i.edge->isAttributeCarrierSelected()) {
753  // enable save button
754  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
755  // change attribute selected
756  i.edge->setAttribute(GNE_ATTR_SELECTED, "false", myTAZFrameParent->myViewNet->getUndoList());
757  }
758  }
759  } else {
760  // only add to selection selected TAZEdges
761  for (const auto& i : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
762  if (!i.edge->isAttributeCarrierSelected()) {
763  // enable save button
764  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
765  // change attribute selected
766  i.edge->setAttribute(GNE_ATTR_SELECTED, "true", myTAZFrameParent->myViewNet->getUndoList());
767  }
768  }
769  }
770  }
771  }
772  // update selection button
773  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
774  // update view net
775  myTAZFrameParent->myViewNet->updateViewNet();
776  return 1;
777 }
778 
779 // ---------------------------------------------------------------------------
780 // GNETAZFrame::TAZSelectionStatistics - methods
781 // ---------------------------------------------------------------------------
782 
784  FXGroupBox(TAZFrameParent->myContentFrame, "Selection Statistics", GUIDesignGroupBoxFrame),
785  myTAZFrameParent(TAZFrameParent) {
786  // create default TAZ Source weight
787  myTAZSourceFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
788  new FXLabel(myTAZSourceFrame, "Source", 0, GUIDesignLabelAttribute);
790  myTAZSourceFrame->hide();
791  // create default TAZ Sink weight
792  myTAZSinkFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
793  new FXLabel(myTAZSinkFrame, "Sink", 0, GUIDesignLabelAttribute);
795  myTAZSinkFrame->hide();
796  // create label for statistics
797  myStatisticsLabel = new FXLabel(this, "Statistics", 0, GUIDesignLabelFrameInformation);
798 }
799 
800 
802 
803 
804 void
806  // update Statistics before show
807  updateStatistics();
808  show();
809 }
810 
811 
812 void
814  // clear children before hide
815  clearSelectedEdges();
816  hide();
817 }
818 
819 
820 bool
822  // find TAZEdge using edge as criterium wasn't previously selected
823  for (const auto& i : myEdgeAndTAZChildrenSelected) {
824  if (i.edge == TAZEdge.edge) {
825  throw ProcessError("TAZEdge already selected");
826  }
827  }
828  // add edge and their TAZ Children into myTAZChildSelected
829  myEdgeAndTAZChildrenSelected.push_back(TAZEdge);
830  // always update statistics after insertion
831  updateStatistics();
832  // update edge colors
833  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
834  // update selection button
835  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
836  return true;
837 }
838 
839 
840 bool
842  if (edge) {
843  // find TAZEdge using edge as criterium
844  for (auto i = myEdgeAndTAZChildrenSelected.begin(); i != myEdgeAndTAZChildrenSelected.end(); i++) {
845  if (i->edge == edge) {
846  myEdgeAndTAZChildrenSelected.erase(i);
847  // always update statistics after insertion
848  updateStatistics();
849  // update edge colors
850  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
851  // update selection button
852  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
853  return true;
854  }
855  }
856  // throw exception if edge wasn't found
857  throw ProcessError("edge wasn't found");
858  } else {
859  throw ProcessError("Invalid edge");
860  }
861 }
862 
863 
864 bool
866  // find TAZEdge using edge as criterium
867  for (const auto& i : myEdgeAndTAZChildrenSelected) {
868  if (i.edge == edge) {
869  return true;
870  }
871  }
872  // edge wasn't found, then return false
873  return false;
874 }
875 
876 
877 void
879  // clear all selected edges (and the TAZ Children)
880  myEdgeAndTAZChildrenSelected.clear();
881  // always update statistics after clear edges
882  updateStatistics();
883  // update edge colors
884  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
885  // update selection button
886  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
887 }
888 
889 
890 const std::vector<GNETAZFrame::TAZCurrent::TAZEdge>&
892  return myEdgeAndTAZChildrenSelected;
893 }
894 
895 
896 long
898  if (obj == myTextFieldTAZSourceWeight) {
899  // check if given value is valid
900  if (GNEAttributeCarrier::canParse<double>(myTextFieldTAZSourceWeight->getText().text())) {
901  double newTAZSourceWeight = GNEAttributeCarrier::parse<double>(myTextFieldTAZSourceWeight->getText().text());
902  // check if myDefaultTAZSourceWeight is greather than 0
903  if (newTAZSourceWeight >= 0) {
904  // set valid color in TextField
905  myTextFieldTAZSourceWeight->setTextColor(FXRGB(0, 0, 0));
906  // enable save button
907  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
908  // update weight of all TAZSources
909  for (const auto& i : myEdgeAndTAZChildrenSelected) {
910  i.TAZSource->setAttribute(SUMO_ATTR_WEIGHT, myTextFieldTAZSourceWeight->getText().text(), myTAZFrameParent->myViewNet->getUndoList());
911  }
912  // refresh TAZ Edges
913  myTAZFrameParent->getTAZCurrentModul()->refreshTAZEdges();
914  } else {
915  // set invalid color
916  myTextFieldTAZSourceWeight->setTextColor(FXRGB(255, 0, 0));
917  }
918  } else {
919  // set invalid color
920  myTextFieldTAZSourceWeight->setTextColor(FXRGB(255, 0, 0));
921  }
922  } else if (obj == myTextFieldTAZSinkWeight) {
923  // check if given value is valid
924  if (GNEAttributeCarrier::canParse<double>(myTextFieldTAZSinkWeight->getText().text())) {
925  double newTAZSinkWeight = GNEAttributeCarrier::parse<double>(myTextFieldTAZSinkWeight->getText().text());
926  // check if myDefaultTAZSinkWeight is greather than 0
927  if (newTAZSinkWeight >= 0) {
928  // set valid color in TextField
929  myTextFieldTAZSinkWeight->setTextColor(FXRGB(0, 0, 0));
930  // enable save button
931  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
932  // update weight of all TAZSources
933  for (const auto& i : myEdgeAndTAZChildrenSelected) {
934  i.TAZSink->setAttribute(SUMO_ATTR_WEIGHT, myTextFieldTAZSinkWeight->getText().text(), myTAZFrameParent->myViewNet->getUndoList());
935  }
936  // refresh TAZ Edges
937  myTAZFrameParent->getTAZCurrentModul()->refreshTAZEdges();
938  } else {
939  // set invalid color
940  myTextFieldTAZSinkWeight->setTextColor(FXRGB(255, 0, 0));
941  }
942  } else {
943  // set invalid color
944  myTextFieldTAZSinkWeight->setTextColor(FXRGB(255, 0, 0));
945  }
946  }
947  return 1;
948 }
949 
950 
951 long
953  if (myEdgeAndTAZChildrenSelected.size() == 0) {
954  // add to selection all TAZEdges
955  for (const auto& i : myTAZFrameParent->getTAZCurrentModul()->getTAZEdges()) {
956  // avoid empty undolists
957  if (!i.edge->isAttributeCarrierSelected()) {
958  // enable save button
959  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
960  // change attribute selected
961  i.edge->setAttribute(GNE_ATTR_SELECTED, "true", myTAZFrameParent->myViewNet->getUndoList());
962  }
963  }
964  } else {
965  // only add to selection selected TAZEdges
966  for (const auto& i : myEdgeAndTAZChildrenSelected) {
967  // avoid empty undolists
968  if (!i.edge->isAttributeCarrierSelected()) {
969  // enable save button
970  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
971  // change attribute selected
972  i.edge->setAttribute(GNE_ATTR_SELECTED, "true", myTAZFrameParent->myViewNet->getUndoList());
973  }
974  }
975  }
976  return 1;
977 }
978 
979 
980 void
982  if (myEdgeAndTAZChildrenSelected.size() > 0) {
983  // show TAZSources/Sinks frames
984  myTAZSourceFrame->show();
985  myTAZSinkFrame->show();
986  // declare string sets for TextFields (to avoid duplicated values)
987  std::set<std::string> weightSourceSet;
988  std::set<std::string> weightSinkSet;
989  // declare stadistic variables
990  double weight = 0;
991  double maxWeightSource = 0;
992  double minWeightSource = -1;
993  double averageWeightSource = 0;
994  double maxWeightSink = 0;
995  double minWeightSink = -1;
996  double averageWeightSink = 0;
997  // iterate over child additional
998  for (const auto& i : myEdgeAndTAZChildrenSelected) {
999  //start with sources
1000  weight = i.TAZSource->getDepartWeight();
1001  // insert source weight in weightSinkTextField
1002  weightSourceSet.insert(toString(weight));
1003  // check max Weight
1004  if (maxWeightSource < weight) {
1005  maxWeightSource = weight;
1006  }
1007  // check min Weight
1008  if (minWeightSource == -1 || (maxWeightSource < weight)) {
1009  minWeightSource = weight;
1010  }
1011  // update Average
1012  averageWeightSource += weight;
1013  // continue with sinks
1014  weight = i.TAZSink->getDepartWeight();
1015  // save sink weight in weightSinkTextField
1016  weightSinkSet.insert(toString(weight));
1017  // check max Weight
1018  if (maxWeightSink < weight) {
1019  maxWeightSink = weight;
1020  }
1021  // check min Weight
1022  if (minWeightSink == -1 || (maxWeightSink < weight)) {
1023  minWeightSink = weight;
1024  }
1025  // update Average
1026  averageWeightSink += weight;
1027  }
1028  // calculate average
1029  averageWeightSource /= myEdgeAndTAZChildrenSelected.size();
1030  averageWeightSink /= myEdgeAndTAZChildrenSelected.size();
1031  // declare ostringstream for statistics
1032  std::ostringstream information;
1033  std::string edgeInformation;
1034  // first fill edgeInformation
1035  if (myEdgeAndTAZChildrenSelected.size() == 1) {
1036  edgeInformation = "- Edge ID: " + myEdgeAndTAZChildrenSelected.begin()->edge->getID();
1037  } else {
1038  edgeInformation = "- Number of edges: " + toString(myEdgeAndTAZChildrenSelected.size());
1039  }
1040  // fill rest of information
1041  information
1042  << edgeInformation << "\n"
1043  << "- Min source: " << toString(minWeightSource) << "\n"
1044  << "- Max source: " << toString(maxWeightSource) << "\n"
1045  << "- Average source: " << toString(averageWeightSource) << "\n"
1046  << "\n"
1047  << "- Min sink: " << toString(minWeightSink) << "\n"
1048  << "- Max sink: " << toString(maxWeightSink) << "\n"
1049  << "- Average sink: " << toString(averageWeightSink);
1050  // set new label
1051  myStatisticsLabel->setText(information.str().c_str());
1052  // set TextFields (Text and color)
1053  myTextFieldTAZSourceWeight->setText(joinToString(weightSourceSet, " ").c_str());
1054  myTextFieldTAZSourceWeight->setTextColor(FXRGB(0, 0, 0));
1055  myTextFieldTAZSinkWeight->setText(joinToString(weightSinkSet, " ").c_str());
1056  myTextFieldTAZSinkWeight->setTextColor(FXRGB(0, 0, 0));
1057  } else {
1058  // hide TAZSources/Sinks frames
1059  myTAZSourceFrame->hide();
1060  myTAZSinkFrame->hide();
1061  // hide myStatisticsLabel
1062  myStatisticsLabel->setText("No edges selected");
1063  }
1064 }
1065 
1066 // ---------------------------------------------------------------------------
1067 // GNETAZFrame::TAZParameters- methods
1068 // ---------------------------------------------------------------------------
1069 
1071  FXGroupBox(TAZFrameParent->myContentFrame, "TAZ parameters", GUIDesignGroupBoxFrame),
1072  myTAZFrameParent(TAZFrameParent) {
1073  // create Button and string textField for color and set blue as default color
1074  FXHorizontalFrame* colorParameter = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
1075  myColorEditor = new FXButton(colorParameter, toString(SUMO_ATTR_COLOR).c_str(), 0, this, MID_GNE_SET_ATTRIBUTE_DIALOG, GUIDesignButtonAttribute);
1076  myTextFieldColor = new FXTextField(colorParameter, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
1077  myTextFieldColor->setText("blue");
1078  // create Label and CheckButton for use innen edges with true as default value
1079  FXHorizontalFrame* useInnenEdges = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
1080  new FXLabel(useInnenEdges, "Edges within", 0, GUIDesignLabelAttribute);
1081  myAddEdgesWithinCheckButton = new FXCheckButton(useInnenEdges, "use", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
1082  myAddEdgesWithinCheckButton->setCheck(true);
1083  // Create help button
1084  myHelpTAZAttribute = new FXButton(this, "Help", 0, this, MID_HELP, GUIDesignButtonRectangular);
1085 }
1086 
1087 
1089 
1090 
1091 void
1093  FXGroupBox::show();
1094 }
1095 
1096 
1097 void
1099  FXGroupBox::hide();
1100 }
1101 
1102 
1103 bool
1105  return GNEAttributeCarrier::canParse<RGBColor>(myTextFieldColor->getText().text());
1106 }
1107 
1108 
1109 bool
1111  return (myAddEdgesWithinCheckButton->getCheck() == TRUE);
1112 }
1113 
1114 
1115 std::map<SumoXMLAttr, std::string>
1117  std::map<SumoXMLAttr, std::string> parametersAndValues;
1118  // get color (currently the only editable attribute)
1119  parametersAndValues[SUMO_ATTR_COLOR] = myTextFieldColor->getText().text();
1120  return parametersAndValues;
1121 }
1122 
1123 
1124 long
1126  // create FXColorDialog
1127  FXColorDialog colordialog(this, tr("Color Dialog"));
1128  colordialog.setTarget(this);
1129  // If previous attribute wasn't correct, set black as default color
1130  if (GNEAttributeCarrier::canParse<RGBColor>(myTextFieldColor->getText().text())) {
1131  colordialog.setRGBA(MFXUtils::getFXColor(RGBColor::parseColor(myTextFieldColor->getText().text())));
1132  } else {
1133  colordialog.setRGBA(MFXUtils::getFXColor(RGBColor::parseColor("blue")));
1134  }
1135  // execute dialog to get a new color
1136  if (colordialog.execute()) {
1137  myTextFieldColor->setText(toString(MFXUtils::getRGBColor(colordialog.getRGBA())).c_str());
1138  onCmdSetAttribute(0, 0, 0);
1139  }
1140  return 0;
1141 }
1142 
1143 
1144 long
1145 GNETAZFrame::TAZParameters::onCmdSetAttribute(FXObject*, FXSelector, void*) {
1146  // only COLOR text field has to be checked
1147  bool currentParametersValid = GNEAttributeCarrier::canParse<RGBColor>(myTextFieldColor->getText().text());
1148  // change color of textfield dependig of myCurrentParametersValid
1149  if (currentParametersValid) {
1150  myTextFieldColor->setTextColor(FXRGB(0, 0, 0));
1151  myTextFieldColor->killFocus();
1152  } else {
1153  myTextFieldColor->setTextColor(FXRGB(255, 0, 0));
1154  currentParametersValid = false;
1155  }
1156  // change useInnenEdgesCheckButton text
1157  if (myAddEdgesWithinCheckButton->getCheck() == TRUE) {
1158  myAddEdgesWithinCheckButton->setText("use");
1159  } else {
1160  myAddEdgesWithinCheckButton->setText("not use");
1161  }
1162  return 0;
1163 }
1164 
1165 
1166 long
1167 GNETAZFrame::TAZParameters::onCmdHelp(FXObject*, FXSelector, void*) {
1168  myTAZFrameParent->openHelpAttributesDialog(GNEAttributeCarrier::getTagProperties(SUMO_TAG_TAZ));
1169  return 1;
1170 }
1171 
1172 // ---------------------------------------------------------------------------
1173 // GNETAZFrame::TAZEdgesGraphic - methods
1174 // ---------------------------------------------------------------------------
1175 
1177  FXGroupBox(TAZFrameParent->myContentFrame, "Edges", GUIDesignGroupBoxFrame),
1178  myTAZFrameParent(TAZFrameParent),
1179  myEdgeDefaultColor(RGBColor::GREY),
1180  myEdgeSelectedColor(RGBColor::MAGENTA) {
1181  // create label for non taz edge color information
1182  FXLabel* NonTAZEdgeLabel = new FXLabel(this, "Non TAZ Edge", nullptr, GUIDesignLabelCenter);
1183  NonTAZEdgeLabel->setBackColor(MFXUtils::getFXColor(myEdgeDefaultColor));
1184  NonTAZEdgeLabel->setTextColor(MFXUtils::getFXColor(RGBColor::WHITE));
1185  // create label for selected TAZEdge color information
1186  FXLabel* selectedTAZEdgeLabel = new FXLabel(this, "Selected TAZ Edge", nullptr, GUIDesignLabelCenter);
1187  selectedTAZEdgeLabel->setBackColor(MFXUtils::getFXColor(myEdgeSelectedColor));
1188  // build rainbow
1190  // create Radio button for show edges by source weight
1191  myColorBySourceWeight = new FXRadioButton(this, "Color by Source", this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1192  // create Radio button for show edges by sink weight
1193  myColorBySinkWeight = new FXRadioButton(this, "Color by Sink", this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1194  // create Radio button for show edges by source + sink weight
1195  myColorBySourcePlusSinkWeight = new FXRadioButton(this, "Color by Source + Sink", this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1196  // create Radio button for show edges by source - sink weight
1197  myColorBySourceMinusSinkWeight = new FXRadioButton(this, "Color by Source - Sink", this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1198  // show by source as default
1199  myColorBySourceWeight->setCheck(true);
1200 }
1201 
1202 
1204 
1205 
1206 void
1208  // update edge colors
1209  updateEdgeColors();
1210  show();
1211 }
1212 
1213 
1214 void
1216  // iterate over all edges and restore color
1217  for (const auto& i : myTAZFrameParent->myTAZCurrent->getNetEdges()) {
1218  for (const auto j : i->getLanes()) {
1219  j->setSpecialColor(nullptr);
1220  }
1221  }
1222  hide();
1223 }
1224 
1225 
1226 void
1228  const std::vector<RGBColor>& scaledColors = GNEViewNetHelper::getRainbowScaledColors();
1229  // start painting all edges in gray
1230  for (const auto& i : myTAZFrameParent->myTAZCurrent->getNetEdges()) {
1231  // set candidate color (in this case, gray)
1232  for (const auto j : i->getLanes()) {
1233  j->setSpecialColor(&myEdgeDefaultColor);
1234  }
1235  }
1236  // now paint Source/sinks colors
1237  for (const auto& i : myTAZFrameParent->myTAZCurrent->getTAZEdges()) {
1238  // set candidate color (in this case,
1239  for (const auto j : i.edge->getLanes()) {
1240  // check what will be painted (source, sink or both)
1241  if (myColorBySourceWeight->getCheck() == TRUE) {
1242  j->setSpecialColor(&scaledColors.at(i.sourceColor), i.TAZSource->getDepartWeight());
1243  } else if (myColorBySinkWeight->getCheck() == TRUE) {
1244  j->setSpecialColor(&scaledColors.at(i.sinkColor), i.TAZSink->getDepartWeight());
1245  } else if (myColorBySourcePlusSinkWeight->getCheck() == TRUE) {
1246  j->setSpecialColor(&scaledColors.at(i.sourcePlusSinkColor), i.TAZSource->getDepartWeight() + i.TAZSink->getDepartWeight());
1247  } else {
1248  j->setSpecialColor(&scaledColors.at(i.sourceMinusSinkColor), i.TAZSource->getDepartWeight() - i.TAZSink->getDepartWeight());
1249  }
1250  }
1251  }
1252  // as last step paint candidate colors
1253  for (const auto& i : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
1254  // set candidate selected color
1255  for (const auto& j : i.edge->getLanes()) {
1256  j->setSpecialColor(&myEdgeSelectedColor);
1257  }
1258  }
1259  // always update view after setting new colors
1260  myTAZFrameParent->myViewNet->updateViewNet();
1261 }
1262 
1263 
1264 long
1265 GNETAZFrame::TAZEdgesGraphic::onCmdChoosenBy(FXObject* obj, FXSelector, void*) {
1266  // check what radio was pressed and disable the others
1267  if (obj == myColorBySourceWeight) {
1268  myColorBySinkWeight->setCheck(FALSE);
1269  myColorBySourcePlusSinkWeight->setCheck(FALSE);
1270  myColorBySourceMinusSinkWeight->setCheck(FALSE);
1271  } else if (obj == myColorBySinkWeight) {
1272  myColorBySourceWeight->setCheck(FALSE);
1273  myColorBySourcePlusSinkWeight->setCheck(FALSE);
1274  myColorBySourceMinusSinkWeight->setCheck(FALSE);
1275  } else if (obj == myColorBySourcePlusSinkWeight) {
1276  myColorBySourceWeight->setCheck(FALSE);
1277  myColorBySinkWeight->setCheck(FALSE);
1278  myColorBySourceMinusSinkWeight->setCheck(FALSE);
1279  } else if (obj == myColorBySourceMinusSinkWeight) {
1280  myColorBySourceWeight->setCheck(FALSE);
1281  myColorBySinkWeight->setCheck(FALSE);
1282  myColorBySourcePlusSinkWeight->setCheck(FALSE);
1283  }
1284  // update edge colors
1285  updateEdgeColors();
1286  return 1;
1287 }
1288 
1289 // ---------------------------------------------------------------------------
1290 // GNETAZFrame - methods
1291 // ---------------------------------------------------------------------------
1292 
1293 GNETAZFrame::GNETAZFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet) :
1294  GNEFrame(horizontalFrameParent, viewNet, "TAZs") {
1295 
1296  // create current TAZ modul
1297  myTAZCurrent = new TAZCurrent(this);
1298 
1299  // Create TAZ Parameters modul
1300  myTAZParameters = new TAZParameters(this);
1301 
1304 
1305  // Create drawing controls modul
1307 
1308  // Create TAZ Edges Common Statistics modul
1310 
1311  // Create save TAZ Edges modul
1312  myTAZSaveChanges = new TAZSaveChanges(this);
1313 
1314  // Create TAZ Edges Common Parameters modul
1316 
1317  // Create TAZ Edges Selection Statistics modul
1319 
1320  // Create TAZ Edges Common Parameters modul
1321  myTAZEdgesGraphic = new TAZEdgesGraphic(this);
1322 
1323  // by default there isn't a TAZ
1324  myTAZCurrent->setTAZ(nullptr);
1325 }
1326 
1327 
1329 }
1330 
1331 
1332 void
1334  // hide frame
1335  GNEFrame::hide();
1336 }
1337 
1338 
1339 bool
1340 GNETAZFrame::processClick(const Position& clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor& objectsUnderCursor) {
1341  // Declare map to keep values
1342  std::map<SumoXMLAttr, std::string> valuesOfElement;
1343  if (myDrawingShape->isDrawing()) {
1344  // add or delete a new point depending of flag "delete last created point"
1347  } else {
1348  myDrawingShape->addNewPoint(clickedPosition);
1349  }
1350  return true;
1351  } else if ((myTAZCurrent->getTAZ() == nullptr) || (objectsUnderCursor.getTAZElementFront() && myTAZCurrent->getTAZ() && !myTAZSaveChanges->isChangesPending())) {
1352  // if user click over an TAZ and there isn't changes pending, then select a new TAZ
1353  if (objectsUnderCursor.getTAZElementFront()) {
1354  // avoid reset of Frame if user doesn't click over an TAZ
1355  myTAZCurrent->setTAZ(dynamic_cast<GNETAZ*>(objectsUnderCursor.getTAZElementFront()));
1356  return true;
1357  } else {
1358  return false;
1359  }
1360  } else if (objectsUnderCursor.getEdgeFront()) {
1361  // if toogle Edge is enabled, select edge. In other case create two new TAZSource/Sinks
1363  // create new TAZSource/Sinks or delete it
1364  return addOrRemoveTAZMember(objectsUnderCursor.getEdgeFront());
1365  } else {
1366  // first check if clicked edge was previously selected
1367  if (myTAZSelectionStatistics->isEdgeSelected(objectsUnderCursor.getEdgeFront())) {
1368  // clear selected edges
1370  } else {
1371  // iterate over TAZEdges saved in TAZCurrent (it contains the Edge and Source/sinks)
1372  for (const auto& i : myTAZCurrent->getTAZEdges()) {
1373  if (i.edge == objectsUnderCursor.getEdgeFront()) {
1374  // clear current selection (to avoid having two or more edges selected at the same time using mouse clicks)
1376  // now select edge
1378  // edge selected, then return true
1379  return true;
1380  }
1381  }
1382  }
1383  // edge wasn't selected, then return false
1384  return false;
1385  }
1386  } else {
1387  // nothing to do
1388  return false;
1389  }
1390 }
1391 
1392 
1393 void
1394 GNETAZFrame::processEdgeSelection(const std::vector<GNEEdge*>& edges) {
1395  // first check that a TAZ is selected
1396  if (myTAZCurrent->getTAZ()) {
1397  // if "toogle Membership" is enabled, create new TAZSources/sinks. In other case simply select edges
1399  // iterate over edges
1400  for (auto i : edges) {
1401  // first check if edge owns a TAZEge
1402  if (myTAZCurrent->isTAZEdge(i) == false) {
1403  // create new TAZ Sources/Sinks
1405  }
1406  }
1407  } else {
1408  // iterate over edges
1409  for (auto i : edges) {
1410  // first check that selected edge isn't already selected
1412  // iterate over TAZEdges saved in TAZCurrent (it contains the Edge and Source/sinks)
1413  for (const auto& j : myTAZCurrent->getTAZEdges()) {
1414  if (j.edge == i) {
1416  }
1417  }
1418  }
1419  }
1420  }
1421  }
1422 }
1423 
1424 
1427  return myDrawingShape;
1428 }
1429 
1430 
1433  return myTAZCurrent;
1434 }
1435 
1436 
1439  return myTAZSelectionStatistics;
1440 }
1441 
1442 
1445  return myTAZSaveChanges;
1446 }
1447 
1448 
1449 bool
1451  // show warning dialogbox and stop check if input parameters are valid
1453  return false;
1454  } else if (myDrawingShape->getTemporalShape().size() == 0) {
1455  WRITE_WARNING("TAZ shape cannot be empty");
1456  return false;
1457  } else {
1458  // Declare map to keep TAZ Parameters values
1459  std::map<SumoXMLAttr, std::string> valuesOfElement = myTAZParameters->getAttributesAndValues();
1460 
1461  // obtain Netedit attributes
1462  myNeteditAttributes->getNeteditAttributesAndValues(valuesOfElement, nullptr);
1463 
1464  // generate new ID
1466 
1467  // obtain shape and close it
1469  shape.closePolygon();
1470  valuesOfElement[SUMO_ATTR_SHAPE] = toString(shape);
1471 
1472  // check if TAZ has to be created with edges
1474  std::vector<std::string> edgeIDs;
1475  auto ACsInBoundary = myViewNet->getAttributeCarriersInBoundary(shape.getBoxBoundary(), true);
1476  for (auto i : ACsInBoundary) {
1477  if (i.second->getTagProperty().getTag() == SUMO_TAG_EDGE) {
1478  edgeIDs.push_back(i.first);
1479  }
1480  }
1481  valuesOfElement[SUMO_ATTR_EDGES] = toString(edgeIDs);
1482  } else {
1483  // TAZ is created without edges
1484  valuesOfElement[SUMO_ATTR_EDGES] = "";
1485  }
1486  // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
1487  SUMOSAXAttributesImpl_Cached SUMOSAXAttrs(valuesOfElement, getPredefinedTagsMML(), toString(SUMO_TAG_TAZ));
1488  // return true if TAZ was successfully created
1489  return GNEAdditionalHandler::buildAdditional(myViewNet->getNet(), true, SUMO_TAG_TAZ, SUMOSAXAttrs, nullptr);
1490  }
1491 }
1492 
1493 
1494 bool
1496  // first check if edge exist;
1497  if (edge) {
1498  // first check if already exist (in this case, remove it)
1499  for (const auto& i : myTAZCurrent->getTAZEdges()) {
1500  if (i.edge == edge) {
1501  // enable save changes button
1503  // remove Source and Sinks using GNEChange_Additional
1504  myViewNet->getUndoList()->add(new GNEChange_TAZElement(i.TAZSource, false), true);
1505  myViewNet->getUndoList()->add(new GNEChange_TAZElement(i.TAZSink, false), true);
1506  // always refresh TAZ Edges after removing TAZSources/Sinks
1508  // update select edges button
1510  return true;
1511  }
1512  }
1513  // if wasn't found, then add it
1515  // create TAZ Sink using GNEChange_Additional and value of TAZChild default parameters
1517  myViewNet->getUndoList()->add(new GNEChange_TAZElement(TAZSource, true), true);
1518  // create TAZ Sink using GNEChange_Additional and value of TAZChild default parameters
1520  myViewNet->getUndoList()->add(new GNEChange_TAZElement(TAZSink, true), true);
1521  // always refresh TAZ Edges after adding TAZSources/Sinks
1523  // update selected button
1525  return true;
1526  } else {
1527  throw ProcessError("Edge cannot be null");
1528  }
1529 }
1530 
1531 
1532 void
1534  // iterate over all TAZEdges
1535  for (const auto& i : myTAZCurrent->getTAZEdges()) {
1536  // enable save changes button
1538  // remove Source and Sinks using GNEChange_Additional
1539  myViewNet->getUndoList()->add(new GNEChange_TAZElement(i.TAZSource, false), true);
1540  myViewNet->getUndoList()->add(new GNEChange_TAZElement(i.TAZSink, false), true);
1541  }
1542  // always refresh TAZ Edges after removing TAZSources/Sinks
1544 }
1545 
1546 
1547 /****************************************************************************/
FXDEFMAP(GNETAZFrame::TAZParameters) TAZParametersMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
Definition: GUIAppEnum.h:717
@ MID_CANCEL
Cancel-button pressed.
Definition: GUIAppEnum.h:247
@ MID_GNE_SET_ATTRIBUTE_DIALOG
attribute edited trought dialog
Definition: GUIAppEnum.h:749
@ MID_CHOOSEN_OPERATION
set type of selection
Definition: GUIAppEnum.h:535
@ MID_HELP
help button
Definition: GUIAppEnum.h:578
@ MID_OK
Ok-button pressed.
Definition: GUIAppEnum.h:245
@ MID_GNE_SELECT
select element
Definition: GUIAppEnum.h:731
#define GUIDesignLabelLeft
Definition: GUIDesigns.h:175
#define GUIDesignLabelCenter
label extended over frame without thick and with text justify to center
Definition: GUIDesigns.h:181
#define GUIDesignButtonAttribute
button extended over over column with thick and raise frame
Definition: GUIDesigns.h:65
#define GUIDesignButton
Definition: GUIDesigns.h:62
#define GUIDesignTextField
Definition: GUIDesigns.h:36
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:313
#define GUIDesignLabelAttribute
label extended over the matrix column with thick frame
Definition: GUIDesigns.h:199
#define GUIDesignButtonRectangular
little button rectangula used in frames (For example, in "help" buttons)
Definition: GUIDesigns.h:68
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition: GUIDesigns.h:54
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
Definition: GUIDesigns.h:278
#define GUIDesignCheckButton
checkButton placed in left position
Definition: GUIDesigns.h:133
#define GUIDesignRadioButton
Definition: GUIDesigns.h:164
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:223
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
@ 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)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ 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
@ 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:250
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
static bool buildAdditional(GNENet *net, bool allowUndoRedo, SumoXMLTag tag, const SUMOSAXAttributes &attrs, LastInsertedElement *insertedAdditionals)
Build additionals.
static const GNETagProperties & getTagProperties(SumoXMLTag tag)
get Tag Properties
const GNETagProperties & getTagProperty() const
get Tag Property assigned to this object
GNENet * getNet() const
get pointer to net
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
bool getNeteditAttributesAndValues(std::map< SumoXMLAttr, std::string > &valuesMap, const GNELane *lane) const
fill valuesMap with netedit attributes
GNEViewNet * myViewNet
View Net.
Definition: GNEFrame.h:113
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
Definition: GNEFrame.h:116
virtual void show()
show Frame
Definition: GNEFrame.cpp:108
virtual void hide()
hide Frame
Definition: GNEFrame.cpp:117
const std::vector< std::string > & getPredefinedTagsMML() const
get predefinedTagsMML
Definition: GNEFrame.cpp:269
bool getDeleteLastCreatedPoint()
get flag delete last created point
const PositionVector & getTemporalShape() const
get Temporal shape
void addNewPoint(const Position &P)
add new point to temporal shape
void removeLastPoint()
remove last added point
bool isDrawing() const
return true if currently a shape is drawed
static FXLabel * buildRainbow(FXComposite *parent)
build rainbow in frame modul
std::string generateTAZElementID(SumoXMLTag TAZElementTag) const
generate TAZElement ID
Definition: GNENet.cpp:3028
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true) const
get edge by id
Definition: GNENet.cpp:1141
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:1249
bool getToggleMembership() const
check if toggle membership is enabled
FXButton * myUseSelectedEdges
button for use selected edges
Definition: GNETAZFrame.h:295
TAZChildDefaultParameters(GNETAZFrame *TAZFrameParent)
FOX-declaration.
FXCheckButton * myToggleMembership
CheckButton to enable or disable Toggle edge Membership.
Definition: GNETAZFrame.h:280
void hideTAZChildDefaultParametersModul()
hide TAZ child default parameters Modul
FXTextField * myTextFieldDefaultValueTAZSources
textField to set a default value for TAZ Sources
Definition: GNETAZFrame.h:286
long onCmdUseSelectedEdges(FXObject *obj, FXSelector, void *)
Called when the user press use selected edges.
void updateSelectEdgesButton()
update "select edges button"
double getDefaultTAZSourceWeight() const
get default TAZSource weight
FXLabel * myInformationLabel
information label
Definition: GNETAZFrame.h:298
FXHorizontalFrame * myDefaultTAZSinkFrame
Horizontal Frame for default TAZ Sink Weight.
Definition: GNETAZFrame.h:289
FXHorizontalFrame * myDefaultTAZSourceFrame
Horizontal Frame for default TAZ Source Weight.
Definition: GNETAZFrame.h:283
FXTextField * myTextFieldDefaultValueTAZSinks
textField to set a default value for TAZ Sinks
Definition: GNETAZFrame.h:292
long onCmdSetDefaultValues(FXObject *obj, FXSelector, void *)
double getDefaultTAZSinkWeight() const
default TAZSink weight
void showTAZChildDefaultParametersModul()
show TAZ child default parameters Modul
TAZCommonStatistics(GNETAZFrame *TAZFrameParent)
constructor
FXLabel * myStatisticsLabel
Statistics labels.
Definition: GNETAZFrame.h:177
void hideTAZCommonStatisticsModul()
hide TAZ Common Statistics Modul
void showTAZCommonStatisticsModul()
show TAZ Common Statistics Modul
void updateStatistics()
update Statistics label
void refreshTAZEdges()
refresh TAZEdges
void addTAZChild(GNETAZSourceSink *additional)
add TAZChild
void setTAZ(GNETAZ *editedTAZ)
set current TAZ
const std::vector< TAZCurrent::TAZEdge > & getTAZEdges() const
get TAZEdges
FXLabel * myTAZCurrentLabel
Label for current TAZ.
Definition: GNETAZFrame.h:134
const std::vector< GNEEdge * > & getNetEdges() const
get current net edges
double myMaxSourcePlusSinkWeight
maximum source plus sink value of current TAZ Edges
Definition: GNETAZFrame.h:137
bool isTAZEdge(GNEEdge *edge) const
check if given edge belongs to current TAZ
GNETAZ * getTAZ() const
get current TAZ
double myMinSourceMinusSinkWeight
minimum source minus sink value of current TAZ Edges
Definition: GNETAZFrame.h:146
GNETAZFrame * myTAZFrameParent
pointer to TAZ Frame
Definition: GNETAZFrame.h:119
const std::vector< GNEEdge * > & getSelectedEdges() const
get current selected edges
double myMinSourcePlusSinkWeight
minimum source plus sink value of current TAZ Edges
Definition: GNETAZFrame.h:140
double myMaxSourceMinusSinkWeight
maximum source minus sink value of current TAZ Edges
Definition: GNETAZFrame.h:143
TAZCurrent(GNETAZFrame *TAZFrameParent)
constructor
GNETAZ * myEditedTAZ
current edited TAZ
Definition: GNETAZFrame.h:122
FXRadioButton * myColorBySourcePlusSinkWeight
add radio button "color source + sink"
Definition: GNETAZFrame.h:487
RGBColor myEdgeSelectedColor
RGBColor color for selected egdes.
Definition: GNETAZFrame.h:496
FXRadioButton * myColorBySinkWeight
add radio button "color by sink"
Definition: GNETAZFrame.h:484
void updateEdgeColors()
update edge colors;
void showTAZEdgesGraphicModul()
show TAZ Edges Graphic Modul
FXRadioButton * myColorBySourceWeight
add radio button "color by source"
Definition: GNETAZFrame.h:481
FXRadioButton * myColorBySourceMinusSinkWeight
add radio button "color source - Sink"
Definition: GNETAZFrame.h:490
RGBColor myEdgeDefaultColor
default RGBColor for all edges
Definition: GNETAZFrame.h:493
void hideTAZEdgesGraphicModul()
hide TAZ Edges Graphic Modul
long onCmdChoosenBy(FXObject *obj, FXSelector, void *)
TAZEdgesGraphic(GNETAZFrame *TAZFrameParent)
FOX-declaration.
std::map< SumoXMLAttr, std::string > 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 hideTAZParametersModul()
hide TAZ parameters
TAZParameters(GNETAZFrame *TAZFrameParent)
FOX-declaration.
FXButton * myHelpTAZAttribute
button for help
Definition: GNETAZFrame.h:440
FXCheckButton * myAddEdgesWithinCheckButton
CheckButton to enable or disable use edges within TAZ after creation.
Definition: GNETAZFrame.h:437
long onCmdSetAttribute(FXObject *, FXSelector, void *)
Called when user set a value.
long onCmdHelp(FXObject *, FXSelector, void *)
Called when help button is pressed.
long onCmdSetColorAttribute(FXObject *, FXSelector, void *)
FXButton * myColorEditor
Button for open color editor.
Definition: GNETAZFrame.h:431
void showTAZParametersModul()
show TAZ parameters and set the default value of parameters
FXTextField * myTextFieldColor
textField to modify the default value of color parameter
Definition: GNETAZFrame.h:434
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 hideTAZSaveChangesModul()
hide TAZ Save Changes Modul
FXButton * myCancelChangesButton
@field FXButton for cancel changes in TAZEdges
Definition: GNETAZFrame.h:227
void showTAZSaveChangesModul()
show TAZ Save Changes Modul
long onCmdCancelChanges(FXObject *, FXSelector, void *)
Called when the user press the button cancel changes.
TAZSaveChanges(GNETAZFrame *TAZFrameParent)
FOX-declaration.
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:363
const std::vector< TAZCurrent::TAZEdge > & getEdgeAndTAZChildrenSelected() const
get map with edge and TAZChildren
bool isEdgeSelected(GNEEdge *edge)
check if an edge is selected
FXHorizontalFrame * myTAZSinkFrame
Horizontal Frame for default TAZ Sink Weight.
Definition: GNETAZFrame.h:369
long onCmdSetNewValues(FXObject *obj, FXSelector, void *)
bool selectEdge(const TAZCurrent::TAZEdge &edge)
add an edge and their TAZ Children in the list of selected items
void clearSelectedEdges()
clear current TAZ children
void showTAZSelectionStatisticsModul()
show TAZ Selection Statistics Modul
FXTextField * myTextFieldTAZSourceWeight
textField for TAZ Source weight
Definition: GNETAZFrame.h:366
void updateStatistics()
update TAZSelectionStatistics
void hideTAZSelectionStatisticsModul()
hide TAZ Selection Statistics Modul
FXTextField * myTextFieldTAZSinkWeight
textField for TAZ Sink weight
Definition: GNETAZFrame.h:372
bool unselectEdge(GNEEdge *edge)
un select an edge (and their TAZ Children)
FXLabel * myStatisticsLabel
Statistics labels.
Definition: GNETAZFrame.h:375
TAZSelectionStatistics * myTAZSelectionStatistics
TAZ Edges selection parameters.
Definition: GNETAZFrame.h:569
TAZEdgesGraphic * myTAZEdgesGraphic
TAZ Edges Graphic.
Definition: GNETAZFrame.h:572
TAZParameters * myTAZParameters
TAZ parameters.
Definition: GNETAZFrame.h:554
bool addOrRemoveTAZMember(GNEEdge *edge)
add or remove a TAZSource and a TAZSink, or remove it if edge is in the list of TAZ Children
void dropTAZMembers()
drop all TAZSources and TAZ Sinks of current TAZ
bool processClick(const Position &clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
process click over Viewnet
TAZSelectionStatistics * getTAZSelectionStatisticsModul() const
get TAZ Selection Statistics modul
TAZCommonStatistics * myTAZCommonStatistics
TAZ Edges common parameters.
Definition: GNETAZFrame.h:551
TAZCurrent * myTAZCurrent
current TAZ
Definition: GNETAZFrame.h:548
bool shapeDrawed()
build a shaped element using the drawed shape return true if was sucesfully created
GNEFrameModuls::DrawingShape * myDrawingShape
Drawing shape.
Definition: GNETAZFrame.h:560
~GNETAZFrame()
Destructor.
TAZSaveChanges * myTAZSaveChanges
save TAZ Edges
Definition: GNETAZFrame.h:563
GNEFrameAttributesModuls::NeteditAttributes * myNeteditAttributes
Netedit parameter.
Definition: GNETAZFrame.h:557
GNEFrameModuls::DrawingShape * getDrawingShapeModul() const
get drawing mode modul
TAZCurrent * getTAZCurrentModul() const
get Current TAZ modul
GNETAZFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
void hide()
hide TAZ frame
void processEdgeSelection(const std::vector< GNEEdge * > &edges)
process selection of edges in view net
TAZSaveChanges * getTAZSaveChangesModul() const
get TAZ Save Changes modul
TAZChildDefaultParameters * myTAZChildDefaultParameters
TAZ child defaults parameters.
Definition: GNETAZFrame.h:566
Definition: GNETAZ.h:33
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
class used to group all variables related with objects under cursor after a click over view
GNETAZElement * getTAZElementFront() const
get front TAZElement or a pointer to nullptr
GNEEdge * getEdgeFront() const
get front edge or a pointer to nullptr
GNENet * getNet() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
std::set< std::pair< std::string, GNEAttributeCarrier * > > getAttributeCarriersInBoundary(const Boundary &boundary, bool forceSelectEdges=false)
get AttributeCarriers in Boundary
Definition: GNEViewNet.cpp:331
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
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
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
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.
static const RGBColor WHITE
Definition: RGBColor.h:187
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:168
Encapsulated Xerces-SAX-attributes.
struct for edges and the source/sink colors
Definition: GNETAZFrame.h:50
void updateColors()
update colors
Definition: GNETAZFrame.cpp:96
~TAZEdge()
destructor (needed because RGBColors has to be deleted)
Definition: GNETAZFrame.cpp:92
static const std::vector< RGBColor > & getRainbowScaledColors()
get scaled rainbow colors