예제 #1
0
파일: GUILane.cpp 프로젝트: p1tt1/sumo
void
GUILane::drawGL(const GUIVisualizationSettings& s) const {
    glPushMatrix();
    const bool isInternal = myEdge->getPurpose() == MSEdge::EDGEFUNCTION_INTERNAL;
    bool mustDrawMarkings = false;
    const bool drawDetails =  s.scale * s.laneWidthExaggeration > 5;
    if (isInternal) {
        // draw internal lanes on top of junctions
        glTranslated(0, 0, GLO_JUNCTION + 0.1);
    } else {
        glTranslated(0, 0, getType());
    }
    // set lane color
    if (!MSGlobals::gUseMesoSim) {
        setColor(s);
        glPushName(getGlID()); // do not register for clicks in MESOSIM
    }
    // draw lane
    // check whether it is not too small
    if (s.scale * s.laneWidthExaggeration < 1.) {
        GLHelper::drawLine(myShape);
        if (!MSGlobals::gUseMesoSim) {
            glPopName();
        }
        glPopMatrix();
    } else {
        if (isRailway(myPermissions)) {
            // draw as railway
            const SUMOReal halfRailWidth = 0.725 * s.laneWidthExaggeration;
            GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, halfRailWidth);
            glColor3d(1, 1, 1);
            glTranslated(0, 0, .1);
            GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, halfRailWidth - 0.2);
            drawCrossties(s, s.laneWidthExaggeration);
        } else {
            const SUMOReal laneWidth = isInternal ? myQuarterLaneWidth : myHalfLaneWidth;
            mustDrawMarkings = !isInternal;
            GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, laneWidth * s.laneWidthExaggeration);
        }
        if (!MSGlobals::gUseMesoSim) {
            glPopName();
        }
        glPopMatrix();
        // draw ROWs (not for inner lanes)
        if (!isInternal && drawDetails) {
            glPushMatrix();
            glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape
            GUINet* net = (GUINet*) MSNet::getInstance();
            glTranslated(0, 0, .2);
            drawLinkRules(*net);
            if (s.showLinkDecals && !isRailway(myPermissions)) {
                drawArrows();
            }
            if (s.showLane2Lane) {
                // this should be independent to the geometry:
                //  draw from end of first to the begin of second
                drawLane2LaneConnections();
            }
            glTranslated(0, 0, .1);
            if (s.drawLinkJunctionIndex) {
                drawLinkNo();
            }
            if (s.drawLinkTLIndex) {
                drawTLSLinkNo(*net);
            }
            glPopMatrix();
        }
    }
    if (mustDrawMarkings && drawDetails) { // needs matrix reset
        drawMarkings(s, s.laneWidthExaggeration);
    }
    // draw vehicles
    if (s.scale > s.minVehicleSize) {
        // retrieve vehicles from lane; disallow simulation
        const MSLane::VehCont& vehicles = getVehiclesSecure();
        for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) {
            if ((*v)->getLane() == this) {
                static_cast<const GUIVehicle* const>(*v)->drawGL(s);
            } // else: this is the shadow during a continuous lane change
        }
        // draw parking vehicles
        const std::set<const MSVehicle*> parking = MSVehicleTransfer::getInstance()->getParkingVehicles(this);
        for (std::set<const MSVehicle*>::const_iterator v = parking.begin(); v != parking.end(); ++v) {
            static_cast<const GUIVehicle* const>(*v)->drawGL(s);
        }
        // allow lane simulation
        releaseVehicles();
    }
}
예제 #2
0
void
GNECrossing::drawGL(const GUIVisualizationSettings& s) const {
    // only draw if option drawCrossingsAndWalkingareas is enabled and size of shape is greather than 0 and zoom is close enough
    if (s.drawCrossingsAndWalkingareas &&
            (myShapeRotations.size() > 0) &&
            (myShapeLengths.size() > 0) &&
            (s.scale > 3.0)) {
        auto crossing = myParentJunction->getNBNode()->getCrossing(myCrossingEdges);
        if (s.editMode != GNE_NMODE_TLS) {
            // push first draw matrix
            glPushMatrix();
            // push name
            glPushName(getGlID());
            // must draw on top of junction
            glTranslated(0, 0, GLO_JUNCTION + 0.1);
            // set color depending of selection and priority
            if (drawUsingSelectColor()) {
                glColor3d(0.118, 0.565, 1.000);
            } else if (!crossing->valid) {
                glColor3d(1.0, 0.1, 0.1);
            } else if (crossing->priority) {
                glColor3d(0.9, 0.9, 0.9);
            } else {
                glColor3d(0.1, 0.1, 0.1);
            }
            // traslate to front
            glTranslated(0, 0, .2);
            // set default values
            double length = 0.5;
            double spacing = 1.0;
            double halfWidth = crossing->width * 0.5;
            // push second draw matrix
            glPushMatrix();
            // draw on top of of the white area between the rails
            glTranslated(0, 0, 0.1);
            for (int i = 0; i < (int)myShape.size() - 1; ++i) {
                // push three draw matrix
                glPushMatrix();
                // translate and rotate
                glTranslated(myShape[i].x(), myShape[i].y(), 0.0);
                glRotated(myShapeRotations[i], 0, 0, 1);
                // draw crossing depending if isn't being drawn for selecting
                if (!s.drawForSelecting) {
                    for (double t = 0; t < myShapeLengths[i]; t += spacing) {
                        glBegin(GL_QUADS);
                        glVertex2d(-halfWidth, -t);
                        glVertex2d(-halfWidth, -t - length);
                        glVertex2d(halfWidth, -t - length);
                        glVertex2d(halfWidth, -t);
                        glEnd();
                    }
                } else {
                    // only draw a single rectangle if it's being drawn only for selecting
                    glBegin(GL_QUADS);
                    glVertex2d(-halfWidth, 0);
                    glVertex2d(-halfWidth, -myShapeLengths.back());
                    glVertex2d(halfWidth, -myShapeLengths.back());
                    glVertex2d(halfWidth, 0);
                    glEnd();
                }
                // pop three draw matrix
                glPopMatrix();
            }
            // XXX draw junction index / tls index
            // pop second draw matrix
            glPopMatrix();
            // traslate to back
            glTranslated(0, 0, -.2);
            // pop name
            glPopName();
            // pop draw matrix
            glPopMatrix();
        }
        // link indices must be drawn in all edit modes if isn't being drawn for selecting
        if (s.drawLinkTLIndex.show && !s.drawForSelecting) {
            drawTLSLinkNo(s);
        }
        // check if dotted contour has to be drawn
        if (!s.drawForSelecting && (myNet->getViewNet()->getDottedAC() == this)) {
            GLHelper::drawShapeDottedContour(getType(), myShape, crossing->width * 0.5);
        }
    }
}