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