Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEDemandElement.h
Go to the documentation of this file.
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/****************************************************************************/
18// A abstract class for demand elements
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32
34
35// ===========================================================================
36// class definitions
37// ===========================================================================
38
40
41public:
43 friend class GNERouteHandler;
46
48 enum class Problem {
49 OK, // There is no problem
50 INVALID_ELEMENT, // Element is invalid (for example, a route without edges)
51 INVALID_PATH, // Path (route, trip... ) is not valid (i.e is empty)
52 DISCONNECTED_PLAN, // Plan element (person, containers) is not connected with the previous or next plan
53 INVALID_STOPPOSITION, // StopPosition is invalid (only used in stops over edges or lanes
54 STOP_DOWNSTREAM, // Stops don't follow their route parent
55 REPEATEDROUTE_DISCONNECTED, // Repeated route is disconnected
56 NO_PLANS // Person or container doesn't have a plan
57 };
58
63
70 GNEDemandElement(const std::string& id, GNENet* net, SumoXMLTag tag, FileBucket* fileBucket);
71
76 GNEDemandElement(GNEDemandElement* demandElementParent, SumoXMLTag tag);
77
79 virtual ~GNEDemandElement();
80
83
86
88 GUIGlObject* getGUIGlObject() override;
89
91 const GUIGlObject* getGUIGlObject() const override;
92
94
96 FileBucket* getFileBucket() const override;
97
99 void changeFileBucket(FileBucket* fileBucket);
100
103
106
109
111 void updateDemandElementGeometry(const GNELane* lane, const double posOverLane);
112
114 void updateDemandElementStackLabel(const int stack);
115
117 void updateDemandElementSpreadGeometry(const GNELane* lane, const double posOverLane);
118
121
123 virtual SUMOVehicleClass getVClass() const = 0;
124
126 virtual const RGBColor& getColor() const = 0;
127
129
132
136 virtual void writeDemandElement(OutputDevice& device) const = 0;
137
139 virtual Problem isDemandElementValid() const = 0;
140
142 virtual std::string getDemandElementProblem() const = 0;
143
145 virtual void fixDemandElementProblem() = 0;
146
148
153 virtual void openDemandElementDialog();
154
157
159 virtual Position getPositionInView() const = 0;
160
162 virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
163
166
168
171
173 bool checkDrawFromContour() const override;
174
176 bool checkDrawToContour() const override;
177
179 bool checkDrawRelatedContour() const override;
180
182 bool checkDrawOverContour() const override;
183
185 bool checkDrawDeleteContour() const override;
186
188 bool checkDrawDeleteContourSmall() const override;
189
191 bool checkDrawSelectContour() const override;
192
194 bool checkDrawMoveContour() const override;
195
197
200
209
218
220 bool isGLObjectLocked() const override;
221
223 void markAsFrontElement() override;
224
226 void deleteGLObject() override;
227
229 void selectGLObject() override;
230
232 void updateGLObject() override;
233
235
238
239 /* @brief method for getting the Attribute of an XML key in position format
240 * @param[in] key The attribute key
241 * @return position with the value associated to key
242 */
243 Position getAttributePosition(SumoXMLAttr key) const override;
244
245 /* @brief method for getting the Attribute of an XML key in positionVector format
246 * @param[in] key The attribute key
247 * @return positionVector with the value associated to key
248 */
250
252
255
257 bool isPathElementSelected() const override;
258
260
262 std::vector<GNEDemandElement*> getInvalidStops() const;
263
264protected:
267
270
273
275 bool isValidDemandElementID(const std::string& value) const;
276
278 bool isValidDemandElementID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;
279
281 void setDemandElementID(const std::string& newID);
282
285
288
290 void drawJunctionLine(const GNEDemandElement* element) const;
291
293 void drawStackLabel(const int number, const std::string& element, const Position& position, const double rotation,
294 const double width, const double length, const double exaggeration) const;
295
298
300 void replaceParentEdges(const std::string& value);
301
303 void replaceFirstParentLane(const std::string& value);
304
306 void replaceFirstParentJunction(const std::string& value);
307
309 void replaceLastParentJunction(const std::string& value);
310
312 void replaceFirstParentEdge(const std::string& value);
313
315 void replaceLastParentEdge(const std::string& value);
316
318 void replaceFirstParentAdditional(SumoXMLTag tag, const std::string& value);
319
321 void replaceLastParentAdditional(SumoXMLTag tag, const std::string& value);
322
324 void replaceDemandElementParent(const std::vector<SumoXMLTag> tags, const std::string& value, const int parentIndex);
325
327
330
333 edge(edge_),
334 stops({stop}) {}
335
337 const GNEEdge* edge = nullptr;
338
340 std::vector<GNEDemandElement*> stops;
341
343 int stopIndex = -1;
344
345 private:
348 };
349
351 std::vector<EdgeStopIndex> getEdgeStopIndex() const;
352
354 RGBColor getColorByScheme(const GUIColorer& c, const SUMOVehicleParameter* parameters) const;
355
358
361
362private:
366 virtual bool checkChildDemandElementRestriction() const;
367
370
373};
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
bool checkDrawFromContour() const override
check if draw from contour (green)
bool isGLObjectLocked() const override
check if element is locked
GNEDemandElement(const GNEDemandElement &)=delete
Invalidated copy constructor.
Position getAttributePosition(SumoXMLAttr key) const override
std::vector< GNEDemandElement * > getInvalidStops() const
get invalid stops
virtual SUMOVehicleClass getVClass() const =0
obtain VClass related with this demand element
void updateDemandElementGeometry(const GNELane *lane, const double posOverLane)
update element stacked geometry (stacked)
void drawStackLabel(const int number, const std::string &element, const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw stack label
GNEHierarchicalElement * getHierarchicalElement() override
methods to retrieve the elements linked to this GNEDemandElement
GNEDemandElement & operator=(const GNEDemandElement &)=delete
Invalidated assignment operator.
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
void changeFileBucket(FileBucket *fileBucket)
change filebucket manually (used only during calibratorFlows creation)
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void selectGLObject() override
select element
GNEDemandElement * getNextChildDemandElement(const GNEDemandElement *demandElement) const
get next child demand element to the given demand element
void updateDemandElementStackLabel(const int stack)
update stack label
virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)=0
split geometry
bool checkDrawDeleteContour() const override
check if draw delete contour (pink/white)
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
virtual const RGBColor & getColor() const =0
get color
bool isPathElementSelected() const override
check if path element is selected
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
virtual Problem isDemandElementValid() const =0
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
void replaceFirstParentAdditional(SumoXMLTag tag, const std::string &value)
replace the first parent additional
virtual void writeDemandElement(OutputDevice &device) const =0
write demand element element into a xml file
GNEDemandElement * getRouteParent() const
get route parent (always the second parent demand element)
virtual std::string getDemandElementProblem() const =0
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
void setDemandElementID(const std::string &newID)
set demand element id
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
bool checkDrawMoveContour() const override
check if draw move contour (red)
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void updateGLObject() override
update GLObject (geometry, ID, etc.)
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
std::vector< EdgeStopIndex > getEdgeStopIndex() const
get edgeStopIndex
bool checkDrawSelectContour() const override
check if draw select contour (blue)
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
void replaceDemandElementParent(const std::vector< SumoXMLTag > tags, const std::string &value, const int parentIndex)
replace demand element parent
void deleteGLObject() override
delete element
void replaceParentEdges(const std::string &value)
all edges
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
FileBucket * getFileBucket() const override
get reference to fileBucket in which save this AC
void updateDemandElementSpreadGeometry(const GNELane *lane, const double posOverLane)
update element spread geometry
virtual Position getPositionInView() const =0
Returns position of demand element in view.
RGBColor getColorByScheme(const GUIColorer &c, const SUMOVehicleParameter *parameters) const
get color by scheme (used by vehicles, persons and containers)
const GUIGeometry & getDemandElementGeometry()
get demand element geometry (stacked)
virtual bool checkChildDemandElementRestriction() const
check restriction with the number of children
GUIGlObject * getGUIGlObject() override
get GUIGlObject associated with this GNEDemandElement
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
Problem
enum class for demandElement problems
GNEDemandElement * getPreviousChildDemandElement(const GNEDemandElement *demandElement) const
get previous child demand element to the given demand element
void replaceFirstParentLane(const std::string &value)
replace the first parent lane
bool checkDrawDeleteContourSmall() const override
check if draw delete contour small (pink/white)
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
virtual ~GNEDemandElement()
Destructor.
virtual void openDemandElementDialog()
open DemandElement Dialog
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
bool checkDrawToContour() const override
check if draw from contour (magenta)
void markAsFrontElement() override
mark element as front element
bool checkDrawOverContour() const override
check if draw over contour (orange)
virtual void fixDemandElementProblem()=0
fix demand element problem (by default throw an exception, has to be reimplemented in children)
The popup menu of a globject.
A window containing a gl-object's parameter.
Static storage of an output device and its base (abstract) implementation.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Structure representing possible vehicle parameter.
auxiliar struct used for calculate pathStopIndex
int stopIndex
stopIndex (-1 menans out of route)
EdgeStopIndex(GNEEdge *edge_, GNEDemandElement *stop)
constructor
EdgeStopIndex()
default constructor (disabled)
const GNEEdge * edge
edge (obtained from segment)
std::vector< GNEDemandElement * > stops
list of stops placed in the edge