Skip to content

Commit

Permalink
Updated GUIPostDrawing functions. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent ad5efe6 commit 4879cdc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/netedit/elements/GNEContour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ GNEContour::drawDottedContourClosed(const GUIVisualizationSettings& s, const Pos
// first build dotted contour
buildDottedContourClosed(s, shape, scale);
// check if mouse is within geometry
gPostDrawing.positionWithinClosedShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(0));
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(0));
// draw dotted contours
drawDottedContours(s, s.drawDottedContour(scale), addOffset, lineWidth);
}
Expand All @@ -83,7 +83,7 @@ GNEContour::drawDottedContourExtruded(const GUIVisualizationSettings& s, const P
// first build dotted contour
buildDottedContourExtruded(s, shape, extrusionWidth, scale, drawFirstExtrem, drawLastExtrem);
// check if mouse is within two lines
gPostDrawing.positionWithinClosedShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(1));
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(1));
// draw dotted contours
drawDottedContours(s, scale, true, lineWidth);
}
Expand All @@ -96,7 +96,7 @@ GNEContour::drawDottedContourRectangle(const GUIVisualizationSettings& s, const
// first build dotted contour
buildDottedContourRectangle(s, pos, width, height, offsetX, offsetY, rot, scale);
// check if mouse is within geometry
gPostDrawing.positionWithinClosedShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(0));
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(0));
// draw dotted contours
drawDottedContours(s, scale, true, lineWidth);
}
Expand Down
15 changes: 2 additions & 13 deletions src/utils/gui/settings/GUIPostDrawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ GUIPostDrawing::isElementUnderCursor(const GUIGlObject* GLObject) const {


bool
GUIPostDrawing::positionWithinCircle(const GUIGlObject* GLObject, const Position &pos, const Position center, const double radius) {
GUIPostDrawing::positionWithinCircle(const GUIGlObject* GLObject, const Position &pos, const Position &center, const double radius) {
if (pos.distanceSquaredTo2D(center) <= (radius * radius)) {
addElementUnderCursor(GLObject);
return true;
Expand All @@ -81,7 +81,7 @@ GUIPostDrawing::positionWithinCircle(const GUIGlObject* GLObject, const Position


bool
GUIPostDrawing::positionWithinClosedShape(const GUIGlObject* GLObject, const Position &pos, const PositionVector shape) {
GUIPostDrawing::positionWithinShape(const GUIGlObject* GLObject, const Position &pos, const PositionVector &shape) {
if (shape.around(pos)) {
addElementUnderCursor(GLObject);
return true;
Expand All @@ -91,17 +91,6 @@ GUIPostDrawing::positionWithinClosedShape(const GUIGlObject* GLObject, const Pos
}


bool
GUIPostDrawing::positionWithinShapeLine(const GUIGlObject* GLObject, const Position &pos, const PositionVector shape, const double width) {
if (shape.distance2D(pos) <= width) {
addElementUnderCursor(GLObject);
return true;
} else {
return false;
}
}


const std::vector<const GUIGlObject*>&
GUIPostDrawing::getElementsUnderCursor() const {
return myElementsUnderCursor;
Expand Down
9 changes: 3 additions & 6 deletions src/utils/gui/settings/GUIPostDrawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,10 @@ class GUIPostDrawing {
bool isElementUnderCursor(const GUIGlObject* GLObject) const;

/// @brief check if mouse is within elements geometry (for circles)
bool positionWithinCircle(const GUIGlObject* GLObject, const Position &pos, const Position center, const double radius);
bool positionWithinCircle(const GUIGlObject* GLObject, const Position &pos, const Position &center, const double radius);

/// @brief check if mouse is within closed geometry (for filled shapes)
bool positionWithinClosedShape(const GUIGlObject* GLObject, const Position &pos, const PositionVector shape);

/// @brief check if mouse is within elements geometry (for shapes)
bool positionWithinShapeLine(const GUIGlObject* GLObject, const Position &pos, const PositionVector shape, const double width);
/// @brief check if mouse is within closed shapes (for filled shapes)
bool positionWithinShape(const GUIGlObject* GLObject, const Position &pos, const PositionVector &shape);

/// @brief get all elements under cursor
const std::vector<const GUIGlObject*>& getElementsUnderCursor() const;
Expand Down

0 comments on commit 4879cdc

Please sign in to comment.