diff --git a/src/netedit/elements/additional/GNEAdditionalHandler.cpp b/src/netedit/elements/additional/GNEAdditionalHandler.cpp index cf826162bb3..905e6289740 100644 --- a/src/netedit/elements/additional/GNEAdditionalHandler.cpp +++ b/src/netedit/elements/additional/GNEAdditionalHandler.cpp @@ -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 + "'"); @@ -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 + "'"); diff --git a/src/netedit/elements/additional/GNEBusStop.cpp b/src/netedit/elements/additional/GNEBusStop.cpp index 1c208321202..3337101b5db 100644 --- a/src/netedit/elements/additional/GNEBusStop.cpp +++ b/src/netedit/elements/additional/GNEBusStop.cpp @@ -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& 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& 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& 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); } @@ -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& 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) { +} + /****************************************************************************/ diff --git a/src/netedit/elements/additional/GNEBusStop.h b/src/netedit/elements/additional/GNEBusStop.h index d57aadb49ea..18045ed59d4 100644 --- a/src/netedit/elements/additional/GNEBusStop.h +++ b/src/netedit/elements/additional/GNEBusStop.h @@ -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& 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 @@ -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& 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& lines, + int personCapacity, double parkingLength, const RGBColor& color, bool friendlyPosition, + const Parameterised::Map& parameters); /// @brief Destructor ~GNEBusStop(); @@ -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& lines, + int personCapacity, double parkingLength, const RGBColor& color, bool friendlyPosition, + const Parameterised::Map& parameters); + /// @brief Invalidated copy constructor. GNEBusStop(const GNEBusStop&) = delete; diff --git a/src/netedit/frames/GNETagSelector.cpp b/src/netedit/frames/GNETagSelector.cpp index 74a8ee3628e..c0c9cfbeac9 100644 --- a/src/netedit/frames/GNETagSelector.cpp +++ b/src/netedit/frames/GNETagSelector.cpp @@ -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);