Skip to content

Commit

Permalink
Updated GNELane. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 3b60965 commit 1608674
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 68 deletions.
12 changes: 5 additions & 7 deletions src/netedit/elements/data/GNEEdgeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,14 @@ GNEEdgeData::drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPathM
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, GLO_EDGEDATA, offsetFront);
GLHelper::setColor(RGBColor::BLACK);
// draw box lines
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(),
laneEdge->getLaneShape(), laneEdge->getShapeRotations(),
laneEdge->getShapeLengths(), {}, laneWidth, onlyDrawContour);
GLHelper::drawBoxLines(laneEdge->getLaneShape(), laneEdge->getShapeRotations(),
laneEdge->getShapeLengths(), laneWidth);
// translate to top
glTranslated(0, 0, 0.01);
GLHelper::setColor(color);
// draw interne box lines
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(),
laneEdge->getLaneShape(), laneEdge->getShapeRotations(),
laneEdge->getShapeLengths(), {}, (laneWidth - 0.1), onlyDrawContour);
// draw internal box lines
GLHelper::drawBoxLines(laneEdge->getLaneShape(), laneEdge->getShapeRotations(),
laneEdge->getShapeLengths(), (laneWidth - 0.1));
// Pop last matrix
GLHelper::popMatrix();
// draw lock icon
Expand Down
12 changes: 5 additions & 7 deletions src/netedit/elements/data/GNEEdgeRelData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,14 @@ GNEEdgeRelData::drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPa
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, GLO_EDGERELDATA, offsetFront);
GLHelper::setColor(RGBColor::BLACK);
// draw box lines
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(),
laneEdge->getLaneShape(), laneEdge->getShapeRotations(),
laneEdge->getShapeLengths(), {}, laneWidth, onlyDrawContour);
GLHelper::drawBoxLines(laneEdge->getLaneShape(), laneEdge->getShapeRotations(),
laneEdge->getShapeLengths(), laneWidth);
// translate to top
glTranslated(0, 0, 0.01);
GLHelper::setColor(color);
// draw interne box lines
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(),
laneEdge->getLaneShape(), laneEdge->getShapeRotations(),
laneEdge->getShapeLengths(), {}, laneWidth - 0.1, onlyDrawContour);
// draw internal box lines
GLHelper::drawBoxLines(laneEdge->getLaneShape(), laneEdge->getShapeRotations(),
laneEdge->getShapeLengths(), (laneWidth - 0.1));
// Pop last matrix
GLHelper::popMatrix();
// draw lock icon
Expand Down
46 changes: 28 additions & 18 deletions src/netedit/elements/network/GNELane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,12 +1295,16 @@ GNELane::drawLane(const GUIVisualizationSettings& s) const {
if (myDrawingConstants->drawAsRailway()) {
// draw as railway
drawLaneAsRailway(s);
} else if (myShapeColors.size() > 0) {
// draw box lines with own colors
GLHelper::drawBoxLines(myDrawingConstants->getDrawingShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), myShapeColors, myDrawingConstants->getDrawingWidth(), 0,
myDrawingConstants->getOffset());
} else {
// draw as box lines
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(),
myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), myShapeColors,
myDrawingConstants->getDrawingWidth(), false, myDrawingConstants->getOffset());
// draw box lines with current color
GLHelper::drawBoxLines(myDrawingConstants->getDrawingShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), myDrawingConstants->getDrawingWidth(), 0,
myDrawingConstants->getOffset());
}
// draw back edge
drawBackEdge(s);
Expand Down Expand Up @@ -1347,14 +1351,10 @@ GNELane::drawBackEdge(const GUIVisualizationSettings& s) const {
glTranslated(0, 0, -0.1);
// set selected edge color
GLHelper::setColor(s.colorSettings.selectedEdgeColor);
// create visible gap depending of draw spread superposed
const double offset = myDrawingConstants->drawSuperposed()? myDrawingConstants->getDrawingWidth() * 0.5 : 0;
const double widthFactor = myDrawingConstants->drawSuperposed()? 0.4 : 1;
// draw as box lines
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(),
myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), {},
myDrawingConstants->getDrawingWidth() * widthFactor, false, offset);
GLHelper::drawBoxLines(myDrawingConstants->getDrawingShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), myDrawingConstants->getDrawingWidth(),
myDrawingConstants->getOffset());
// Pop matrix
GLHelper::popMatrix();
}
Expand All @@ -1371,8 +1371,9 @@ GNELane::drawShapeEdited(const GUIVisualizationSettings& s) const {
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, GLO_JUNCTION + 1);
// set selected edge color
GLHelper::setColor(s.colorSettings.editShapeColor);
// draw again to show the selected edge
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(), myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(), myLaneGeometry.getShapeLengths(), {}, 0.25);
// draw shape around
GLHelper::drawBoxLines(myDrawingConstants->getDrawingShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), 0.25);
// move front
glTranslated(0, 0, 1);
// color
Expand Down Expand Up @@ -1730,8 +1731,15 @@ GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s) const {
const double halfInnerFeetWidth = myDrawingConstants->getHalfLaneWidth() - 0.039 * myDrawingConstants->getExaggeration();
const double halfRailWidth = halfInnerFeetWidth + 0.15 * myDrawingConstants->getExaggeration();
const double halfCrossTieWidth = myDrawingConstants->getHalfLaneWidth() * 1.81;
// Draw extern lane
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(), myDrawingConstants->getDrawingShape(), myLaneGeometry.getShapeRotations(), myLaneGeometry.getShapeLengths(), myShapeColors, halfRailWidth);
// draw as box lines
if (myShapeColors.size() > 0) {
GLHelper::drawBoxLines(myDrawingConstants->getDrawingShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), myShapeColors, halfRailWidth,
myDrawingConstants->getOffset());
} else {
GLHelper::drawBoxLines(myDrawingConstants->getDrawingShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), halfRailWidth, myDrawingConstants->getOffset());
}
// continue depending of detail
if (myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::LaneDetails) {
// Save current color
Expand All @@ -1740,8 +1748,10 @@ GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s) const {
glColor3d(0.8, 0.8, 0.8);
// move
glTranslated(0, 0, 0.1);
// draw lane geometry again
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(), myDrawingConstants->getDrawingShape(), myLaneGeometry.getShapeRotations(), myLaneGeometry.getShapeLengths(), {}, halfInnerFeetWidth);
// draw as box lines
GLHelper::drawBoxLines(myDrawingConstants->getDrawingShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), halfInnerFeetWidth,
myDrawingConstants->getOffset());
// Set current color back
GLHelper::setColor(current);
// Draw crossties
Expand Down
30 changes: 0 additions & 30 deletions src/utils/gui/div/GUIGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,36 +400,6 @@ GUIGeometry::drawMovingHint(const GUIVisualizationSettings& s, const GUIGlObject
}


