コード例 #1
0
ファイル: objectsettings.cpp プロジェクト: dwickeroth/covise
double ObjectSettings::
    objectT(double s, double t, double roadDistance)
{
    LaneSection *laneSection = object_->getParentRoad()->getLaneSection(s);
    double dist = 0.0;
    double sSection = s - laneSection->getSStart();

    if (t >= 0)
    {
        dist = laneSection->getLaneSpanWidth(0, laneSection->getLeftmostLaneId(), sSection) + roadDistance;
    }
    else
    {
        dist = -laneSection->getLaneSpanWidth(0, laneSection->getRightmostLaneId(), sSection) - roadDistance;
    }

    return dist;
}
コード例 #2
0
ファイル: oscbridgeitem.cpp プロジェクト: dwickeroth/covise
/*!
* Initializes the path (only once).
*/
void
OSCBridgeItem::createPath()
{
	if (path_)
	{
		delete path_;
	}

	path_ = new QPainterPath();

    setBrush(QBrush(outerColor_));
    setPen(QPen(outerColor_, 2.0));


    if (bridge_->getLength() > NUMERICAL_ZERO3) // Bridge is repeated
    {
        double totalLength = 0.0;
        double currentS = bridge_->getSStart();

        // Left and right side //
        //
        while ((totalLength < bridge_->getLength()) && (currentS < road_->getLength()))
        {
            LaneSection *laneSection = road_->getLaneSection(currentS);
            double t = laneSection->getLaneSpanWidth(0, laneSection->getRightmostLaneId() - 1, currentS);
            QPointF currentPos = road_->getGlobalPoint(currentS, t);

            if (totalLength == 0)
            {
                path_->moveTo(currentPos.x(), currentPos.y());
            }
            else
            {
                path_->lineTo(currentPos.x(), currentPos.y());
                path_->moveTo(currentPos.x(), currentPos.y());
            }

            //				double dist = 4; // TODO get configured tesselation length Jutta knows where to get this from
            double dist = 1 / getProjectGraph()->getProjectWidget()->getLODSettings()->TopViewEditorPointsPerMeter;

            if ((totalLength + dist) > bridge_->getLength())
            {
                QPointF currentPos = road_->getGlobalPoint(currentS + (bridge_->getLength() - totalLength), t);
                path_->lineTo(currentPos.x(), currentPos.y());
            }

            totalLength += dist;
            currentS += dist;
        }

        totalLength = 0.0;
        currentS = bridge_->getSStart();

        // Left and right side //
        //
        while ((totalLength < bridge_->getLength()) && (currentS < road_->getLength()))
        {
            LaneSection *laneSection = road_->getLaneSection(currentS);
            double t = -laneSection->getLaneSpanWidth(laneSection->getLeftmostLaneId(), 0, currentS);
            QPointF currentPos = road_->getGlobalPoint(currentS, t);

            if (totalLength == 0)
            {
                path_->moveTo(currentPos.x(), currentPos.y());
            }
            else
            {
                path_->lineTo(currentPos.x(), currentPos.y());
                path_->moveTo(currentPos.x(), currentPos.y());
            }

            //				double dist = 4; // TODO get configured tesselation length Jutta knows where to get this from
            double dist = 1 / getProjectGraph()->getProjectWidget()->getLODSettings()->TopViewEditorPointsPerMeter;

            if ((totalLength + dist) > bridge_->getLength())
            {
                QPointF currentPos = road_->getGlobalPoint(currentS + (bridge_->getLength() - totalLength), t);
                path_->lineTo(currentPos.x(), currentPos.y());
            }

            totalLength += dist;
            currentS += dist;
        }
    }

    setPath(*path_);
}