Skip to content

Commit

Permalink
Renamed LaneDrawingConstants to DrawingConstants. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 21d1da3 commit e69f854
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5359,7 +5359,7 @@ GNEViewNet::drawTemporalSplitJunction() const {
const auto lane = gPostDrawing.markedEdge->getLanes().back();
auto shape = lane->getLaneShape();
// move shape to side
shape.move2side(lane->getLaneDrawingConstants()->getWidth() * -1);
shape.move2side(lane->getDrawingConstants()->getWidth() * -1);
const auto offset = shape.nearest_offset_to_point2D(snapToActiveGrid(getPositionInformation()));
const auto splitPosition = shape.positionAtOffset2D(offset);
// get junction exaggeration
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/GNEContour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ GNEContour::buildDottedContourEdge(const GUIVisualizationSettings& s, const GNEE
myDottedGeometries->at(0) = GUIDottedGeometry(s, topLane->getLaneGeometry().getShape(), false, true);
myDottedGeometries->at(2) = GUIDottedGeometry(s, botLane->getLaneGeometry().getShape().reverse(), false, true);
// move geometries top and bot
myDottedGeometries->at(0).moveShapeToSide(topLane->getLaneDrawingConstants()->getWidth() * topLane->getLaneDrawingConstants()->getExaggeration() * -1);
myDottedGeometries->at(2).moveShapeToSide(botLane->getLaneDrawingConstants()->getWidth() * botLane->getLaneDrawingConstants()->getExaggeration() * -1);
myDottedGeometries->at(0).moveShapeToSide(topLane->getDrawingConstants()->getWidth() * topLane->getDrawingConstants()->getExaggeration() * -1);
myDottedGeometries->at(2).moveShapeToSide(botLane->getDrawingConstants()->getWidth() * botLane->getDrawingConstants()->getExaggeration() * -1);
// create left and right geometries
if (drawFirstExtrem) {
myDottedGeometries->at(3) = GUIDottedGeometry(s, {
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/demand/GNEStopPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ GNEStopPlan::updateGeometry() {
const GNELane* backLane = getParentEdges().front()->getLanes().back();
// calculate front position
const Position frontPosition = frontLane->getLaneShape().positionAtOffset2D(getAttributeDouble(GNE_ATTR_PLAN_GEOMETRY_ENDPOS),
frontLane->getLaneDrawingConstants()->getWidth());
frontLane->getDrawingConstants()->getWidth());
// calulate length between both shapes
const double length = backLane->getLaneShape().distance2D(frontPosition, true);
// calculate back position
const Position backPosition = frontLane->getLaneShape().positionAtOffset2D(getAttributeDouble(GNE_ATTR_PLAN_GEOMETRY_ENDPOS),
(length + backLane->getLaneDrawingConstants()->getWidth() - frontLane->getLaneDrawingConstants()->getWidth()) * -1);
(length + backLane->getDrawingConstants()->getWidth() - frontLane->getDrawingConstants()->getWidth()) * -1);
// update demand element geometry using both positions
myDemandElementGeometry.updateGeometry({frontPosition, backPosition});
}
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNEEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2771,7 +2771,7 @@ GNEEdge::drawTAZElements(const GUIVisualizationSettings& s) const {
}
// draw as box lines
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), lane->getLaneGeometry(),
lane->getLaneDrawingConstants()->getWidth());
lane->getDrawingConstants()->getWidth());
// Pop layer matrix
GLHelper::popMatrix();
}
Expand Down
72 changes: 36 additions & 36 deletions src/netedit/elements/network/GNELane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ FXIMPLEMENT(GNELane, FXDelegator, 0, 0)
// GNELane::LaneDrawingConstants - methods
// ---------------------------------------------------------------------------

GNELane::LaneDrawingConstants::LaneDrawingConstants(const GNELane* lane) :
GNELane::DrawingConstants::DrawingConstants(const GNELane* lane) :
myLane(lane) {
}


