Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/GNEAttributesEditor.cpp
169678 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 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
bool
96
GNEAttributesEditor::checkAttributes(const bool showWarning) {
97
if (!myBasicAttributesEditor->checkAttributes(showWarning)) {
98
return false;
99
} else if (!myExtendedAttributesEditor->checkAttributes(showWarning)) {
100
return false;
101
} else if (!myFlowAttributesEditor->checkAttributes(showWarning)) {
102
return false;
103
} else if (!myGeoAttributesEditor->checkAttributes(showWarning)) {
104
return false;
105
} else if (!myParametersAttributesEditor->checkAttributes(showWarning)) {
106
return false;
107
} else if (!myNeteditAttributesEditor->checkAttributes(showWarning)) {
108
return false;
109
} else {
110
return true;
111
}
112
}
113
114
115
SumoXMLAttr
116
GNEAttributesEditor::fillSumoBaseObject(CommonXMLStructure::SumoBaseObject* baseObject) const {
117
// check if edited AC is a vehicle (needed to avoid empty attributes in SUMOVehicleParser
118
bool useSUMOVehicleparser = false;
119
if (myBasicAttributesEditor->getEditedAttributeCarriers().size() > 0) {
120
if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isVehicle()) {
121
useSUMOVehicleparser = true;
122
} else if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isPerson()) {
123
useSUMOVehicleparser = true;
124
} else if (myBasicAttributesEditor->getEditedAttributeCarriers().front()->getTagProperty()->isContainer()) {
125
useSUMOVehicleparser = true;
126
}
127
}
128
SumoXMLAttr fillResult = SUMO_ATTR_DEFAULT;
129
fillResult = myBasicAttributesEditor->fillSumoBaseObject(baseObject, !useSUMOVehicleparser);
130
if (fillResult != SUMO_ATTR_NOTHING) {
131
return fillResult;
132
}
133
fillResult = myExtendedAttributesEditor->fillSumoBaseObject(baseObject, true);
134
if (fillResult != SUMO_ATTR_NOTHING) {
135
return fillResult;
136
}
137
fillResult = myFlowAttributesEditor->fillSumoBaseObject(baseObject, true);
138
if (fillResult != SUMO_ATTR_NOTHING) {
139
return fillResult;
140
}
141
fillResult = myGeoAttributesEditor->fillSumoBaseObject(baseObject, true);
142
if (fillResult != SUMO_ATTR_NOTHING) {
143
return fillResult;
144
}
145
fillResult = myParametersAttributesEditor->fillSumoBaseObject(baseObject, true);
146
if (fillResult != SUMO_ATTR_NOTHING) {
147
return fillResult;
148
}
149
fillResult = myNeteditAttributesEditor->fillSumoBaseObject(baseObject, true);
150
if (fillResult != SUMO_ATTR_NOTHING) {
151
return fillResult;
152
}
153
return fillResult;
154
}
155
156
157
bool
158
GNEAttributesEditor::isReparenting() const {
159
return myNeteditAttributesEditor->isReparenting();
160
}
161
162
163
bool
164
GNEAttributesEditor::checkNewParent(const GNEAttributeCarrier* AC) const {
165
return myNeteditAttributesEditor->checkNewParent(AC);
166
}
167
168
169
void
170
GNEAttributesEditor::setNewParent(const GNEAttributeCarrier* AC) {
171
myNeteditAttributesEditor->setNewParent(AC);
172
}
173
174
175
void
176
GNEAttributesEditor::abortReparenting() {
177
myNeteditAttributesEditor->abortReparenting();
178
}
179
180
/****************************************************************************/
181
182