Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/network/GNECrossingFrame.cpp
169685 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file GNECrossingFrame.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Oct 2016
17
///
18
// The Widget for add Crossing elements
19
/****************************************************************************/
20
21
#include <netedit/GNENet.h>
22
#include <netedit/GNETagPropertiesDatabase.h>
23
#include <netedit/GNEUndoList.h>
24
#include <netedit/GNEViewParent.h>
25
#include <netedit/changes/GNEChange_Crossing.h>
26
#include <netedit/elements/network/GNECrossing.h>
27
#include <netedit/frames/network/GNECreateEdgeFrame.h>
28
#include <utils/foxtools/MFXDynamicLabel.h>
29
#include <utils/gui/div/GUIDesigns.h>
30
#include <utils/gui/windows/GUIAppEnum.h>
31
32
#include "GNECrossingFrame.h"
33
34
// ===========================================================================
35
// FOX callback mapping
36
// ===========================================================================
37
38
FXDEFMAP(GNECrossingFrame::EdgesSelector) EdgesSelectorMap[] = {
39
FXMAPFUNC(SEL_COMMAND, MID_GNE_USESELECTED, GNECrossingFrame::EdgesSelector::onCmdUseSelectedEdges),
40
FXMAPFUNC(SEL_COMMAND, MID_GNE_CLEARSELECTION, GNECrossingFrame::EdgesSelector::onCmdClearSelection)
41
};
42
43
FXDEFMAP(GNECrossingFrame::CrossingParameters) CrossingParametersMap[] = {
44
FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNECrossingFrame::CrossingParameters::onCmdSetAttribute),
45
FXMAPFUNC(SEL_COMMAND, MID_HELP, GNECrossingFrame::CrossingParameters::onCmdHelp),
46
};
47
48
FXDEFMAP(GNECrossingFrame::CreateCrossing) CreateCrossingMap[] = {
49
FXMAPFUNC(SEL_COMMAND, MID_GNE_CREATE, GNECrossingFrame::CreateCrossing::onCmdCreateCrossing),
50
};
51
52
// Object implementation
53
FXIMPLEMENT(GNECrossingFrame::EdgesSelector, MFXGroupBoxModule, EdgesSelectorMap, ARRAYNUMBER(EdgesSelectorMap))
54
FXIMPLEMENT(GNECrossingFrame::CrossingParameters, MFXGroupBoxModule, CrossingParametersMap, ARRAYNUMBER(CrossingParametersMap))
55
FXIMPLEMENT(GNECrossingFrame::CreateCrossing, MFXGroupBoxModule, CreateCrossingMap, ARRAYNUMBER(CreateCrossingMap))
56
57
58
// ===========================================================================
59
// method definitions
60
// ===========================================================================
61
62
// ---------------------------------------------------------------------------
63
// GNECrossingFrame::CurrentJunction - methods
64
// ---------------------------------------------------------------------------
65
66
GNECrossingFrame::JunctionInformation::JunctionInformation(GNECrossingFrame* crossingFrameParent) :
67
MFXGroupBoxModule(crossingFrameParent, TL("Junction")) {
68
// Create frame for junction ID
69
FXHorizontalFrame* junctionIDFrame = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
70
// create label
71
new FXLabel(junctionIDFrame, TL("Edited"), nullptr, GUIDesignLabelThickedFixed(100));
72
// create text field and disable it
73
myTextFieldJunctionID = new FXTextField(junctionIDFrame, GUIDesignTextFieldNCol, this, MID_GNE_SELECT, GUIDesignTextField);
74
myTextFieldJunctionID->disable();
75
}
76
77
78
GNECrossingFrame::JunctionInformation::~JunctionInformation() {}
79
80
81
void
82
GNECrossingFrame::JunctionInformation::updateCurrentJunctionLabel(const std::string& junctionID) {
83
if (junctionID.empty()) {
84
myTextFieldJunctionID->setText("");
85
} else {
86
myTextFieldJunctionID->setText(junctionID.c_str());
87
}
88
}
89
90
// ---------------------------------------------------------------------------
91
// GNECrossingFrame::EdgesSelector - methods
92
// ---------------------------------------------------------------------------
93
94
GNECrossingFrame::EdgesSelector::EdgesSelector(GNECrossingFrame* crossingFrameParent) :
95
MFXGroupBoxModule(crossingFrameParent, TL("selection of edges")),
96
myCrossingFrameParent(crossingFrameParent),
97
myCurrentJunction(nullptr) {
98
99
// Create button for selected edges
100
myUseSelectedEdges = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Use selected edges"), "", "", nullptr, this, MID_GNE_USESELECTED, GUIDesignButton);
101
102
// Create button for clear selection
103
myClearEdgesSelection = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Clear edges"), "", "", nullptr, this, MID_GNE_CLEARSELECTION, GUIDesignButton);
104
}
105
106
107
GNECrossingFrame::EdgesSelector::~EdgesSelector() {}
108
109
110
GNEJunction*
111
GNECrossingFrame::EdgesSelector::getCurrentJunction() const {
112
return myCurrentJunction;
113
}
114
115
116
void
117
GNECrossingFrame::EdgesSelector::enableEdgeSelector(GNEJunction* currentJunction) {
118
// restore color of all lanes of edge candidates
119
restoreEdgeColors();
120
// Set current junction
121
myCurrentJunction = currentJunction;
122
// Update view net to show the new colors
123
myCrossingFrameParent->getViewNet()->updateViewNet();
124
// check if use selected eges must be enabled
125
myUseSelectedEdges->disable();
126
for (const auto& edge : myCurrentJunction->getChildEdges()) {
127
if (edge->isAttributeCarrierSelected()) {
128
myUseSelectedEdges->enable();
129
}
130
}
131
// Enable rest of elements
132
myClearEdgesSelection->enable();
133
}
134
135
136
void
137
GNECrossingFrame::EdgesSelector::disableEdgeSelector() {
138
// disable current junction
139
myCurrentJunction = nullptr;
140
// disable all elements of the EdgesSelector
141
myUseSelectedEdges->disable();
142
myClearEdgesSelection->disable();
143
// Disable crossing parameters
144
myCrossingFrameParent->myCrossingParameters->disableCrossingParameters();
145
// Update view net to show the new colors
146
myCrossingFrameParent->getViewNet()->updateViewNet();
147
}
148
149
150
void
151
GNECrossingFrame::EdgesSelector::restoreEdgeColors() {
152
if (myCurrentJunction != nullptr) {
153
// restore color of all lanes of edge candidates
154
for (const auto& edge : myCurrentJunction->getChildEdges()) {
155
edge->resetCandidateFlags();
156
}
157
// Update view net to show the new colors
158
myCrossingFrameParent->getViewNet()->updateViewNet();
159
myCurrentJunction = nullptr;
160
}
161
}
162
163
164
long
165
GNECrossingFrame::EdgesSelector::onCmdUseSelectedEdges(FXObject*, FXSelector, void*) {
166
myCrossingFrameParent->myCrossingParameters->useSelectedEdges(myCurrentJunction);
167
return 1;
168
}
169
170
171
long
172
GNECrossingFrame::EdgesSelector::onCmdClearSelection(FXObject*, FXSelector, void*) {
173
myCrossingFrameParent->myCrossingParameters->clearEdges();
174
return 1;
175
}
176
177
// ---------------------------------------------------------------------------
178
// GNECrossingFrame::GNENeteditAttributes- methods
179
// ---------------------------------------------------------------------------
180
181
GNECrossingFrame::CrossingParameters::CrossingParameters(GNECrossingFrame* crossingFrameParent) :
182
MFXGroupBoxModule(crossingFrameParent, TL("Crossing parameters")),
183
myCrossingFrameParent(crossingFrameParent),
184
myCurrentParametersValid(true) {
185
FXHorizontalFrame* crossingParameter = nullptr;
186
// create label and string textField for edges
187
crossingParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
188
myCrossingEdgesLabel = new FXLabel(crossingParameter, toString(SUMO_ATTR_EDGES).c_str(), nullptr, GUIDesignLabelThickedFixed(100));
189
myCrossingEdges = new FXTextField(crossingParameter, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
190
myCrossingEdgesLabel->disable();
191
myCrossingEdges->disable();
192
// create label and checkbox for Priority
193
crossingParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
194
myCrossingPriorityLabel = new FXLabel(crossingParameter, toString(SUMO_ATTR_PRIORITY).c_str(), nullptr, GUIDesignLabelThickedFixed(100));
195
myCrossingPriorityCheckButton = new FXCheckButton(crossingParameter, "", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
196
myCrossingPriorityLabel->disable();
197
myCrossingPriorityCheckButton->disable();
198
// create label and textfield for width
199
crossingParameter = new FXHorizontalFrame(getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame);
200
myCrossingWidthLabel = new FXLabel(crossingParameter, toString(SUMO_ATTR_WIDTH).c_str(), nullptr, GUIDesignLabelThickedFixed(100));
201
myCrossingWidth = new FXTextField(crossingParameter, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
202
myCrossingWidthLabel->disable();
203
myCrossingWidth->disable();
204
// Create help button
205
myHelpCrossingAttribute = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Help"), "", "", nullptr, this, MID_HELP, GUIDesignButtonRectangular);
206
myHelpCrossingAttribute->disable();
207
}
208
209
210
GNECrossingFrame::CrossingParameters::~CrossingParameters() {
211
}
212
213
214
void
215
GNECrossingFrame::CrossingParameters::enableCrossingParameters(bool hasTLS) {
216
// obtain Tag Values
217
const auto crossingTagProperties = myCrossingFrameParent->getViewNet()->getNet()->getACTemplates()->getTemplateAC(SUMO_TAG_CROSSING)->getTagProperty();
218
// Enable all elements of the crossing frames
219
myCrossingEdgesLabel->enable();
220
myCrossingEdges->enable();
221
myCrossingPriorityLabel->enable();
222
// only enable priority check button if junction's crossing doesn't have TLS
223
if (hasTLS) {
224
myCrossingPriorityCheckButton->disable();
225
} else {
226
myCrossingPriorityCheckButton->enable();
227
}
228
myCrossingWidthLabel->enable();
229
myCrossingWidth->enable();
230
myHelpCrossingAttribute->enable();
231
// set values of parameters
232
onCmdSetAttribute(nullptr, 0, nullptr);
233
// Crossings placed in junctinos with TLS always has priority
234
if (hasTLS) {
235
myCrossingPriorityCheckButton->setCheck(TRUE);
236
} else {
237
myCrossingPriorityCheckButton->setCheck(crossingTagProperties->getDefaultBoolValue(SUMO_ATTR_PRIORITY));
238
}
239
myCrossingWidth->setText(crossingTagProperties->getDefaultStringValue(SUMO_ATTR_WIDTH).c_str());
240
myCrossingWidth->setTextColor(GUIDesignTextColorBlack);
241
}
242
243
244
void
245
GNECrossingFrame::CrossingParameters::disableCrossingParameters() {
246
// clear all values of parameters
247
myCrossingEdges->setText("");
248
myCrossingPriorityCheckButton->setCheck(false);
249
myCrossingPriorityCheckButton->setText("false");
250
myCrossingWidth->setText("");
251
// Disable all elements of the crossing frames
252
myCrossingEdgesLabel->disable();
253
myCrossingEdges->disable();
254
myCrossingPriorityLabel->disable();
255
myCrossingPriorityCheckButton->disable();
256
myCrossingWidthLabel->disable();
257
myCrossingWidth->disable();
258
myHelpCrossingAttribute->disable();
259
myCrossingFrameParent->myCreateCrossing->setCreateCrossingButton(false);
260
}
261
262
263
bool
264
GNECrossingFrame::CrossingParameters::isCrossingParametersEnabled() const {
265
return myCrossingEdgesLabel->isEnabled();
266
}
267
268
269
void
270
GNECrossingFrame::CrossingParameters::markEdge(GNEEdge* edge) {
271
GNEJunction* currentJunction = myCrossingFrameParent->myEdgeSelector->getCurrentJunction();
272
if (currentJunction != nullptr) {
273
// Check if edge belongs to junction's edge
274
if (std::find(currentJunction->getChildEdges().begin(), currentJunction->getChildEdges().end(), edge) != currentJunction->getChildEdges().end()) {
275
// Update text field with the new edge
276
std::vector<std::string> crossingEdges = GNEAttributeCarrier::parse<std::vector<std::string> > (myCrossingEdges->getText().text());
277
// Check if new edge must be added or removed
278
std::vector<std::string>::iterator itFinder = std::find(crossingEdges.begin(), crossingEdges.end(), edge->getID());
279
if (itFinder == crossingEdges.end()) {
280
crossingEdges.push_back(edge->getID());
281
} else {
282
crossingEdges.erase(itFinder);
283
}
284
myCrossingEdges->setText(joinToString(crossingEdges, " ").c_str());
285
}
286
// Update colors and attributes
287
onCmdSetAttribute(nullptr, 0, nullptr);
288
}
289
}
290
291
292
void
293
GNECrossingFrame::CrossingParameters::clearEdges() {
294
myCrossingEdges->setText("");
295
// Update colors and attributes
296
onCmdSetAttribute(nullptr, 0, nullptr);
297
}
298
299
300
void
301
GNECrossingFrame::CrossingParameters::useSelectedEdges(GNEJunction* parentJunction) {
302
std::vector<std::string> crossingEdges;
303
for (const auto& edge : parentJunction->getChildEdges()) {
304
if (edge->isAttributeCarrierSelected()) {
305
crossingEdges.push_back(edge->getID());
306
}
307
}
308
myCrossingEdges->setText(joinToString(crossingEdges, " ").c_str());
309
// Update colors and attributes
310
onCmdSetAttribute(nullptr, 0, nullptr);
311
}
312
313
314
std::vector<NBEdge*>
315
GNECrossingFrame::CrossingParameters::getCrossingEdges() const {
316
std::vector<NBEdge*> NBEdgeVector;
317
// Iterate over myCurrentSelectedEdges
318
for (const auto& edge : myCurrentSelectedEdges) {
319
NBEdgeVector.push_back(edge->getNBEdge());
320
}
321
return NBEdgeVector;
322
}
323
324
325
bool
326
GNECrossingFrame::CrossingParameters::getCrossingPriority() const {
327
if (myCrossingPriorityCheckButton->getCheck()) {
328
return true;
329
} else {
330
return false;
331
}
332
}
333
334
335
bool
336
GNECrossingFrame::CrossingParameters::isCurrentParametersValid() const {
337
return myCurrentParametersValid;
338
}
339
340
341
double
342
GNECrossingFrame::CrossingParameters::getCrossingWidth() const {
343
return GNEAttributeCarrier::parse<double>(myCrossingWidth->getText().text());
344
}
345
346
347
long
348
GNECrossingFrame::CrossingParameters::onCmdSetAttribute(FXObject*, FXSelector, void*) {
349
myCurrentParametersValid = true;
350
// get string vector with the edges
351
const auto& crossingEdgeIDs = GNEAttributeCarrier::parse<std::vector<std::string> > (myCrossingEdges->getText().text());
352
GNEJunction* currentJunction = myCrossingFrameParent->myEdgeSelector->getCurrentJunction();
353
// Clear selected edges
354
myCurrentSelectedEdges.clear();
355
// iterate over vector of edge IDs
356
for (const auto& crossingEdgeID : crossingEdgeIDs) {
357
GNEEdge* edge = myCrossingFrameParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveEdge(crossingEdgeID, false);
358
// Check that edge exists and belongs to Junction
359
if (edge == nullptr) {
360
myCurrentParametersValid = false;
361
} else if (currentJunction && (std::find(currentJunction->getChildEdges().begin(), currentJunction->getChildEdges().end(), edge) == currentJunction->getChildEdges().end())) {
362
myCurrentParametersValid = false;
363
} else {
364
// select or unselected edge
365
auto itFinder = std::find(myCurrentSelectedEdges.begin(), myCurrentSelectedEdges.end(), edge);
366
if (itFinder == myCurrentSelectedEdges.end()) {
367
myCurrentSelectedEdges.push_back(edge);
368
} else {
369
myCurrentSelectedEdges.erase(itFinder);
370
}
371
}
372
}
373
// change color of textfield dependig of myCurrentParametersValid
374
if (myCurrentParametersValid) {
375
myCrossingEdges->setTextColor(GUIDesignTextColorBlack);
376
myCrossingEdges->killFocus();
377
} else {
378
myCrossingEdges->setTextColor(GUIDesignTextColorRed);
379
myCurrentParametersValid = false;
380
}
381
// Update edge colors
382
if (currentJunction) {
383
if (myCurrentSelectedEdges.empty()) {
384
for (const auto& edge : myCrossingFrameParent->myEdgeSelector->getCurrentJunction()->getChildEdges()) {
385
// restore colors
386
edge->resetCandidateFlags();
387
// mark all edges as possible candidate
388
edge->setPossibleCandidate(true);
389
}
390
} else {
391
EdgeVector selected;
392
for (GNEEdge* e : myCurrentSelectedEdges) {
393
selected.push_back(e->getNBEdge());
394
}
395
for (const auto& edge : myCrossingFrameParent->myEdgeSelector->getCurrentJunction()->getChildEdges()) {
396
// restore colors
397
edge->resetCandidateFlags();
398
// set selected or candidate color
399
if (std::find(myCurrentSelectedEdges.begin(), myCurrentSelectedEdges.end(), edge) != myCurrentSelectedEdges.end()) {
400
edge->setTargetCandidate(true);
401
} else {
402
EdgeVector newCandidates = selected;;
403
newCandidates.push_back(edge->getNBEdge());
404
if (currentJunction->getNBNode()->checkCrossing(newCandidates, true) == 0) {
405
edge->setInvalidCandidate(true);
406
} else {
407
edge->setPossibleCandidate(true);
408
}
409
}
410
}
411
}
412
}
413
// Update view net
414
myCrossingFrameParent->getViewNet()->updateViewNet();
415
// Check that at least there are one selected edge
416
if (crossingEdgeIDs.empty()) {
417
myCurrentParametersValid = false;
418
}
419
// change label of crossing priority
420
if (myCrossingPriorityCheckButton->getCheck()) {
421
myCrossingPriorityCheckButton->setText("true");
422
} else {
423
myCrossingPriorityCheckButton->setText("false");
424
}
425
426
// Check width
427
if (GNEAttributeCarrier::canParse<double>(myCrossingWidth->getText().text()) &&
428
GNEAttributeCarrier::parse<double>(myCrossingWidth->getText().text()) > 0) {
429
myCrossingWidth->setTextColor(GUIDesignTextColorBlack);
430
myCrossingWidth->killFocus();
431
} else {
432
myCrossingWidth->setTextColor(GUIDesignTextColorRed);
433
myCurrentParametersValid = false;
434
}
435
436
// Enable or disable create crossing button depending of the current parameters
437
myCrossingFrameParent->myCreateCrossing->setCreateCrossingButton(myCurrentParametersValid);
438
return 0;
439
}
440
441
442
long
443
GNECrossingFrame::CrossingParameters::onCmdHelp(FXObject*, FXSelector, void*) {
444
return 1;
445
}
446
447
// ---------------------------------------------------------------------------
448
// GNECrossingFrame::CreateCrossing - methods
449
// ---------------------------------------------------------------------------
450
451
GNECrossingFrame::CreateCrossing::CreateCrossing(GNECrossingFrame* crossingFrameParent) :
452
MFXGroupBoxModule(crossingFrameParent, TL("Create")),
453
myCrossingFrameParent(crossingFrameParent) {
454
// Create groupbox for create crossings
455
myCreateCrossingButton = GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Create crossing"), "", "", 0, this, MID_GNE_CREATE, GUIDesignButton);
456
myCreateCrossingButton->disable();
457
}
458
459
460
GNECrossingFrame::CreateCrossing::~CreateCrossing() {}
461
462
463
long
464
GNECrossingFrame::CreateCrossing::onCmdCreateCrossing(FXObject*, FXSelector, void*) {
465
// First check that current parameters are valid
466
if (myCrossingFrameParent->myCrossingParameters->isCurrentParametersValid()) {
467
// iterate over junction's crossing to find duplicated crossings
468
if (myCrossingFrameParent->myEdgeSelector->getCurrentJunction()->getNBNode()->checkCrossingDuplicated(myCrossingFrameParent->myCrossingParameters->getCrossingEdges()) == false) {
469
// create new crossing
470
myCrossingFrameParent->myViewNet->getUndoList()->add(new GNEChange_Crossing(myCrossingFrameParent->myEdgeSelector->getCurrentJunction(),
471
myCrossingFrameParent->myCrossingParameters->getCrossingEdges(),
472
myCrossingFrameParent->myCrossingParameters->getCrossingWidth(),
473
myCrossingFrameParent->myCrossingParameters->getCrossingPriority(),
474
-1, -1,
475
PositionVector::EMPTY,
476
false, true), true);
477
// clear selected edges
478
myCrossingFrameParent->myEdgeSelector->onCmdClearSelection(0, 0, 0);
479
// update default create edge option
480
myCrossingFrameParent->getViewNet()->getViewParent()->getCreateEdgeFrame()->getEdgeTypeSelector()->enableCheckBoxDisablePedestrians();
481
} else {
482
WRITE_WARNING(TL("There is already another crossing with the same edges in the junction; Duplicated crossing aren't allowed."));
483
}
484
}
485
return 1;
486
}
487
488
489
void
490
GNECrossingFrame::CreateCrossing::setCreateCrossingButton(bool value) {
491
if (value) {
492
myCreateCrossingButton->enable();
493
} else {
494
myCreateCrossingButton->disable();
495
}
496
}
497
498
// ---------------------------------------------------------------------------
499
// GNECrossingFrame::Legend - methods
500
// ---------------------------------------------------------------------------
501
502
GNECrossingFrame::Information::Information(GNECrossingFrame* crossingFrameParent) :
503
MFXGroupBoxModule(crossingFrameParent, TL("Information")) {
504
505
// create label
506
new MFXDynamicLabel(getCollapsableFrame(), (std::string("- ") + TL("Click over junction to mark candidate edges.") + std::string("\n- ") + TL("Click over candidate edges for selecting.")).c_str(), 0, GUIDesignLabelFrameInformation);
507
// candidate
508
FXLabel* colorCandidateLabel = new FXLabel(getCollapsableFrame(), TL(" Candidate"), 0, GUIDesignLabel(JUSTIFY_LEFT));
509
colorCandidateLabel->setBackColor(MFXUtils::getFXColor(crossingFrameParent->getViewNet()->getVisualisationSettings().candidateColorSettings.possible));
510
colorCandidateLabel->setTextColor(MFXUtils::getFXColor(RGBColor::WHITE));
511
// selected
512
FXLabel* colorSelectedLabel = new FXLabel(getCollapsableFrame(), TL(" Selected"), 0, GUIDesignLabel(JUSTIFY_LEFT));
513
colorSelectedLabel->setBackColor(MFXUtils::getFXColor(crossingFrameParent->getViewNet()->getVisualisationSettings().candidateColorSettings.target));
514
// invalid
515
FXLabel* colorInvalidLabel = new FXLabel(getCollapsableFrame(), TL(" Invalid"), 0, GUIDesignLabel(JUSTIFY_LEFT));
516
colorInvalidLabel->setBackColor(MFXUtils::getFXColor(crossingFrameParent->getViewNet()->getVisualisationSettings().candidateColorSettings.invalid));
517
colorInvalidLabel->setTextColor(MFXUtils::getFXColor(RGBColor::WHITE));
518
}
519
520
521
GNECrossingFrame::Information::~Information() {}
522
523
// ---------------------------------------------------------------------------
524
// GNECrossingFrame - methods
525
// ---------------------------------------------------------------------------
526
527
GNECrossingFrame::GNECrossingFrame(GNEViewParent* viewParent, GNEViewNet* viewNet) :
528
GNEFrame(viewParent, viewNet, TL("Crossings")) {
529
// create JunctionInformation module
530
myJunctionInformation = new JunctionInformation(this);
531
532
// Create edge Selector module
533
myEdgeSelector = new EdgesSelector(this);
534
535
// Create CrossingParameters module
536
myCrossingParameters = new CrossingParameters(this);
537
538
// create CreateCrossing module
539
myCreateCrossing = new CreateCrossing(this);
540
541
// create information module
542
myInformation = new Information(this);
543
544
// disable edge selector
545
myEdgeSelector->disableEdgeSelector();
546
}
547
548
549
GNECrossingFrame::~GNECrossingFrame() {
550
}
551
552
553
void
554
GNECrossingFrame::hide() {
555
// restore color of all lanes of edge candidates
556
myEdgeSelector->restoreEdgeColors();
557
// hide frame
558
GNEFrame::hide();
559
}
560
561
562
void
563
GNECrossingFrame::addCrossing(const GNEViewNetHelper::ViewObjectsSelector& viewObjects) {
564
// If current element is a junction
565
if (viewObjects.getJunctionFront() && (viewObjects.getAttributeCarriers().front() == viewObjects.getJunctionFront())) {
566
// change label
567
myJunctionInformation->updateCurrentJunctionLabel(viewObjects.getJunctionFront()->getID());
568
// Enable edge selector and crossing parameters
569
myEdgeSelector->enableEdgeSelector(viewObjects.getJunctionFront());
570
myCrossingParameters->enableCrossingParameters(viewObjects.getJunctionFront()->getNBNode()->isTLControlled());
571
// clears selected edges
572
myCrossingParameters->clearEdges();
573
} else if (viewObjects.getEdgeFront()) {
574
// check if mark edge
575
if (!viewObjects.getEdgeFront()->isInvalidCandidate()) {
576
myCrossingParameters->markEdge(viewObjects.getEdgeFront());
577
}
578
} else {
579
// set default label
580
myJunctionInformation->updateCurrentJunctionLabel("");
581
// restore color of all lanes of edge candidates
582
myEdgeSelector->restoreEdgeColors();
583
// Disable edge selector
584
myEdgeSelector->disableEdgeSelector();
585
}
586
// always update view after an operation
587
myViewNet->updateViewNet();
588
}
589
590
591
void
592
GNECrossingFrame::createCrossingHotkey() {
593
if (myEdgeSelector->getCurrentJunction()) {
594
// simply call onCmdCreateCrossing of CreateCrossing module
595
myCreateCrossing->onCmdCreateCrossing(0, 0, 0);
596
}
597
}
598
599
600
void
601
GNECrossingFrame::clearEdgesHotkey() {
602
if (myCrossingParameters->getCrossingEdges().size() > 0) {
603
myCrossingParameters->clearEdges();
604
} else if (myEdgeSelector->getCurrentJunction()) {
605
myEdgeSelector->restoreEdgeColors();
606
myEdgeSelector->disableEdgeSelector();
607
}
608
}
609
610
611
GNECrossingFrame::EdgesSelector*
612
GNECrossingFrame::getEdgesSelector() const {
613
return myEdgeSelector;
614
}
615
616
/****************************************************************************/
617
618