Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/frames/GNEPlanCreator.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 GNEPlanCreator.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 "GNEPlanSelector.h"
24
25
// ===========================================================================
26
// class declaration
27
// ===========================================================================
28
29
class GNEFrame;
30
class GNEPathManager;
31
32
// ===========================================================================
33
// class definitions
34
// ===========================================================================
35
36
class GNEPlanCreator : public MFXGroupBoxModule {
37
/// @brief FOX-declaration
38
FXDECLARE(GNEPlanCreator)
39
40
public:
41
/// @brief class for path
42
class PlanPath {
43
44
public:
45
/// @brief constructor for from-to edges
46
PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEEdge* toEdge);
47
48
/// @brief constructor for from edge and to junction
49
PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEJunction* toJunction);
50
51
/// @brief constructor for from junction and to edge
52
PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEEdge* toEdge);
53
54
/// @brief constructor for from-to edges
55
PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEJunction* toJunction);
56
57
/// @brief get sub path
58
const std::vector<GNEEdge*>& getSubPath() const;
59
60
/// @brief check if current path is conflict due vClass
61
bool isConflictVClass() const;
62
63
/// @brief check if current path is conflict due is disconnected
64
bool isConflictDisconnected() const;
65
66
protected:
67
/// @brief sub path
68
std::vector<GNEEdge*> mySubPath;
69
70
/// @brief flag to mark this path as conflicted
71
bool myConflictVClass;
72
73
/// @brief flag to mark this path as disconnected
74
bool myConflictDisconnected;
75
76
private:
77
/// @brief default constructor
78
PlanPath();
79
80
/// @brief Invalidated copy constructor.
81
PlanPath(PlanPath*) = delete;
82
83
/// @brief Invalidated assignment operator.
84
PlanPath& operator=(PlanPath*) = delete;
85
};
86
87
/// @brief default constructor
88
GNEPlanCreator(GNEFrame* frameParent, GNEPathManager* pathManager);
89
90
/// @brief destructor
91
~GNEPlanCreator();
92
93
/// @brief check if plan can be created
94
bool planCanBeCreated(const GNEDemandElement* planTemplate) const;
95
96
/// @brief show plan creator for the given tag property
97
void showPlanCreatorModule(const GNEPlanSelector* planSelector, const GNEDemandElement* previousPlan);
98
99
/// @brief show GNEPlanCreator
100
void hidePathCreatorModule();
101
102
/// @brief add route
103
bool addRoute(GNEDemandElement* route);
104
105
/// @brief add edge (clicking over lanes)
106
bool addEdge(GNELane* lane);
107
108
/// @brief add junction
109
bool addJunction(GNEJunction* junction);
110
111
/// @brief add TAZ
112
bool addTAZ(GNEAdditional* taz);
113
114
/// @brief add from to stoppingPlace
115
bool addStoppingPlace(GNEAdditional* stoppingPlace);
116
117
/// @brief get plan parameters
118
const CommonXMLStructure::PlanParameters& getPlanParameteres() const;
119
120
/// @brief get clicked position over lane
121
double getClickedPositionOverLane() const;
122
123
/// @brief get path route
124
const std::vector<PlanPath>& getPath() const;
125
126
/// @brief draw temporal route
127
void drawTemporalRoute(const GUIVisualizationSettings& s) const;
128
129
/// @brief abort path creation
130
void abortPathCreation();
131
132
/// @brief remove path element
133
void removeLastElement();
134
135
/// @name FOX-callbacks
136
/// @{
137
/// @brief Called when the user click over button "Finish route creation"
138
long onCmdCreatePath(FXObject*, FXSelector, void*);
139
140
/// @brief Called when the user click over button "Use last route"
141
long onCmdUseLastRoute(FXObject*, FXSelector, void*);
142
143
/// @brief Called when update button "Use last route"
144
long onUpdUseLastRoute(FXObject*, FXSelector, void*);
145
146
/// @brief Called when the user click over button "Abort route creation"
147
long onCmdAbortPathCreation(FXObject*, FXSelector, void*);
148
149
/// @brief Called when the user click over button "Remove las inserted edge"
150
long onCmdRemoveLastElement(FXObject*, FXSelector, void*);
151
/// @}
152
153
protected:
154
/// @brief FOX need this
155
FOX_CONSTRUCTOR(GNEPlanCreator)
156
157
// @brief planParents
158
enum PlanParents {
159
CONSECUTIVE_EDGES = 1 << 0, // Plan is placed over consecutive edges
160
ROUTE = 1 << 1, // Plan is placed over a single route
161
EDGE = 1 << 2, // Plan is placed over a single edge
162
STOPPINGPLACE = 1 << 3, // Plan is placed over a stoppingPlace
163
START_EDGE = 1 << 4, // Plan begins in edge
164
START_TAZ = 1 << 5, // Plan begins in TAZ
165
START_JUNCTION = 1 << 6, // Plan begins in junction
166
START_STOPPINGPLACE = 1 << 7, // Plan begins in busStop
167
END_EDGE = 1 << 8, // Plan ends in edge
168
END_TAZ = 1 << 9, // Plan ends in TAZ
169
END_JUNCTION = 1 << 10, // Plan ends in junction
170
END_STOPPINGPLACE = 1 << 11, // Plan ends in stoppingPlace
171
};
172
173
/// @brief clear edges
174
void clearPath();
175
176
/// @brief recalculate path
177
void recalculatePath();
178
179
/// @brief current frame parent
180
GNEFrame* myFrameParent;
181
182
/// @brief path manager used in this plan creator
183
GNEPathManager* myPathManager;
184
185
/// @brief current vClass
186
SUMOVehicleClass myVClass;
187
188
/// @brief allowed plan parents
189
int myPlanParents;
190
191
/// @brief previous person plan element
192
const GNEDemandElement* myPreviousPlanElement = nullptr;
193
194
/// @brief plan parameters
195
CommonXMLStructure::PlanParameters myPlanParameteres;
196
197
/// @brief clicked position over lane
198
double myClickedPositionOverLane = 0;
199
200
/// @brief vector with current path
201
std::vector<PlanPath> myPath;
202
203
/// @brief button for use last inserted route
204
FXButton* myUseLastRoute;
205
206
/// @brief button for finish route creation
207
FXButton* myFinishCreationButton;
208
209
/// @brief button for abort route creation
210
FXButton* myAbortCreationButton;
211
212
/// @brief button for removing last inserted element
213
FXButton* myRemoveLastInsertedElement;
214
215
/// @brief info label
216
FXLabel* myInfoLabel;
217
218
private:
219
/// @brief get number of selected elements
220
int getNumberOfSelectedElements() const;
221
222
/// @brief check if enable remove last item button
223
void updateRemoveLastItemButton() const;
224
225
/// @brief show creation buttons
226
void showCreationButtons();
227
228
/// @brief hide creation buttons
229
void hideCreationButtons();
230
231
/// @brief update info label
232
void updateInfoLabel();
233
234
/// @brief add edge
235
bool addSingleEdge(GNELane* lane);
236
237
/// @brief add stoppingPlace
238
bool addSingleStoppingPlace(GNEAdditional* stoppingPlace);
239
240
/// @brief add consecutive edge
241
bool addConsecutiveEdge(GNEEdge* edge);
242
243
/// @brief add junction
244
bool addFromToJunction(GNEJunction* junction);
245
246
/// @brief add TAZ
247
bool addFromToTAZ(GNEAdditional* taz);
248
249
/// @brief add from to edge
250
bool addFromToEdge(GNEEdge* edge);
251
252
/// @brief add from to stoppingPlace
253
bool addFromToStoppingPlace(GNEAdditional* stoppingPlace);
254
255
/// @brief Invalidated copy constructor.
256
GNEPlanCreator(GNEPlanCreator*) = delete;
257
258
/// @brief Invalidated assignment operator.
259
GNEPlanCreator& operator=(GNEPlanCreator*) = delete;
260
};
261
262