Skip to content

Commit

Permalink
Updated drawGL() netedit functions. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 28a4a25 commit f216c90
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 121 deletions.
8 changes: 4 additions & 4 deletions src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3316,16 +3316,16 @@ GNEViewNet::updateObjectsUnderCursor(const Position &pos) {
GLHelper::pushMatrix();
// draw back (to avoid overlapping)
glTranslated(0, 0, -10);
// force draw for rectangle selection
myVisualizationSettings->drawForRectangleSelection = true;
// enable draw for object under cursor
myVisualizationSettings->drawForObjectUnderCursor = true;
// create an small boundary
Boundary cursorBoundary;
cursorBoundary.add(pos);
cursorBoundary.grow(POSITION_EPS);
// draw all GL elements within the small boundary
drawGLElements(cursorBoundary);
// restore draw for rectangle selection
myVisualizationSettings->drawForRectangleSelection = false;
// restore draw for object under cursor
myVisualizationSettings->drawForObjectUnderCursor = false;
// pop matrix
GLHelper::popMatrix();
// after draw elements, update objects under cursor
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/GNEViewNetHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ GNEViewNetHelper::ObjectsUnderCursor::filterLanes() {

void
GNEViewNetHelper::ObjectsUnderCursor::filterLockedElements(const std::vector<GUIGlObjectType> ignoreFilter) {
// get all lanes to filter
std::vector<const GUIGlObject*> GUIGlObjects;
// get all locked elements
for (const auto &GUIGlObject : myObjects.GUIGlObjects) {
if (GUIGlObject->isGLObjectLocked()) {
GUIGlObjects;
GUIGlObjects.push_back(GUIGlObject);
}
}
// apply ignore filter
Expand Down
30 changes: 15 additions & 15 deletions src/netedit/elements/GNEContour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ GNEContour::drawDottedContourClosed(const GUIVisualizationSettings& s, const Pos
// first build dotted contour
buildDottedContourClosed(s, shape, scale);
// check if mouse is within geometry (only in rectangle selection mode)
if (s.drawForRectangleSelection) {
if (s.drawForObjectUnderCursor) {
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(0));
} else {
drawDottedContours(s, s.drawDottedContour(scale), addOffset, lineWidth);
}
// draw dotted contours
drawDottedContours(s, s.drawDottedContour(scale), addOffset, lineWidth);
}


Expand All @@ -85,11 +85,11 @@ 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 (only in rectangle selection mode)
if (s.drawForRectangleSelection) {
if (s.drawForObjectUnderCursor) {
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(1));
} else {
drawDottedContours(s, scale, true, lineWidth);
}
// draw dotted contours
drawDottedContours(s, scale, true, lineWidth);
}


Expand All @@ -100,11 +100,11 @@ 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 (only in rectangle selection mode)
if (s.drawForRectangleSelection) {
if (s.drawForObjectUnderCursor) {
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(0));
} else {
drawDottedContours(s, scale, true, lineWidth);
}
// draw dotted contours
drawDottedContours(s, scale, true, lineWidth);
}


Expand All @@ -114,11 +114,11 @@ GNEContour::drawDottedContourCircle(const GUIVisualizationSettings& s, const Pos
// first build dotted contour
buildDottedContourCircle(s, pos, radius, scale);
// check if mouse is within geometry (only in rectangle selection mode)
if (s.drawForRectangleSelection) {
if (s.drawForObjectUnderCursor) {
gPostDrawing.positionWithinCircle(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), pos, (radius * scale));
} else {
drawDottedContours(s, scale, true, lineWidth);
}
// draw dotted contours
drawDottedContours(s, scale, true, lineWidth);
}


Expand All @@ -128,11 +128,11 @@ GNEContour::drawDottedContourEdge(const GUIVisualizationSettings& s, const GNEEd
// first build dotted contour
buildDottedContourEdge(s, edge, drawFirstExtrem, drawLastExtrem);
// check if mouse is within two lines (only in rectangle selection mode)
if (s.drawForRectangleSelection) {
if (s.drawForObjectUnderCursor) {
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(2));
} else {
drawDottedContours(s, 1, true, lineWidth);
}
// draw dotted contours
drawDottedContours(s, 1, true, lineWidth);
}


Expand Down
12 changes: 4 additions & 8 deletions src/netedit/elements/additional/GNEAdditional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,14 +677,12 @@ GNEAdditional::calculatePerpendicularLine(const double endLaneposition) {

void
GNEAdditional::drawSquaredAdditional(const GUIVisualizationSettings& s, const Position& pos, const double size, GUITexture texture, GUITexture selectedTexture) const {
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// Obtain drawing exaggeration
const double exaggeration = getExaggeration(s);
// first check if additional has to be drawn
if (s.drawAdditionals(exaggeration) && myNet->getViewNet()->getDataViewOptions().showAdditionals()) {
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(getCenteringBoundary());
}
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// Start drawing adding an gl identificator
Expand Down Expand Up @@ -728,6 +726,8 @@ GNEAdditional::drawSquaredAdditional(const GUIVisualizationSettings& s, const Po
void
GNEAdditional::drawListedAdditional(const GUIVisualizationSettings& s, const Position& parentPosition, const double offsetX, const double extraOffsetY,
const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const {
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// first check if additional has to be drawn
if (s.drawAdditionals(getExaggeration(s)) && myNet->getViewNet()->getDataViewOptions().showAdditionals()) {
// declare offsets
Expand All @@ -752,10 +752,6 @@ GNEAdditional::drawListedAdditional(const GUIVisualizationSettings& s, const Pos
if (!s.drawForObjectUnderCursor) {
// set position depending of indexes
signPosition.add(4.5 + (baseOffsetX * offsetX), (drawPositionIndex * -1) - extraOffsetY + 1, 0);
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(getCenteringBoundary());
}
// Start drawing adding an gl identifier
GLHelper::pushName(getGlID());
// calculate colors
Expand Down
6 changes: 2 additions & 4 deletions src/netedit/elements/additional/GNEPOI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,10 @@ GNEPOI::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {

void
GNEPOI::drawGL(const GUIVisualizationSettings& s) const {
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// first check if POI can be drawn
if (myNet->getViewNet()->getDemandViewOptions().showShapes() && myNet->getViewNet()->getDataViewOptions().showShapes()) {
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(myAdditionalBoundary);
}
// check if POI can be drawn
if (GUIPointOfInterest::checkDraw(s, this)) {
// obtain POIExaggeration
Expand Down
6 changes: 2 additions & 4 deletions src/netedit/elements/additional/GNEParkingSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ GNEParkingSpace::getParentName() const {

void
GNEParkingSpace::drawGL(const GUIVisualizationSettings& s) const {
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// Set initial values
const double parkingAreaExaggeration = getExaggeration(s);
// first check if additional has to be drawn
Expand All @@ -207,10 +209,6 @@ GNEParkingSpace::drawGL(const GUIVisualizationSettings& s) const {
const double width = myShapeWidth.length2D() * 0.5 + (parkingAreaExaggeration * 0.1);
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(getCenteringBoundary());
}
// get angle
const double angle = getAttributeDouble(SUMO_ATTR_ANGLE);
// get contour color
Expand Down
6 changes: 2 additions & 4 deletions src/netedit/elements/additional/GNEPoly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,8 @@ GNEPoly::drawGL(const GUIVisualizationSettings& s) const {
GUIPolygon::checkDraw(s, this, this)) {
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(myAdditionalBoundary);
}
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// check if draw start und end
const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE;
Expand Down
6 changes: 2 additions & 4 deletions src/netedit/elements/additional/GNETAZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,8 @@ GNETAZ::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {

void
GNETAZ::drawGL(const GUIVisualizationSettings& s) const {
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(getCenteringBoundary());
}
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// first check if poly can be drawn
if (myNet->getViewNet()->getDemandViewOptions().showShapes() && GUIPolygon::checkDraw(s, this, this)) {
// get exaggeration
Expand Down
6 changes: 2 additions & 4 deletions src/netedit/elements/data/GNETAZRelData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,13 @@ GNETAZRelData::fixGenericDataProblem() {

void
GNETAZRelData::drawGL(const GUIVisualizationSettings& s) const {
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// draw TAZRels
if (drawTAZRel()) {
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
const auto& color = setColor(s);
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(getCenteringBoundary());
}
// get flag for only draw contour
const bool onlyDrawContour = !isGenericDataVisible();
// push name (needed for getGUIGlObjectsUnderCursor(...)
Expand Down
4 changes: 0 additions & 4 deletions src/netedit/elements/demand/GNEDemandElementPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,10 +1110,6 @@ GNEDemandElementPlan::drawPlanGL(const bool drawPlan, const GUIVisualizationSett
const double pathWidth = 0.25 * (duplicateWidth ? 2 : 1);
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(myPlanElement->getCenteringBoundary());
}
// push GL ID
GLHelper::pushName(myPlanElement->getGlID());
// push matrix
Expand Down
4 changes: 0 additions & 4 deletions src/netedit/elements/network/GNEConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,6 @@ GNEConnection::drawGL(const GUIVisualizationSettings& s) const {
// Set color depending of the link state
connectionColor = GNEInternalLane::colorForLinksState(getLinkState());
}
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(getCenteringBoundary());
}
// Push name
if (pushGLID) {
GLHelper::pushName(getGlID());
Expand Down
70 changes: 34 additions & 36 deletions src/netedit/elements/network/GNEEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,29 +547,24 @@ GNEEdge::getOppositeEdges() const {

void
GNEEdge::drawGL(const GUIVisualizationSettings& s) const {
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(getCenteringBoundary());
}
// first draw draw lanes
for (const auto& lane : myLanes) {
lane->drawGL(s);
}
// draw geometry points
drawEdgeGeometryPoints(s);
// draw edge shape (a red line only visible if lane shape is strange)
drawEdgeShape(s);
// draw edge stopOffset
drawLaneStopOffset(s);
// draw childrens
drawChildrens(s);
// draw edge name
drawEdgeName(s);
}
// first draw draw lanes
for (const auto& lane : myLanes) {
lane->drawGL(s);
}
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// draw geometry points
drawEdgeGeometryPoints(s);
// draw edge shape (a red line only visible if lane shape is strange)
drawEdgeShape(s);
// draw edge stopOffset
drawLaneStopOffset(s);
// draw edge name
drawEdgeName(s);
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), getPositionInView(), 1);
// draw childrens
drawChildrens(s);
// draw dotted geometry
myContour.drawDottedContourEdge(s, this, true, true, s.dottedContourSettings.segmentWidth);
}
Expand Down Expand Up @@ -2606,7 +2601,7 @@ GNEEdge::drawEndGeometryPoint(const GUIVisualizationSettings& s, const double ci
void
GNEEdge::drawEdgeName(const GUIVisualizationSettings& s) const {
// check if we can draw it
if (!s.drawForRectangleSelection) {
if (!s.drawForObjectUnderCursor && !s.drawForRectangleSelection) {
// draw the name and/or the street name
const bool drawStreetName = s.streetName.show(this) && (myNBEdge->getStreetName() != "");
const bool spreadSuperposed = s.spreadSuperposed && myNBEdge->getBidiEdge() != nullptr;
Expand Down Expand Up @@ -2671,21 +2666,24 @@ GNEEdge::drawEdgeName(const GUIVisualizationSettings& s) const {

void
GNEEdge::drawLaneStopOffset(const GUIVisualizationSettings& s) const {
// Push stopOffset matrix
GLHelper::pushMatrix();
// translate to front (note: Special case)
if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
glTranslated(0, 0, GLO_FRONTELEMENT);
} else {
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, GLO_LANE);
}
if (myNBEdge->myEdgeStopOffset.isDefined() && (myNBEdge->myEdgeStopOffset.getPermissions() & SVC_PASSENGER) != 0) {
for (const auto& lane : getLanes()) {
lane->drawLaneStopOffset(s, myNBEdge->myEdgeStopOffset.getOffset());
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// Push stopOffset matrix
GLHelper::pushMatrix();
// translate to front (note: Special case)
if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
glTranslated(0, 0, GLO_FRONTELEMENT);
} else {
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, GLO_LANE);
}
if (myNBEdge->myEdgeStopOffset.isDefined() && (myNBEdge->myEdgeStopOffset.getPermissions() & SVC_PASSENGER) != 0) {
for (const auto& lane : getLanes()) {
lane->drawLaneStopOffset(s, myNBEdge->myEdgeStopOffset.getOffset());
}
}
// Push stopOffset matrix
GLHelper::popMatrix();
}
// Push stopOffset matrix
GLHelper::popMatrix();
}


Expand Down Expand Up @@ -2805,7 +2803,7 @@ GNEEdge::drawTAZElements(const GUIVisualizationSettings& s) const {
void
GNEEdge::drawEdgeShape(const GUIVisualizationSettings& s) const {
// avoid draw for railways
if ((gPostDrawing.markedFirstGeometryPoint == this) && (s.laneWidthExaggeration >= 1) && !myLanes.front()->drawAsRailway(s)) {
if (!s.drawForObjectUnderCursor && (gPostDrawing.markedFirstGeometryPoint == this) && (s.laneWidthExaggeration >= 1) && !myLanes.front()->drawAsRailway(s)) {
// push draw matrix
GLHelper::pushMatrix();
// translate to front depending of big points
Expand Down
6 changes: 2 additions & 4 deletions src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,8 @@ GNEJunction::updateCenteringBoundary(const bool updateGrid) {

void
GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
// check if boundary has to be drawn
if (s.drawBoundaries) {
GLHelper::drawBoundary(getCenteringBoundary());
}
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// get junction exaggeration
const double junctionExaggeration = getExaggeration(s);
// check if draw junction as shape
Expand Down
18 changes: 9 additions & 9 deletions src/netedit/elements/network/GNELane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,10 @@ GNELane::drawLane2LaneConnections() const {

void
GNELane::drawGL(const GUIVisualizationSettings& s) const {
// get lane drawing constants
const LaneDrawingConstants laneDrawingConstants(s, this);
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// get lane drawing constants
const LaneDrawingConstants laneDrawingConstants(s, this);
// get lane color
const RGBColor color = setLaneColor(s);
// get flag for draw lane as railway
Expand Down Expand Up @@ -681,14 +681,14 @@ GNELane::drawGL(const GUIVisualizationSettings& s) const {
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), getPositionInView(), 1);
}
// draw children
drawChildren(s);
// draw path additional elements
myNet->getPathManager()->drawLanePathElements(s, this);
// draw dotted geometry
myContour.drawDottedContourExtruded(s, getLaneShape(), laneDrawingConstants.halfWidth, 1, true, true,
s.dottedContourSettings.segmentWidth);
}
// draw children
drawChildren(s);
// draw path additional elements
myNet->getPathManager()->drawLanePathElements(s, this);
// draw dotted geometry
myContour.drawDottedContourExtruded(s, getLaneShape(), laneDrawingConstants.halfWidth, 1, true, true,
s.dottedContourSettings.segmentWidth);
}


Expand Down

0 comments on commit f216c90

Please sign in to comment.