Skip to content

Commit

Permalink
Updated draw<>GeometryPoint() functions. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 8173327 commit 3b6321a
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 55 deletions.
46 changes: 26 additions & 20 deletions src/netedit/elements/additional/GNEAdditional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,26 +1041,28 @@ GNEAdditional::drawParentChildLines(const GUIVisualizationSettings& s, const RGB


void
GNEAdditional::drawUpGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift) {
drawSemiCircleGeometryPoint(viewNet, pos, rot, baseColor, -90, 90, ignoreShift);
GNEAdditional::drawUpGeometryPoint(const GUIVisualizationSettings& s, const Position& pos, const double rot,
const RGBColor& baseColor, const bool ignoreShift) const {
drawSemiCircleGeometryPoint(s, pos, rot, baseColor, -90, 90, ignoreShift);
}


void
GNEAdditional::drawDownGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift) {
drawSemiCircleGeometryPoint(viewNet, pos, rot, baseColor, 90, 270, ignoreShift);
GNEAdditional::drawDownGeometryPoint(const GUIVisualizationSettings& s, const Position& pos, const double rot,
const RGBColor& baseColor, const bool ignoreShift) const {
drawSemiCircleGeometryPoint(s, pos, rot, baseColor, 90, 270, ignoreShift);
}


void
GNEAdditional::drawLeftGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift) {
drawSemiCircleGeometryPoint(viewNet, pos, rot, baseColor, -90, 90, ignoreShift);
GNEAdditional::drawLeftGeometryPoint(const GUIVisualizationSettings& s, const Position& pos, const double rot,
const RGBColor& baseColor, const bool ignoreShift) const {
drawSemiCircleGeometryPoint(s, pos, rot, baseColor, -90, 90, ignoreShift);
}


void
GNEAdditional::drawRightGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift) {
drawSemiCircleGeometryPoint(viewNet, pos, rot, baseColor, 270, 90, ignoreShift);
GNEAdditional::drawRightGeometryPoint(const GUIVisualizationSettings& s, const Position& pos, const double rot,
const RGBColor& baseColor, const bool ignoreShift) const {
drawSemiCircleGeometryPoint(s, pos, rot, baseColor, 270, 90, ignoreShift);
}


Expand Down Expand Up @@ -1157,27 +1159,31 @@ GNEAdditional::checkChildAdditionalRestriction() const {


void
GNEAdditional::drawSemiCircleGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor,
const double fromAngle, const double toAngle, const bool ignoreShift) {
GNEAdditional::drawSemiCircleGeometryPoint(const GUIVisualizationSettings& s, const Position& pos, const double rot, const RGBColor& baseColor,
const double fromAngle, const double toAngle, const bool ignoreShift) const {
// first check that we're in move mode and shift key is pressed
if (viewNet->getEditModes().isCurrentSupermodeNetwork() && (viewNet->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE) &&
(viewNet->getMouseButtonKeyPressed().shiftKeyPressed() || ignoreShift)) {
// calculate new color
const RGBColor color = baseColor.changedBrightness(-50);
if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
(myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE) &&
(myNet->getViewNet()->getMouseButtonKeyPressed().shiftKeyPressed() || ignoreShift)) {
// push matrix
GLHelper::pushMatrix();
// translated to front
glTranslated(0, 0, 0.1);
// set color
GLHelper::setColor(color);
// set color depending if check if mouse is over element
if (gPostDrawing.positionWithinCircle(this, myNet->getViewNet()->getPositionInformation(), pos,
s.neteditSizeSettings.additionalGeometryPointRadius)) {
GLHelper::setColor(RGBColor::ORANGE);
} else {
GLHelper::setColor(baseColor.changedBrightness(-50));
}
// push geometry point matrix
GLHelper::pushMatrix();
// translate and rotate
glTranslated(pos.x(), pos.y(), 0.1);
glRotated(rot, 0, 0, 1);
// draw geometry point
GLHelper::drawFilledCircle(viewNet->getVisualisationSettings().neteditSizeSettings.additionalGeometryPointRadius,
viewNet->getVisualisationSettings().getCircleResolution(), fromAngle, toAngle);
GLHelper::drawFilledCircle(s.neteditSizeSettings.additionalGeometryPointRadius,
s.getCircleResolution(), fromAngle, toAngle);
// pop geometry point matrix
GLHelper::popMatrix();
// pop draw matrix
Expand Down
17 changes: 11 additions & 6 deletions src/netedit/elements/additional/GNEAdditional.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,20 @@ class GNEAdditional : public GNEPathManager::PathElement, public GNEHierarchical
void drawParentChildLines(const GUIVisualizationSettings& s, const RGBColor& color, const bool onlySymbols = false) const;

/// @brief draw up geometry point
static void drawUpGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift = false);
void drawUpGeometryPoint(const GUIVisualizationSettings& s, const Position& pos, const double rot,
const RGBColor& baseColor, const bool ignoreShift = false) const;

/// @brief draw down geometry point
static void drawDownGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift = false);
void drawDownGeometryPoint(const GUIVisualizationSettings& s, const Position& pos, const double rot,
const RGBColor& baseColor, const bool ignoreShift = false) const;

/// @brief draw left geometry point
static void drawLeftGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift = false);
void drawLeftGeometryPoint(const GUIVisualizationSettings& s, const Position& pos, const double rot,
const RGBColor& baseColor, const bool ignoreShift = false) const;

/// @brief draw right geometry point
static void drawRightGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift = false);
void drawRightGeometryPoint(const GUIVisualizationSettings& s, const Position& pos, const double rot,
const RGBColor& baseColor, const bool ignoreShift = false) const;