void
GUIGeometry::drawLaneGeometry(const GUIVisualizationSettings& s, const Position& mousePos, const PositionVector& shape,
const std::vector<double>& rotations, const std::vector<double>& lengths, const std::vector<RGBColor>& colors,
double width, const bool onlyContour, const double offset) {
// first check if we're in draw a contour or for selecting cliking mode
if (onlyContour) {
// get shapes
PositionVector shapeA = shape;
PositionVector shapeB = shape;
// move both shapes
shapeA.move2side((width - 0.1));
shapeB.move2side((width - 0.1) * -1);
// reverse shape B
shapeB = shapeB.reverse();
// append shape B to shape A
shapeA.append(shapeB, 0);
// close shape A
shapeA.closePolygon();
// draw box lines using shapeA
GLHelper::drawBoxLines(shapeA, 0.1);
} else if (colors.size() > 0) {
// draw box lines with own colors
GLHelper::drawBoxLines(shape, rotations, lengths, colors, width, 0, offset);
} else {
// draw box lines with current color
GLHelper::drawBoxLines(shape, rotations, lengths, width, 0, offset);
}
}


void
GUIGeometry::drawParentLine(const GUIVisualizationSettings& s, const Position& parent, const Position& child,
const RGBColor& color, const bool drawEntire, const double lineWidth) {
Expand Down
6 changes: 0 additions & 6 deletions src/utils/gui/div/GUIGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ class GUIGeometry {
/// @name draw functions
/// @{

/// @brief draw lane geometry (use their own function due colors)
static void drawLaneGeometry(const GUIVisualizationSettings& s, const Position& mousePos, const PositionVector& shape,
const std::vector<double>& rotations, const std::vector<double>& lengths,
const std::vector<RGBColor>& colors, double width, const bool onlyContour = false,
const double offset = 0);

/// @brief draw geometry
static void drawGeometry(const GUIVisualizationSettings& s, const Position& mousePos, const GUIGeometry& geometry,
const double width, double offset = 0);
Expand Down

0 comments on commit 1608674

Please sign in to comment.