Skip to content

Commit

Permalink
Now internal lanes works again. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent cfeb434 commit b5c987a
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 21 deletions.
2 changes: 0 additions & 2 deletions src/netedit/GNENetHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2413,7 +2413,6 @@ GNENetHelper::AttributeCarriers::insertInternalLane(GNEInternalLane* internalLan
} else {
myInternalLanes[internalLane->getGUIGlObject()] = internalLane;
}
myNet->addGLObjectIntoGrid(internalLane);
}


Expand All @@ -2425,7 +2424,6 @@ GNENetHelper::AttributeCarriers::deleteInternalLane(GNEInternalLane* internalLan
} else {
myInternalLanes.erase(finder);
}
myNet->removeGLObjectFromGrid(internalLane);
}


Expand Down
4 changes: 4 additions & 0 deletions src/netedit/GNEViewNetHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,13 @@ GNEViewNetHelper::ObjectsUnderCursor::updateNetworkElements(ObjectsContainer& co
if (glObject == frontGLObject) {
// insert at front
container.internalLanes.insert(container.internalLanes.begin(), internalLane);
container.attributeCarriers.insert(container.attributeCarriers.begin(), internalLane);
container.GUIGlObjects.insert(container.GUIGlObjects.begin(), internalLane);
} else {
// insert at back
container.internalLanes.push_back(internalLane);
container.attributeCarriers.push_back(internalLane);
container.GUIGlObjects.push_back(internalLane);
}
break;
}
Expand Down
37 changes: 21 additions & 16 deletions src/netedit/elements/network/GNEInternalLane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ FXIMPLEMENT(GNEInternalLane, FXDelegator, 0, 0)
StringBijection<FXuint>::Entry GNEInternalLane::linkStateNamesValues[] = {
{ "Green-Major", LINKSTATE_TL_GREEN_MAJOR },
{ "Green-Minor", LINKSTATE_TL_GREEN_MINOR },
//{ "Yellow-Major", LINKSTATE_TL_YELLOW_MAJOR }, (should not be used)
{ "Yellow", LINKSTATE_TL_YELLOW_MINOR },
//{ "Yellow-Major", LINKSTATE_TL_YELLOW_MAJOR }, (should not be used)
{ "Yellow", LINKSTATE_TL_YELLOW_MINOR },
{ "Red", LINKSTATE_TL_RED },
{ "Red-Yellow", LINKSTATE_TL_REDYELLOW },
{ "Stop", LINKSTATE_STOP },
Expand All @@ -58,35 +58,40 @@ const StringBijection<FXuint> GNEInternalLane::LinkStateNames(
// method definitions
// ===========================================================================

GNEInternalLane::GNEInternalLane(GNETLSEditorFrame* editor, const GNEJunction* junctionParent,
GNEInternalLane::GNEInternalLane(GNETLSEditorFrame* editor, GNEJunction* junctionParent,
const std::string& id, const PositionVector& shape, int tlIndex, LinkState state) :
GNENetworkElement(junctionParent->getNet(), id, GLO_TLLOGIC, GNE_TAG_INTERNAL_LANE,
GUIIconSubSys::getIcon(GUIIcon::LANE), {}, {}, {}, {}, {}, {}),
myJunctionParent(junctionParent),
myState(state),
myStateTarget(myState),
myEditor(editor),
myTlIndex(tlIndex),
myPopup(nullptr) {
GUIIconSubSys::getIcon(GUIIcon::LANE), {}, {}, {}, {}, {}, {}),
myJunctionParent(junctionParent),
myState(state),
myStateTarget(myState),
myEditor(editor),
myTlIndex(tlIndex),
myPopup(nullptr) {
// calculate internal lane geometry
myInternalLaneGeometry.updateGeometry(shape);
// update centering boundary without updating grid
updateCenteringBoundary(false);
// vinculate this internal lane with their junction parent
myJunctionParent->addInternalLane(this);
}


GNEInternalLane::GNEInternalLane() :
GNENetworkElement(nullptr, "dummyInternalLane", GLO_TLLOGIC, GNE_TAG_INTERNAL_LANE,
GUIIconSubSys::getIcon(GUIIcon::LANE), {}, {}, {}, {}, {}, {}),
myJunctionParent(nullptr),
myState(0),
myEditor(0),
myTlIndex(0),
myPopup(nullptr) {
myJunctionParent(nullptr),
myState(0),
myEditor(0),
myTlIndex(0),
myPopup(nullptr) {
}


GNEInternalLane::~GNEInternalLane() {}
GNEInternalLane::~GNEInternalLane() {
// remove this internal lane from junction parent
myJunctionParent->removeInternalLane(this);
}


void
Expand Down
5 changes: 3 additions & 2 deletions src/netedit/elements/network/GNEInternalLane.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class GNEInternalLane : public GNENetworkElement, public FXDelegator {
* @param[in] shape The shape of the lane
* @param[in] tlIndex The tl-index of the lane
*/
GNEInternalLane(GNETLSEditorFrame* editor, const GNEJunction* junctionParent, const std::string& id, const PositionVector& shape, int tlIndex, LinkState state = LINKSTATE_DEADEND);
GNEInternalLane(GNETLSEditorFrame* editor, GNEJunction* junctionParent, const std::string& id,
const PositionVector& shape, int tlIndex, LinkState state = LINKSTATE_DEADEND);

/// @brief Destructor
~GNEInternalLane();
Expand Down Expand Up @@ -191,7 +192,7 @@ class GNEInternalLane : public GNENetworkElement, public FXDelegator {

private:
/// @brief pointer to junction parent
const GNEJunction* myJunctionParent;
GNEJunction* myJunctionParent;

/// @brief internal lane geometry
GUIGeometry myInternalLaneGeometry;
Expand Down
28 changes: 27 additions & 1 deletion src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
#include <netedit/GNEViewParent.h>
#include <netedit/frames/network/GNECreateEdgeFrame.h>


#include "GNEConnection.h"
#include "GNEJunction.h"
#include "GNECrossing.h"
#include "GNEWalkingArea.h"
#include "GNEInternalLane.h"


// ===========================================================================
Expand Down Expand Up @@ -1221,6 +1221,28 @@ GNEJunction::rebuildGNEWalkingAreas() {
}



void
GNEJunction::addInternalLane(const GNEInternalLane* internalLane) {
if (std::find(myInternalLanes.begin(), myInternalLanes.end(), internalLane) != myInternalLanes.end()) {
throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' already exist");
} else {
myInternalLanes.push_back(internalLane);
}
}


void
GNEJunction::removeInternalLane(const GNEInternalLane* internalLane) {
const auto finder = std::find(myInternalLanes.begin(), myInternalLanes.end(), internalLane);
if (finder == myInternalLanes.end()) {
throw ProcessError(internalLane->getTagStr() + " with ID='" + internalLane->getID() + "' wasn't previously inserted");
} else {
myInternalLanes.erase(finder);
}
}


std::string
GNEJunction::getAttribute(SumoXMLAttr key) const {
switch (key) {
Expand Down Expand Up @@ -1677,6 +1699,10 @@ GNEJunction::drawJunctionChildren(const GUIVisualizationSettings& s) const {
for (const auto& walkingArea : myGNEWalkingAreas) {
walkingArea->drawGL(s);
}
// draw internalLanes
for (const auto& internalLanes : myInternalLanes) {
internalLanes->drawGL(s);
}
// draw connections and route elements connections (Only for incoming edges)
for (const auto& incomingEdge : myGNEIncomingEdges) {
for (const auto& connection : incomingEdge->getGNEConnections()) {
Expand Down
10 changes: 10 additions & 0 deletions src/netedit/elements/network/GNEJunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class GNEEdge;
class GNECrossing;
class NBTrafficLightDefinition;
class GNEConnection;
class GNEInternalLane;

// ===========================================================================
// class definitions
Expand Down Expand Up @@ -285,6 +286,12 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {
/// @brief rebuilds WalkingAreas objects for this junction
void rebuildGNEWalkingAreas();

/// @brief add internal lane
void addInternalLane(const GNEInternalLane* internalLane);

/// @brief remove internal lane
void removeInternalLane(const GNEInternalLane* internalLane);

protected:
/// @brief A reference to the represented junction
NBNode* myNBNode;
Expand All @@ -301,6 +308,9 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {
/// @brief the built walkingArea objects
std::vector<GNEWalkingArea*> myGNEWalkingAreas;

/// @brief internal lanes related placed in this junction
std::vector<const GNEInternalLane*> myInternalLanes;

/// @brief The maximum size (in either x-, or y-dimension) for determining whether to draw or not
double myMaxDrawingSize;

Expand Down

0 comments on commit b5c987a

Please sign in to comment.