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