// =========================================================================== // method definitions // =========================================================================== GUIContainerStop::GUIContainerStop(const std::string& id, const std::vector<std::string>& lines, MSLane& lane, SUMOReal frompos, SUMOReal topos) : MSStoppingPlace(id, lines, lane, frompos, topos), GUIGlObject_AbstractAdd("containerStop", GLO_TRIGGER, id) { myFGShape = lane.getShape(); myFGShape.move2side((SUMOReal) 1.65); myFGShape = myFGShape.getSubpart(frompos, topos); myFGShapeRotations.reserve(myFGShape.size() - 1); myFGShapeLengths.reserve(myFGShape.size() - 1); int e = (int) myFGShape.size() - 1; for (int i = 0; i < e; ++i) { const Position& f = myFGShape[i]; const Position& s = myFGShape[i + 1]; myFGShapeLengths.push_back(f.distanceTo(s)); myFGShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI); } PositionVector tmp = myFGShape; tmp.move2side(1.5); myFGSignPos = tmp.getLineCenter(); myFGSignRot = 0; if (tmp.length() != 0) { myFGSignRot = myFGShape.rotationDegreeAtOffset(SUMOReal((myFGShape.length() / 2.))); myFGSignRot -= 90; } }
// =========================================================================== // method definitions // =========================================================================== GUIChargingStation::GUIChargingStation(const std::string& id, MSLane& lane, SUMOReal frompos, SUMOReal topos, SUMOReal chargingPower, SUMOReal efficiency, bool chargeInTransit, int chargeDelay) : MSChargingStation(id, lane, frompos, topos, chargingPower, efficiency, chargeInTransit, chargeDelay), GUIGlObject_AbstractAdd("chargingStation", GLO_TRIGGER, id) { myFGShape = lane.getShape(); myFGShape = myFGShape.getSubpart(frompos, topos); myFGShapeRotations.reserve(myFGShape.size() - 1); myFGShapeLengths.reserve(myFGShape.size() - 1); int e = (int) myFGShape.size() - 1; for (int i = 0; i < e; ++i) { const Position& f = myFGShape[i]; const Position& s = myFGShape[i + 1]; myFGShapeLengths.push_back(f.distanceTo(s)); myFGShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI); } PositionVector tmp = myFGShape; tmp.move2side(1.5); myFGSignPos = tmp.getLineCenter(); myFGSignRot = 0; if (tmp.length() != 0) { myFGSignRot = myFGShape.rotationDegreeAtOffset(SUMOReal((myFGShape.length() / 2.))); myFGSignRot -= 90; } }
// =========================================================================== // method definitions // =========================================================================== GUIParkingArea::GUIParkingArea(const std::string& id, const std::vector<std::string>& lines, MSLane& lane, SUMOReal frompos, SUMOReal topos, unsigned int capacity, SUMOReal width, SUMOReal length, SUMOReal angle) : MSParkingArea(id, lines, lane, frompos, topos, capacity, width, length, angle), GUIGlObject_AbstractAdd("parkingArea", GLO_TRIGGER, id) { myShapeRotations.reserve(myShape.size() - 1); myShapeLengths.reserve(myShape.size() - 1); int e = (int) myShape.size() - 1; for (int i = 0; i < e; ++i) { const Position& f = myShape[i]; const Position& s = myShape[i + 1]; myShapeLengths.push_back(f.distanceTo(s)); myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI); } PositionVector tmp = myShape; tmp.move2side(lane.getWidth() + myWidth); mySignPos = tmp.getLineCenter(); mySignRot = 0; if (tmp.length() != 0) { mySignRot = myShape.rotationDegreeAtOffset(SUMOReal((myShape.length() / 2.))); mySignRot -= 90; } }
// =========================================================================== // method definitions // =========================================================================== GUIParkingArea::GUIParkingArea(const std::string& id, const std::vector<std::string>& lines, MSLane& lane, double frompos, double topos, unsigned int capacity, double width, double length, double angle, const std::string& name) : MSParkingArea(id, lines, lane, frompos, topos, capacity, width, length, angle, name), GUIGlObject_AbstractAdd(GLO_PARKING_AREA, id) { const double offsetSign = MSNet::getInstance()->lefthand() ? -1 : 1; myShapeRotations.reserve(myShape.size() - 1); myShapeLengths.reserve(myShape.size() - 1); int e = (int) myShape.size() - 1; for (int i = 0; i < e; ++i) { const Position& f = myShape[i]; const Position& s = myShape[i + 1]; myShapeLengths.push_back(f.distanceTo(s)); myShapeRotations.push_back((double) atan2((s.x() - f.x()), (f.y() - s.y())) * (double) 180.0 / (double) M_PI); } PositionVector tmp = myShape; tmp.move2side((lane.getWidth() + myWidth) * offsetSign); mySignPos = tmp.getLineCenter(); mySignRot = 0; if (tmp.length() != 0) { mySignRot = myShape.rotationDegreeAtOffset(double((myShape.length() / 2.))); mySignRot -= 90; } }
void GNEContainerStop::updateGeometry() { // Clear all containers myShapeRotations.clear(); myShapeLengths.clear(); // Get value of option "lefthand" SUMOReal offsetSign = OptionsCont::getOptions().getBool("lefthand") ? -1 : 1; // Get shape of lane parent myShape = myLane->getShape(); // Move shape to side myShape.move2side(1.65 * offsetSign); // Cut shape using as delimitators from start position and end position myShape = myShape.getSubpart(myLane->getPositionRelativeToParametricLenght(myStartPos), myLane->getPositionRelativeToParametricLenght(myEndPos)); // Get number of parts of the shape int numberOfSegments = (int) myShape.size() - 1; // If number of segments is more than 0 if (numberOfSegments >= 0) { // Reserve memory (To improve efficiency) myShapeRotations.reserve(numberOfSegments); myShapeLengths.reserve(numberOfSegments); // For every part of the shape for (int i = 0; i < numberOfSegments; ++i) { // Obtain first position const Position& f = myShape[i]; // Obtain next position const Position& s = myShape[i + 1]; // Save distance between position into myShapeLengths myShapeLengths.push_back(f.distanceTo(s)); // Save rotation (angle) of the vector constructed by points f and s myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI); } } // Obtain a copy of the shape PositionVector tmpShape = myShape; // Move shape to side tmpShape.move2side(1.5 * offsetSign); // Get position of the sign mySignPos = tmpShape.getLineCenter(); // Set block icon position myBlockIconPosition = myShape.getLineCenter(); // Set block icon rotation, and using their rotation for sign setBlockIconRotation(myLane); // Refresh element (neccesary to avoid grabbing problems) myViewNet->getNet()->refreshAdditional(this); }