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