Skip to content

Commit

Permalink
Added new constructors for trainStops. Fixed #15472
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Sep 12, 2024
1 parent a85825c commit c515df6
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/netedit/elements/additional/GNEAdditionalHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ GNEAdditionalHandler::buildBusStop(const CommonXMLStructure::SumoBaseObject* sum
writeErrorInvalidNegativeValue(SUMO_TAG_BUS_STOP, id, SUMO_ATTR_PARKING_LENGTH);
} else {
// build busStop
GNEAdditional* busStop = new GNEBusStop(SUMO_TAG_BUS_STOP, id, lane, myNet, startPos, endPos, name, lines, personCapacity,
parkingLength, color, friendlyPosition, parameters);
GNEAdditional* busStop = GNEBusStop::buildBusStop(id, lane, myNet, startPos, endPos, name, lines, personCapacity,
parkingLength, color, friendlyPosition, parameters);
// insert depending of allowUndoRedo
if (myAllowUndoRedo) {
myNet->getViewNet()->getUndoList()->begin(busStop, TL("add bus stop '") + id + "'");
Expand Down Expand Up @@ -143,8 +143,8 @@ GNEAdditionalHandler::buildTrainStop(const CommonXMLStructure::SumoBaseObject* s
writeErrorInvalidNegativeValue(SUMO_TAG_TRAIN_STOP, id, SUMO_ATTR_PARKING_LENGTH);
} else {
// build trainStop
GNEAdditional* trainStop = new GNEBusStop(SUMO_TAG_TRAIN_STOP, id, lane, myNet, startPos, endPos, name, lines, personCapacity,
parkingLength, color, friendlyPosition, parameters);
GNEAdditional* trainStop = GNEBusStop::buildTrainStop(id, lane, myNet, startPos, endPos, name, lines, personCapacity,
parkingLength, color, friendlyPosition, parameters);
// insert depending of allowUndoRedo
if (myAllowUndoRedo) {
myNet->getViewNet()->getUndoList()->begin(trainStop, TL("add train stop '") + id + "'");
Expand Down
62 changes: 47 additions & 15 deletions src/netedit/elements/additional/GNEBusStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,35 @@
// method definitions
// ===========================================================================

GNEBusStop::GNEBusStop(SumoXMLTag tag, GNENet* net) :
GNEStoppingPlace("", net, GLO_BUS_STOP, tag, GUIIconSubSys::getIcon(GUIIcon::BUSSTOP), nullptr, 0, 0, "", false, Parameterised::Map()),
myPersonCapacity(0),
myParkingLength(0),
myColor(RGBColor::BLACK) {
// reset default values
resetDefaultValues();
GNEBusStop*
GNEBusStop::buildBusStop(GNENet* net) {
return new GNEBusStop(SUMO_TAG_BUS_STOP, GLO_BUS_STOP, GUIIcon::BUSSTOP, net);
}


GNEBusStop::GNEBusStop(SumoXMLTag tag, const std::string& id, GNELane* lane, GNENet* net, const double startPos, const double endPos,
const std::string& name, const std::vector<std::string>& lines, int personCapacity, double parkingLength, const RGBColor& color,
bool friendlyPosition, const Parameterised::Map& parameters) :
GNEStoppingPlace(id, net, GLO_BUS_STOP, tag, GUIIconSubSys::getIcon(GUIIcon::BUSSTOP), lane, startPos, endPos, name, friendlyPosition, parameters),
myLines(lines),
myPersonCapacity(personCapacity),
myParkingLength(parkingLength),
myColor(color) {
GNEBusStop*
GNEBusStop::buildTrainStop(GNENet* net) {
return new GNEBusStop(SUMO_TAG_TRAIN_STOP, GLO_TRAIN_STOP, GUIIcon::TRAINSTOP, net);
}


GNEBusStop*
GNEBusStop::buildBusStop(const std::string& id, GNELane* lane, GNENet* net,
const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines,
int personCapacity, double parkingLength, const RGBColor& color, bool friendlyPosition,
const Parameterised::Map& parameters) {
return new GNEBusStop(SUMO_TAG_BUS_STOP, GLO_BUS_STOP, GUIIcon::BUSSTOP, id, lane, net, startPos, endPos, name, lines,
personCapacity, parkingLength, color, friendlyPosition, parameters);
}


GNEBusStop*
GNEBusStop::buildTrainStop(const std::string& id, GNELane* lane, GNENet* net,
const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines,
int personCapacity, double parkingLength, const RGBColor& color, bool friendlyPosition,
const Parameterised::Map& parameters) {
return new GNEBusStop(SUMO_TAG_TRAIN_STOP, GLO_TRAIN_STOP, GUIIcon::TRAINSTOP, id, lane, net, startPos, endPos, name, lines,
personCapacity, parkingLength, color, friendlyPosition, parameters);
}


Expand Down Expand Up @@ -390,4 +401,25 @@ GNEBusStop::setAttribute(SumoXMLAttr key, const std::string& value) {
}
}


GNEBusStop::GNEBusStop(SumoXMLTag tag, GUIGlObjectType type, GUIIcon icon, GNENet* net) :
GNEStoppingPlace("", net, type, tag, GUIIconSubSys::getIcon(icon), nullptr, 0, 0, "", false, Parameterised::Map()),
myPersonCapacity(0),
myParkingLength(0),
myColor(RGBColor::BLACK) {
// reset default values
resetDefaultValues();
}


GNEBusStop::GNEBusStop(SumoXMLTag tag, GUIGlObjectType type, GUIIcon icon, const std::string& id, GNELane* lane, GNENet* net,
const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines,
int personCapacity, double parkingLength, const RGBColor& color, bool friendlyPosition, const Parameterised::Map& parameters) :
GNEStoppingPlace(id, net, type, tag, GUIIconSubSys::getIcon(icon), lane, startPos, endPos, name, friendlyPosition, parameters),
myLines(lines),
myPersonCapacity(personCapacity),
myParkingLength(parkingLength),
myColor(color) {
}

/****************************************************************************/
59 changes: 53 additions & 6 deletions src/netedit/elements/additional/GNEBusStop.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,31 @@ class GNEBusStop : public GNEStoppingPlace {

public:
/// @brief default constructor
GNEBusStop(SumoXMLTag tag, GNENet* net);
static GNEBusStop* buildBusStop(GNENet* net);

/**@brief parameter Constructor
* @param[in] tag busStop or trainStop tag
/// @brief default constructor
static GNEBusStop* buildTrainStop(GNENet* net);

/**@brief parameter constructor for bus stops
* @param[in] id The storage of gl-ids to get the one for this lane representation from
* @param[in] lane Lane of this StoppingPlace belongs
* @param[in] net pointer to GNENet of this additional element belongs
* @param[in] startPos Start position of the StoppingPlace
* @param[in] endPos End position of the StoppingPlace
* @param[in] name Name of busStop
* @param[in] lines lines of the busStop
* @param[in] personCapacity larger numbers of persons trying to enter will create an upstream jam on the sidewalk.
* @param[in] parkingLength parking length
* @param[in] color busStop color
* @param[in] friendlyPos enable or disable friendly position
* @param[in] parameters generic parameters
*/
static GNEBusStop* buildBusStop(const std::string& id, GNELane* lane, GNENet* net,
const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines,
int personCapacity, double parkingLength, const RGBColor& color, bool friendlyPosition,
const Parameterised::Map& parameters);

/**@brief parameter constructor for train stops
* @param[in] id The storage of gl-ids to get the one for this lane representation from
* @param[in] lane Lane of this StoppingPlace belongs
* @param[in] net pointer to GNENet of this additional element belongs
Expand All @@ -51,9 +72,10 @@ class GNEBusStop : public GNEStoppingPlace {
* @param[in] friendlyPos enable or disable friendly position
* @param[in] parameters generic parameters
*/
GNEBusStop(SumoXMLTag tag, const std::string& id, GNELane* lane, GNENet* net, const double startPos, const double endPos,
const std::string& name, const std::vector<std::string>& lines, int personCapacity, double parkingLength,
const RGBColor& color, bool friendlyPosition, const Parameterised::Map& parameters);
static GNEBusStop* buildTrainStop(const std::string& id, GNELane* lane, GNENet* net,
const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines,
int personCapacity, double parkingLength, const RGBColor& color, bool friendlyPosition,
const Parameterised::Map& parameters);

/// @brief Destructor
~GNEBusStop();
Expand Down Expand Up @@ -122,6 +144,31 @@ class GNEBusStop : public GNEStoppingPlace {
/// @brief set attribute after validation
void setAttribute(SumoXMLAttr key, const std::string& value);

/// @brief default constructor
GNEBusStop(SumoXMLTag tag, GUIGlObjectType type, GUIIcon icon, GNENet* net);

/**@brief parameter Constructor
* @param[in] tag busStop or trainStop tag
* @param[in] type busStop or trainStop GLO type
* @param[in] icon busStop or trainStop icon
* @param[in] id The storage of gl-ids to get the one for this lane representation from
* @param[in] lane Lane of this StoppingPlace belongs
* @param[in] net pointer to GNENet of this additional element belongs
* @param[in] startPos Start position of the StoppingPlace
* @param[in] endPos End position of the StoppingPlace
* @param[in] name Name of busStop
* @param[in] lines lines of the busStop
* @param[in] personCapacity larger numbers of persons trying to enter will create an upstream jam on the sidewalk.
* @param[in] parkingLength parking length
* @param[in] color busStop color
* @param[in] friendlyPos enable or disable friendly position
* @param[in] parameters generic parameters
*/
GNEBusStop(SumoXMLTag tag, GUIGlObjectType type, GUIIcon icon, const std::string& id, GNELane* lane, GNENet* net,
const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines,
int personCapacity, double parkingLength, const RGBColor& color, bool friendlyPosition,
const Parameterised::Map& parameters);

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

Expand Down
4 changes: 3 additions & 1 deletion src/netedit/frames/GNETagSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,10 @@ GNETagSelector::ACTemplate::ACTemplate(GNENet* net, const GNETagProperties tagPr
switch (tagProperty.getTag()) {
// additional elements
case SUMO_TAG_BUS_STOP:
myAC = GNEBusStop::buildBusStop(net);
break;
case SUMO_TAG_TRAIN_STOP:
myAC = new GNEBusStop(tagProperty.getTag(), net);
myAC = GNEBusStop::buildTrainStop(net);
break;
case SUMO_TAG_ACCESS:
myAC = new GNEAccess(net);
Expand Down

0 comments on commit c515df6

Please sign in to comment.