/// @brief get draw position index (used in rerouters and VSS)
int getDrawPositionIndex() const;
Expand Down Expand Up @@ -449,8 +453,9 @@ class GNEAdditional : public GNEPathManager::PathElement, public GNEHierarchical
virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;

/// @brief draw geometry point
static void drawSemiCircleGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor,
const double fromAngle, const double toAngle, const bool ignoreShift);
void drawSemiCircleGeometryPoint(const GUIVisualizationSettings& s, const Position& pos, const double rot,
const RGBColor& baseColor,const double fromAngle, const double toAngle,
const bool ignoreShift) const;

/// @brief adjust listed additional text
std::string adjustListedAdditionalText(const std::string& text) const;
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/additional/GNEBusStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ GNEBusStop::drawGL(const GUIVisualizationSettings& s) const {
}
// draw geometry points
if (myStartPosition != INVALID_DOUBLE) {
drawLeftGeometryPoint(myNet->getViewNet(), myAdditionalGeometry.getShape().front(), myAdditionalGeometry.getShapeRotations().front(), baseColor);
drawLeftGeometryPoint(s, myAdditionalGeometry.getShape().front(), myAdditionalGeometry.getShapeRotations().front(), baseColor);
}
if (myEndPosition != INVALID_DOUBLE) {
drawRightGeometryPoint(myNet->getViewNet(), myAdditionalGeometry.getShape().back(), myAdditionalGeometry.getShapeRotations().back(), baseColor);
drawRightGeometryPoint(s, myAdditionalGeometry.getShape().back(), myAdditionalGeometry.getShapeRotations().back(), baseColor);
}
// pop layer matrix
GLHelper::popMatrix();
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/additional/GNEChargingStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ GNEChargingStation::drawGL(const GUIVisualizationSettings& s) const {
}
// draw geometry points
if (myStartPosition != INVALID_DOUBLE) {
drawLeftGeometryPoint(myNet->getViewNet(), myAdditionalGeometry.getShape().front(), myAdditionalGeometry.getShapeRotations().front(), baseColor);
drawLeftGeometryPoint(s, myAdditionalGeometry.getShape().front(), myAdditionalGeometry.getShapeRotations().front(), baseColor);
}
if (myEndPosition != INVALID_DOUBLE) {
drawRightGeometryPoint(myNet->getViewNet(), myAdditionalGeometry.getShape().back(), myAdditionalGeometry.getShapeRotations().back(), baseColor);
drawRightGeometryPoint(s, myAdditionalGeometry.getShape().back(), myAdditionalGeometry.getShapeRotations().back(), baseColor);
}
// pop layer matrix
GLHelper::popMatrix();
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/additional/GNEContainerStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ GNEContainerStop::drawGL(const GUIVisualizationSettings& s) const {
}
// draw geometry points
if (myStartPosition != INVALID_DOUBLE) {
drawLeftGeometryPoint(myNet->getViewNet(), myAdditionalGeometry.getShape().front(), myAdditionalGeometry.getShapeRotations().front(), baseColor);
drawLeftGeometryPoint(s, myAdditionalGeometry.getShape().front(), myAdditionalGeometry.getShapeRotations().front(), baseColor);
}
if (myEndPosition != INVALID_DOUBLE) {
drawRightGeometryPoint(myNet->getViewNet(), myAdditionalGeometry.getShape().back(), myAdditionalGeometry.getShapeRotations().back(), baseColor);
drawRightGeometryPoint(s, myAdditionalGeometry.getShape().back(), myAdditionalGeometry.getShapeRotations().back(), baseColor);
}
// pop layer matrix
GLHelper::popMatrix();
Expand Down
12 changes: 6 additions & 6 deletions src/netedit/elements/additional/GNELaneAreaDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ GNELaneAreaDetector::drawGL(const GUIVisualizationSettings& s) const {
drawE2DetectorLogo(s, E2Exaggeration, "E2", textColor);
}
// draw geometry points
drawLeftGeometryPoint(myNet->getViewNet(), myAdditionalGeometry.getShape().front(), myAdditionalGeometry.getShapeRotations().front(), E2Color);
drawRightGeometryPoint(myNet->getViewNet(), myAdditionalGeometry.getShape().back(), myAdditionalGeometry.getShapeRotations().back(), E2Color);
drawLeftGeometryPoint(s, myAdditionalGeometry.getShape().front(), myAdditionalGeometry.getShapeRotations().front(), E2Color);
drawRightGeometryPoint(s, myAdditionalGeometry.getShape().back(), myAdditionalGeometry.getShapeRotations().back(), E2Color);
// pop layer matrix
GLHelper::popMatrix();
// Pop name
Expand Down Expand Up @@ -395,12 +395,12 @@ GNELaneAreaDetector::drawLanePartialGL(const GUIVisualizationSettings& s, const
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), E2Geometry, E2DetectorWidth);
// draw geometry points
if (segment->isFirstSegment() && segment->isLastSegment()) {
drawLeftGeometryPoint(myNet->getViewNet(), E2Geometry.getShape().front(), E2Geometry.getShapeRotations().front(), E2Color, true);
drawRightGeometryPoint(myNet->getViewNet(), E2Geometry.getShape().back(), E2Geometry.getShapeRotations().back(), E2Color, true);
drawLeftGeometryPoint(s, E2Geometry.getShape().front(), E2Geometry.getShapeRotations().front(), E2Color, true);
drawRightGeometryPoint(s, E2Geometry.getShape().back(), E2Geometry.getShapeRotations().back(), E2Color, true);
} else if (segment->isFirstSegment()) {
drawLeftGeometryPoint(myNet->getViewNet(), E2Geometry.getShape().front(), E2Geometry.getShapeRotations().front(), E2Color, true);
drawLeftGeometryPoint(s, E2Geometry.getShape().front(), E2Geometry.getShapeRotations().front(), E2Color, true);
} else if (segment->isLastSegment()) {
drawRightGeometryPoint(myNet->getViewNet(), E2Geometry.getShape().back(), E2Geometry.getShapeRotations().back(), E2Color, true);
drawRightGeometryPoint(s, E2Geometry.getShape().back(), E2Geometry.getShapeRotations().back(), E2Color, true);
// draw arrow
if (E2Geometry.getShape().size() > 1) {
glTranslated(0, 0, 0.1);
Expand Down
8 changes: 4 additions & 4 deletions src/netedit/elements/additional/GNEOverheadWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,12 @@ GNEOverheadWire::drawLanePartialGL(const GUIVisualizationSettings& s, const GNEP
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), overheadWireGeometryBot, 0.2);
// draw geometry points
if (segment->isFirstSegment() && segment->isLastSegment()) {
drawLeftGeometryPoint(myNet->getViewNet(), overheadWireGeometry.getShape().front(), overheadWireGeometry.getShapeRotations().front(), overheadWireColorTop, true);
drawRightGeometryPoint(myNet->getViewNet(), overheadWireGeometry.getShape().back(), overheadWireGeometry.getShapeRotations().back(), overheadWireColorTop, true);
drawLeftGeometryPoint(s, overheadWireGeometry.getShape().front(), overheadWireGeometry.getShapeRotations().front(), overheadWireColorTop, true);
drawRightGeometryPoint(s, overheadWireGeometry.getShape().back(), overheadWireGeometry.getShapeRotations().back(), overheadWireColorTop, true);
} else if (segment->isFirstSegment()) {
drawLeftGeometryPoint(myNet->getViewNet(), overheadWireGeometry.getShape().front(), overheadWireGeometry.getShapeRotations().front(), overheadWireColorTop, true);
drawLeftGeometryPoint(s, overheadWireGeometry.getShape().front(), overheadWireGeometry.getShapeRotations().front(), overheadWireColorTop, true);
} else if (segment->isLastSegment()) {
drawRightGeometryPoint(myNet->getViewNet(), overheadWireGeometry.getShape().back(), overheadWireGeometry.getShapeRotations().back(), overheadWireColorTop, true);
drawRightGeometryPoint(s, overheadWireGeometry.getShape().back(), overheadWireGeometry.getShapeRotations().back(), overheadWireColorTop, true);
}
// Pop layer matrix
GLHelper::popMatrix();
Expand Down
8 changes: 4 additions & 4 deletions src/netedit/elements/additional/GNEPOI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,12 @@ GNEPOI::drawGL(const GUIVisualizationSettings& s) const {
}
// draw geometry points
if (myShapeHeight.size() > 0) {
GNEAdditional::drawUpGeometryPoint(myNet->getViewNet(), myShapeHeight.front(), 180, RGBColor::ORANGE);
GNEAdditional::drawDownGeometryPoint(myNet->getViewNet(), myShapeHeight.back(), 180, RGBColor::ORANGE);
drawUpGeometryPoint(s, myShapeHeight.front(), 180, RGBColor::ORANGE);
drawDownGeometryPoint(s, myShapeHeight.back(), 180, RGBColor::ORANGE);
}
if (myShapeWidth.size() > 0) {
GNEAdditional::drawLeftGeometryPoint(myNet->getViewNet(), myShapeWidth.back(), -90, RGBColor::ORANGE);
GNEAdditional::drawRightGeometryPoint(myNet->getViewNet(), myShapeWidth.front(), -90, RGBColor::ORANGE);
drawLeftGeometryPoint(s, myShapeWidth.back(), -90, RGBColor::ORANGE);
drawRightGeometryPoint(s, myShapeWidth.front(), -90, RGBColor::ORANGE);
}
// pop name
GLHelper::popName();
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/additional/GNEParkingArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ GNEParkingArea::drawGL(const GUIVisualizationSettings& s) const {
}
// draw geometry points
if (myStartPosition != INVALID_DOUBLE) {
drawLeftGeometryPoint(myNet->getViewNet(), myAdditionalGeometry.getShape().front(), myAdditionalGeometry.getShapeRotations().front(), baseColor);
drawLeftGeometryPoint(s, myAdditionalGeometry.getShape().front(), myAdditionalGeometry.getShapeRotations().front(), baseColor);
}
if (myEndPosition != INVALID_DOUBLE) {
drawRightGeometryPoint(myNet->getViewNet(), myAdditionalGeometry.getShape().back(), myAdditionalGeometry.getShapeRotations().back(), baseColor);
drawRightGeometryPoint(s, myAdditionalGeometry.getShape().back(), myAdditionalGeometry.getShapeRotations().back(), baseColor);
}
// pop layer matrix
GLHelper::popMatrix();
Expand Down
6 changes: 3 additions & 3 deletions src/netedit/elements/additional/GNEParkingSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ GNEParkingSpace::drawGL(const GUIVisualizationSettings& s) const {
GLHelper::drawBoxLines(shapeLengthInner, width - 0.1);
}
// draw geometry points
drawUpGeometryPoint(myNet->getViewNet(), myShapeLength.back(), angle, contourColor);
drawLeftGeometryPoint(myNet->getViewNet(), myShapeWidth.back(), angle - 90, contourColor);
drawRightGeometryPoint(myNet->getViewNet(), myShapeWidth.front(), angle - 90, contourColor);
drawUpGeometryPoint(s, myShapeLength.back(), angle, contourColor);
drawLeftGeometryPoint(s, myShapeWidth.back(), angle - 90, contourColor);
drawRightGeometryPoint(s, myShapeWidth.front(), angle - 90, contourColor);
// pop layer matrix
GLHelper::popMatrix();
// pop name
Expand Down
2 changes: 0 additions & 2 deletions src/netedit/elements/demand/GNEContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ GNEContainer::drawGL(const GUIVisualizationSettings& s) const {
// obtain width and length
const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
// obtain diameter around container (used to calculate distance bewteen cursor and container)
const double distanceSquared = pow(exaggeration * std::max(length, width), 2);
// obtain img file
const std::string file = getTypeParent()->getAttribute(SUMO_ATTR_IMGFILE);
// obtain position
Expand Down
2 changes: 0 additions & 2 deletions src/netedit/elements/demand/GNEPerson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ GNEPerson::drawGL(const GUIVisualizationSettings& s) const {
// obtain width and length
const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
// obtain diameter around person (used to calculate distance bewteen cursor and person)
const double distanceSquared = pow(exaggeration * std::max(length, width), 2);
// obtain img file
const std::string file = getTypeParent()->getAttribute(SUMO_ATTR_IMGFILE);
// obtain position
Expand Down

0 comments on commit 3b6321a

Please sign in to comment.