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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // 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, FXGroupBoxModule, TAZParametersMap, ARRAYNUMBER(TAZParametersMap))
66 FXIMPLEMENT(GNETAZFrame::TAZSaveChanges, FXGroupBoxModule, TAZSaveChangesMap, ARRAYNUMBER(TAZSaveChangesMap))
67 FXIMPLEMENT(GNETAZFrame::TAZChildDefaultParameters, FXGroupBoxModule, TAZChildDefaultParametersMap, ARRAYNUMBER(TAZChildDefaultParametersMap))
68 FXIMPLEMENT(GNETAZFrame::TAZSelectionStatistics, FXGroupBoxModule, TAZSelectionStatisticsMap, ARRAYNUMBER(TAZSelectionStatisticsMap))
69 FXIMPLEMENT(GNETAZFrame::TAZEdgesGraphic, FXGroupBoxModule, TAZEdgesGraphicMap, ARRAYNUMBER(TAZEdgesGraphicMap))
70 
71 
72 // ===========================================================================
73 // method definitions
74 // ===========================================================================
75 
76 // ---------------------------------------------------------------------------
77 // GNETAZFrame::CurrentTAZ - methods
78 // ---------------------------------------------------------------------------
79 
81  edge(_edge),
82  source(_source),
83  sink(_sink),
84  sourceColor(0),
85  sinkColor(0),
86  sourcePlusSinkColor(0),
87  sourceMinusSinkColor(0),
88  myCurrentTAZParent(CurrentTAZParent) {
89 }
90 
91 
93 
94 
95 void
97  sourceColor = GNEAttributeCarrier::parse<int>(source->getAttribute(GNE_ATTR_TAZCOLOR));
98  sinkColor = GNEAttributeCarrier::parse<int>(sink->getAttribute(GNE_ATTR_TAZCOLOR));
99  // Obtain Source+Sink needs more steps. First obtain Source+Sink Weight
100  double sourcePlusSinkWeight = source->getDepartWeight() + sink->getDepartWeight();
101  // avoid division between zero
102  if ((myCurrentTAZParent->myMaxSourcePlusSinkWeight - myCurrentTAZParent->myMinSourcePlusSinkWeight) == 0) {
103  sourcePlusSinkColor = 0;
104  } else {
105  // calculate percentage relative to the max and min Source+Sink weight
106  double percentage = (sourcePlusSinkWeight - myCurrentTAZParent->myMinSourcePlusSinkWeight) /
107  (myCurrentTAZParent->myMaxSourcePlusSinkWeight - myCurrentTAZParent->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 = source->getDepartWeight() - sink->getDepartWeight();
119  // avoid division between zero
120  if ((myCurrentTAZParent->myMaxSourceMinusSinkWeight - myCurrentTAZParent->myMinSourceMinusSinkWeight) == 0) {
121  sourceMinusSinkColor = 0;
122  } else {
123  // calculate percentage relative to the max and min Source-Sink weight
124  double percentage = (sourceMinusSinkWeight - myCurrentTAZParent->myMinSourceMinusSinkWeight) /
125  (myCurrentTAZParent->myMaxSourceMinusSinkWeight - myCurrentTAZParent->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  edge(nullptr),
140  source(nullptr),
141  sink(nullptr),
142  sourceColor(0),
143  sinkColor(0),
144  sourcePlusSinkColor(0),
145  sourceMinusSinkColor(0),
146  myCurrentTAZParent(nullptr) {
147 }
148 
149 
151  FXGroupBoxModule(TAZFrameParent->myContentFrame, "TAZ"),
152  myTAZFrameParent(TAZFrameParent),
153  myEditedTAZ(nullptr),
158  // create TAZ label
159  myCurrentTAZLabel = new FXLabel(getCollapsableFrame(), "No TAZ selected", 0, GUIDesignLabelLeft);
160 }
161 
162 
164 
165 
166 void
168  // set new current TAZ
169  myEditedTAZ = editedTAZ;
170  // update label and moduls
171  if (myEditedTAZ != nullptr) {
172  myCurrentTAZLabel->setText(("Current TAZ: " + myEditedTAZ->getID()).c_str());
173  // obtain a copy of all SELECTED edges of the net (to avoid slowdown during manipulations)
174  mySelectedEdges = myTAZFrameParent->myViewNet->getNet()->getAttributeCarriers()->getSelectedEdges();
175  // resfresh TAZ Edges
176  refreshTAZEdges();
177  // hide TAZ parameters
178  myTAZFrameParent->myTAZParameters->hideTAZParametersModule();
179  // hide Netedit parameters
180  myTAZFrameParent->myNeteditAttributes->hideNeteditAttributesModule();
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->showTAZChildDefaultParametersModule();
189  // show Edges graphics
190  myTAZFrameParent->myTAZEdgesGraphic->showTAZEdgesGraphicModule();
191  } else {
192  // show TAZ parameters
193  myTAZFrameParent->myTAZParameters->showTAZParametersModule();
194  // show Netedit parameters
195  myTAZFrameParent->myNeteditAttributes->showNeteditAttributesModule(GNEAttributeCarrier::getTagProperty(SUMO_TAG_TAZ));
196  // show drawing shape
197  myTAZFrameParent->myDrawingShape->showDrawingShape();
198  // hide edge common parameters
199  myTAZFrameParent->myTAZCommonStatistics->hideTAZCommonStatisticsModule();
200  // hide edge common parameters
201  myTAZFrameParent->myTAZChildDefaultParameters->hideTAZChildDefaultParametersModule();
202  // hide Edges graphics
203  myTAZFrameParent->myTAZEdgesGraphic->hideTAZEdgesGraphicModule();
204  // hide save TAZ Edges
205  myTAZFrameParent->myTAZSaveChanges->hideTAZSaveChangesModule();
206  // restore label
207  myCurrentTAZLabel->setText("No TAZ selected");
208  // clear selected edges
209  mySelectedEdges.clear();
210  // reset all weight values
211  myMaxSourcePlusSinkWeight = 0;
212  myMinSourcePlusSinkWeight = -1;
213  myMaxSourceMinusSinkWeight = 0;
214  myMinSourceMinusSinkWeight = -1;
215  }
216 }
217 
218 
219 GNETAZ*
221  return myEditedTAZ;
222 }
223 
224 
225 bool
227  // simply iterate over edges and check edge parameter
228  for (const auto& TAZEdgeColor : myTAZEdgeColors) {
229  if (TAZEdgeColor.edge == edge) {
230  return true;
231  }
232  }
233  // not found, then return false
234  return false;
235 }
236 
237 
238 const std::vector<GNEEdge*>&
240  return mySelectedEdges;
241 }
242 
243 
244 const std::vector<GNETAZFrame::CurrentTAZ::TAZEdgeColor>&
246  return myTAZEdgeColors;
247 }
248 
249 
250 void
252  // clear all curren TAZEdges
253  myTAZEdgeColors.clear();
254  // clear weight values
255  myMaxSourcePlusSinkWeight = 0;
256  myMinSourcePlusSinkWeight = -1;
257  myMaxSourceMinusSinkWeight = 0;
258  myMinSourceMinusSinkWeight = -1;
259  // only refresh if we're editing an TAZ
260  if (myEditedTAZ) {
261  // first update TAZ Stadistics
262  myEditedTAZ->updateTAZStadistic();
263  myTAZFrameParent->myTAZCommonStatistics->updateStatistics();
264  // iterate over child TAZElements and create TAZEdges
265  for (const auto& TAZElement : myEditedTAZ->getChildTAZElements()) {
266  addTAZChild(dynamic_cast<GNETAZSourceSink*>(TAZElement));
267  }
268  // update colors after add all edges
269  for (auto& TAZEdgeColor : myTAZEdgeColors) {
271  }
272  // update edge colors
273  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
274  }
275 }
276 
277 
278 void
280  // first make sure that TAZElements is an TAZ Source or Sink
281  if (sourceSink && ((sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) || (sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSINK))) {
282  GNEEdge* edge = myTAZFrameParent->myViewNet->getNet()->getAttributeCarriers()->retrieveEdge(sourceSink->getAttribute(SUMO_ATTR_EDGE));
283  // first check if TAZEdgeColor has to be created
284  bool createTAZEdge = true;
285  for (auto& TAZEdgeColor : myTAZEdgeColors) {
286  if (TAZEdgeColor.edge == edge) {
287  createTAZEdge = false;
288  // update TAZ Source or Sink
289  if (sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
290  TAZEdgeColor.source = sourceSink;
291  } else {
292  TAZEdgeColor.sink = sourceSink;
293  }
294  }
295  }
296  // check if TAZElements has to be created
297  if (createTAZEdge) {
298  if (sourceSink->getTagProperty().getTag() == SUMO_TAG_TAZSOURCE) {
299  myTAZEdgeColors.push_back(TAZEdgeColor(this, edge, sourceSink, nullptr));
300  } else {
301  myTAZEdgeColors.push_back(TAZEdgeColor(this, edge, nullptr, sourceSink));
302  }
303  }
304  // recalculate weights
305  myMaxSourcePlusSinkWeight = 0;
306  myMinSourcePlusSinkWeight = -1;
307  myMaxSourceMinusSinkWeight = 0;
308  myMinSourceMinusSinkWeight = -1;
309  for (const auto& TAZEdgeColor : myTAZEdgeColors) {
310  // make sure that both TAZ Source and Sink exist
312  // obtain source plus sink
313  double sourcePlusSink = TAZEdgeColor.source->getDepartWeight() + TAZEdgeColor.sink->getDepartWeight();
314  // check myMaxSourcePlusSinkWeight
315  if (sourcePlusSink > myMaxSourcePlusSinkWeight) {
316  myMaxSourcePlusSinkWeight = sourcePlusSink;
317  }
318  // check myMinSourcePlusSinkWeight
319  if ((myMinSourcePlusSinkWeight == -1) || (sourcePlusSink < myMinSourcePlusSinkWeight)) {
320  myMinSourcePlusSinkWeight = sourcePlusSink;
321  }
322  // obtain source minus sink
323  double sourceMinusSink = TAZEdgeColor.source->getDepartWeight() - TAZEdgeColor.sink->getDepartWeight();
324  // use valor absolute
325  if (sourceMinusSink < 0) {
326  sourceMinusSink *= -1;
327  }
328  // check myMaxSourcePlusSinkWeight
329  if (sourceMinusSink > myMaxSourceMinusSinkWeight) {
330  myMaxSourceMinusSinkWeight = sourceMinusSink;
331  }
332  // check myMinSourcePlusSinkWeight
333  if ((myMinSourceMinusSinkWeight == -1) || (sourceMinusSink < myMinSourceMinusSinkWeight)) {
334  myMinSourceMinusSinkWeight = sourceMinusSink;
335  }
336  }
337  }
338  } else {
339  throw ProcessError("Invalid TAZ Child");
340  }
341 }
342 
343 // ---------------------------------------------------------------------------
344 // GNETAZFrame::TAZCommonStatistics - methods
345 // ---------------------------------------------------------------------------
346 
348  FXGroupBoxModule(TAZFrameParent->myContentFrame, "TAZ Statistics"),
349  myTAZFrameParent(TAZFrameParent) {
350  // create label for statistics
351  myStatisticsLabel = new FXLabel(getCollapsableFrame(), "Statistics", 0, GUIDesignLabelFrameInformation);
352 }
353 
354 
356 
357 
358 void
360  // always update statistics after show
361  updateStatistics();
362  show();
363 }
364 
365 
366 void
368  hide();
369 }
370 
371 
372 void
374  if (myTAZFrameParent->myCurrentTAZ->getTAZ()) {
375  // declare ostringstream for statistics
376  std::ostringstream information;
377  information
378  << "- Number of edges: " << toString(myTAZFrameParent->myCurrentTAZ->getTAZ()->getChildTAZElements().size() / 2) << "\n"
379  << "- Min source: " << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_MIN_SOURCE) << "\n"
380  << "- Max source: " << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_MAX_SOURCE) << "\n"
381  << "- Average source: " << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_AVERAGE_SOURCE) << "\n"
382  << "\n"
383  << "- Min sink: " << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_MIN_SINK) << "\n"
384  << "- Max sink: " << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_MAX_SINK) << "\n"
385  << "- Average sink: " << myTAZFrameParent->myCurrentTAZ->getTAZ()->getAttribute(GNE_ATTR_AVERAGE_SINK);
386  // set new label
387  myStatisticsLabel->setText(information.str().c_str());
388  } else {
389  myStatisticsLabel->setText("No TAZ Selected");
390  }
391 }
392 
393 // ---------------------------------------------------------------------------
394 // GNETAZFrame::TAZSaveChanges - methods
395 // ---------------------------------------------------------------------------
396 
398  FXGroupBoxModule(TAZFrameParent->myContentFrame, "Modifications"),
399  myTAZFrameParent(TAZFrameParent) {
400  // Create groupbox for save changes
402  mySaveChangesButton->disable();
403  // Create groupbox cancel changes
405  myCancelChangesButton->disable();
406 }
407 
408 
410 
411 
412 void
414  show();
415 }
416 
417 
418 void
420  // cancel changes before hidding modul
421  onCmdCancelChanges(0, 0, 0);
422  hide();
423 }
424 
425 
426 void
428  // check that save changes is disabled
429  if (!mySaveChangesButton->isEnabled()) {
430  // enable mySaveChangesButton and myCancelChangesButton
431  mySaveChangesButton->enable();
432  myCancelChangesButton->enable();
433  // start undo list set
434  myTAZFrameParent->myViewNet->getUndoList()->begin(GUIIcon::TAZ, "TAZ changes");
435  }
436 }
437 
438 
439 bool
441  // simply check if save Changes Button is enabled
442  return mySaveChangesButton->isEnabled();
443 }
444 
445 
446 long
447 GNETAZFrame::TAZSaveChanges::onCmdSaveChanges(FXObject*, FXSelector, void*) {
448  // check that save changes is enabled
449  if (mySaveChangesButton->isEnabled()) {
450  // disable mySaveChangesButton and myCancelChangesButtonand
451  mySaveChangesButton->disable();
452  myCancelChangesButton->disable();
453  // finish undo list set
454  myTAZFrameParent->myViewNet->getUndoList()->end();
455  // always refresh TAZ Edges after removing TAZSources/Sinks
456  myTAZFrameParent->myCurrentTAZ->refreshTAZEdges();
457  // update use edges button
458  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
459 
460  }
461  return 1;
462 }
463 
464 
465 long
466 GNETAZFrame::TAZSaveChanges::onCmdCancelChanges(FXObject*, FXSelector, void*) {
467  // check that save changes is enabled
468  if (mySaveChangesButton->isEnabled()) {
469  // disable buttons
470  mySaveChangesButton->disable();
471  myCancelChangesButton->disable();
472  // abort undo list
473  myTAZFrameParent->myViewNet->getUndoList()->abortAllChangeGroups();
474  // always refresh TAZ Edges after removing TAZSources/Sinks
475  myTAZFrameParent->myCurrentTAZ->refreshTAZEdges();
476  // update use edges button
477  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
478  }
479  return 1;
480 }
481 
482 // ---------------------------------------------------------------------------
483 // GNETAZFrame::TAZChildDefaultParameters - methods
484 // ---------------------------------------------------------------------------
485 
487  FXGroupBoxModule(TAZFrameParent->myContentFrame, "TAZ Sources/Sinks"),
488  myTAZFrameParent(TAZFrameParent),
489  myDefaultTAZSourceWeight(1),
490  myDefaultTAZSinkWeight(1) {
491  // create checkbox for toggle membership
492  FXHorizontalFrame* toggleMembershipFrame = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
493  new FXLabel(toggleMembershipFrame, "Membership", 0, GUIDesignLabelAttribute);
494  myToggleMembership = new FXCheckButton(toggleMembershipFrame, "Toggle", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
495  // by default enabled
496  myToggleMembership->setCheck(TRUE);
497  // create default TAZ Source weight
499  new FXLabel(myDefaultTAZSourceFrame, "New source", 0, GUIDesignLabelAttribute);
501  myTextFieldDefaultValueTAZSources->setText("1");
502  // create default TAZ Sink weight
504  new FXLabel(myDefaultTAZSinkFrame, "New sink", 0, GUIDesignLabelAttribute);
506  myTextFieldDefaultValueTAZSinks->setText("1");
507  // Create button for use selected edges
508  myUseSelectedEdges = new FXButton(getCollapsableFrame(), "Use selected edges", nullptr, this, MID_GNE_SELECT, GUIDesignButton);
509  // Create information label
510  std::ostringstream information;
511  information
512  << "- Toggle Membership:\n"
513  << " Create new Sources/Sinks\n"
514  << " with given weights.";
515  myInformationLabel = new FXLabel(getCollapsableFrame(), information.str().c_str(), 0, GUIDesignLabelFrameInformation);
516 }
517 
518 
520 
521 
522 void
524  // check if TAZ selection Statistics Module has to be shown
525  if (myToggleMembership->getCheck() == FALSE) {
526  myTAZFrameParent->myTAZSelectionStatistics->showTAZSelectionStatisticsModule();
527  } else {
528  myTAZFrameParent->myTAZSelectionStatistics->hideTAZSelectionStatisticsModule();
529  }
530  // update selected button
531  updateSelectEdgesButton();
532  // show modul
533  show();
534 }
535 
536 
537 void
539  // hide TAZ Selection Statistics Module
540  myTAZFrameParent->myTAZSelectionStatistics->hideTAZSelectionStatisticsModule();
541  // hide modul
542  hide();
543 }
544 
545 
546 void
548  if (myToggleMembership->getCheck() == TRUE) {
549  // check if use selected edges has to be enabled
550  if (myTAZFrameParent->myCurrentTAZ->getSelectedEdges().size() > 0) {
551  myUseSelectedEdges->setText("Use selected edges");
552  myUseSelectedEdges->enable();
553  } else if (myTAZFrameParent->myCurrentTAZ->getTAZEdges().size() > 0) {
554  myUseSelectedEdges->setText("Remove all edges");
555  myUseSelectedEdges->enable();
556  } else {
557  myUseSelectedEdges->setText("Use selected edges");
558  myUseSelectedEdges->disable();
559  }
560  } else if (myTAZFrameParent->getCurrentTAZModule()->getTAZEdges().size() > 0) {
561  // enable myUseSelectedEdges button
562  myUseSelectedEdges->enable();
563  // update mySelectEdgesOfSelection label
564  if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size() == 0) {
565  // check if all edges of TAZChildren are selected
566  bool allSelected = true;
567  for (const auto& TAZEdgeColor : myTAZFrameParent->getCurrentTAZModule()->getTAZEdges()) {
568  if (!TAZEdgeColor.edge->isAttributeCarrierSelected()) {
569  allSelected = false;
570  }
571  }
572  if (allSelected) {
573  myUseSelectedEdges->setText("Remove all edges from selection");
574  } else {
575  myUseSelectedEdges->setText("Add all edges to selection");
576  }
577  } else if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size() == 1) {
578  if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().front().edge->isAttributeCarrierSelected()) {
579  myUseSelectedEdges->setText("Remove edge from selection");
580  } else {
581  myUseSelectedEdges->setText("Add edge to selection");
582  }
583  } else {
584  // check if all edges of TAZChildren selected are selected
585  bool allSelected = true;
586  for (const auto& selectedEdge : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
587  if (!selectedEdge.edge->isAttributeCarrierSelected()) {
588  allSelected = false;
589  }
590  }
591  if (allSelected) {
592  myUseSelectedEdges->setText(("Remove " + toString(myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size()) + " from to selection").c_str());
593  } else {
594  myUseSelectedEdges->setText(("Add " + toString(myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size()) + " edges to selection").c_str());
595  }
596  }
597  } else {
598  // TAZ doesn't have children, then disable button
599  myUseSelectedEdges->disable();
600  }
601 }
602 
603 
604 double
606  return myDefaultTAZSourceWeight;
607 }
608 
609 
610 double
612  return myDefaultTAZSinkWeight;
613 }
614 
615 
616 bool
618  return (myToggleMembership->getCheck() == TRUE);
619 }
620 
621 
622 long
624  // find edited object
625  if (obj == myToggleMembership) {
626  // first clear selected edges
627  myTAZFrameParent->myTAZSelectionStatistics->clearSelectedEdges();
628  // set text of myToggleMembership
629  if (myToggleMembership->getCheck() == TRUE) {
630  myToggleMembership->setText("toggle");
631  // show source/Sink Frames
632  myDefaultTAZSourceFrame->show();
633  myDefaultTAZSinkFrame->show();
634  // update information label
635  std::ostringstream information;
636  information
637  << "- Toggle Membership:\n"
638  << " Create new Sources/Sinks\n"
639  << " with given weights.";
640  myInformationLabel->setText(information.str().c_str());
641  // hide TAZSelectionStatistics
642  myTAZFrameParent->myTAZSelectionStatistics->hideTAZSelectionStatisticsModule();
643  // check if use selected edges has to be enabled
644  if (myTAZFrameParent->myCurrentTAZ->getSelectedEdges().size() > 0) {
645  myUseSelectedEdges->setText("Use selected edges");
646  } else if (myTAZFrameParent->myCurrentTAZ->getTAZEdges().size() > 0) {
647  myUseSelectedEdges->setText("Remove all edges");
648  } else {
649  myUseSelectedEdges->setText("Use selected edges");
650  myUseSelectedEdges->disable();
651  }
652  } else {
653  myToggleMembership->setText("keep");
654  // hide source/Sink Frames
655  myDefaultTAZSourceFrame->hide();
656  myDefaultTAZSinkFrame->hide();
657  // update information label
658  std::ostringstream information;
659  information
660  << "- Keep Membership:\n"
661  << " Select Sources/Sinks.\n"
662  << "- Press ESC to clear\n"
663  << " current selection.";
664  myInformationLabel->setText(information.str().c_str());
665  // show TAZSelectionStatistics
666  myTAZFrameParent->myTAZSelectionStatistics->showTAZSelectionStatisticsModule();
667  }
668  // update button
669  updateSelectEdgesButton();
670  } else if (obj == myTextFieldDefaultValueTAZSources) {
671  // check if given value is valid
672  if (GNEAttributeCarrier::canParse<double>(myTextFieldDefaultValueTAZSources->getText().text())) {
673  myDefaultTAZSourceWeight = GNEAttributeCarrier::parse<double>(myTextFieldDefaultValueTAZSources->getText().text());
674  // check if myDefaultTAZSourceWeight is greather than 0
675  if (myDefaultTAZSourceWeight >= 0) {
676  // set valid color
677  myTextFieldDefaultValueTAZSources->setTextColor(FXRGB(0, 0, 0));
678  } else {
679  // set invalid color
680  myTextFieldDefaultValueTAZSources->setTextColor(FXRGB(255, 0, 0));
681  myDefaultTAZSourceWeight = 1;
682  }
683  } else {
684  // set invalid color
685  myTextFieldDefaultValueTAZSources->setTextColor(FXRGB(255, 0, 0));
686  myDefaultTAZSourceWeight = 1;
687  }
688  } else if (obj == myTextFieldDefaultValueTAZSinks) {
689  // check if given value is valid
690  if (GNEAttributeCarrier::canParse<double>(myTextFieldDefaultValueTAZSinks->getText().text())) {
691  myDefaultTAZSinkWeight = GNEAttributeCarrier::parse<double>(myTextFieldDefaultValueTAZSinks->getText().text());
692  // check if myDefaultTAZSinkWeight is greather than 0
693  if (myDefaultTAZSinkWeight >= 0) {
694  // set valid color
695  myTextFieldDefaultValueTAZSinks->setTextColor(FXRGB(0, 0, 0));
696  } else {
697  // set invalid color
698  myTextFieldDefaultValueTAZSinks->setTextColor(FXRGB(255, 0, 0));
699  myDefaultTAZSinkWeight = 1;
700  }
701  } else {
702  // set invalid color
703  myTextFieldDefaultValueTAZSinks->setTextColor(FXRGB(255, 0, 0));
704  myDefaultTAZSinkWeight = 1;
705  }
706  }
707  return 1;
708 }
709 
710 
711 long
713  // select edge or create new TAZ Source/Child, depending of myToggleMembership
714  if (myToggleMembership->getCheck() == TRUE) {
715  // first drop all edges
716  myTAZFrameParent->dropTAZMembers();
717  // iterate over selected edges and add it as TAZMember
718  for (const auto& selectedEdge : myTAZFrameParent->myCurrentTAZ->getSelectedEdges()) {
719  myTAZFrameParent->addOrRemoveTAZMember(selectedEdge);
720  }
721  // update selected button
722  updateSelectEdgesButton();
723  } else {
724  if (myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected().size() == 0) {
725  // first check if all TAZEdges are selected
726  bool allSelected = true;
727  for (const auto& TAZEdgeColor : myTAZFrameParent->getCurrentTAZModule()->getTAZEdges()) {
728  if (!TAZEdgeColor.edge->isAttributeCarrierSelected()) {
729  allSelected = false;
730  }
731  }
732  // select or unselect all depending of allSelected
733  if (allSelected) {
734  // remove form selection all TAZEdges
735  for (const auto& TAZEdgeColor : myTAZFrameParent->getCurrentTAZModule()->getTAZEdges()) {
736  // change attribute selected (without undo-redo)
737  TAZEdgeColor.edge->unselectAttributeCarrier();
738  }
739  } else {
740  // add to selection all TAZEdges
741  for (const auto& TAZEdgeColor : myTAZFrameParent->getCurrentTAZModule()->getTAZEdges()) {
742  // change attribute selected (without undo-redo)
743  TAZEdgeColor.edge->selectAttributeCarrier();
744  }
745  }
746  } else {
747  // first check if all TAZEdges are selected
748  bool allSelected = true;
749  for (const auto& selectedEdge : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
750  if (!selectedEdge.edge->isAttributeCarrierSelected()) {
751  allSelected = false;
752  }
753  }
754  // select or unselect all depending of allSelected
755  if (allSelected) {
756  // only remove from selection selected TAZEdges
757  for (const auto& selectedEdge : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
758  if (selectedEdge.edge->isAttributeCarrierSelected()) {
759  // change attribute selected (without undo-redo)
760  selectedEdge.edge->unselectAttributeCarrier();
761  }
762  }
763  } else {
764  // only add to selection selected TAZEdges
765  for (const auto& selectedEdge : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
766  if (!selectedEdge.edge->isAttributeCarrierSelected()) {
767  // change attribute selected (without undo-redo)
768  selectedEdge.edge->selectAttributeCarrier();
769  }
770  }
771  }
772  }
773  }
774  // update selection button
775  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
776  // update view net
777  myTAZFrameParent->myViewNet->updateViewNet();
778  return 1;
779 }
780 
781 // ---------------------------------------------------------------------------
782 // GNETAZFrame::TAZSelectionStatistics - methods
783 // ---------------------------------------------------------------------------
784 
786  FXGroupBoxModule(TAZFrameParent->myContentFrame, "Selection Statistics"),
787  myTAZFrameParent(TAZFrameParent) {
788  // create default TAZ Source weight
790  new FXLabel(myTAZSourceFrame, "Source", 0, GUIDesignLabelAttribute);
792  myTAZSourceFrame->hide();
793  // create default TAZ Sink weight
795  new FXLabel(myTAZSinkFrame, "Sink", 0, GUIDesignLabelAttribute);
797  myTAZSinkFrame->hide();
798  // create label for statistics
799  myStatisticsLabel = new FXLabel(getCollapsableFrame(), "Statistics", 0, GUIDesignLabelFrameInformation);
800 }
801 
802 
804 
805 
806 void
808  // update Statistics before show
809  updateStatistics();
810  show();
811 }
812 
813 
814 void
816  // clear children before hide
817  clearSelectedEdges();
818  hide();
819 }
820 
821 
822 bool
824  // find TAZEdgeColor using edge as criterium wasn't previously selected
825  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
826  if (selectedEdge.edge == TAZEdgeColor.edge) {
827  throw ProcessError("TAZEdgeColor already selected");
828  }
829  }
830  // add edge and their TAZ Children into myTAZChildSelected
831  myEdgeAndTAZChildrenSelected.push_back(TAZEdgeColor);
832  // always update statistics after insertion
833  updateStatistics();
834  // update edge colors
835  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
836  // update selection button
837  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
838  return true;
839 }
840 
841 
842 bool
844  if (edge) {
845  // find TAZEdgeColor using edge as criterium
846  for (auto it = myEdgeAndTAZChildrenSelected.begin(); it != myEdgeAndTAZChildrenSelected.end(); it++) {
847  if (it->edge == edge) {
848  myEdgeAndTAZChildrenSelected.erase(it);
849  // always update statistics after insertion
850  updateStatistics();
851  // update edge colors
852  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
853  // update selection button
854  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
855  return true;
856  }
857  }
858  // throw exception if edge wasn't found
859  throw ProcessError("edge wasn't found");
860  } else {
861  throw ProcessError("Invalid edge");
862  }
863 }
864 
865 
866 bool
868  // find TAZEdgeColor using edge as criterium
869  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
870  if (selectedEdge.edge == edge) {
871  return true;
872  }
873  }
874  // edge wasn't found, then return false
875  return false;
876 }
877 
878 
879 void
881  // clear all selected edges (and the TAZ Children)
882  myEdgeAndTAZChildrenSelected.clear();
883  // always update statistics after clear edges
884  updateStatistics();
885  // update edge colors
886  myTAZFrameParent->myTAZEdgesGraphic->updateEdgeColors();
887  // update selection button
888  myTAZFrameParent->myTAZChildDefaultParameters->updateSelectEdgesButton();
889 }
890 
891 
892 const std::vector<GNETAZFrame::CurrentTAZ::TAZEdgeColor>&
894  return myEdgeAndTAZChildrenSelected;
895 }
896 
897 
898 long
900  if (obj == myTextFieldTAZSourceWeight) {
901  // check if given value is valid
902  if (GNEAttributeCarrier::canParse<double>(myTextFieldTAZSourceWeight->getText().text())) {
903  double newTAZSourceWeight = GNEAttributeCarrier::parse<double>(myTextFieldTAZSourceWeight->getText().text());
904  // check if myDefaultTAZSourceWeight is greather than 0
905  if (newTAZSourceWeight >= 0) {
906  // set valid color in TextField
907  myTextFieldTAZSourceWeight->setTextColor(FXRGB(0, 0, 0));
908  // enable save button
909  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
910  // update weight of all TAZSources
911  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
912  selectedEdge.source->setAttribute(SUMO_ATTR_WEIGHT, myTextFieldTAZSourceWeight->getText().text(), myTAZFrameParent->myViewNet->getUndoList());
913  }
914  // refresh TAZ Edges
915  myTAZFrameParent->getCurrentTAZModule()->refreshTAZEdges();
916  } else {
917  // set invalid color
918  myTextFieldTAZSourceWeight->setTextColor(FXRGB(255, 0, 0));
919  }
920  } else {
921  // set invalid color
922  myTextFieldTAZSourceWeight->setTextColor(FXRGB(255, 0, 0));
923  }
924  } else if (obj == myTextFieldTAZSinkWeight) {
925  // check if given value is valid
926  if (GNEAttributeCarrier::canParse<double>(myTextFieldTAZSinkWeight->getText().text())) {
927  double newTAZSinkWeight = GNEAttributeCarrier::parse<double>(myTextFieldTAZSinkWeight->getText().text());
928  // check if myDefaultTAZSinkWeight is greather than 0
929  if (newTAZSinkWeight >= 0) {
930  // set valid color in TextField
931  myTextFieldTAZSinkWeight->setTextColor(FXRGB(0, 0, 0));
932  // enable save button
933  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
934  // update weight of all TAZSources
935  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
936  selectedEdge.sink->setAttribute(SUMO_ATTR_WEIGHT, myTextFieldTAZSinkWeight->getText().text(), myTAZFrameParent->myViewNet->getUndoList());
937  }
938  // refresh TAZ Edges
939  myTAZFrameParent->getCurrentTAZModule()->refreshTAZEdges();
940  } else {
941  // set invalid color
942  myTextFieldTAZSinkWeight->setTextColor(FXRGB(255, 0, 0));
943  }
944  } else {
945  // set invalid color
946  myTextFieldTAZSinkWeight->setTextColor(FXRGB(255, 0, 0));
947  }
948  }
949  return 1;
950 }
951 
952 
953 long
955  if (myEdgeAndTAZChildrenSelected.size() == 0) {
956  // add to selection all TAZEdges
957  for (const auto& TAZEdgeColor : myTAZFrameParent->getCurrentTAZModule()->getTAZEdges()) {
958  // avoid empty undolists
959  if (!TAZEdgeColor.edge->isAttributeCarrierSelected()) {
960  // enable save button
961  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
962  // change attribute selected
963  TAZEdgeColor.edge->setAttribute(GNE_ATTR_SELECTED, "true", myTAZFrameParent->myViewNet->getUndoList());
964  }
965  }
966  } else {
967  // only add to selection selected TAZEdges
968  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
969  // avoid empty undolists
970  if (!selectedEdge.edge->isAttributeCarrierSelected()) {
971  // enable save button
972  myTAZFrameParent->myTAZSaveChanges->enableButtonsAndBeginUndoList();
973  // change attribute selected
974  selectedEdge.edge->setAttribute(GNE_ATTR_SELECTED, "true", myTAZFrameParent->myViewNet->getUndoList());
975  }
976  }
977  }
978  return 1;
979 }
980 
981 
982 void
984  if (myEdgeAndTAZChildrenSelected.size() > 0) {
985  // show TAZSources/Sinks frames
986  myTAZSourceFrame->show();
987  myTAZSinkFrame->show();
988  // declare string sets for TextFields (to avoid duplicated values)
989  std::set<std::string> weightSourceSet;
990  std::set<std::string> weightSinkSet;
991  // declare stadistic variables
992  double weight = 0;
993  double maxWeightSource = 0;
994  double minWeightSource = -1;
995  double averageWeightSource = 0;
996  double maxWeightSink = 0;
997  double minWeightSink = -1;
998  double averageWeightSink = 0;
999  // iterate over child TAZElements
1000  for (const auto& selectedEdge : myEdgeAndTAZChildrenSelected) {
1001  //start with sources
1002  weight = selectedEdge.source->getDepartWeight();
1003  // insert source weight in weightSinkTextField
1004  weightSourceSet.insert(toString(weight));
1005  // check max Weight
1006  if (maxWeightSource < weight) {
1007  maxWeightSource = weight;
1008  }
1009  // check min Weight
1010  if (minWeightSource == -1 || (maxWeightSource < weight)) {
1011  minWeightSource = weight;
1012  }
1013  // update Average
1014  averageWeightSource += weight;
1015  // continue with sinks
1016  weight = selectedEdge.sink->getDepartWeight();
1017  // save sink weight in weightSinkTextField
1018  weightSinkSet.insert(toString(weight));
1019  // check max Weight
1020  if (maxWeightSink < weight) {
1021  maxWeightSink = weight;
1022  }
1023  // check min Weight
1024  if (minWeightSink == -1 || (maxWeightSink < weight)) {
1025  minWeightSink = weight;
1026  }
1027  // update Average
1028  averageWeightSink += weight;
1029  }
1030  // calculate average
1031  averageWeightSource /= myEdgeAndTAZChildrenSelected.size();
1032  averageWeightSink /= myEdgeAndTAZChildrenSelected.size();
1033  // declare ostringstream for statistics
1034  std::ostringstream information;
1035  std::string edgeInformation;
1036  // first fill edgeInformation
1037  if (myEdgeAndTAZChildrenSelected.size() == 1) {
1038  edgeInformation = "- Edge ID: " + myEdgeAndTAZChildrenSelected.begin()->edge->getID();
1039  } else {
1040  edgeInformation = "- Number of edges: " + toString(myEdgeAndTAZChildrenSelected.size());
1041  }
1042  // fill rest of information
1043  information
1044  << edgeInformation << "\n"
1045  << "- Min source: " << toString(minWeightSource) << "\n"
1046  << "- Max source: " << toString(maxWeightSource) << "\n"
1047  << "- Average source: " << toString(averageWeightSource) << "\n"
1048  << "\n"
1049  << "- Min sink: " << toString(minWeightSink) << "\n"
1050  << "- Max sink: " << toString(maxWeightSink) << "\n"
1051  << "- Average sink: " << toString(averageWeightSink);
1052  // set new label
1053  myStatisticsLabel->setText(information.str().c_str());
1054  // set TextFields (Text and color)
1055  myTextFieldTAZSourceWeight->setText(joinToString(weightSourceSet, " ").c_str());
1056  myTextFieldTAZSourceWeight->setTextColor(FXRGB(0, 0, 0));
1057  myTextFieldTAZSinkWeight->setText(joinToString(weightSinkSet, " ").c_str());
1058  myTextFieldTAZSinkWeight->setTextColor(FXRGB(0, 0, 0));
1059  } else {
1060  // hide TAZSources/Sinks frames
1061  myTAZSourceFrame->hide();
1062  myTAZSinkFrame->hide();
1063  // hide myStatisticsLabel
1064  myStatisticsLabel->setText("No edges selected");
1065  }
1066 }
1067 
1068 // ---------------------------------------------------------------------------
1069 // GNETAZFrame::TAZParameters- methods
1070 // ---------------------------------------------------------------------------
1071 
1073  FXGroupBoxModule(TAZFrameParent->myContentFrame, "TAZ parameters"),
1074  myTAZFrameParent(TAZFrameParent),
1075  myTAZTemplate(nullptr) {
1076  // create TAZ Template
1077  myTAZTemplate = new GNETAZ(TAZFrameParent->getViewNet()->getNet());
1078  // create Button and string textField for center (by default, empty)
1079  FXHorizontalFrame* centerParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
1080  new FXLabel(centerParameter, toString(SUMO_ATTR_CENTER).c_str(), 0, GUIDesignLabelAttribute);
1081  myTextFieldCenter = new FXTextField(centerParameter, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
1082  // create Button and string textField for color and set blue as default color
1083  FXHorizontalFrame* fillParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
1084  new FXLabel(fillParameter, toString(SUMO_ATTR_FILL).c_str(), 0, GUIDesignLabelAttribute);
1085  myCheckButtonFill = new FXCheckButton(fillParameter, "false", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
1086  myCheckButtonFill->setCheck(FALSE);
1087  // create Button and string textField for color and set blue as default color
1088  FXHorizontalFrame* colorParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
1089  myColorEditor = new FXButton(colorParameter, toString(SUMO_ATTR_COLOR).c_str(), 0, this, MID_GNE_SET_ATTRIBUTE_DIALOG, GUIDesignButtonAttribute);
1090  myTextFieldColor = new FXTextField(colorParameter, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
1091  myTextFieldColor->setText("blue");
1092  // create Button and string textField for name and set blue as default name
1093  FXHorizontalFrame* nameParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
1094  new FXLabel(nameParameter, toString(SUMO_ATTR_NAME).c_str(), 0, GUIDesignLabelAttribute);
1095  myTextFieldName = new FXTextField(nameParameter, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
1096  // create Label and CheckButton for use innen edges with true as default value
1097  FXHorizontalFrame* useInnenEdges = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
1098  new FXLabel(useInnenEdges, "Edges within", 0, GUIDesignLabelAttribute);
1099  myAddEdgesWithinCheckButton = new FXCheckButton(useInnenEdges, "use", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
1100  myAddEdgesWithinCheckButton->setCheck(true);
1101  // Create help button
1102  myHelpTAZAttribute = new FXButton(getCollapsableFrame(), "Help", 0, this, MID_HELP, GUIDesignButtonRectangular);
1103 }
1104 
1105 
1107  delete myTAZTemplate;
1108 }
1109 
1110 
1111 void
1113  FXGroupBoxModule::show();
1114 }
1115 
1116 
1117 void
1119  FXGroupBoxModule::hide();
1120 }
1121 
1122 
1123 bool
1125  const bool validColor = GNEAttributeCarrier::canParse<RGBColor>(myTextFieldColor->getText().text());
1126  const bool validCenter = myTextFieldCenter->getText().empty() || GNEAttributeCarrier::canParse<Position>(myTextFieldCenter->getText().text());
1127  const bool validName = SUMOXMLDefinitions::isValidAttribute(myTextFieldName->getText().text());
1128  return (validColor && validCenter && validName);
1129 }
1130 
1131 
1132 bool
1134  return (myAddEdgesWithinCheckButton->getCheck() == TRUE);
1135 }
1136 
1137 
1138 void
1140  // check if baseTAZ exist, and if yes, delete it
1141  if (myTAZFrameParent->myBaseTAZ) {
1142  // delete baseTAZ (and all children)
1143  delete myTAZFrameParent->myBaseTAZ;
1144  }
1145  // create a base TAZ
1146  myTAZFrameParent->myBaseTAZ = new CommonXMLStructure::SumoBaseObject(nullptr);
1147  // set tag
1148  myTAZFrameParent->myBaseTAZ->setTag(SUMO_TAG_TAZ);
1149  // get attributes
1150  myTAZFrameParent->myBaseTAZ->addPositionAttribute(SUMO_ATTR_CENTER, myTextFieldCenter->getText().empty() ? Position::INVALID : GNEAttributeCarrier::parse<Position>(myTextFieldCenter->getText().text()));
1151  myTAZFrameParent->myBaseTAZ->addBoolAttribute(SUMO_ATTR_FILL, (myCheckButtonFill->getCheck() == TRUE));
1152  myTAZFrameParent->myBaseTAZ->addColorAttribute(SUMO_ATTR_COLOR, GNEAttributeCarrier::parse<RGBColor>(myTextFieldColor->getText().text()));
1153  myTAZFrameParent->myBaseTAZ->addStringAttribute(SUMO_ATTR_NAME, myTextFieldName->getText().text());
1154 }
1155 
1156 
1157 long
1159  // create FXColorDialog
1160  FXColorDialog colordialog(getCollapsableFrame(), tr("Color Dialog"));
1161  colordialog.setTarget(this);
1162  // If previous attribute wasn't correct, set black as default color
1163  if (GNEAttributeCarrier::canParse<RGBColor>(myTextFieldColor->getText().text())) {
1164  colordialog.setRGBA(MFXUtils::getFXColor(GNEAttributeCarrier::parse<RGBColor>(myTextFieldColor->getText().text())));
1165  } else {
1166  colordialog.setRGBA(MFXUtils::getFXColor(RGBColor::BLUE));
1167  }
1168  // execute dialog to get a new color
1169  if (colordialog.execute()) {
1170  myTextFieldColor->setText(toString(MFXUtils::getRGBColor(colordialog.getRGBA())).c_str());
1171  onCmdSetAttribute(0, 0, 0);
1172  }
1173  return 0;
1174 }
1175 
1176 
1177 long
1178 GNETAZFrame::TAZParameters::onCmdSetAttribute(FXObject* obj, FXSelector, void*) {
1179  if (obj == myTextFieldColor) {
1180  // check color
1181  if (GNEAttributeCarrier::canParse<RGBColor>(myTextFieldColor->getText().text())) {
1182  myTextFieldColor->setTextColor(FXRGB(0, 0, 0));
1183  myTextFieldColor->killFocus();
1184  } else {
1185  myTextFieldColor->setTextColor(FXRGB(255, 0, 0));
1186  }
1187  } else if (obj == myTextFieldCenter) {
1188  // check center
1189  if (myTextFieldCenter->getText().empty() || GNEAttributeCarrier::canParse<RGBColor>(myTextFieldCenter->getText().text())) {
1190  myTextFieldCenter->setTextColor(FXRGB(0, 0, 0));
1191  myTextFieldCenter->killFocus();
1192  } else {
1193  myTextFieldCenter->setTextColor(FXRGB(255, 0, 0));
1194  }
1195  } else if (obj == myTextFieldName) {
1196  // check name
1197  if (SUMOXMLDefinitions::isValidAttribute(myTextFieldName->getText().text())) {
1198  myTextFieldName->setTextColor(FXRGB(0, 0, 0));
1199  myTextFieldName->killFocus();
1200  } else {
1201  myTextFieldName->setTextColor(FXRGB(255, 0, 0));
1202  }
1203  } else if (obj == myAddEdgesWithinCheckButton) {
1204  // change useInnenEdgesCheckButton text
1205  if (myAddEdgesWithinCheckButton->getCheck() == TRUE) {
1206  myAddEdgesWithinCheckButton->setText("use");
1207  } else {
1208  myAddEdgesWithinCheckButton->setText("not use");
1209  }
1210  } else if (obj == myCheckButtonFill) {
1211  // change myCheckButtonFill text
1212  if (myCheckButtonFill->getCheck() == TRUE) {
1213  myCheckButtonFill->setText("true");
1214  } else {
1215  myCheckButtonFill->setText("false");
1216  }
1217  }
1218  return 0;
1219 }
1220 
1221 
1222 long
1223 GNETAZFrame::TAZParameters::onCmdHelp(FXObject*, FXSelector, void*) {
1224  myTAZFrameParent->openHelpAttributesDialog(myTAZTemplate);
1225  return 1;
1226 }
1227 
1228 // ---------------------------------------------------------------------------
1229 // GNETAZFrame::TAZEdgesGraphic - methods
1230 // ---------------------------------------------------------------------------
1231 
1233  FXGroupBoxModule(TAZFrameParent->myContentFrame, "Edges"),
1234  myTAZFrameParent(TAZFrameParent),
1235  myEdgeDefaultColor(RGBColor::GREY),
1236  myEdgeSelectedColor(RGBColor::MAGENTA) {
1237  // create label for non taz edge color information
1238  FXLabel* NonTAZEdgeLabel = new FXLabel(getCollapsableFrame(), "Non TAZ Edge", nullptr, GUIDesignLabelCenter);
1239  NonTAZEdgeLabel->setBackColor(MFXUtils::getFXColor(myEdgeDefaultColor));
1240  NonTAZEdgeLabel->setTextColor(MFXUtils::getFXColor(RGBColor::WHITE));
1241  // create label for selected TAZEdgeColor color information
1242  FXLabel* selectedTAZEdgeLabel = new FXLabel(getCollapsableFrame(), "Selected TAZ Edge", nullptr, GUIDesignLabelCenter);
1243  selectedTAZEdgeLabel->setBackColor(MFXUtils::getFXColor(myEdgeSelectedColor));
1244  // build rainbow
1246  // create Radio button for show edges by source weight
1247  myColorBySourceWeight = new FXRadioButton(getCollapsableFrame(), "Color by Source", this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1248  // create Radio button for show edges by sink weight
1249  myColorBySinkWeight = new FXRadioButton(getCollapsableFrame(), "Color by Sink", this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1250  // create Radio button for show edges by source + sink weight
1251  myColorBySourcePlusSinkWeight = new FXRadioButton(getCollapsableFrame(), "Color by Source + Sink", this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1252  // create Radio button for show edges by source - sink weight
1253  myColorBySourceMinusSinkWeight = new FXRadioButton(getCollapsableFrame(), "Color by Source - Sink", this, MID_CHOOSEN_OPERATION, GUIDesignRadioButton);
1254  // show by source as default
1255  myColorBySourceWeight->setCheck(true);
1256 }
1257 
1258 
1260 
1261 
1262 void
1264  // update edge colors
1265  updateEdgeColors();
1266  show();
1267 }
1268 
1269 
1270 void
1272  // iterate over all edges and restore color
1273  for (const auto& edge : myTAZFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
1274  for (const auto& lane : edge.second->getLanes()) {
1275  lane->setSpecialColor(nullptr);
1276  }
1277  }
1278  hide();
1279 }
1280 
1281 
1282 void
1284  const std::vector<RGBColor>& scaledColors = GNEViewNetHelper::getRainbowScaledColors();
1285  // start painting all edges in gray
1286  for (const auto& edge : myTAZFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
1287  if (!edge.second->isAttributeCarrierSelected()) {
1288  // set candidate color (in this case, gray)
1289  for (const auto lane : edge.second->getLanes()) {
1290  lane->setSpecialColor(&myEdgeDefaultColor);
1291  }
1292  }
1293  }
1294  // now paint Source/sinks colors
1295  for (const auto& TAZEdgeColor : myTAZFrameParent->myCurrentTAZ->getTAZEdges()) {
1296  if (!TAZEdgeColor.edge->isAttributeCarrierSelected()) {
1297  // set candidate color (in this case,
1298  for (const auto& lane : TAZEdgeColor.edge->getLanes()) {
1299  // check what will be painted (source, sink or both)
1300  if (myColorBySourceWeight->getCheck() == TRUE) {
1301  lane->setSpecialColor(&scaledColors.at(TAZEdgeColor.sourceColor), TAZEdgeColor.source->getDepartWeight());
1302  } else if (myColorBySinkWeight->getCheck() == TRUE) {
1303  lane->setSpecialColor(&scaledColors.at(TAZEdgeColor.sinkColor), TAZEdgeColor.sink->getDepartWeight());
1304  } else if (myColorBySourcePlusSinkWeight->getCheck() == TRUE) {
1305  lane->setSpecialColor(&scaledColors.at(TAZEdgeColor.sourcePlusSinkColor), TAZEdgeColor.source->getDepartWeight() + TAZEdgeColor.sink->getDepartWeight());
1306  } else {
1307  lane->setSpecialColor(&scaledColors.at(TAZEdgeColor.sourceMinusSinkColor), TAZEdgeColor.source->getDepartWeight() - TAZEdgeColor.sink->getDepartWeight());
1308  }
1309  }
1310  }
1311  }
1312  // as last step paint candidate colors
1313  for (const auto& selectedEdge : myTAZFrameParent->myTAZSelectionStatistics->getEdgeAndTAZChildrenSelected()) {
1314  if (!selectedEdge.edge->isAttributeCarrierSelected()) {
1315  // set candidate selected color
1316  for (const auto& lane : selectedEdge.edge->getLanes()) {
1317  lane->setSpecialColor(&myEdgeSelectedColor);
1318  }
1319  }
1320  }
1321  // always update view after setting new colors
1322  myTAZFrameParent->myViewNet->updateViewNet();
1323 }
1324 
1325 
1326 long
1327 GNETAZFrame::TAZEdgesGraphic::onCmdChoosenBy(FXObject* obj, FXSelector, void*) {
1328  // check what radio was pressed and disable the others
1329  if (obj == myColorBySourceWeight) {
1330  myColorBySinkWeight->setCheck(FALSE);
1331  myColorBySourcePlusSinkWeight->setCheck(FALSE);
1332  myColorBySourceMinusSinkWeight->setCheck(FALSE);
1333  } else if (obj == myColorBySinkWeight) {
1334  myColorBySourceWeight->setCheck(FALSE);
1335  myColorBySourcePlusSinkWeight->setCheck(FALSE);
1336  myColorBySourceMinusSinkWeight->setCheck(FALSE);
1337  } else if (obj == myColorBySourcePlusSinkWeight) {
1338  myColorBySourceWeight->setCheck(FALSE);
1339  myColorBySinkWeight->setCheck(FALSE);
1340  myColorBySourceMinusSinkWeight->setCheck(FALSE);
1341  } else if (obj == myColorBySourceMinusSinkWeight) {
1342  myColorBySourceWeight->setCheck(FALSE);
1343  myColorBySinkWeight->setCheck(FALSE);
1344  myColorBySourcePlusSinkWeight->setCheck(FALSE);
1345  }
1346  // update edge colors
1347  updateEdgeColors();
1348  return 1;
1349 }
1350 
1351 // ---------------------------------------------------------------------------
1352 // GNETAZFrame - methods
1353 // ---------------------------------------------------------------------------
1354 
1355 GNETAZFrame::GNETAZFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet) :
1356  GNEFrame(horizontalFrameParent, viewNet, "TAZs"),
1357  myBaseTAZ(nullptr) {
1358 
1359  // create current TAZ modul
1360  myCurrentTAZ = new CurrentTAZ(this);
1361 
1362  // Create TAZ Parameters modul
1363  myTAZParameters = new TAZParameters(this);
1364 
1367 
1368  // Create drawing controls modul
1370 
1371  // Create TAZ Edges Common Statistics modul
1373 
1374  // Create save TAZ Edges modul
1375  myTAZSaveChanges = new TAZSaveChanges(this);
1376 
1377  // Create TAZ Edges Common Parameters modul
1379 
1380  // Create TAZ Edges Selection Statistics modul
1382 
1383  // Create TAZ Edges Common Parameters modul
1384  myTAZEdgesGraphic = new TAZEdgesGraphic(this);
1385 
1386  // by default there isn't a TAZ
1387  myCurrentTAZ->setTAZ(nullptr);
1388 }
1389 
1390 
1392  // check if we have to delete base TAZ object
1393  if (myBaseTAZ) {
1394  delete myBaseTAZ;
1395  }
1396 }
1397 
1398 
1399 void
1401  // hide frame
1402  GNEFrame::hide();
1403 }
1404 
1405 
1406 bool
1407 GNETAZFrame::processClick(const Position& clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor& objectsUnderCursor) {
1408  // Declare map to keep values
1409  std::map<SumoXMLAttr, std::string> valuesOfElement;
1410  if (myDrawingShape->isDrawing()) {
1411  // add or delete a new point depending of flag "delete last created point"
1414  } else {
1415  myDrawingShape->addNewPoint(clickedPosition);
1416  }
1417  return true;
1418  } else if ((myCurrentTAZ->getTAZ() == nullptr) || (objectsUnderCursor.getTAZElementFront() && myCurrentTAZ->getTAZ() && !myTAZSaveChanges->isChangesPending())) {
1419  // if user click over an TAZ and there isn't changes pending, then select a new TAZ
1420  if (objectsUnderCursor.getTAZElementFront()) {
1421  // avoid reset of Frame if user doesn't click over an TAZ
1422  myCurrentTAZ->setTAZ(dynamic_cast<GNETAZ*>(objectsUnderCursor.getTAZElementFront()));
1423  // update TAZStadistics
1426  return true;
1427  } else {
1428  return false;
1429  }
1430  } else if (objectsUnderCursor.getEdgeFront()) {
1431  // if toggle Edge is enabled, select edge. In other case create two new source/Sinks
1433  // create new source/Sinks or delete it
1434  return addOrRemoveTAZMember(objectsUnderCursor.getEdgeFront());
1435  } else {
1436  // first check if clicked edge was previously selected
1437  if (myTAZSelectionStatistics->isEdgeSelected(objectsUnderCursor.getEdgeFront())) {
1438  // clear selected edges
1440  } else {
1441  // iterate over TAZEdges saved in CurrentTAZ (it contains the Edge and Source/sinks)
1442  for (const auto& TAZEdgeColor : myCurrentTAZ->getTAZEdges()) {
1443  if (TAZEdgeColor.edge == objectsUnderCursor.getEdgeFront()) {
1444  // clear current selection (to avoid having two or more edges selected at the same time using mouse clicks)
1446  // now select edge
1447  myTAZSelectionStatistics->selectEdge(TAZEdgeColor);
1448  // edge selected, then return true
1449  return true;
1450  }
1451  }
1452  }
1453  // edge wasn't selected, then return false
1454  return false;
1455  }
1456  } else {
1457  // nothing to do
1458  return false;
1459  }
1460 }
1461 
1462 
1463 void
1464 GNETAZFrame::processEdgeSelection(const std::vector<GNEEdge*>& edges) {
1465  // first check that a TAZ is selected
1466  if (myCurrentTAZ->getTAZ()) {
1467  // if "toggle Membership" is enabled, create new TAZSources/sinks. In other case simply select edges
1469  // iterate over edges
1470  for (const auto& edge : edges) {
1471  // first check if edge owns a TAZEge
1472  if (myCurrentTAZ->isTAZEdge(edge) == false) {
1473  // create new TAZ Sources/Sinks
1474  addOrRemoveTAZMember(edge);
1475  }
1476  }
1477  } else {
1478  // iterate over edges
1479  for (const auto& edge : edges) {
1480  // first check that selected edge isn't already selected
1482  // iterate over TAZEdges saved in CurrentTAZ (it contains the Edge and Source/sinks)
1483  for (const auto& TAZEdgeColor : myCurrentTAZ->getTAZEdges()) {
1484  if (TAZEdgeColor.edge == edge) {
1485  myTAZSelectionStatistics->selectEdge(TAZEdgeColor);
1486  }
1487  }
1488  }
1489  }
1490  }
1491  }
1492 }
1493 
1494 
1497  return myDrawingShape;
1498 }
1499 
1500 
1503  return myCurrentTAZ;
1504 }
1505 
1506 
1509  return myTAZSelectionStatistics;
1510 }
1511 
1512 
1515  return myTAZSaveChanges;
1516 }
1517 
1518 
1519 bool
1521  // show warning dialogbox and stop check if input parameters are valid
1523  return false;
1524  } else if (myDrawingShape->getTemporalShape().size() < 3) {
1525  WRITE_WARNING("TAZ shape needs at least three points");
1526  return false;
1527  } else {
1528  // get attributes and values
1530  // obtain Netedit attributes
1532  // generate new ID
1534  // obtain shape and close it
1536  shape.closePolygon();
1538  // set center if is invalid
1541  }
1542  // check if TAZ has to be created with edges
1544  std::vector<std::string> edgeIDs;
1545  const auto ACsInBoundary = myViewNet->getAttributeCarriersInBoundary(shape.getBoxBoundary(), true);
1546  // get only edges with geometry around shape
1547  for (const auto& AC : ACsInBoundary) {
1548  if ((AC.second->getTagProperty().getTag() == SUMO_TAG_EDGE) &&
1550  edgeIDs.push_back(AC.first);
1551  }
1552  }
1554  } else {
1555  // TAZ is created without edges
1556  myBaseTAZ->addStringListAttribute(SUMO_ATTR_EDGES, std::vector<std::string>());
1557  }
1558  // declare additional handler
1559  GNEAdditionalHandler additionalHandler(myViewNet->getNet(), true);
1560  // build TAZ
1561  additionalHandler.parseSumoBaseObject(myBaseTAZ);
1562  // TAZ created, then return true
1563  return true;
1564  }
1565 }
1566 
1567 
1568 bool
1570  // first check if edge exist;
1571  if (edge) {
1572  // first check if already exist (in this case, remove it)
1573  for (const auto& TAZEdgeColor : myCurrentTAZ->getTAZEdges()) {
1574  if (TAZEdgeColor.edge == edge) {
1575  // enable save changes button
1577  // remove Source and Sinks using GNEChange_TAZElement
1578  if (myViewNet->getNet()->getAttributeCarriers()->TAZElementExist(TAZEdgeColor.source)) {
1579  myViewNet->getUndoList()->add(new GNEChange_TAZElement(TAZEdgeColor.source, false), true);
1580  }
1581  if (myViewNet->getNet()->getAttributeCarriers()->TAZElementExist(TAZEdgeColor.sink)) {
1582  myViewNet->getUndoList()->add(new GNEChange_TAZElement(TAZEdgeColor.sink, false), true);
1583  }
1584  // always refresh TAZ Edges after removing TAZSources/Sinks
1586  // update select edges button
1588  return true;
1589  }
1590  }
1591  // if wasn't found, then add it
1593  // create TAZ Sink using GNEChange_TAZElement and value of TAZChild default parameters
1595  myViewNet->getUndoList()->add(new GNEChange_TAZElement(source, true), true);
1596  // create TAZ Sink using GNEChange_TAZElement and value of TAZChild default parameters
1598  myViewNet->getUndoList()->add(new GNEChange_TAZElement(sink, true), true);
1599  // always refresh TAZ Edges after adding TAZSources/Sinks
1601  // update selected button
1603  return true;
1604  } else {
1605  throw ProcessError("Edge cannot be null");
1606  }
1607 }
1608 
1609 
1610 void
1612  // iterate over all TAZEdges
1613  for (const auto& TAZEdgeColor : myCurrentTAZ->getTAZEdges()) {
1614  // enable save changes button
1616  // remove Source and Sinks using GNEChange_TAZElement
1617  if (myViewNet->getNet()->getAttributeCarriers()->TAZElementExist(TAZEdgeColor.source)) {
1618  myViewNet->getUndoList()->add(new GNEChange_TAZElement(TAZEdgeColor.source, false), true);
1619  }
1620  if (myViewNet->getNet()->getAttributeCarriers()->TAZElementExist(TAZEdgeColor.sink)) {
1621  myViewNet->getUndoList()->add(new GNEChange_TAZElement(TAZEdgeColor.sink, false), true);
1622  }
1623  }
1624  // always refresh TAZ Edges after removing TAZSources/Sinks
1626 }
1627 
1628 
1629 /****************************************************************************/
FXDEFMAP(GNETAZFrame::TAZParameters) TAZParametersMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
Definition: GUIAppEnum.h:797
@ MID_CANCEL
Cancel-button pressed.
Definition: GUIAppEnum.h:255
@ MID_GNE_SET_ATTRIBUTE_DIALOG
attribute edited trought dialog
Definition: GUIAppEnum.h:831
@ MID_CHOOSEN_OPERATION
set type of selection
Definition: GUIAppEnum.h:551
@ MID_HELP
help button
Definition: GUIAppEnum.h:600
@ MID_OK
Ok-button pressed.
Definition: GUIAppEnum.h:253
@ MID_GNE_SELECT
select element
Definition: GUIAppEnum.h:813
#define GUIDesignLabelLeft
Definition: GUIDesigns.h:193
#define GUIDesignLabelCenter
label extended over frame without thick and with text justify to center
Definition: GUIDesigns.h:199
#define GUIDesignButtonAttribute
button extended over over column with thick and raise frame
Definition: GUIDesigns.h:71
#define GUIDesignButton
Definition: GUIDesigns.h:68
#define GUIDesignTextField
Definition: GUIDesigns.h:42
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:343
#define GUIDesignLabelAttribute
label extended over the matrix column with thick frame
Definition: GUIDesigns.h:217
#define GUIDesignButtonRectangular
little button rectangula used in frames (For example, in "help" buttons)
Definition: GUIDesigns.h:74
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition: GUIDesigns.h:60
#define GUIDesignCheckButton
checkButton placed in left position
Definition: GUIDesigns.h:145
#define GUIDesignRadioButton
Definition: GUIDesigns.h:179
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:244
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
@ 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
@ 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:269
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)
FXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toogled)
Builds additional objects for GNENet (busStops, chargingStations, detectors, etc.....
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * getNet() const
get pointer to net
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
bool getNeteditAttributesAndValues(CommonXMLStructure::SumoBaseObject *baseObject, const GNELane *lane) const
fill valuesMap with netedit attributes
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:133
GNEViewNet * myViewNet
View Net.
Definition: GNEFrame.h:114
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
Definition: GNEFrame.h:117
virtual void show()
show Frame
Definition: GNEFrame.cpp:108
virtual void hide()
hide Frame
Definition: GNEFrame.cpp:117
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
bool isNetworkElementAroundShape(GNEAttributeCarrier *AC, const PositionVector &shape) const
check if shape of given AC (network element) is around the given shape
std::string generateTAZElementID(SumoXMLTag TAZElementTag) const
generate TAZElement ID
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
std::vector< GNEEdge * > getSelectedEdges() const
return all edges
bool TAZElementExist(const GNETAZElement *TAZElement) const
return true if given TAZElement exist
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:125
struct for edges and the source/sink colors
Definition: GNETAZFrame.h:51
GNETAZSourceSink * sink
@brif sink TAZ
Definition: GNETAZFrame.h:70
GNETAZSourceSink * source
source TAZ
Definition: GNETAZFrame.h:67
~TAZEdgeColor()
destructor (needed because RGBColors has to be deleted)
Definition: GNETAZFrame.cpp:92
void refreshTAZEdges()
refresh TAZEdges
double myMinSourceMinusSinkWeight
minimum source minus sink value of current TAZ Edges
Definition: GNETAZFrame.h:146
bool isTAZEdge(GNEEdge *edge) const
check if given edge belongs to current TAZ
GNETAZFrame * myTAZFrameParent
pointer to TAZ Frame
Definition: GNETAZFrame.h:122
GNETAZ * myEditedTAZ
current edited TAZ
Definition: GNETAZFrame.h:125
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:143
FXLabel * myCurrentTAZLabel
Label for current TAZ.
Definition: GNETAZFrame.h:134
CurrentTAZ(GNETAZFrame *TAZFrameParent)
constructor
double myMaxSourcePlusSinkWeight
maximum source plus sink value of current TAZ Edges
Definition: GNETAZFrame.h:137
double myMinSourcePlusSinkWeight
minimum source plus sink value of current TAZ Edges
Definition: GNETAZFrame.h:140
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:294
TAZChildDefaultParameters(GNETAZFrame *TAZFrameParent)
FOX-declaration.
void showTAZChildDefaultParametersModule()
show TAZ child default parameters Module
FXCheckButton * myToggleMembership
CheckButton to enable or disable Toggle edge Membership.
Definition: GNETAZFrame.h:279
FXTextField * myTextFieldDefaultValueTAZSources
textField to set a default value for TAZ Sources
Definition: GNETAZFrame.h:285
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 source weight
void hideTAZChildDefaultParametersModule()
hide TAZ child default parameters Module
FXLabel * myInformationLabel
information label
Definition: GNETAZFrame.h:297
FXHorizontalFrame * myDefaultTAZSinkFrame
Horizontal Frame for default TAZ Sink Weight.
Definition: GNETAZFrame.h:288
FXHorizontalFrame * myDefaultTAZSourceFrame
Horizontal Frame for default TAZ Source Weight.
Definition: GNETAZFrame.h:282
FXTextField * myTextFieldDefaultValueTAZSinks
textField to set a default value for TAZ Sinks
Definition: GNETAZFrame.h:291
long onCmdSetDefaultValues(FXObject *obj, FXSelector, void *)
double getDefaultTAZSinkWeight() const
default sink weight
void showTAZCommonStatisticsModule()
show TAZ Common Statistics Module
TAZCommonStatistics(GNETAZFrame *TAZFrameParent)
constructor
FXLabel * myStatisticsLabel
Statistics labels.
Definition: GNETAZFrame.h:176
void hideTAZCommonStatisticsModule()
hide TAZ Common Statistics Module
void updateStatistics()
update Statistics label
FXRadioButton * myColorBySourcePlusSinkWeight
add radio button "color source + sink"
Definition: GNETAZFrame.h:498
RGBColor myEdgeSelectedColor
RGBColor color for selected egdes.
Definition: GNETAZFrame.h:507
FXRadioButton * myColorBySinkWeight
add radio button "color by sink"
Definition: GNETAZFrame.h:495
void showTAZEdgesGraphicModule()
show TAZ Edges Graphic Module
void updateEdgeColors()
update edge colors;
FXRadioButton * myColorBySourceWeight
add radio button "color by source"
Definition: GNETAZFrame.h:492
FXRadioButton * myColorBySourceMinusSinkWeight
add radio button "color source - Sink"
Definition: GNETAZFrame.h:501
RGBColor myEdgeDefaultColor
default RGBColor for all edges
Definition: GNETAZFrame.h:504
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:445
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:451
FXCheckButton * myAddEdgesWithinCheckButton
CheckButton to enable or disable use edges within TAZ after creation.
Definition: GNETAZFrame.h:448
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:433
FXTextField * myTextFieldCenter
text field center
Definition: GNETAZFrame.h:436
FXTextField * myTextFieldColor
textField to modify the default value of color parameter
Definition: GNETAZFrame.h:442
FXCheckButton * myCheckButtonFill
CheckButton to enable or disable fill.
Definition: GNETAZFrame.h:439
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:223
void showTAZSaveChangesModule()
show TAZ Save Changes Module
FXButton * myCancelChangesButton
@field FXButton for cancel changes in TAZEdges
Definition: GNETAZFrame.h:226
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:362
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:368
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:365
void updateStatistics()
update TAZSelectionStatistics
FXTextField * myTextFieldTAZSinkWeight
textField for TAZ Sink weight
Definition: GNETAZFrame.h:371
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:374
TAZSelectionStatistics * myTAZSelectionStatistics
TAZ Edges selection parameters.
Definition: GNETAZFrame.h:583
TAZSelectionStatistics * getTAZSelectionStatisticsModule() const
get TAZ Selection Statistics modul
GNEFrameAttributeModules::NeteditAttributes * myNeteditAttributes
Netedit parameter.
Definition: GNETAZFrame.h:571
TAZSaveChanges * getTAZSaveChangesModule() const
get TAZ Save Changes modul
CurrentTAZ * myCurrentTAZ
current TAZ
Definition: GNETAZFrame.h:562
TAZEdgesGraphic * myTAZEdgesGraphic
TAZ Edges Graphic.
Definition: GNETAZFrame.h:586
TAZParameters * myTAZParameters
TAZ parameters.
Definition: GNETAZFrame.h:568
bool addOrRemoveTAZMember(GNEEdge *edge)
add or remove a source and a sink, or remove it if edge is in the list of TAZ Children
GNEFrameModules::DrawingShape * getDrawingShapeModule() const
get drawing mode modul
void dropTAZMembers()
drop all TAZSources and TAZ Sinks of current TAZ
bool processClick(const Position &clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
process click over Viewnet
CurrentTAZ * getCurrentTAZModule() const
get Current TAZ modul
TAZCommonStatistics * myTAZCommonStatistics
TAZ Edges common parameters.
Definition: GNETAZFrame.h:565
GNEFrameModules::DrawingShape * myDrawingShape
Drawing shape.
Definition: GNETAZFrame.h:574
bool shapeDrawed()
build a shaped element using the drawed shape return true if was sucesfully created
~GNETAZFrame()
Destructor.
TAZSaveChanges * myTAZSaveChanges
save TAZ Edges
Definition: GNETAZFrame.h:577
CommonXMLStructure::SumoBaseObject * myBaseTAZ
SumoBaseObject used for creating TAZ.
Definition: GNETAZFrame.h:546
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
TAZChildDefaultParameters * myTAZChildDefaultParameters
TAZ child defaults parameters.
Definition: GNETAZFrame.h:580
Definition: GNETAZ.h:34
void updateTAZStadistic()
update TAZ Stadistic
Definition: GNETAZ.cpp:568
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
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:385
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:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:293
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