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