Skip to content

Commit

Permalink
Reduced calls to gPostDrawing(). Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 218e107 commit 24aa922
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 37 deletions.
34 changes: 8 additions & 26 deletions src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1353,8 +1353,6 @@ GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
myNet->getPathManager()->getPathDraw()->clearPathDraw();
// draw all GL elements
int hits = drawGLElements(bound);
// after draw elements, update objects under cursor
myObjectsUnderCursor.updateObjectUnderCursor();
// begin post drawing
myVisualizationSettings->postDrawing = true;
// force draw inspected and front elements (due parent/child lines)
Expand Down Expand Up @@ -1985,10 +1983,6 @@ GNEViewNet::checkDrawOverContour(const GUIGlObject* GLObject) const {

bool
GNEViewNet::checkDrawDeleteContour(const GUIGlObject* GLObject, const bool isSelected) const {
// avoid draw in rectangle selection
if (myVisualizationSettings->drawForRectangleSelection) {
return false;
}
// check if elemet is blocked
if (myLockManager.isObjectLocked(GLObject->getType(), isSelected)) {
return false;
Expand All @@ -1997,19 +1991,7 @@ GNEViewNet::checkDrawDeleteContour(const GUIGlObject* GLObject, const bool isSel
if (!gPostDrawing.isElementUnderCursor(GLObject)) {
return false;
}
// check if we're in post drawing
if (myVisualizationSettings->postDrawing) {
// in post-drawing, draw always
return true;
} else {
// check if set as markedElementDeleteContour
if ((gPostDrawing.markedElementDeleteContour == nullptr) ||
(GLObject->getType() > gPostDrawing.markedElementDeleteContour->getType())) {
gPostDrawing.markedElementDeleteContour = GLObject;
}
// we wan't to draw select contour in this moment
return false;
}
return true;
}


Expand Down Expand Up @@ -3334,24 +3316,26 @@ GNEViewNet::updateCursor() {

void
GNEViewNet::updateObjectsUnderCursor() {
// clear post drawing elements
gPostDrawing.clearElements();
// push matrix
GLHelper::pushMatrix();
// draw back (to avoid overlapping)
glTranslated(0, 0, -10);
// force draw for rectangle selction
myVisualizationSettings->forceDrawForRectangleSelection = true;
// force draw for rectangle selection
myVisualizationSettings->drawForRectangleSelection = true;
// create an small boundary
Boundary cursorBoundary;
cursorBoundary.add(myNet->getViewNet()->getPositionInformation());
cursorBoundary.grow(POSITION_EPS);
// draw all GL elements within the small boundary
drawGLElements(cursorBoundary);
// after draw elements, update objects under cursor
myObjectsUnderCursor.updateObjectUnderCursor();
// restore draw for rectangle selection
myVisualizationSettings->forceDrawForRectangleSelection = false;
myVisualizationSettings->drawForRectangleSelection = false;
// pop matrix
GLHelper::popMatrix();
// after draw elements, update objects under cursor
myObjectsUnderCursor.updateObjectUnderCursor();
}


Expand All @@ -3368,8 +3352,6 @@ GNEViewNet::drawGLElements(const Boundary& bound) const {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_POLYGON_OFFSET_FILL);
glEnable(GL_POLYGON_OFFSET_LINE);
// clear post drawing elements
gPostDrawing.clearElements();
// draw all elements between minB and maxB, obtain objects included in minB and maxB
return myGrid->Search(minB, maxB, *myVisualizationSettings);
}
Expand Down
32 changes: 21 additions & 11 deletions src/netedit/elements/GNEContour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ GNEContour::drawDottedContourClosed(const GUIVisualizationSettings& s, const Pos
const double scale, const bool addOffset, const double lineWidth) const {
// first build dotted contour
buildDottedContourClosed(s, shape, scale);
// check if mouse is within geometry
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(0));
// check if mouse is within geometry (only in rectangle selection mode)
if (s.drawForRectangleSelection) {
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(0));
}
// draw dotted contours
drawDottedContours(s, s.drawDottedContour(scale), addOffset, lineWidth);
}
Expand All @@ -82,8 +84,10 @@ GNEContour::drawDottedContourExtruded(const GUIVisualizationSettings& s, const P
const bool drawLastExtrem, const double lineWidth) const {
// first build dotted contour
buildDottedContourExtruded(s, shape, extrusionWidth, scale, drawFirstExtrem, drawLastExtrem);
// check if mouse is within two lines
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(1));
// check if mouse is within two lines (only in rectangle selection mode)
if (s.drawForRectangleSelection) {
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(1));
}
// draw dotted contours
drawDottedContours(s, scale, true, lineWidth);
}
Expand All @@ -95,8 +99,10 @@ GNEContour::drawDottedContourRectangle(const GUIVisualizationSettings& s, const
const double scale, const double lineWidth) const {
// first build dotted contour
buildDottedContourRectangle(s, pos, width, height, offsetX, offsetY, rot, scale);
// check if mouse is within geometry
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(0));
// check if mouse is within geometry (only in rectangle selection mode)
if (s.drawForRectangleSelection) {
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(0));
}
// draw dotted contours
drawDottedContours(s, scale, true, lineWidth);
}
Expand All @@ -107,8 +113,10 @@ GNEContour::drawDottedContourCircle(const GUIVisualizationSettings& s, const Pos
const double scale, const double lineWidth) const {
// first build dotted contour
buildDottedContourCircle(s, pos, radius, scale);
// check if mouse is within geometry
gPostDrawing.positionWithinCircle(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), pos, (radius * scale));
// check if mouse is within geometry (only in rectangle selection mode)
if (s.drawForRectangleSelection) {
gPostDrawing.positionWithinCircle(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), pos, (radius * scale));
}
// draw dotted contours
drawDottedContours(s, scale, true, lineWidth);
}
Expand All @@ -119,8 +127,10 @@ GNEContour::drawDottedContourEdge(const GUIVisualizationSettings& s, const GNEEd
const bool drawLastExtrem, const double lineWidth) const {
// first build dotted contour
buildDottedContourEdge(s, edge, drawFirstExtrem, drawLastExtrem);
// check if mouse is within two lines
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(2));
// check if mouse is within two lines (only in rectangle selection mode)
if (s.drawForRectangleSelection) {
gPostDrawing.positionWithinShape(myAC->getGUIGlObject(), myAC->getNet()->getViewNet()->getPositionInformation(), myCachedShapes->at(2));
}
// draw dotted contours
drawDottedContours(s, 1, true, lineWidth);
}
Expand All @@ -129,7 +139,7 @@ GNEContour::drawDottedContourEdge(const GUIVisualizationSettings& s, const GNEEd
void
GNEContour::drawDottedContourEdges(const GUIVisualizationSettings& s, const GNEEdge* fromEdge, const GNEEdge* toEdge,
const double lineWidth) const {
// first build dotted contour
// first build dotted contour (only in rectangle selection mode)
buildDottedContourEdges(s, fromEdge, toEdge);
// draw dotted contours
drawDottedContours(s, 1, true, lineWidth);
Expand Down

0 comments on commit 24aa922

Please sign in to comment.