Skip to content

Commit

Permalink
Reduced calls to myObjectsUnderCursor.updateObjectUnderCursor(). Refs #…
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 0196ac2 commit 320eea3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ void
GNEViewNet::doInit() {}


GUIGlID
GNEViewNet::getToolTipID() {
if (myObjectsUnderCursor.getGUIGlObjectFront()) {
return myObjectsUnderCursor.getGUIGlObjectFront()->getGlID();
} else {
return 0;
}
}


void
GNEViewNet::buildViewToolBars(GUIGlChildWindow* v) {
// build coloring tools
Expand Down Expand Up @@ -497,7 +507,7 @@ GNEViewNet::getObjectsUnderCursor() const {

void
GNEViewNet::updateObjectsUnderCursor(const Position& pos) {
myObjectsUnderCursor.updateObjectUnderCursor(/*getGUIGlObjectsAtPosition(pos, 0.1)*/);
//myObjectsUnderCursor.updateObjectUnderCursor(/*getGUIGlObjectsAtPosition(pos, 0.1)*/);
}


Expand Down Expand Up @@ -540,8 +550,6 @@ GNEViewNet::openObjectDialogAtCursor(const FXEvent* /*ev*/) {
ungrab();
// make network current
if (isEnabled() && myAmInitialised) {
// get GLObjects under cursor
myObjectsUnderCursor.updateObjectUnderCursor();
// check if we're cliking while alt button is pressed
if (myMouseButtonKeyPressed.altKeyPressed()) {
// set clicked popup position
Expand Down Expand Up @@ -1281,8 +1289,6 @@ GNEViewNet::getRelDataAttrs() const {

int
GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
// execute post drawing tasks
gPostDrawing.executePostDrawingTasks();
// init view settings
if (!myVisualizationSettings->drawForPositionSelection && myVisualizationSettings->forceDrawForPositionSelection) {
myVisualizationSettings->drawForPositionSelection = true;
Expand Down Expand Up @@ -1386,10 +1392,14 @@ GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
myVisualizationSettings->scale = lw;
glEnable(GL_POLYGON_OFFSET_FILL);
glEnable(GL_POLYGON_OFFSET_LINE);
// clear post drawing elements
gPostDrawing.clearElements();
// set current mouse position in gPostDrawing
gPostDrawing.mousePos = getPositionInformation();
// obtain objects included in minB and maxB
int hits2 = myGrid->Search(minB, maxB, *myVisualizationSettings);
// fill objects under cursor
myObjectsUnderCursor.updateObjectUnderCursor();
// begin post drawing
myPostDrawing = true;
// force draw inspected and front elements (due parent/child lines)
Expand Down Expand Up @@ -1437,6 +1447,8 @@ GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
myNet->getGrid().updateBoundaries(gPostDrawing.recomputeBoundaries);
}
*/
// execute post drawing tasks
gPostDrawing.executePostDrawingTasks();
// end post drawing
myPostDrawing = false;
return hits2;
Expand All @@ -1449,8 +1461,6 @@ GNEViewNet::onLeftBtnPress(FXObject*, FXSelector, void* eventData) {
setFocus();
// update MouseButtonKeyPressed
myMouseButtonKeyPressed.update(eventData);
// fill objects under cursor
myObjectsUnderCursor.updateObjectUnderCursor();
// process left button press function depending of supermode
if (myEditModes.isCurrentSupermodeNetwork()) {
processLeftButtonPressNetwork(eventData);
Expand Down Expand Up @@ -1480,8 +1490,6 @@ GNEViewNet::onLeftBtnRelease(FXObject* obj, FXSelector sel, void* eventData) {
GUISUMOAbstractView::onLeftBtnRelease(obj, sel, eventData);
// update MouseButtonKeyPressed
myMouseButtonKeyPressed.update(eventData);
// fill objects under cursor
myObjectsUnderCursor.updateObjectUnderCursor();
// process left button release function depending of supermode
if (myEditModes.isCurrentSupermodeNetwork()) {
processLeftButtonReleaseNetwork();
Expand Down Expand Up @@ -5915,8 +5923,6 @@ GNEViewNet::processLeftButtonReleaseNetwork() {
myViewParent->getTAZFrame()->processEdgeSelection(mySelectingArea.processEdgeRectangleSelection());
}
} else if (myMouseButtonKeyPressed.shiftKeyPressed()) {
// update objects under cursor again
myObjectsUnderCursor.updateObjectUnderCursor();
// check if there is a lane in objects under cursor
if (myObjectsUnderCursor.getLaneFront()) {
// if we clicked over an lane with shift key pressed, select or unselect it
Expand Down
3 changes: 3 additions & 0 deletions src/netedit/GNEViewNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@ class GNEViewNet : public GUISUMOAbstractView {
/// @brief called after some features are already initialized
void doInit();

/// @brief returns the id of object under cursor to show their tooltip
GUIGlID getToolTipID();

private:
/// @name structs related with modes and testing mode
/// @{
Expand Down

0 comments on commit 320eea3

Please sign in to comment.