Skip to content

Commit

Permalink
Avoid double junction drawing. Refs #14175
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 22, 2023
1 parent fba75eb commit 9aab683
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,12 @@ GNEViewNet::checkSelectEdges() const {
}


long
GNEViewNet::getDrawingStart() const {
return myDrawingStart;
}


int
GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
// set lefthand and laneIcons
Expand Down Expand Up @@ -3284,7 +3290,9 @@ GNEViewNet::updateCursor() {


int
GNEViewNet::drawGLElements(const Boundary& bound) const {
GNEViewNet::drawGLElements(const Boundary& bound) {
// save draw start (needed for draw junctions
myDrawingStart = SysUtils::getCurrentMillis();
// set default scale
myVisualizationSettings->scale = m2p(SUMO_const_laneWidth);
// calculate boundary extremes
Expand Down
8 changes: 7 additions & 1 deletion src/netedit/GNEViewNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ class GNEViewNet : public GUISUMOAbstractView {
/// @brief return list of loaded edgeRelation and tazRelation attributes
std::vector<std::string> getRelDataAttrs() const;

/// @brief get draw start (used for drawing junctions)
long getDrawingStart() const;

/// @brief check if select edges (toggle using button or shift)
bool checkSelectEdges() const;

Expand Down Expand Up @@ -720,6 +723,9 @@ class GNEViewNet : public GUISUMOAbstractView {
/// @brief flag for mark if during this frame a popup was created (needed to avoid problems in linux with CursorDialogs)
bool myCreatedPopup = false;

/// @brief draw start (used in drawGLElements)
long myDrawingStart = 0;

/// @brief create edit mode buttons and elements
void buildEditModeControls();

Expand Down Expand Up @@ -784,7 +790,7 @@ class GNEViewNet : public GUISUMOAbstractView {
/// @{

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

/// @brief draw grid and update grid button
void drawGrid() const;
Expand Down
9 changes: 7 additions & 2 deletions src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ GNEJunction::GNEJunction(GNENet* net, NBNode* nbn, bool loaded) :
GNENetworkElement(net, nbn->getID(), GLO_JUNCTION, SUMO_TAG_JUNCTION,
GUIIconSubSys::getIcon(GUIIcon::JUNCTION), {}, {}, {}, {}, {}, {}),
myNBNode(nbn),
myDrawingStart(new long),
myLogicStatus(loaded ? FEATURE_LOADED : FEATURE_GUESSED),
myHasValidLogic(loaded),
myTesselation(nbn->getID(), "", RGBColor::MAGENTA, nbn->getShape(), false, true, 0) {
Expand All @@ -72,6 +73,8 @@ GNEJunction::GNEJunction(GNENet* net, NBNode* nbn, bool loaded) :


GNEJunction::~GNEJunction() {
// delete drawing start
delete myDrawingStart;
// delete all GNECrossing
for (const auto& crossing : myGNECrossings) {
crossing->decRef();
Expand Down Expand Up @@ -620,8 +623,8 @@ GNEJunction::updateCenteringBoundary(const bool updateGrid) {

void
GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
// first check drawing boundary selection
if (checkDrawingBoundarySelection()) {
// first check drawing start and boundary selection
if ((*myDrawingStart != myNet->getViewNet()->getDrawingStart()) && checkDrawingBoundarySelection()) {
// draw boundaries
if (myJunctionInGrid) {
GLHelper::drawBoundary(s, getCenteringBoundary());
Expand Down Expand Up @@ -668,6 +671,8 @@ GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
// draw Junction childs
drawJunctionChildren(s, d);
}
// update drawing start
*myDrawingStart = myNet->getViewNet()->getDrawingStart();
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/netedit/elements/network/GNEJunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {
/// @brief flag for check if junction is currently in grid
bool myJunctionInGrid = true;

/// @brief drawing start (used to avoid double draws)
long *myDrawingStart;

/// @brief variable used for draw circle contours
GNEContour myCircleContour;

Expand Down

0 comments on commit 9aab683

Please sign in to comment.