void
GNELane::LaneDrawingConstants::update(const GUIVisualizationSettings& s) {
GNELane::DrawingConstants::update(const GUIVisualizationSettings& s) {
const double selectionScale = myLane->isAttributeCarrierSelected() || myLane->myParentEdge->isAttributeCarrierSelected() ? s.selectorFrameScale : 1;
myExaggeration = selectionScale * s.laneWidthExaggeration;
myHalfLaneWidth = myExaggeration * (myLane->myParentEdge->getNBEdge()->getLaneWidth(myLane->getIndex()) / 2);
Expand All @@ -81,25 +81,25 @@ GNELane::LaneDrawingConstants::update(const GUIVisualizationSettings& s) {


double
GNELane::LaneDrawingConstants::getExaggeration() const {
GNELane::DrawingConstants::getExaggeration() const {
return myExaggeration;
}


double
GNELane::LaneDrawingConstants::getHalfLaneWidth() const {
GNELane::DrawingConstants::getHalfLaneWidth() const {
return myHalfLaneWidth;
}


double
GNELane::LaneDrawingConstants::getMarkWidth() const {
GNELane::DrawingConstants::getMarkWidth() const {
return myMarkWidth;
}


double
GNELane::LaneDrawingConstants::getWidth() const {
GNELane::DrawingConstants::getWidth() const {
return myWidth;
}

Expand All @@ -112,7 +112,7 @@ GNELane::GNELane(GNEEdge* edge, const int index) :
GUIIconSubSys::getIcon(GUIIcon::LANE), {}, {}, {}, {}, {}, {}),
myParentEdge(edge),
myIndex(index),
myLaneDrawingConstants(new LaneDrawingConstants(this)),
myDrawingConstants(new DrawingConstants(this)),
mySpecialColor(nullptr),
mySpecialColorValue(-1),
myLane2laneConnections(this){
Expand All @@ -126,16 +126,16 @@ GNELane::GNELane() :
GUIIconSubSys::getIcon(GUIIcon::LANE), {}, {}, {}, {}, {}, {}),
myParentEdge(nullptr),
myIndex(-1),
myLaneDrawingConstants(nullptr),
myDrawingConstants(nullptr),
mySpecialColor(nullptr),
mySpecialColorValue(-1),
myLane2laneConnections(this) {
}


GNELane::~GNELane() {
if (myLaneDrawingConstants) {
delete myLaneDrawingConstants;
if (myDrawingConstants) {
delete myDrawingConstants;
}
}

Expand Down Expand Up @@ -180,9 +180,9 @@ GNELane::getShapeLengths() const {
}


const GNELane::LaneDrawingConstants*
GNELane::getLaneDrawingConstants() const {
return myLaneDrawingConstants;
const GNELane::DrawingConstants*
GNELane::getDrawingConstants() const {
return myDrawingConstants;
}


Expand Down Expand Up @@ -614,9 +614,9 @@ GNELane::drawLane2LaneConnections() const {
void
GNELane::drawGL(const GUIVisualizationSettings& s) const {
// update lane drawing constan
myLaneDrawingConstants->update(s);
myDrawingConstants->update(s);
// get detail level
const auto d = s.getDetailLevel(myLaneDrawingConstants->getExaggeration());
const auto d = s.getDetailLevel(myDrawingConstants->getExaggeration());
// check drawing conditions
if (!s.drawForObjectUnderCursor) {
// Push layer matrix
Expand All @@ -639,7 +639,7 @@ GNELane::drawGL(const GUIVisualizationSettings& s) const {
// draw children
drawChildren(s, d);
// draw dotted geometry
myContour.drawDottedContourExtruded(s, d, getLaneShape(), myLaneDrawingConstants->getWidth(), 1, true, true,
myContour.drawDottedContourExtruded(s, d, getLaneShape(), myDrawingConstants->getWidth(), 1, true, true,
s.dottedContourSettings.segmentWidth);
}

Expand Down Expand Up @@ -683,7 +683,7 @@ GNELane::drawChildren(const GUIVisualizationSettings& s, const GUIVisualizationS
void
GNELane::drawLaneMarkings(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const bool drawRailway) const {
// check conditions
if (s.laneShowBorders && (myLaneDrawingConstants->getExaggeration() == 1) && !drawRailway) {
if (s.laneShowBorders && (myDrawingConstants->getExaggeration() == 1) && !drawRailway) {
// optionally draw inverse markings
bool haveChangeProhibitions = false;
if (myIndex > 0 && (myParentEdge->getNBEdge()->getPermissions(myIndex - 1) & myParentEdge->getNBEdge()->getPermissions(myIndex)) != 0) {
Expand All @@ -692,7 +692,7 @@ GNELane::drawLaneMarkings(const GUIVisualizationSettings& s, const GUIVisualizat
const bool cl = myParentEdge->getNBEdge()->allowsChangingLeft(myIndex - 1, SVC_PASSENGER);
const bool cr = myParentEdge->getNBEdge()->allowsChangingRight(myIndex, SVC_PASSENGER);
GLHelper::drawInverseMarkings(myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(), myLaneGeometry.getShapeLengths(),
3, 6, myLaneDrawingConstants->getHalfLaneWidth(), cl, cr, s.lefthand, myLaneDrawingConstants->getExaggeration());
3, 6, myDrawingConstants->getHalfLaneWidth(), cl, cr, s.lefthand, myDrawingConstants->getExaggeration());
haveChangeProhibitions = !(cl && cr);
GLHelper::popMatrix();
}
Expand All @@ -702,16 +702,16 @@ GNELane::drawLaneMarkings(const GUIVisualizationSettings& s, const GUIVisualizat
// highlightchange prohibitions
glTranslated(0, 0, -0.05);
GLHelper::setColor(RGBColor::ORANGE);
const double offset = myLaneDrawingConstants->getHalfLaneWidth() * myLaneDrawingConstants->getExaggeration() * (s.lefthand ? -1 : 1);
const double offset = myDrawingConstants->getHalfLaneWidth() * myDrawingConstants->getExaggeration() * (s.lefthand ? -1 : 1);
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), myLaneGeometry,
(myLaneDrawingConstants->getHalfLaneWidth() * 0.5) * myLaneDrawingConstants->getExaggeration(), offset);
(myDrawingConstants->getHalfLaneWidth() * 0.5) * myDrawingConstants->getExaggeration(), offset);
glTranslated(0, 0, 0.05);
}
// draw white boundings and white markings
glTranslated(0, 0, -0.1);
GLHelper::setColor(RGBColor::WHITE);
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), myLaneGeometry,
(myLaneDrawingConstants->getHalfLaneWidth() + SUMO_const_laneMarkWidth) * myLaneDrawingConstants->getExaggeration());
(myDrawingConstants->getHalfLaneWidth() + SUMO_const_laneMarkWidth) * myDrawingConstants->getExaggeration());
GLHelper::popMatrix();
}
}
Expand Down Expand Up @@ -1236,13 +1236,13 @@ GNELane::drawLane(const GUIVisualizationSettings& s, const GUIVisualizationSetti
drawLaneAsRailway(s, d);
} else {
// create visible gap depending of draw spread superposed
const double offset = drawSpreadSuperposed? myLaneDrawingConstants->getWidth() * 0.5 : 0;
const double offset = drawSpreadSuperposed? myDrawingConstants->getWidth() * 0.5 : 0;
const double widthFactor = drawSpreadSuperposed? 0.4 : 1;
// draw as box lines
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(),
myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), myShapeColors,
myLaneDrawingConstants->getWidth() * widthFactor, false, offset);
myDrawingConstants->getWidth() * widthFactor, false, offset);
}
// draw back edge
drawBackEdge(s, d, drawSpreadSuperposed);
Expand Down Expand Up @@ -1282,21 +1282,21 @@ GNELane::drawLane(const GUIVisualizationSettings& s, const GUIVisualizationSetti
void
GNELane::drawBackEdge(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const bool drawSpreadSuperposed) const {
// only draw if width and mark width are differents
if (myLaneDrawingConstants->getWidth() != myLaneDrawingConstants->getMarkWidth()) {
if (myDrawingConstants->getWidth() != myDrawingConstants->getMarkWidth()) {
// Push matrix
GLHelper::pushMatrix();
// move back
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 = drawSpreadSuperposed? myLaneDrawingConstants->getWidth() * 0.5 : 0;
const double offset = drawSpreadSuperposed? myDrawingConstants->getWidth() * 0.5 : 0;
const double widthFactor = drawSpreadSuperposed? 0.4 : 1;
// draw as box lines
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(),
myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), {},
myLaneDrawingConstants->getWidth() * widthFactor, false, offset);
myDrawingConstants->getWidth() * widthFactor, false, offset);
// Pop matrix
GLHelper::popMatrix();
}
Expand Down Expand Up @@ -1615,10 +1615,10 @@ GNELane::drawLaneStopOffset(const GUIVisualizationSettings& s, const GUIVisualiz
glRotated(rot, 0, 0, 1);
glTranslated(0, laneStopOffset.getOffset(), 0);
glBegin(GL_QUADS);
glVertex2d(-myLaneDrawingConstants->getWidth(), 0.0);
glVertex2d(-myLaneDrawingConstants->getWidth(), 0.2);
glVertex2d(myLaneDrawingConstants->getWidth(), 0.2);
glVertex2d(myLaneDrawingConstants->getWidth(), 0.0);
glVertex2d(-myDrawingConstants->getWidth(), 0.0);
glVertex2d(-myDrawingConstants->getWidth(), 0.2);
glVertex2d(myDrawingConstants->getWidth(), 0.2);
glVertex2d(myDrawingConstants->getWidth(), 0.0);
glEnd();
GLHelper::popMatrix();
}
Expand All @@ -1641,7 +1641,7 @@ GNELane::drawDirectionIndicators(const GUIVisualizationSettings& s, const GUIVis
glColor3d(0.3, 0.3, 0.3);
}
// get width and sideOffset
const double width = MAX2(NUMERICAL_EPS, (myLaneDrawingConstants->getHalfLaneWidth() * 2 * myLaneDrawingConstants->getExaggeration() * (spreadSuperposed ? 0.4 : 1)));
const double width = MAX2(NUMERICAL_EPS, (myDrawingConstants->getHalfLaneWidth() * 2 * myDrawingConstants->getExaggeration() * (spreadSuperposed ? 0.4 : 1)));
const double sideOffset = spreadSuperposed ? width * -0.5 : 0;
// push direction indicator matrix
GLHelper::pushMatrix();
Expand Down Expand Up @@ -1687,16 +1687,16 @@ GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s, const GUIVisualiza
// draw as railway: assume standard gauge of 1435mm when lane width is not set
// draw foot width 150mm, assume that distance between rail feet inner sides is reduced on both sides by 39mm with regard to the gauge
// assume crosstie length of 181% gauge (2600mm for standard gauge)
double halfGauge = 0.5 * (width == SUMO_const_laneWidth ? 1.4350 : width) * myLaneDrawingConstants->getExaggeration();
double halfGauge = 0.5 * (width == SUMO_const_laneWidth ? 1.4350 : width) * myDrawingConstants->getExaggeration();
// check if we have to modify shape
if (spreadSuperposed) {
shape.move2side(halfGauge * 0.8);
halfGauge *= 0.4;
//std::cout << "spreadSuperposed " << getID() << " old=" << myLaneGeometry.getShape() << " new=" << shape << "\n";
}
// calculate constant
const double halfInnerFeetWidth = halfGauge - 0.039 * myLaneDrawingConstants->getExaggeration();
const double halfRailWidth = halfInnerFeetWidth + 0.15 * myLaneDrawingConstants->getExaggeration();
const double halfInnerFeetWidth = halfGauge - 0.039 * myDrawingConstants->getExaggeration();
const double halfRailWidth = halfInnerFeetWidth + 0.15 * myDrawingConstants->getExaggeration();
const double halfCrossTieWidth = halfGauge * 1.81;
// Draw lane geometry
GUIGeometry::drawLaneGeometry(s, myNet->getViewNet()->getPositionInformation(), shape, myLaneGeometry.getShapeRotations(), myLaneGeometry.getShapeLengths(), myShapeColors, halfRailWidth);
Expand All @@ -1711,7 +1711,7 @@ GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s, const GUIVisualiza
// Set current color back
GLHelper::setColor(current);
// Draw crossties
GLHelper::drawCrossTies(shape, myLaneGeometry.getShapeRotations(), myLaneGeometry.getShapeLengths(), 0.26 * myLaneDrawingConstants->getExaggeration(), 0.6 * myLaneDrawingConstants->getExaggeration(), halfCrossTieWidth, s.drawForRectangleSelection);
GLHelper::drawCrossTies(shape, myLaneGeometry.getShapeRotations(), myLaneGeometry.getShapeLengths(), 0.26 * myDrawingConstants->getExaggeration(), 0.6 * myDrawingConstants->getExaggeration(), halfCrossTieWidth, s.drawForRectangleSelection);
// check if dotted contours has to be drawn
myContour.drawDottedContourExtruded(s, d, shape, halfGauge, 1, true, true, s.dottedContourSettings.segmentWidth);
}
Expand All @@ -1722,7 +1722,7 @@ GNELane::drawTextures(const GUIVisualizationSettings& s, const GUIVisualizationS
// check all conditions for drawing textures
if (!s.disableLaneIcons && (myLaneRestrictedTexturePositions.size() > 0)) {
// Declare default width of icon (3)
const double iconWidth = myLaneDrawingConstants->getHalfLaneWidth();
const double iconWidth = myDrawingConstants->getHalfLaneWidth();
// Draw list of icons
for (int i = 0; i < (int)myLaneRestrictedTexturePositions.size(); i++) {
// Push draw matrix 2
Expand Down
21 changes: 12 additions & 9 deletions src/netedit/elements/network/GNELane.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ class GNELane : public GNENetworkElement, public GNECandidateElement, public FXD
FXDECLARE(GNELane)

public:
/// @brief class for LaneDrawingConstants
class LaneDrawingConstants {
/// @brief class for lane drawing constants
class DrawingConstants {

public:
/// @brief parameter constructor (reference)
LaneDrawingConstants(const GNELane* lane);
/// @brief parameter constructor
DrawingConstants(const GNELane* lane);

/// @brief update lane drawing constants
void update(const GUIVisualizationSettings& s);
Expand Down Expand Up @@ -86,11 +86,14 @@ class GNELane : public GNENetworkElement, public GNECandidateElement, public FXD
/// @brief lane width (but reduced,to make sure that a selected edge can still be seen
double myWidth = 0;

/// @brief invalidate default constructor
DrawingConstants(const GNELane* lane) = delete;

/// @brief Invalidated copy constructor.
LaneDrawingConstants(const LaneDrawingConstants&) = delete;
DrawingConstants(const DrawingConstants&) = delete;

/// @brief Invalidated assignment operator.
LaneDrawingConstants& operator=(const LaneDrawingConstants&) = delete;
DrawingConstants& operator=(const DrawingConstants&) = delete;
};

/**@brief Constructor
Expand Down Expand Up @@ -124,8 +127,8 @@ class GNELane : public GNENetworkElement, public GNECandidateElement, public FXD
/// @brief get lengths of the single shape parts
const std::vector<double>& getShapeLengths() const;

/// @brief get LaneDrawingConstants
const LaneDrawingConstants* getLaneDrawingConstants() const;
/// @brief get lane drawing constants (previously calculated in drawGL())
const DrawingConstants* getDrawingConstants() const;

/// @brief update pre-computed geometry information
void updateGeometry();
Expand Down Expand Up @@ -313,7 +316,7 @@ class GNELane : public GNENetworkElement, public GNECandidateElement, public FXD
GUIGeometry myLaneGeometry;

/// @brief LaneDrawingConstants
LaneDrawingConstants *myLaneDrawingConstants;
DrawingConstants *myDrawingConstants;

/// @name computed only once (for performance) in updateGeometry()
/// @{
Expand Down

0 comments on commit e69f854

Please sign in to comment.