Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/network/GNECrossingFrame.h
193905 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 GNECrossingFrame.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Oct 2016
17
///
18
// The Widget for add Crossing elements
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/frames/GNEFrame.h>
24
#include <netedit/GNEViewNetHelper.h>
25
#include <netedit/frames/common/GNEGroupBoxModule.h>
26
27
// ===========================================================================
28
// class definitions
29
// ===========================================================================
30
31
class GNECrossingFrame : public GNEFrame {
32
33
public:
34
35
// ===========================================================================
36
// class CurrentJunction
37
// ===========================================================================
38
39
class JunctionInformation : public GNEGroupBoxModule {
40
41
public:
42
/// @brief constructor
43
JunctionInformation(GNECrossingFrame* crossingFrameParent);
44
45
/// @brief destructor
46
~JunctionInformation();
47
48
/// @brief set current junction label
49
void updateCurrentJunctionLabel(const std::string& junctionID);
50
51
private:
52
/// @brief Text field for junction ID
53
FXTextField* myTextFieldJunctionID;
54
};
55
56
// ===========================================================================
57
// class EdgesSelector
58
// ===========================================================================
59
60
class EdgesSelector : public GNEGroupBoxModule {
61
/// @brief FOX-declaration
62
FXDECLARE(GNECrossingFrame::EdgesSelector)
63
64
public:
65
/// @brief constructor
66
EdgesSelector(GNECrossingFrame* crossingFrameParent);
67
68
/// @brief destructor
69
~EdgesSelector();
70
71
/// @brief get current junction
72
GNEJunction* getCurrentJunction() const;
73
74
/// @brief enable edgeSelector
75
void enableEdgeSelector(GNEJunction* currentJunction);
76
77
/// @brief disable edgeSelector
78
void disableEdgeSelector();
79
80
/// @brief restore colors of all edges
81
void restoreEdgeColors();
82
83
/// @name FOX-callbacks
84
/// @{
85
/// @brief called when useSelectedEdges button edge is pressed
86
long onCmdUseSelectedEdges(FXObject*, FXSelector, void*);
87
88
/// @brief called when clear selection button is pressed
89
long onCmdClearSelection(FXObject*, FXSelector, void*);
90
91
/// @}
92
93
protected:
94
/// @brief FOX needs this
95
FOX_CONSTRUCTOR(EdgesSelector)
96
97
private:
98
/// @brief pointer to GNECrossingFrame parent
99
GNECrossingFrame* myCrossingFrameParent;
100
101
/// @brief CheckBox for selected edges
102
FXButton* myUseSelectedEdges;
103
104
/// @brief button for clear selection
105
FXButton* myClearEdgesSelection;
106
107
/// @brief current Junction
108
GNEJunction* myCurrentJunction;
109
};
110
111
// ===========================================================================
112
// class CrossingParameters
113
// ===========================================================================
114
115
class CrossingParameters : public GNEGroupBoxModule {
116
/// @brief FOX-declaration
117
FXDECLARE(GNECrossingFrame::CrossingParameters)
118
119
public:
120
/// @brief constructor
121
CrossingParameters(GNECrossingFrame* crossingFrameParent);
122
123
/// @brief destructor
124
~CrossingParameters();
125
126
/// @brief enable crossing parameters and set the default value of parameters
127
void enableCrossingParameters(bool hasTLS);
128
129
/// @brief disable crossing parameters and clear parameters
130
void disableCrossingParameters();
131
132
/// @brief check if currently the CrossingParameters is enabled
133
bool isCrossingParametersEnabled() const;
134
135
/// @brief mark or dismark edge
136
void markEdge(GNEEdge* edge);
137
138
/// @brief clear edges
139
void clearEdges();
140
141
/// @brief use selected eges
142
void useSelectedEdges(GNEJunction* parentJunction);
143
144
/// @brief get crossing NBedges
145
std::vector<NBEdge*> getCrossingEdges() const;
146
147
/// @brief get crossing priority
148
bool getCrossingPriority() const;
149
150
/// @brief get crossing width
151
double getCrossingWidth() const;
152
153
/// @brief check if current parameters are valid
154
bool isCurrentParametersValid() const;
155
156
/// @name FOX-callbacks
157
/// @{
158
/// @brief Called when user set a value
159
long onCmdSetAttribute(FXObject*, FXSelector, void*);
160
161
/// @brief Called when help button is pressed
162
long onCmdHelp(FXObject*, FXSelector, void*);
163
/// @}
164
165
protected:
166
/// @brief FOX needs this
167
FOX_CONSTRUCTOR(CrossingParameters)
168
169
private:
170
/// @brief pointer to GNECrossingFrame parent
171
GNECrossingFrame* myCrossingFrameParent;
172
173
/// @brief current selected edges
174
std::vector<GNEEdge*> myCurrentSelectedEdges;
175
176
/// @brief current invalid edges
177
std::vector<GNEEdge*> myCurrentInvalidEdges;
178
179
/// @brief Label for edges
180
FXLabel* myCrossingEdgesLabel;
181
182
/// @brief TextField for edges
183
FXTextField* myCrossingEdges;
184
185
/// @brief Label for Priority
186
FXLabel* myCrossingPriorityLabel;
187
188
/// @brief CheckBox for Priority
189
FXCheckButton* myCrossingPriorityCheckButton;
190
191
/// @brief Label for width
192
FXLabel* myCrossingWidthLabel;
193
194
/// @brief TextField for width
195
FXTextField* myCrossingWidth;
196
197
/// @brief button for help
198
FXButton* myHelpCrossingAttribute;
199
200
/// @brief flag to check if current parameters are valid
201
bool myCurrentParametersValid;
202
};
203
204
// ===========================================================================
205
// class CreateCrossing
206
// ===========================================================================
207
208
class CreateCrossing : public GNEGroupBoxModule {
209
/// @brief FOX-declaration
210
FXDECLARE(GNECrossingFrame::CreateCrossing)
211
212
public:
213
/// @brief constructor
214
CreateCrossing(GNECrossingFrame* crossingFrameParent);
215
216
/// @brief destructor
217
~CreateCrossing();
218
219
/// @brief enable or disable button create crossing
220
void setCreateCrossingButton(bool value);
221
222
/// @name FOX-callbacks
223
/// @{
224
/// @brief Called when the user press the button create edge
225
long onCmdCreateCrossing(FXObject*, FXSelector, void*);
226
/// @}
227
228
protected:
229
/// @brief FOX needs this
230
FOX_CONSTRUCTOR(CreateCrossing)
231
232
private:
233
/// @brief pointer to crossingFrame parent
234
GNECrossingFrame* myCrossingFrameParent;
235
236
/// @field FXButton for create Crossing
237
FXButton* myCreateCrossingButton;
238
};
239
240
// ===========================================================================
241
// class Information
242
// ===========================================================================
243
244
class Information : public GNEGroupBoxModule {
245
246
public:
247
/// @brief constructor
248
Information(GNECrossingFrame* crossingFrameParent);
249
250
/// @brief destructor
251
~Information();
252
};
253
254
/**@brief Constructor
255
* @brief viewParent GNEViewParent in which this GNEFrame is placed
256
* @brief viewNet viewNet that uses this GNEFrame
257
*/
258
GNECrossingFrame(GNEViewParent* viewParent, GNEViewNet* viewNet);
259
260
/// @brief Destructor
261
~GNECrossingFrame();
262
263
/// @brief hide crossing frame
264
void hide();
265
266
/**@brief add Crossing element
267
* @param viewObjects collection of objects under cursor after click over view
268
*/
269
void addCrossing(const GNEViewNetHelper::ViewObjectsSelector& viewObjects);
270
271
/// @brief create crossing (used when user press ENTER key in Crossing mode)
272
void createCrossingHotkey();
273
274
/// @brief clear edges (used when user press ESC key in Crossing mode)
275
void clearEdgesHotkey();
276
277
/// @brief get edge selector modul
278
GNECrossingFrame::EdgesSelector* getEdgesSelector() const;
279
280
protected:
281
/// @brief FOX need this
282
FOX_CONSTRUCTOR(GNECrossingFrame)
283
284
private:
285
/// @brief junction information modul
286
GNECrossingFrame::JunctionInformation* myJunctionInformation = nullptr;
287
288
/// @brief edge selector modul
289
GNECrossingFrame::EdgesSelector* myEdgeSelector = nullptr;
290
291
/// @brief crossing parameters modul
292
GNECrossingFrame::CrossingParameters* myCrossingParameters = nullptr;
293
294
/// @brief create crossing modul
295
GNECrossingFrame::CreateCrossing* myCreateCrossing = nullptr;
296
297
/// @brief information modul
298
GNECrossingFrame::Information* myInformation = nullptr;
299
};
300
301