Skip to content

Commit

Permalink
Added function updateObjectsUnderCursor() in GNEViewNet. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 42c3760 commit 218e107
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1289,10 +1289,6 @@ GNEViewNet::getRelDataAttrs() const {

int
GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
// first check if force drawing for rectangle selection
if (myVisualizationSettings->forceDrawForRectangleSelection) {
myVisualizationSettings->drawForRectangleSelection = true;
}
// set lefthand and laneIcons
myVisualizationSettings->lefthand = OptionsCont::getOptions().getBool("lefthand");
myVisualizationSettings->disableLaneIcons = OptionsCont::getOptions().getBool("disable-laneIcons");
Expand All @@ -1305,6 +1301,12 @@ GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);
// first step: obtain all objects under cursor
updateObjectsUnderCursor();
// check if force drawing for rectangle selection
if (myVisualizationSettings->forceDrawForRectangleSelection) {
myVisualizationSettings->drawForRectangleSelection = true;
}
// visualize rectangular selection
mySelectingArea.drawRectangleSelection(myVisualizationSettings->colorSettings.selectionColor);
// draw certain elements only if we aren't in rectangle selection mode
Expand Down Expand Up @@ -3330,6 +3332,29 @@ GNEViewNet::updateCursor() {
}


void
GNEViewNet::updateObjectsUnderCursor() {
// push matrix
GLHelper::pushMatrix();
// draw back (to avoid overlapping)
glTranslated(0, 0, -10);
// force draw for rectangle selction
myVisualizationSettings->forceDrawForRectangleSelection = 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;
// pop matrix
GLHelper::popMatrix();
}


int
GNEViewNet::drawGLElements(const Boundary& bound) const {
// set default scale
Expand Down
3 changes: 3 additions & 0 deletions src/netedit/GNEViewNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ class GNEViewNet : public GUISUMOAbstractView {
/// @brief draw functions
/// @{

/// @brief get objects under cursor
void updateObjectsUnderCursor();

/// @brief draw all gl elements of netedit
int drawGLElements(const Boundary& bound) const;

Expand Down
1 change: 1 addition & 0 deletions src/utils/gui/windows/GUISUMOAbstractView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ GUISUMOAbstractView::getObjectsUnderCursor() {
}



std::vector<GUIGlObject*>
GUISUMOAbstractView::getGUIGlObjectsUnderCursor() {
return getGUIGlObjectsAtPosition(getPositionInformation(), SENSITIVITY);
Expand Down

0 comments on commit 218e107

Please sign in to comment.