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