Skip to content

Commit

Permalink
Updated drawGeometryPoints(). Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 9c73f26 commit 751a679
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/netedit/elements/additional/GNEPoly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ GNEPoly::drawGL(const GUIVisualizationSettings& s) const {
// check move mode flag
const bool moveMode = (myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, d, this, myNet->getViewNet()->getPositionInformation(), myPolygonGeometry.getShape(), darkerColor, invertedColor,
GUIGeometry::drawGeometryPoints(s, this, myNet->getViewNet()->getPositionInformation(), myPolygonGeometry.getShape(), darkerColor, invertedColor,
s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5), polyExaggeration,
myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
// draw moving hint points
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/additional/GNETAZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ GNETAZ::drawGL(const GUIVisualizationSettings& s) const {
// check move mode flag
const bool moveMode = (myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, d, this, myNet->getViewNet()->getPositionInformation(), myAdditionalGeometry.getShape(), darkerColor, invertedColor,
GUIGeometry::drawGeometryPoints(s, this, myNet->getViewNet()->getPositionInformation(), myAdditionalGeometry.getShape(), darkerColor, invertedColor,
s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5), TAZExaggeration,
myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
// draw moving hint points
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNEConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ GNEConnection::drawGL(const GUIVisualizationSettings& s) const {
// color
const RGBColor darkerColor = connectionColor.changedBrightness(-32);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, d, this, myNet->getViewNet()->getPositionInformation(), myConnectionGeometry.getShape(), darkerColor, RGBColor::BLACK,
GUIGeometry::drawGeometryPoints(s, this, myNet->getViewNet()->getPositionInformation(), myConnectionGeometry.getShape(), darkerColor, RGBColor::BLACK,
s.neteditSizeSettings.connectionGeometryPointRadius, 1,
myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
// draw moving hint
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNECrossing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ GNECrossing::drawGL(const GUIVisualizationSettings& s) const {
// color
const RGBColor darkerColor = crossingColor.changedBrightness(-32);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, d, this, myNet->getViewNet()->getPositionInformation(), myCrossingGeometry.getShape(), darkerColor, RGBColor::BLACK,
GUIGeometry::drawGeometryPoints(s, this, myNet->getViewNet()->getPositionInformation(), myCrossingGeometry.getShape(), darkerColor, RGBColor::BLACK,
s.neteditSizeSettings.crossingGeometryPointRadius, selectionScale,
myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
// draw moving hint
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,7 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, const GUIVis
// draw shape
GUIGeometry::drawGeometry(s, mousePos, junctionGeometry, s.neteditSizeSettings.junctionGeometryPointRadius * 0.5);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, d, this, mousePos, junctionOpenShape, darkerColor, RGBColor::BLACK,
GUIGeometry::drawGeometryPoints(s, this, mousePos, junctionOpenShape, darkerColor, RGBColor::BLACK,
s.neteditSizeSettings.junctionGeometryPointRadius, exaggeration,
myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
// draw moving hint
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/network/GNELane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ GNELane::drawGL(const GUIVisualizationSettings& s) const {
const LaneDrawingConstants laneDrawingConstants(s, this);
// get detail level
const auto d = s.getDetailLevel(laneDrawingConstants.exaggeration);
// draw geometry only if we'rent in drawForObjectUnderCursor mode
// check drawing conditions
if (!s.drawForObjectUnderCursor) {
// Push edge parent name
GLHelper::pushName(myParentEdge->getGlID());
Expand Down Expand Up @@ -1295,7 +1295,7 @@ GNELane::drawShapeEdited(const GUIVisualizationSettings& s, const GUIVisualizati
// color
const RGBColor darkerColor = s.colorSettings.editShapeColor.changedBrightness(-32);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, d, this, myNet->getViewNet()->getPositionInformation(), myLaneGeometry.getShape(), darkerColor, RGBColor::BLACK,
GUIGeometry::drawGeometryPoints(s, this, myNet->getViewNet()->getPositionInformation(), myLaneGeometry.getShape(), darkerColor, RGBColor::BLACK,
s.neteditSizeSettings.laneGeometryPointRadius, 1, myNet->getViewNet()->getNetworkViewOptions().editingElevation(), true);
// Pop shape edited matrix
GLHelper::popMatrix();
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNEWalkingArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ GNEWalkingArea::drawTesselatedWalkingArea(const GUIVisualizationSettings& s, con
// color
const RGBColor darkerColor = color.changedBrightness(-32);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, d, this, myNet->getViewNet()->getPositionInformation(), myTesselation.getShape(), darkerColor, RGBColor::BLACK,
GUIGeometry::drawGeometryPoints(s, this, myNet->getViewNet()->getPositionInformation(), myTesselation.getShape(), darkerColor, RGBColor::BLACK,
s.neteditSizeSettings.crossingGeometryPointRadius, 1,
myNet->getViewNet()->getNetworkViewOptions().editingElevation(), true);
// draw moving hint
Expand Down
3 changes: 1 addition & 2 deletions src/netedit/frames/GNEConsecutiveSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ GNEConsecutiveSelector::drawTemporalConsecutiveLanePath(const GUIVisualizationSe
const Position firstPosition = myLanePath.front().first->getLaneShape().positionAtOffset2D(myLanePath.front().second);
const Position secondPosition = myLanePath.back().first->getLaneShape().positionAtOffset2D(myLanePath.back().second);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, GUIVisualizationSettings::Detail::GeometryPoint, nullptr,
myFrameParent->getViewNet()->getPositionInformation(), {firstPosition, secondPosition},
GUIGeometry::drawGeometryPoints(s, nullptr, myFrameParent->getViewNet()->getPositionInformation(), {firstPosition, secondPosition},
pointColor, RGBColor::WHITE, s.neteditSizeSettings.polylineWidth, 1, false, true);
// Pop last matrix
GLHelper::popMatrix();
Expand Down
87 changes: 45 additions & 42 deletions src/utils/gui/div/GUIGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,52 +306,55 @@ GUIGeometry::drawContourGeometry(const GUIGeometry& geometry, const double width


void
GUIGeometry::drawGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const GUIGlObject* glObject,
GUIGeometry::drawGeometryPoints(const GUIVisualizationSettings& s, const GUIGlObject* glObject,
const Position& mousePos, const PositionVector& shape, const RGBColor& geometryPointColor, const RGBColor& textColor,
const double radius, const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols) {
// get exaggeratedRadio
const double exaggeratedRadio = (radius * exaggeration);
// iterate over shape
for (const auto& vertex : shape) {
// first check if mouse is over geometry point
const bool mouseOverGeometryPoint = glObject? gPostDrawing.positionWithinCircle(glObject, mousePos, vertex, exaggeratedRadio) : false;
// don't draw in draw for object under cursor)
if (!s.drawForObjectUnderCursor) {
// get current detail level
const auto d = s.getDetailLevel(exaggeratedRadio);
// push geometry point matrix
GLHelper::pushMatrix();
// move to vertex
glTranslated(vertex.x(), vertex.y(), 0.2);
// set color depending if cursor is over geometry point
GLHelper::setColor(mouseOverGeometryPoint? RGBColor::ORANGE : geometryPointColor);
// draw circle detailled
GLHelper::drawFilledCircleDetailled(d, exaggeratedRadio);
// pop geometry point matrix
GLHelper::popMatrix();
// draw elevation or special symbols (Start, End and Block)
if (d <= GUIVisualizationSettings::Detail::Text) {
if (editingElevation) {
// Push Z matrix
GLHelper::pushMatrix();
// draw Z (elevation)
GLHelper::drawText(toString(vertex.z()), vertex, 0.3, 0.7, textColor);
// pop Z matrix
GLHelper::popMatrix();
} else if ((vertex == shape.front()) && drawExtremeSymbols) {
// push "S" matrix
GLHelper::pushMatrix();
// draw a "s" over first point
GLHelper::drawText("S", vertex, 0.3, 2 * exaggeratedRadio, textColor);
// pop "S" matrix
GLHelper::popMatrix();
} else if ((vertex == shape.back()) && (shape.isClosed() == false) && drawExtremeSymbols) {
// push "E" matrix
GLHelper::pushMatrix();
// draw a "e" over last point if polygon isn't closed
GLHelper::drawText("E", vertex, 0.3, 2 * exaggeratedRadio, textColor);
// pop "E" matrix
GLHelper::popMatrix();
// get current detail level
const auto d = s.getDetailLevel(exaggeratedRadio);
// check detail level
if (d <= GUIVisualizationSettings::Detail::GeometryPoint) {
// iterate over shape
for (const auto& vertex : shape) {
// first check if mouse is over geometry point
const bool mouseOverGeometryPoint = glObject? gPostDrawing.positionWithinCircle(glObject, mousePos, vertex, exaggeratedRadio) : false;
// don't draw in draw for object under cursor)
if (!s.drawForObjectUnderCursor) {
// push geometry point matrix
GLHelper::pushMatrix();
// move to vertex
glTranslated(vertex.x(), vertex.y(), 0.2);
// set color depending if cursor is over geometry point
GLHelper::setColor(mouseOverGeometryPoint? RGBColor::ORANGE : geometryPointColor);
// draw circle detailled
GLHelper::drawFilledCircleDetailled(d, exaggeratedRadio);
// pop geometry point matrix
GLHelper::popMatrix();
// draw elevation or special symbols (Start, End and Block)
if (d <= GUIVisualizationSettings::Detail::Text) {
if (editingElevation) {
// Push Z matrix
GLHelper::pushMatrix();
// draw Z (elevation)
GLHelper::drawText(toString(vertex.z()), vertex, 0.3, 0.7, textColor);
// pop Z matrix
GLHelper::popMatrix();
} else if ((vertex == shape.front()) && drawExtremeSymbols) {
// push "S" matrix
GLHelper::pushMatrix();
// draw a "s" over first point
GLHelper::drawText("S", vertex, 0.3, 2 * exaggeratedRadio, textColor);
// pop "S" matrix
GLHelper::popMatrix();
} else if ((vertex == shape.back()) && (shape.isClosed() == false) && drawExtremeSymbols) {
// push "E" matrix
GLHelper::pushMatrix();
// draw a "e" over last point if polygon isn't closed
GLHelper::drawText("E", vertex, 0.3, 2 * exaggeratedRadio, textColor);
// pop "E" matrix
GLHelper::popMatrix();
}
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/utils/gui/div/GUIGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ class GUIGeometry {
static void drawContourGeometry(const GUIGeometry& geometry, const double width, const bool drawExtremes = false);

/// @brief draw geometry points
static void drawGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const GUIGlObject* glObject, const Position& mousePos, const PositionVector& shape,
const RGBColor& geometryPointColor, const RGBColor& textColor, const double radius,
const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols);
static void drawGeometryPoints(const GUIVisualizationSettings& s, const GUIGlObject* glObject, const Position& mousePos,
const PositionVector& shape, const RGBColor& geometryPointColor, const RGBColor& textColor,
const double radius, const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols);

/// @brief draw moving hint (circle over shape in which create new vertex)
static void drawMovingHint(const GUIVisualizationSettings& s, const GUIGlObject* glObject, const Position& mousePos,
Expand Down

0 comments on commit 751a679

Please sign in to comment.