void GNECalibrator::drawGL(const GUIVisualizationSettings& s) const { // get values glPushName(getGlID()); glLineWidth(1.0); const double exaggeration = s.addSize.getExaggeration(s, this); // iterate over every Calibrator symbol for (int i = 0; i < (int)myGeometry.shape.size(); ++i) { const Position& pos = myGeometry.shape[i]; double rot = myGeometry.shapeRotations[i]; glPushMatrix(); glTranslated(pos.x(), pos.y(), getType()); glRotated(rot, 0, 0, 1); glTranslated(0, 0, getType()); glScaled(exaggeration, exaggeration, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { GLHelper::setColor(RGBColor(255, 204, 0)); } // base glBegin(GL_TRIANGLES); glVertex2d(0 - 1.4, 0); glVertex2d(0 - 1.4, 6); glVertex2d(0 + 1.4, 6); glVertex2d(0 + 1.4, 0); glVertex2d(0 - 1.4, 0); glVertex2d(0 + 1.4, 6); glEnd(); // draw text if isn't being drawn for selecting if ((s.scale * exaggeration >= 1.) && !s.drawForSelecting) { // set color depending of selection status RGBColor textColor = drawUsingSelectColor() ? s.selectionColor : RGBColor::BLACK; // draw "C" GLHelper::drawText("C", Position(0, 1.5), 0.1, 3, textColor, 180); // draw "edge" or "lane " if (getLaneParents().size() > 0) { GLHelper::drawText("lane", Position(0, 3), .1, 1, textColor, 180); } else if (getEdgeParents().size() > 0) { GLHelper::drawText("edge", Position(0, 3), .1, 1, textColor, 180); } else { throw ProcessError("Both myEdge and myLane aren't defined"); } } glPopMatrix(); // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { GLHelper::drawShapeDottedContour(getType(), pos, 2.8, 6, rot, 0, 3); } } // draw name drawName(getPositionInView(), s.scale, s.addName); // pop name glPopName(); }
void GNEConnection::drawGL(const GUIVisualizationSettings& s) const { // Check if connection must be drawed if (!myShapeDeprecated && (myNet->getViewNet()->getViewOptions().showConnections() || (myNet->getViewNet()->getEditModes().currentSupermode == GNE_SUPERMODE_DEMAND))) { // Push draw matrix 1 glPushMatrix(); // Push name glPushName(getGlID()); // Traslate matrix glTranslated(0, 0, GLO_JUNCTION + 0.1); // must draw on top of junction // Set color if (drawUsingSelectColor()) { // override with special colors (unless the color scheme is based on selection) GLHelper::setColor(s.selectedConnectionColor); } else if (mySpecialColor != nullptr) { GLHelper::setColor(*mySpecialColor); } else { // Set color depending of the link state GLHelper::setColor(GNEInternalLane::colorForLinksState(getLinkState())); } // draw connection checking whether it is not too small if isn't being drawn for selecting const double selectionScale = isAttributeCarrierSelected() ? s.selectionScale : 1; if ((s.scale * selectionScale < 5.) && !s.drawForSelecting) { // If it's small, draw a simple line GLHelper::drawLine(myShape); } else { // draw a list of lines const bool spreadSuperposed = s.scale >= 1 && s.spreadSuperposed && myFromLane->drawAsRailway(s) && getEdgeFrom()->getNBEdge()->isBidiRail(); PositionVector shape = myShape; if (spreadSuperposed) { shape.move2side(0.5); } GLHelper::drawBoxLines(shape, myShapeRotations, myShapeLengths, 0.2 * selectionScale); glTranslated(0, 0, 0.1); GLHelper::setColor(GLHelper::getColor().changedBrightness(51)); // check if internal junction marker has to be drawn if (myInternalJunctionMarker.size() > 0) { GLHelper::drawLine(myInternalJunctionMarker); } // check if dotted contour has to be drawn (not useful at high zoom) if (!s.drawForSelecting && (myNet->getViewNet()->getDottedAC() == this)) { GLHelper::drawShapeDottedContour(getType(), shape, 0.25); } } // Pop name glPopName(); // Pop draw matrix 1 glPopMatrix(); } }
void GNEPOI::drawGL(const GUIVisualizationSettings& s) const { // check if boundary has to be drawn if(s.drawBoundaries) { GLHelper::drawBoundary(getCenteringBoundary()); } // first clear vertices myPOIVertices.clear(); // check if POI can be drawn if (checkDraw(s)) { // push name (needed for getGUIGlObjectsUnderCursor(...) glPushName(getGlID()); // draw inner polygon drawInnerPOI(s, drawUsingSelectColor()); // draw an orange square mode if there is an image(see #4036) if (!getShapeImgFile().empty() && OptionsCont::getOptions().getBool("gui-testing")) { // Add a draw matrix for drawing logo glPushMatrix(); glTranslated(x(), y(), getType() + 0.01); GLHelper::setColor(RGBColor::ORANGE); GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1); glPopMatrix(); } // check if dotted contour has to be drawn if (myNet->getViewNet()->getDottedAC() == this) { if (getShapeImgFile() != DEFAULT_IMG_FILE) { const double exaggeration = s.poiSize.getExaggeration(s, this); GLHelper::drawShapeDottedContour(getType(), *this, 2 * myHalfImgWidth * exaggeration, 2 * myHalfImgHeight * exaggeration); } else if (myPOIVertices.size() > 0) { glPushMatrix(); glTranslated(x(), y(), getType() + 0.01); GLHelper::drawShapeDottedContour(getType(), myPOIVertices); glPopMatrix(); } } // pop name glPopName(); } }
void GNEDetectorE1::drawGL(const GUIVisualizationSettings& s) const { // get values glPushName(getGlID()); double width = (double) 2.0 * s.scale; glLineWidth(1.0); const double exaggeration = s.addSize.getExaggeration(s, this); // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { GLHelper::setColor(s.SUMO_color_E1); } // draw shape glPushMatrix(); glTranslated(0, 0, getType()); glTranslated(myGeometry.shape[0].x(), myGeometry.shape[0].y(), 0); glRotated(myGeometry.shapeRotations[0], 0, 0, 1); glScaled(exaggeration, exaggeration, 1); glBegin(GL_QUADS); glVertex2d(-1.0, 2); glVertex2d(-1.0, -2); glVertex2d(1.0, -2); glVertex2d(1.0, 2); glEnd(); glTranslated(0, 0, .01); glBegin(GL_LINES); glVertex2d(0, 2 - .1); glVertex2d(0, -2 + .1); glEnd(); // outline if isn't being drawn for selecting if ((width * exaggeration > 1) && !s.drawForSelecting) { // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectionColor); } else { GLHelper::setColor(RGBColor::WHITE); } glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glBegin(GL_QUADS); glVertex2f(-1.0, 2); glVertex2f(-1.0, -2); glVertex2f(1.0, -2); glVertex2f(1.0, 2); glEnd(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } // position indicator if isn't being drawn for selecting if ((width * exaggeration > 1) && !s.drawForSelecting) { // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectionColor); } else { GLHelper::setColor(RGBColor::WHITE); } glRotated(90, 0, 0, -1); glBegin(GL_LINES); glVertex2d(0, 1.7); glVertex2d(0, -1.7); glEnd(); } // Pop shape matrix glPopMatrix(); // Check if the distance is enought to draw details and isn't being drawn for selecting if ((s.scale * exaggeration >= 10) && !s.drawForSelecting) { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myGeometry.shape.getLineCenter().x(), myGeometry.shape.getLineCenter().y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-1, 0, 0); // draw E1 logo if (drawUsingSelectColor()) { GLHelper::drawText("E1", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E1", Position(), .1, 1.5, RGBColor::BLACK); } // pop matrix glPopMatrix(); // Show Lock icon depending of the Edit mode myBlockIcon.draw(); } // Finish draw if isn't being drawn for selecting if (!s.drawForSelecting) { drawName(getPositionInView(), s.scale, s.addName); } // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape[0], 2, 4, myGeometry.shapeRotations[0]); } // pop name glPopName(); }
void GNEDetectorE2::drawGL(const GUIVisualizationSettings& s) const { // Start drawing adding an gl identificator glPushName(getGlID()); // Add a draw matrix glPushMatrix(); // Start with the drawing of the area traslating matrix to origin glTranslated(0, 0, getType()); // Set color of the base if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { // set color depending if is or isn't valid if (myE2valid) { GLHelper::setColor(s.SUMO_color_E2); } else { GLHelper::setColor(RGBColor::RED); } } // Obtain exaggeration of the draw const double exaggeration = s.addSize.getExaggeration(s, this); // check if we have to drawn a E2 single lane or a E2 multiLane if (myGeometry.shape.size() > 0) { // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration); } else { // iterate over multishapes for (int i = 0; i < (int)myGeometry.multiShape.size(); i++) { // don't draw shapes over connections if "show connections" is enabled if (!myViewNet->getViewOptions().showConnections() || (i % 2 == 0)) { GLHelper::drawBoxLines(myGeometry.multiShape.at(i), myGeometry.multiShapeRotations.at(i), myGeometry.multiShapeLengths.at(i), exaggeration); } } } // Pop last matrix glPopMatrix(); // Check if the distance is enougth to draw details and isn't being drawn for selecting if ((s.scale * exaggeration >= 10) && !s.drawForSelecting) { // draw logo depending if this is an Multilane E2 detector if (myTagProperty.getTag() == SUMO_TAG_E2DETECTOR) { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myGeometry.shape.getLineCenter().x(), myGeometry.shape.getLineCenter().y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-0.75, 0, 0); // draw E2 logo if (drawUsingSelectColor()) { GLHelper::drawText("E2", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK); } } else { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myBlockIcon.position.x(), myBlockIcon.position.y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-1.5, 0, 0); // draw E2 logo if (drawUsingSelectColor()) { GLHelper::drawText("E2", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK); } //move to logo position glTranslated(1.2, 0, 0); // Rotate depending of myBlockIcon.rotation glRotated(90, 0, 0, 1); if (drawUsingSelectColor()) { GLHelper::drawText("multi", Position(), .1, 0.9, s.selectedAdditionalColor); } else { GLHelper::drawText("multi", Position(), .1, 0.9, RGBColor::BLACK); } } // pop matrix glPopMatrix(); // Show Lock icon depending of the Edit mode myBlockIcon.draw(); } // Draw name if isn't being drawn for selecting if (!s.drawForSelecting) { drawName(getPositionInView(), s.scale, s.addName); } // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { if (myGeometry.shape.size() > 0) { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape, exaggeration); } else { GLHelper::drawShapeDottedContour(getType(), myGeometry.multiShapeUnified, exaggeration); } } // Pop name glPopName(); }
void GNEStop::drawGL(const GUIVisualizationSettings& s) const { // only drawn in super mode demand if (myViewNet->getViewOptions().showDemandElements()) { // Obtain exaggeration of the draw const double exaggeration = s.addSize.getExaggeration(s, this); // Start drawing adding an gl identificator glPushName(getGlID()); // Add a draw matrix glPushMatrix(); // Start with the drawing of the area traslating matrix to origin glTranslated(0, 0, getType()); // Set color of the base if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { GLHelper::setColor(s.SUMO_color_stops); } // draw lines depending if it's placed over a lane or over a stoppingPlace if (getLaneParents().size() > 0) { // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration * 0.1, 0, getLaneParents().front()->getParentEdge().getNBEdge()->getLaneWidth(getLaneParents().front()->getIndex()) * 0.5); GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration * 0.1, 0, getLaneParents().front()->getParentEdge().getNBEdge()->getLaneWidth(getLaneParents().front()->getIndex()) * -0.5); } else { // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration * 0.1, 0, exaggeration * -1); GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration * 0.1, 0, exaggeration); } // pop draw matrix glPopMatrix(); // Add a draw matrix glPushMatrix(); // move to geometry front glTranslated(myGeometry.shape.back().x(), myGeometry.shape.back().y(), getType()); glRotated(myGeometry.shapeRotations.back(), 0, 0, 1); // draw front of Stop depending if it's placed over a lane or over a stoppingPlace if (getLaneParents().size() > 0) { // draw front of Stop GLHelper::drawBoxLine(Position(0, 0), 0, exaggeration * 0.5, getLaneParents().front()->getParentEdge().getNBEdge()->getLaneWidth(getLaneParents().front()->getIndex()) * 0.5); } else { // draw front of Stop GLHelper::drawBoxLine(Position(0, 0), 0, exaggeration * 0.5, exaggeration); } // move to "S" position glTranslated(0, 1, 0); // draw "S" symbol GLHelper::drawText("S", Position(), .1, 2.8, s.SUMO_color_stops); // move to subtitle positin glTranslated(0, 1.4, 0); // draw subtitle depending of tag if (myTagProperty.getTag() == SUMO_TAG_STOP_BUSSTOP) { GLHelper::drawText("busStop", Position(), .1, .5, s.SUMO_color_stops, 180); } else if (myTagProperty.getTag() == SUMO_TAG_STOP_CONTAINERSTOP) { GLHelper::drawText("container", Position(), .1, .5, s.SUMO_color_stops, 180); glTranslated(0, 0.5, 0); GLHelper::drawText("Stop", Position(), .1, .5, s.SUMO_color_stops, 180); } else if (myTagProperty.getTag() == SUMO_TAG_STOP_CHARGINGSTATION) { GLHelper::drawText("charging", Position(), .1, .5, s.SUMO_color_stops, 180); glTranslated(0, 0.5, 0); GLHelper::drawText("Station", Position(), .1, .5, s.SUMO_color_stops, 180); } else if (myTagProperty.getTag() == SUMO_TAG_STOP_PARKINGAREA) { GLHelper::drawText("parking", Position(), .1, .5, s.SUMO_color_stops, 180); glTranslated(0, 0.5, 0); GLHelper::drawText("Area", Position(), .1, .5, s.SUMO_color_stops, 180); } else if (myTagProperty.getTag() == SUMO_TAG_STOP_LANE) { GLHelper::drawText("lane", Position(), .1, 1, s.SUMO_color_stops, 180); } // pop draw matrix glPopMatrix(); // Draw name if isn't being drawn for selecting drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { // draw dooted contour depending if it's placed over a lane or over a stoppingPlace if (getLaneParents().size() > 0) { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape, getLaneParents().front()->getParentEdge().getNBEdge()->getLaneWidth(getLaneParents().front()->getIndex()) * 0.5); } else { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape, exaggeration); } } // Pop name glPopName(); } }
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); } } }