Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/network/GNEConnectorFrame.h
169686 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 GNEConnectorFrame.h
15
/// @author Jakob Erdmann
16
/// @date May 2011
17
///
18
// The Widget for modifying lane-to-lane connections
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netbuild/NBEdge.h>
24
#include <netedit/frames/GNEFrame.h>
25
26
// ===========================================================================
27
// class definitions
28
// ===========================================================================
29
/**
30
* @class GNEConnectorFrame
31
* The Widget for modifying selections of network-elements
32
*/
33
class GNEConnectorFrame : public GNEFrame {
34
35
public:
36
37
// ===========================================================================
38
// class CurrentLane
39
// ===========================================================================
40
41
class CurrentLane : public MFXGroupBoxModule {
42
43
public:
44
/// @brief constructor
45
CurrentLane(GNEConnectorFrame* connectorFrameParent);
46
47
/// @brief destructor
48
~CurrentLane();
49
50
/// @brief set current junction label
51
void updateCurrentLaneLabel(const std::string& laneID);
52
53
private:
54
/// @brief Label for current Lane
55
FXLabel* myCurrentLaneLabel;
56
};
57
58
// ===========================================================================
59
// class ConnectionModifications
60
// ===========================================================================
61
62
class ConnectionModifications : public MFXGroupBoxModule {
63
/// @brief FOX-declaration
64
FXDECLARE(GNEConnectorFrame::ConnectionModifications)
65
66
public:
67
/// @brief constructor
68
ConnectionModifications(GNEConnectorFrame* connectorFrameParent);
69
70
/// @brief destructor
71
~ConnectionModifications();
72
73
/// @name FOX-callbacks
74
/// @{
75
76
/// @brief Called when the user presses the OK-Button saves any connection modifications
77
long onCmdSaveModifications(FXObject*, FXSelector, void*);
78
79
/// @brief Called when the user presses the Cancel-button discards any connection modifications
80
long onCmdCancelModifications(FXObject*, FXSelector, void*);
81
/// @}
82
83
protected:
84
FOX_CONSTRUCTOR(ConnectionModifications)
85
86
private:
87
/// @brief pointer to connectorFrame parent
88
GNEConnectorFrame* myConnectorFrameParent;
89
90
/// @brief "Cancel" button
91
FXButton* myCancelButton;
92
93
/// @brief "OK" button
94
FXButton* mySaveButton;
95
96
/// @brief protect routes checkbox
97
FXCheckButton* myProtectRoutesCheckBox;
98
};
99
100
// ===========================================================================
101
// class ConnectionOperations
102
// ===========================================================================
103
104
class ConnectionOperations : public MFXGroupBoxModule {
105
/// @brief FOX-declaration
106
FXDECLARE(GNEConnectorFrame::ConnectionOperations)
107
108
public:
109
/// @brief constructor
110
ConnectionOperations(GNEConnectorFrame* connectorFrameParent);
111
112
/// @brief destructor
113
~ConnectionOperations();
114
115
/// @name FOX-callbacks
116
/// @{
117
118
/// @brief Called when the user presses the select dead ends button
119
long onCmdSelectDeadEnds(FXObject*, FXSelector, void*);
120
121
/// @brief Called when the user presses the select dead starts button
122
long onCmdSelectDeadStarts(FXObject*, FXSelector, void*);
123
124
/// @brief Called when the user presses the select conflicts button
125
long onCmdSelectConflicts(FXObject*, FXSelector, void*);
126
127
/// @brief Called when the user presses the select pass button
128
long onCmdSelectPass(FXObject*, FXSelector, void*);
129
130
/// @brief Called when the user presses the clear selected connections button
131
long onCmdClearSelectedConnections(FXObject*, FXSelector, void*);
132
133
/// @brief Called when the user presses the reset selected connections button
134
long onCmdResetSelectedConnections(FXObject*, FXSelector, void*);
135
/// @}
136
137
protected:
138
FOX_CONSTRUCTOR(ConnectionOperations)
139
140
private:
141
/// @brief pointer to connectorFrame parent
142
GNEConnectorFrame* myConnectorFrameParent;
143
144
/// @brief "Select Dead Ends" button
145
FXButton* mySelectDeadEndsButton;
146
147
/// @brief "Select Dead Starts" button
148
FXButton* mySelectDeadStartsButton;
149
150
/// @brief "Select Conflicts" button
151
FXButton* mySelectConflictsButton;
152
153
/// @brief "Select Edges which may always pass"
154
FXButton* mySelectPassingButton;
155
156
/// @brief "Clear Selected"
157
FXButton* myClearSelectedButton;
158
159
/// @brief "Reset Selected"
160
FXButton* myResetSelectedButton;
161
};
162
163
// ===========================================================================
164
// class ConnectionSelection
165
// ===========================================================================
166
167
class ConnectionSelection : public MFXGroupBoxModule {
168
169
public:
170
/// @brief constructor
171
ConnectionSelection(GNEConnectorFrame* connectorFrameParent);
172
173
/// @brief destructor
174
~ConnectionSelection();
175
};
176
177
// ===========================================================================
178
// class Legend
179
// ===========================================================================
180
181
class Legend : public MFXGroupBoxModule {
182
183
public:
184
/// @brief constructor
185
Legend(GNEConnectorFrame* connectorFrameParent);
186
187
/// @brief destructor
188
~Legend();
189
190
private:
191
};
192
193
/**@brief Constructor
194
* @brief viewParent GNEViewParent in which this GNEFrame is placed
195
* @brief viewNet viewNet that uses this GNEFrame
196
*/
197
GNEConnectorFrame(GNEViewParent* viewParent, GNEViewNet* viewNet);
198
199
/// @brief Destructor
200
~GNEConnectorFrame();
201
202
/**@brief either sets the current lane or toggles the connection of the
203
* @param viewObjects collection of objects under cursor after click over view
204
*/
205
void handleLaneClick(const GNEViewNetHelper::ViewObjectsSelector& viewObjects);
206
207
/// @brief get pointer to ConnectionModifications module
208
ConnectionModifications* getConnectionModifications() const;
209
210
private:
211
/// @brief the status of a target lane
212
enum class LaneStatus {
213
UNCONNECTED,
214
CONNECTED,
215
CONNECTED_PASS,
216
CONFLICTED
217
};
218
219
/**@brief either sets the current lane or toggles the connection of the
220
* current lane to this lane (if they share a junction)
221
* @param[in] lane Either the lane to set as current lane, or the destination from current lane
222
* @param[in] mayDefinitelyPass Whether new connections shall have the pass attribute set
223
* @param[in] toggle Whether non-existing connections shall be created
224
*/
225
void buildConnection(GNELane* lane, const bool mayDefinitelyPass, const bool allowConflict, const bool toggle);
226
227
/// @brief init targets
228
void initTargets();
229
230
/// @brief clean up when deselecting current lane
231
void cleanup();
232
233
/// @brief remove connections
234
void removeConnections(GNELane* lane);
235
236
/// @brief return the status of toLane
237
LaneStatus getLaneStatus(const std::vector<NBEdge::Connection>& connections, const GNELane* targetLane) const;
238
239
/// @brief CurrentLane module
240
CurrentLane* myCurrentLane;
241
242
/// @brief ConnectionModifications module
243
GNEConnectorFrame::ConnectionModifications* myConnectionModifications = nullptr;
244
245
/// @brief ConnectionOperations module
246
GNEConnectorFrame::ConnectionOperations* myConnectionOperations = nullptr;
247
248
/// @brief ConnectionSelection module
249
GNEConnectorFrame::ConnectionSelection* myConnectionSelection = nullptr;
250
251
/// @brief Legend module
252
GNEConnectorFrame::Legend* myLegend = nullptr;
253
254
/// @brief the lane of which connections are to be modified
255
GNELane* myCurrentEditedLane;
256
257
/// @brief the set of lanes to which the current lane may be connected
258
std::set<GNELane*> myPotentialTargets;
259
260
/// @brief number of changes
261
int myNumChanges;
262
263
/// @brief the internal lanes belonging the current junction indexed by their tl-index
264
std::map<int, GNEInternalLane*> myInternalLanes;
265
266
/// @brief vector of connections deleted in the current editing step
267
std::vector<NBEdge::Connection> myDeletedConnections;
268
};
269
270