Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/GNEAttributesEditor.cpp
193674 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 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 GNEAttributesEditor.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Feb 2025
17
///
18
// pack of all GNEAttributesEditorTypes
19
/****************************************************************************/
20
21
#include "GNEAttributesEditor.h"
22
23
#include <netedit/elements/GNEAttributeCarrier.h>
24
#include <netedit/GNETagProperties.h>
25
26
// ===========================================================================
27
// method definitions
28
// ===========================================================================
29
30
GNEAttributesEditor::GNEAttributesEditor(GNEFrame* frameParent, GNEAttributesEditorType::EditorType editorType) {
31
myBasicAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Internal attributes"), editorType, GNEAttributesEditorType::AttributeType::BASIC);
32
myExtendedAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Extended attributes"), editorType, GNEAttributesEditorType::AttributeType::EXTENDED);
33
myFlowAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Flow attributes"), editorType, GNEAttributesEditorType::AttributeType::FLOW);
34
myGeoAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Geo attributes"), editorType, GNEAttributesEditorType::AttributeType::GEO);
35
myParametersAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Parameters"), editorType, GNEAttributesEditorType::AttributeType::PARAMETERS);
36
myNeteditAttributesEditor = new GNEAttributesEditorType(frameParent, this, TL("Netedit attributes"), editorType, GNEAttributesEditorType::AttributeType::NETEDIT);
37
}
38
39
40
void
41
GNEAttributesEditor::showAttributesEditor(GNEAttributeCarrier* AC, const bool primaryAttributeEditor) {
42
myBasicAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);
43
myExtendedAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);
44
myFlowAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);
45
myGeoAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);
46
myParametersAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);
47
myNeteditAttributesEditor->showAttributesEditor(AC, primaryAttributeEditor);
48
}
49
50
51
void
52
GNEAttributesEditor::showAttributesEditor(const std::unordered_set<GNEAttributeCarrier*>& ACs, const bool primaryAttributeEditor) {
53
myBasicAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);
54
myExtendedAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);
55
myFlowAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);
56
myGeoAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);
57
myParametersAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);
58
myNeteditAttributesEditor->showAttributesEditor(ACs, primaryAttributeEditor);
59
}
60
61
62
void
63
GNEAttributesEditor::hideAttributesEditor() {
64
myBasicAttributesEditor->hideAttributesEditor();
65
myExtendedAttributesEditor->hideAttributesEditor();
66
myFlowAttributesEditor->hideAttributesEditor();
67
myGeoAttributesEditor->hideAttributesEditor();
68
myParametersAttributesEditor->hideAttributesEditor();
69
myNeteditAttributesEditor->hideAttributesEditor();
70
}
71
72
73
void
74
GNEAttributesEditor::refreshAttributesEditor() {
75
myBasicAttributesEditor->refreshAttributesEditor();
76
myExtendedAttributesEditor->refreshAttributesEditor();
77
myFlowAttributesEditor->refreshAttributesEditor();
78
myGeoAttributesEditor->refreshAttributesEditor();
79
myParametersAttributesEditor->refreshAttributesEditor();
80
myNeteditAttributesEditor->refreshAttributesEditor();
81
}
82
83
84
void
85
GNEAttributesEditor::disableAttributesEditor() {
86
myBasicAttributesEditor->disableAttributesEditor();
87
myExtendedAttributesEditor->disableAttributesEditor();
88
myFlowAttributesEditor->disableAttributesEditor();
89
myGeoAttributesEditor->disableAttributesEditor();
90
myParametersAttributesEditor->disableAttributesEditor();
91
myNeteditAttributesEditor->disableAttributesEditor();
92
}
93
94
95
GNEAttributesEditorType*
96
GNEAttributesEditor::getNeteditAttributesEditor() const {
97
return myNeteditAttributesEditor;
98
}
99
100
101
bool
102
GNEAttributesEditor::checkAttributes(const bool showWarning) {
103
if (!myBasicAttributesEditor->checkAttributes(showWarning)) {
104
return false;
105
} else if (!myExtendedAttributesEditor->checkAttributes(showWarning)) {
106
return false;
107
} else if (!myFlowAttributesEditor->checkAttributes(showWarning)) {
108
return false;
109
} else if (!myGeoAttributesEditor->checkAttributes(showWarning)) {
110
return false;
111
} else if (!myParametersAttributesEditor->checkAttributes(showWarning)) {
112
return false;
113
} else if (!myNeteditAttributesEditor->checkAttributes(showWarning)) {
114
return false;
115
} else {
116
return true;
117
}
118
}
119
120
121
SumoXMLAttr
122
GNEAttributesEditor::fillSumoBaseObject(CommonXMLStructure::SumoBaseObject* baseObject) const {
123
// check if edited AC is a vehicle (needed to avoid empty attributes in SUMOVehicleParser
124
bool useSUMOVehicleparser = false;
125
if (myBasicAttributesEditor->getEditedAttributeCarriers().size() > 0) {
126
if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isVehicle()) {
127
useSUMOVehicleparser = true;
128
} else if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isPerson()) {
129
useSUMOVehicleparser = true;
130
} else if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isContainer()) {
131
useSUMOVehicleparser = true;
132
}
133
}
134
SumoXMLAttr fillResult = SUMO_ATTR_DEFAULT;
135
fillResult = myBasicAttributesEditor->fillSumoBaseObject(baseObject, !useSUMOVehicleparser);
136
if (fillResult != SUMO_ATTR_NOTHING) {
137
return fillResult;
138
}
139
fillResult = myExtendedAttributesEditor->fillSumoBaseObject(baseObject, true);
140
if (fillResult != SUMO_ATTR_NOTHING) {
141
return fillResult;
142
}
143
fillResult = myFlowAttributesEditor->fillSumoBaseObject(baseObject, true);
144
if (fillResult != SUMO_ATTR_NOTHING) {
145
return fillResult;
146
}
147
fillResult = myGeoAttributesEditor->fillSumoBaseObject(baseObject, true);
148
if (fillResult != SUMO_ATTR_NOTHING) {
149
return fillResult;
150
}
151
fillResult = myParametersAttributesEditor->fillSumoBaseObject(baseObject, true);
152
if (fillResult != SUMO_ATTR_NOTHING) {
153
return fillResult;
154
}
155
fillResult = myNeteditAttributesEditor->fillSumoBaseObject(baseObject, true);
156
if (fillResult != SUMO_ATTR_NOTHING) {
157
return fillResult;
158
}
159
return fillResult;
160
}
161
162
163
bool
164
GNEAttributesEditor::isReparenting() const {
165
return myNeteditAttributesEditor->isReparenting();
166
}
167
168
169
bool
170
GNEAttributesEditor::checkNewParent(const GNEAttributeCarrier* AC) const {
171
return myNeteditAttributesEditor->checkNewParent(AC);
172
}
173
174
175
void
176
GNEAttributesEditor::setNewParent(const GNEAttributeCarrier* AC) {
177
myNeteditAttributesEditor->setNewParent(AC);
178
}
179
180
181
void
182
GNEAttributesEditor::abortReparenting() {
183
myNeteditAttributesEditor->abortReparenting();
184
}
185
186
/****************************************************************************/
187
188