Skip to content

Commit

Permalink
Updated GNEDemandElementPlan. Refs #13784
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Sep 7, 2023
1 parent 5328473 commit 55c3a06
Show file tree
Hide file tree
Showing 21 changed files with 697 additions and 564 deletions.
4 changes: 1 addition & 3 deletions src/netedit/elements/demand/GNEContainer.h
Expand Up @@ -27,9 +27,7 @@
// ===========================================================================
// class definitions
// ===========================================================================
/**
* @class GNEContainer
*/

class GNEContainer : public GNEDemandElement, public GNEDemandElementFlow {

public:
Expand Down
468 changes: 0 additions & 468 deletions src/netedit/elements/demand/GNEDemandElement.cpp

Large diffs are not rendered by default.

32 changes: 1 addition & 31 deletions src/netedit/elements/demand/GNEDemandElement.h
Expand Up @@ -48,16 +48,13 @@ class GNEJunction;
// class definitions
// ===========================================================================

/**
* @class GNEDemandElement
* @brief An Element which don't belong to GNENet but has influence in the simulation
*/
class GNEDemandElement : public GNEPathManager::PathElement, public GNEHierarchicalElement, public GNEMoveElement, public GNEDemandElementDistribution {

public:
/// @brief friend declaration (needed for vTypes)
friend class GNERouteHandler;
friend class GNEDemandElementFlow;
friend class GNEDemandElementPlan;

/// @brief enum class for demandElement problems
enum class Problem {
Expand Down Expand Up @@ -352,33 +349,6 @@ class GNEDemandElement : public GNEPathManager::PathElement, public GNEHierarchi
/// @brief get route parent (always the second parent demand element)
GNEDemandElement* getRouteParent() const;

/// @name Only for person plans
/// @{
/// @brief check if person plan can be drawn
bool drawPersonPlan() const;

/// @brief check if container plan can be drawn
bool drawContainerPlan() const;

/// @brief draw person plan partial lane
void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront,
const double personPlanWidth, const RGBColor& personPlanColor) const;

/// @brief draw person plan partial junction
void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment,
const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const;

/// @brief check if person plan is valid
Problem isPersonPlanValid() const;

/// @brief get person plan problem
std::string getPersonPlanProblem() const;

/// @brief person plans arrival position radius
static const double myPersonPlanArrivalPositionDiameter;

/// @}

/// @brief draw line between junctions
void drawJunctionLine(const GNEDemandElement* element) const;

Expand Down
4 changes: 0 additions & 4 deletions src/netedit/elements/demand/GNEDemandElementDistribution.h
Expand Up @@ -32,10 +32,6 @@ class GNEUndoList;
// class definitions
// ===========================================================================

/**
* @class GNEDemandElementDistribution
* @brief Module used for represent attribute distributions
*/
class GNEDemandElementDistribution {

/// @brief friend declaration
Expand Down
526 changes: 526 additions & 0 deletions src/netedit/elements/demand/GNEDemandElementPlan.cpp

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions src/netedit/elements/demand/GNEDemandElementPlan.h
@@ -0,0 +1,77 @@
/****************************************************************************/
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0/
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License 2.0 are satisfied: GNU General Public License, version 2
// or later which is available at
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
/****************************************************************************/
/// @file GNEDemandElementPlan.h
/// @author Pablo Alvarez Lopez
/// @date Sep 2023
///
// An auxiliar, asbtract class for plan elements
/****************************************************************************/
#pragma once
#include <config.h>

#include <utils/geom/Position.h>
#include <utils/xml/SUMOXMLDefinitions.h>
#include <utils/vehicle/SUMOVehicleParameter.h>

// ===========================================================================
// class declaration
// ===========================================================================

class SUMOVehicleParameter;
class GNEDemandElement;

// ===========================================================================
// class definitions
// ===========================================================================

class GNEDemandElementPlan {

protected:
/// @brief constructor
GNEDemandElementPlan(const GNEDemandElement* planElement);

/// @brief check if person plan can be drawn
bool drawPersonPlan() const;

/// @brief check if container plan can be drawn
bool drawContainerPlan() const;

/// @brief draw person plan partial lane
void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront,
const double personPlanWidth, const RGBColor& personPlanColor) const;

/// @brief draw person plan partial junction
void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment,
const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const;

/// @brief check if person plan is valid
GNEDemandElement::Problem isPersonPlanValid() const;

/// @brief get person plan problem
std::string getPersonPlanProblem() const;

protected:
/// @brief person plans arrival position radius
static const double myPersonPlanArrivalPositionDiameter;

private:
/// @brief pointer to plan element
const GNEDemandElement* myPlanElement;

/// @brief Invalidated copy constructor.
GNEDemandElementPlan(const GNEDemandElementPlan&) = delete;

/// @brief Invalidated assignment operator.
GNEDemandElementPlan& operator=(const GNEDemandElementPlan&) = delete;
};
4 changes: 1 addition & 3 deletions src/netedit/elements/demand/GNEPerson.h
Expand Up @@ -27,9 +27,7 @@
// ===========================================================================
// class definitions
// ===========================================================================
/**
* @class GNEPerson
*/

class GNEPerson : public GNEDemandElement, public GNEDemandElementFlow {

public:
Expand Down
5 changes: 5 additions & 0 deletions src/netedit/elements/demand/GNEPersonTrip.cpp
Expand Up @@ -38,6 +38,7 @@
GNEPersonTrip::GNEPersonTrip(SumoXMLTag tag, GNENet* net) :
GNEDemandElement("", net, GLO_PERSONTRIP, tag, GUIIconSubSys::getIcon(GUIIcon::PERSONTRIP_FROMTO),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}),
GNEDemandElementPlan(this),
myArrivalPosition(0) {
// reset default values
resetDefaultValues();
Expand All @@ -49,6 +50,7 @@ GNEPersonTrip::GNEPersonTrip(GNENet* net, GNEDemandElement* personParent, GNEEdg
const std::vector<std::string>& lines) :
GNEDemandElement(personParent, net, GLO_PERSONTRIP, GNE_TAG_PERSONTRIP_EDGE, GUIIconSubSys::getIcon(GUIIcon::PERSONTRIP_FROMTO),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {personParent}, {}),
GNEDemandElementPlan(this),
myArrivalPosition(arrivalPosition),
myVTypes(types),
myModes(modes),
Expand All @@ -62,6 +64,7 @@ GNEPersonTrip::GNEPersonTrip(bool isTrain, GNENet* net, GNEDemandElement* person
GNEDemandElement(personParent, net, GLO_PERSONTRIP, isTrain ? GNE_TAG_PERSONTRIP_TRAINSTOP : GNE_TAG_PERSONTRIP_BUSSTOP,
GUIIconSubSys::getIcon(isTrain ? GUIIcon::PERSONTRIP_TRAINSTOP : GUIIcon::PERSONTRIP_BUSSTOP),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge}, {}, {toStoppingPlace}, {personParent}, {}),
GNEDemandElementPlan(this),
myArrivalPosition(arrivalPosition),
myVTypes(types),
myModes(modes),
Expand All @@ -74,6 +77,7 @@ GNEPersonTrip::GNEPersonTrip(GNENet* net, GNEDemandElement* personParent, GNEJun
const std::vector<std::string>& lines) :
GNEDemandElement(personParent, net, GLO_PERSONTRIP, GNE_TAG_PERSONTRIP_JUNCTIONS, GUIIconSubSys::getIcon(GUIIcon::PERSONTRIP_JUNCTIONS),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {fromJunction, toJunction}, {}, {}, {}, {personParent}, {}),
GNEDemandElementPlan(this),
myArrivalPosition(arrivalPosition),
myVTypes(types),
myModes(modes),
Expand All @@ -86,6 +90,7 @@ GNEPersonTrip::GNEPersonTrip(GNENet* net, GNEDemandElement* personParent, GNEAdd
const std::vector<std::string>& lines) :
GNEDemandElement(personParent, net, GLO_PERSONTRIP, GNE_TAG_PERSONTRIP_TAZS, GUIIconSubSys::getIcon(GUIIcon::PERSONTRIP_JUNCTIONS),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {fromTAZ, toTAZ}, {personParent}, {}),
GNEDemandElementPlan(this),
myArrivalPosition(arrivalPosition),
myVTypes(types),
myModes(modes),
Expand Down
12 changes: 8 additions & 4 deletions src/netedit/elements/demand/GNEPersonTrip.h
Expand Up @@ -19,21 +19,25 @@
/****************************************************************************/
#pragma once
#include <config.h>
#include "GNEDemandElement.h"
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>

#include "GNEDemandElement.h"
#include "GNEDemandElementPlan.h"

// ===========================================================================
// class declarations
// ===========================================================================

class GNEEdge;
class GNEConnection;
class GNEVehicle;


// ===========================================================================
// class definitions
// ===========================================================================
class GNEPersonTrip : public GNEDemandElement, public Parameterised {
// ====================================================================

class GNEPersonTrip : public GNEDemandElement, public Parameterised, public GNEDemandElementPlan {

public:
/// @brief default constructor
GNEPersonTrip(SumoXMLTag tag, GNENet* net);
Expand Down
13 changes: 8 additions & 5 deletions src/netedit/elements/demand/GNERide.cpp
Expand Up @@ -36,7 +36,8 @@
GNERide::GNERide(SumoXMLTag tag, GNENet* net) :
GNEDemandElement("", net, GLO_RIDE, tag, GUIIconSubSys::getIcon(GUIIcon::RIDE_FROMTO),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}),
myArrivalPosition(0) {
GNEDemandElementPlan(this),
myArrivalPosition(0) {
// reset default values
resetDefaultValues();
}
Expand All @@ -46,8 +47,9 @@ GNERide::GNERide(GNENet* net, GNEDemandElement* personParent, GNEEdge* fromEdge,
double arrivalPosition, const std::vector<std::string>& lines) :
GNEDemandElement(personParent, net, GLO_RIDE, GNE_TAG_RIDE_EDGE, GUIIconSubSys::getIcon(GUIIcon::RIDE_FROMTO),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {personParent}, {}),
myArrivalPosition(arrivalPosition),
myLines(lines) {
GNEDemandElementPlan(this),
myArrivalPosition(arrivalPosition),
myLines(lines) {
}


Expand All @@ -56,8 +58,9 @@ GNERide::GNERide(bool isTrain, GNENet* net, GNEDemandElement* personParent, GNEE
GNEDemandElement(personParent, net, GLO_RIDE, isTrain ? GNE_TAG_RIDE_TRAINSTOP : GNE_TAG_RIDE_BUSSTOP,
GUIIconSubSys::getIcon(isTrain ? GUIIcon::RIDE_TRAINSTOP : GUIIcon::RIDE_BUSSTOP),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge}, {}, {toBusStop}, {personParent}, {}),
myArrivalPosition(arrivalPosition),
myLines(lines) {
GNEDemandElementPlan(this),
myArrivalPosition(arrivalPosition),
myLines(lines) {
}


Expand Down
7 changes: 5 additions & 2 deletions src/netedit/elements/demand/GNERide.h
Expand Up @@ -19,12 +19,15 @@
/****************************************************************************/
#pragma once
#include <config.h>
#include "GNEDemandElement.h"
#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>

#include "GNEDemandElement.h"
#include "GNEDemandElementPlan.h"

// ===========================================================================
// class declarations
// ===========================================================================

class GNEEdge;
class GNEConnection;
class GNEVehicle;
Expand All @@ -33,7 +36,7 @@ class GNEVehicle;
// class definitions
// ===========================================================================

class GNERide : public GNEDemandElement, public Parameterised {
class GNERide : public GNEDemandElement, public Parameterised, public GNEDemandElementPlan {

public:
/// @brief default constructor
Expand Down
1 change: 1 addition & 0 deletions src/netedit/elements/demand/GNERoute.h
Expand Up @@ -28,6 +28,7 @@
// ===========================================================================
// class declarations
// ===========================================================================

class GNEEdge;
class GNEConnection;
class GNEVehicle;
Expand Down
18 changes: 11 additions & 7 deletions src/netedit/elements/demand/GNEStop.cpp
Expand Up @@ -42,7 +42,8 @@
GNEStop::GNEStop(SumoXMLTag tag, GNENet* net) :
GNEDemandElement("", net, GLO_STOP, tag, GUIIconSubSys::getIcon(GUIIcon::STOP),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}),
myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
GNEDemandElementPlan(this),
myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
// reset default values
resetDefaultValues();
// enable parking for stops in parkin)gAreas
Expand All @@ -65,8 +66,9 @@ myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
GNEStop::GNEStop(SumoXMLTag tag, GNENet* net, GNEDemandElement* stopParent, GNEAdditional* stoppingPlace, const SUMOVehicleParameter::Stop& stopParameter) :
GNEDemandElement(stopParent, net, GLO_STOP, tag, GUIIconSubSys::getIcon(GUIIcon::STOP),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {stoppingPlace}, {stopParent}, {}),
SUMOVehicleParameter::Stop(stopParameter),
myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
SUMOVehicleParameter::Stop(stopParameter),
GNEDemandElementPlan(this),
myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
// enable parking for stops in parkingAreas
if ((tag == GNE_TAG_STOP_PARKINGAREA) || (tag == GNE_TAG_WAYPOINT_PARKINGAREA)) {
parametersSet |= STOP_PARKING_SET;
Expand All @@ -91,8 +93,9 @@ myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
GNEStop::GNEStop(SumoXMLTag tag, GNENet* net, GNEDemandElement* stopParent, GNELane* lane, const SUMOVehicleParameter::Stop& stopParameter) :
GNEDemandElement(stopParent, net, GLO_STOP, tag, GUIIconSubSys::getIcon(GUIIcon::STOP),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {lane}, {}, {stopParent}, {}),
SUMOVehicleParameter::Stop(stopParameter),
myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
SUMOVehicleParameter::Stop(stopParameter),
GNEDemandElementPlan(this),
myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
// set parking
if (parametersSet & STOP_PARKING_SET) {
parking = ParkingType::OFFROAD;
Expand All @@ -113,8 +116,9 @@ myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
GNEStop::GNEStop(SumoXMLTag tag, GNENet* net, GNEDemandElement* stopParent, GNEEdge* edge, const SUMOVehicleParameter::Stop& stopParameter) :
GNEDemandElement(stopParent, net, GLO_STOP, tag, GUIIconSubSys::getIcon(GUIIcon::STOP),
GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {edge}, {}, {}, {stopParent}, {}),
SUMOVehicleParameter::Stop(stopParameter),
myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
SUMOVehicleParameter::Stop(stopParameter),
GNEDemandElementPlan(this),
myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) {
// enable parking for stops in parkingAreas
if ((tag == GNE_TAG_STOP_PARKINGAREA) || (tag == GNE_TAG_WAYPOINT_PARKINGAREA)) {
parametersSet |= STOP_PARKING_SET;
Expand Down
7 changes: 3 additions & 4 deletions src/netedit/elements/demand/GNEStop.h
Expand Up @@ -21,14 +21,13 @@
#include <config.h>

#include "GNEDemandElement.h"
#include "GNEDemandElementPlan.h"

// ===========================================================================
// class definitions
// ===========================================================================
/**
* @class GNEStop
*/
class GNEStop : public GNEDemandElement, public SUMOVehicleParameter::Stop {

class GNEStop : public GNEDemandElement, public SUMOVehicleParameter::Stop, public GNEDemandElementPlan {

public:
/// @brief default constructor
Expand Down

0 comments on commit 55c3a06

Please sign in to comment.