Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/dialogs/basic/GNEOverwriteElement.cpp
169684 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 GNEOverwriteElement.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Jul 2017
17
///
18
// Dialog used to ask user if overwrite elements during loading
19
/****************************************************************************/
20
#include <config.h>
21
22
#include <netedit/GNENet.h>
23
#include <netedit/GNETagProperties.h>
24
#include <netedit/GNEViewParent.h>
25
#include <utils/gui/div/GUIDesigns.h>
26
#include <utils/handlers/CommonHandler.h>
27
28
#include "GNEOverwriteElement.h"
29
30
// ===========================================================================
31
// member method definitions
32
// ===========================================================================
33
34
GNEOverwriteElement::GNEOverwriteElement(CommonHandler* commonHandler, const GNEAttributeCarrier* AC) :
35
GNEDialog(AC->getNet()->getViewNet()->getViewParent()->getGNEAppWindows(),
36
TLF("Overwrite % '%'", AC->getTagProperty()->getTagStr(), AC->getID()), GUIIcon::QUESTION_SMALL,
37
DialogType::OVERWRITE, GNEDialog::Buttons::YES_NO_CANCEL, GNEDialog::OpenType::MODAL, ResizeMode::STATIC),
38
myCommonHandler(commonHandler) {
39
// create dialog layout (obtained from FXMessageBox)
40
auto infoFrame = new FXVerticalFrame(myContentFrame, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10);
41
// add information label
42
new FXLabel(infoFrame, TLF("There is already a % '%'. Overwrite?", AC->getTagProperty()->getTagStr(), AC->getID()).c_str(),
43
nullptr, JUSTIFY_LEFT | ICON_BEFORE_TEXT | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y);
44
// add checkButton
45
myApplySolutionToAllCheckButon = new FXCheckButton(infoFrame, TL("Apply this solution to all conflicted elements"), nullptr, 0, GUIDesignCheckButton);
46
// open modal dialog
47
openDialog();
48
}
49
50
51
GNEOverwriteElement::~GNEOverwriteElement() {
52
}
53
54
55
void
56
GNEOverwriteElement::runInternalTest(const InternalTestStep::DialogArgument* dialogArgument) {
57
if (dialogArgument->getCustomAction() == "applyToAll") {
58
myApplySolutionToAllCheckButon->setCheck(TRUE);
59
}
60
}
61
62
63
64
long
65
GNEOverwriteElement::onCmdAccept(FXObject*, FXSelector, void*) {
66
if (myApplySolutionToAllCheckButon->getCheck() == TRUE) {
67
myCommonHandler->forceOverwriteElements();
68
}
69
return closeDialogAccepting();
70
}
71
72
73
long
74
GNEOverwriteElement::onCmdCancel(FXObject*, FXSelector, void*) {
75
if (myApplySolutionToAllCheckButon->getCheck() == TRUE) {
76
myCommonHandler->forceRemainElements();
77
}
78
return closeDialogCanceling();
79
}
80
81
82
long
83
GNEOverwriteElement::onCmdAbort(FXObject*, FXSelector, void*) {
84
myCommonHandler->abortLoading();
85
return closeDialogAborting();
86
}
87
88
/****************************************************************************/
89
90