Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/GNEPathCreator.h
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 GNEPathCreator.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Mar 2022
17
///
18
// Frame for create paths
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <utils/foxtools/MFXGroupBoxModule.h>
24
25
// ===========================================================================
26
// class declaration
27
// ===========================================================================
28
29
class GNEFrame;
30
class GNETagProperties;
31
class GNEPathManager;
32
33
// ===========================================================================
34
// class definitions
35
// ===========================================================================
36
37
class GNEPathCreator : public MFXGroupBoxModule {
38
/// @brief FOX-declaration
39
FXDECLARE(GNEPathCreator)
40
41
public:
42
/// @brief class for path
43
class Path {
44
45
public:
46
/// @brief constructor for single edge
47
Path(const SUMOVehicleClass vClass, GNEEdge* edge);
48
49
/// @brief constructor for two edges
50
Path(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* edgeFrom, GNEEdge* edgeTo);
51
52
/// @brief constructor for two junctions
53
Path(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* junctionFrom, GNEJunction* junctionTo);
54
55
/// @brief get sub path
56
const std::vector<GNEEdge*>& getSubPath() const;
57
58
/// @brief check if current path is conflict due vClass
59
bool isConflictVClass() const;
60
61
/// @brief check if current path is conflict due is disconnected
62
bool isConflictDisconnected() const;
63
64
protected:
65
/// @brief sub path
66
std::vector<GNEEdge*> mySubPath;
67
68
/// @brief flag to mark this path as conflicted
69
bool myConflictVClass;
70
71
/// @brief flag to mark this path as disconnected
72
bool myConflictDisconnected;
73
74
private:
75
/// @brief default constructor
76
Path();
77
78
/// @brief Invalidated copy constructor.
79
Path(Path*) = delete;
80
81
/// @brief Invalidated assignment operator.
82
Path& operator=(Path*) = delete;
83
};
84
85
/// @brief default constructor
86
GNEPathCreator(GNEFrame* frameParent, GNEPathManager* pathManager);
87
88
/// @brief destructor
89
~GNEPathCreator();
90
91
/// @brief show GNEPathCreator for the given tag
92
void showPathCreatorModule(const GNETagProperties* tagProperty, const bool consecutives);
93
94
/// @brief show GNEPathCreator
95
void hidePathCreatorModule();
96
97
/// @brief get vClass
98
SUMOVehicleClass getVClass() const;
99
100
/// @brief set vClass
101
void setVClass(SUMOVehicleClass vClass);
102
103
/// @brief add junction
104
bool addJunction(GNEJunction* junction);
105
106
/// @brief add TAZ
107
bool addTAZ(GNETAZ* taz);
108
109
/// @brief add edge
110
bool addEdge(GNEEdge* edge, const bool shiftKeyPressed, const bool controlKeyPressed);
111
112
/// @brief get current selected edges
113
const std::vector<GNEEdge*>& getSelectedEdges() const;
114
115
/// @brief get current selected junctions
116
const std::vector<GNEJunction*>& getSelectedJunctions() const;
117
118
/// @brief get current selected TAZs
119
const std::vector<GNETAZ*>& getSelectedTAZs() const;
120
121
/// @brief add route
122
bool addRoute(GNEDemandElement* route);
123
124
/// @brief get route
125
GNEDemandElement* getRoute() const;
126
127
/// @brief get path route
128
const std::vector<Path>& getPath() const;
129
130
/// @brief draw candidate edges with special color (Only for candidates, special and conflicted)
131
bool drawCandidateEdgesWithSpecialColor() const;
132
133
/// @brief update junction colors
134
void updateJunctionColors();
135
136
/// @brief update edge colors
137
void updateEdgeColors();
138
139
/// @brief clear junction colors
140
void clearJunctionColors();
141
142
/// @brief clear edge colors
143
void clearEdgeColors();
144
145
/// @brief draw temporal route
146
void drawTemporalRoute(const GUIVisualizationSettings& s) const;
147
148
/// @brief create path
149
bool createPath(const bool useLastRoute);
150
151
/// @brief abort path creation
152
void abortPathCreation();
153
154
/// @brief remove path element
155
void removeLastElement();
156
157
/// @name FOX-callbacks
158
/// @{
159
/// @brief Called when the user click over button "Finish route creation"
160
long onCmdCreatePath(FXObject*, FXSelector, void*);
161
162
/// @brief Called when the user click over button "Use last route"
163
long onCmdUseLastRoute(FXObject*, FXSelector, void*);
164
165
/// @brief Called when update button "Use last route"
166
long onUpdUseLastRoute(FXObject*, FXSelector, void*);
167
168
/// @brief Called when the user click over button "Abort route creation"
169
long onCmdAbortPathCreation(FXObject*, FXSelector, void*);
170
171
/// @brief Called when the user click over button "Remove las inserted edge"
172
long onCmdRemoveLastElement(FXObject*, FXSelector, void*);
173
174
/// @brief Called when the user click over check button "show candidate edges"
175
long onCmdShowCandidateEdges(FXObject*, FXSelector, void*);
176
/// @}
177
178
protected:
179
FOX_CONSTRUCTOR(GNEPathCreator)
180
181
// @brief creation mode
182
enum Mode {
183
ONLY_FROMTO = 1 << 0, // Path only had two elements (first and last)
184
CONSECUTIVE_EDGES = 1 << 1, // Path's edges are consecutives
185
NONCONSECUTIVE_EDGES = 1 << 2, // Path's edges aren't consecutives
186
START_EDGE = 1 << 3, // Path begins in edge
187
END_EDGE = 1 << 4, // Path ends in edge
188
START_JUNCTION = 1 << 5, // Path begins in junction
189
END_JUNCTION = 1 << 6, // Path ends in junction
190
START_TAZ = 1 << 7, // Path begins in TAZ
191
END_TAZ = 1 << 8, // Path ends in TAZ
192
ROUTE = 1 << 9, // Path is over an existent edge
193
SHOW_CANDIDATE_EDGES = 1 << 10, // Show candidate edges
194
SHOW_CANDIDATE_JUNCTIONS = 1 << 11, // show candidate junctions
195
};
196
197
/// @brief update InfoRouteLabel
198
void updateInfoRouteLabel();
199
200
/// @brief clear edges (and restore colors)
201
void clearPath();
202
203
/// @brief recalculate path
204
void recalculatePath();
205
206
/// @brief set special candidates (This function will be called recursively)
207
void setSpecialCandidates(GNEEdge* originEdge);
208
209
/// @brief set edgereachability (This function will be called recursively)
210
void setPossibleCandidates(GNEEdge* originEdge, const SUMOVehicleClass vClass);
211
212
/// @brief current frame parent
213
GNEFrame* myFrameParent;
214
215
/// @brief path manager
216
GNEPathManager* myPathManager;
217
218
/// @brief current vClass
219
SUMOVehicleClass myVClass;
220
221
/// @brief current creation mode
222
int myCreationMode;
223
224
/// @brief vector with selected junctions
225
std::vector<GNEJunction*> mySelectedJunctions;
226
227
/// @brief vector with selected TAZs
228
std::vector<GNETAZ*> mySelectedTAZs;
229
230
/// @brief vector with selected edges
231
std::vector<GNEEdge*> mySelectedEdges;
232
233
/// @brief route (usually a busStop)
234
GNEDemandElement* myRoute;
235
236
/// @brief vector with current path
237
std::vector<Path> myPath;
238
239
/// @brief label with route info
240
FXLabel* myInfoRouteLabel;
241
242
/// @brief button for use last inserted route
243
FXButton* myUseLastRoute;
244
245
/// @brief button for finish route creation
246
FXButton* myFinishCreationButton;
247
248
/// @brief button for abort route creation
249
FXButton* myAbortCreationButton;
250
251
/// @brief button for removing last inserted element
252
FXButton* myRemoveLastInsertedElement;
253
254
/// @brief CheckBox for show candidate edges
255
FXCheckButton* myShowCandidateEdges;
256
257
/// @brief label for shift information
258
FXLabel* myShiftLabel;
259
260
/// @brief label for control information
261
FXLabel* myControlLabel;
262
263
/// @brief label for backSpace information
264
FXLabel* myBackSpaceLabel;
265
private:
266
/// @brief Invalidated copy constructor.
267
GNEPathCreator(GNEPathCreator*) = delete;
268
269
/// @brief Invalidated assignment operator.
270
GNEPathCreator& operator=(GNEPathCreator*) = delete;
271
};
272
273