Skip to content

Commit

Permalink
Updated GUIObjectsInPosition. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent d37b90b commit 2e164f5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
22 changes: 11 additions & 11 deletions src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1982,7 +1982,7 @@ GNEViewNet::getJunctionAtPopupPosition() {
// get first object that can be found in their container
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto junction = myNet->getAttributeCarriers()->retrieveJunction(glObject.first, false);
auto junction = myNet->getAttributeCarriers()->retrieveJunction(glObject.object, false);
if (junction) {
return junction;
}
Expand All @@ -1997,7 +1997,7 @@ GNEViewNet::getConnectionAtPopupPosition() {
// get first object that can be found in their container
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto connection = myNet->getAttributeCarriers()->retrieveConnection(glObject.first, false);
auto connection = myNet->getAttributeCarriers()->retrieveConnection(glObject.object, false);
if (connection) {
return connection;
}
Expand All @@ -2012,7 +2012,7 @@ GNEViewNet::getCrossingAtPopupPosition() {
// get first object that can be found in their container
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto crossing = myNet->getAttributeCarriers()->retrieveCrossing(glObject.first, false);
auto crossing = myNet->getAttributeCarriers()->retrieveCrossing(glObject.object, false);
if (crossing) {
return crossing;
}
Expand All @@ -2027,7 +2027,7 @@ GNEViewNet::getWalkingAreaAtPopupPosition() {
// get first object that can be found in their container
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto walkingArea = myNet->getAttributeCarriers()->retrieveWalkingArea(glObject.first, false);
auto walkingArea = myNet->getAttributeCarriers()->retrieveWalkingArea(glObject.object, false);
if (walkingArea) {
return walkingArea;
}
Expand All @@ -2042,7 +2042,7 @@ GNEViewNet::getEdgeAtPopupPosition() {
// get first object that can be found in their container
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto edge = myNet->getAttributeCarriers()->retrieveEdge(glObject.first, false);
auto edge = myNet->getAttributeCarriers()->retrieveEdge(glObject.object, false);
if (edge) {
return edge;
}
Expand All @@ -2057,7 +2057,7 @@ GNEViewNet::getLaneAtPopupPosition() {
// get first object that can be found in their container
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto lane = myNet->getAttributeCarriers()->retrieveLane(glObject.first, false);
auto lane = myNet->getAttributeCarriers()->retrieveLane(glObject.object, false);
if (lane) {
return lane;
}
Expand All @@ -2072,7 +2072,7 @@ GNEViewNet::getAdditionalAtPopupPosition() {
// get first object that can be found in their container
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto additionalElement = myNet->getAttributeCarriers()->retrieveAdditional(glObject.first, false);
auto additionalElement = myNet->getAttributeCarriers()->retrieveAdditional(glObject.object, false);
if (additionalElement) {
return additionalElement;
}
Expand All @@ -2087,7 +2087,7 @@ GNEViewNet::getDemandElementAtPopupPosition() {
// get first object that can be found in their container
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto demandElement = myNet->getAttributeCarriers()->retrieveDemandElement(glObject.first, false);
auto demandElement = myNet->getAttributeCarriers()->retrieveDemandElement(glObject.object, false);
if (demandElement) {
return demandElement;
}
Expand All @@ -2102,7 +2102,7 @@ GNEViewNet::getPolygonAtPopupPosition() {
// get first object that can be parsed to poly element
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto polygon = dynamic_cast<GNEPoly*>(myNet->getAttributeCarriers()->retrieveAdditional(glObject.first, false));
auto polygon = dynamic_cast<GNEPoly*>(myNet->getAttributeCarriers()->retrieveAdditional(glObject.object, false));
if (polygon) {
return polygon;
}
Expand All @@ -2117,7 +2117,7 @@ GNEViewNet::getPOIAtPopupPosition() {
// get first object that can be parsed to POI element
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto POI = dynamic_cast<GNEPOI*>(myNet->getAttributeCarriers()->retrieveAdditional(glObject.first, false));
auto POI = dynamic_cast<GNEPOI*>(myNet->getAttributeCarriers()->retrieveAdditional(glObject.object, false));
if (POI) {
return POI;
}
Expand All @@ -2132,7 +2132,7 @@ GNEViewNet::getTAZAtPopupPosition() {
// get first object that can be parsed to TAZ element
for (const auto& glObjectLayer : gObjectsInPosition.getElementsUnderCursor()) {
for (const auto &glObject : glObjectLayer.second) {
auto TAZ = dynamic_cast<GNETAZ*>(myNet->getAttributeCarriers()->retrieveAdditional(glObject.first, false));
auto TAZ = dynamic_cast<GNETAZ*>(myNet->getAttributeCarriers()->retrieveAdditional(glObject.object, false));
if (TAZ) {
return TAZ;
}
Expand Down
12 changes: 6 additions & 6 deletions src/netedit/GNEViewNetHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,12 +1015,12 @@ GNEViewNetHelper::ObjectsUnderCursor::processGUIGlObjects(const GUIObjectsInPosi
for (const auto& glObjectLayer : objectsContainer) {
for (const auto &glObject : glObjectLayer.second) {
// update all elements by categories
updateNetworkElements(myObjects, glObject.first);
updateAdditionalElements(myObjects, glObject.first);
updateShapeElements(myObjects, glObject.first);
updateTAZElements(myObjects, glObject.first);
updateDemandElements(myObjects, glObject.first);
updateGenericDataElements(myObjects, glObject.first);
updateNetworkElements(myObjects, glObject.object);
updateAdditionalElements(myObjects, glObject.object);
updateShapeElements(myObjects, glObject.object);
updateTAZElements(myObjects, glObject.object);
updateDemandElements(myObjects, glObject.object);
updateGenericDataElements(myObjects, glObject.object);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/additional/GNEPoly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ GNEPoly::drawPolygon(const GUIVisualizationSettings& s, const GUIVisualizationSe
void
GNEPoly::drawPolygonContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const RGBColor &color, const double exaggeration) const {
// draw contour if shape isn't blocked
// draw contour if don't move whole polygon
if (!myNet->getViewNet()->getViewParent()->getMoveFrame()->getNetworkModeOptions()->getMoveWholePolygons()) {
// get draw color
const RGBColor darkerColor = color.changedBrightness(-32);
Expand Down
14 changes: 7 additions & 7 deletions src/utils/gui/settings/GUIObjectsInPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ GUIObjectsInPosition::getGeometryPoints(const GUIGlObject* GLObject) const {

void
GUIObjectsInPosition::updateFrontElement(const GUIGlObject* GLObject) {
ObjectContainer frontElement;
ObjectContainer frontElement(nullptr);
// extract element
for (auto &elementLayer : myElementsUnderCursor) {
auto it = elementLayer.second.begin();
Expand Down Expand Up @@ -157,10 +157,10 @@ GUIObjectsInPosition::addElementUnderCursor(const GUIGlObject* GLObject) {
const auto layer = dynamic_cast<const Shape*>(GLObject);
if (layer) {
auto &layerContainer = myElementsUnderCursor[layer->getShapeLayer() * -1];
layerContainer.insert(layerContainer.begin(), std::make_pair(GLObject, myEmptyGeometryPoints));
layerContainer.insert(layerContainer.begin(), ObjectContainer(GLObject));
} else {
auto &layerContainer = myElementsUnderCursor[GLObject->getType() * -1];
layerContainer.insert(layerContainer.begin(), std::make_pair(GLObject, myEmptyGeometryPoints));
layerContainer.insert(layerContainer.begin(), ObjectContainer(GLObject));
}
return true;
}
Expand Down Expand Up @@ -189,12 +189,12 @@ GUIObjectsInPosition::addGeometryPointUnderCursor(const GUIGlObject* GLObject, c
const auto layer = dynamic_cast<const Shape*>(GLObject);
if (layer) {
auto &layerContainer = myElementsUnderCursor[layer->getShapeLayer() * -1];
auto it = layerContainer.insert(layerContainer.begin(), std::make_pair(GLObject, myEmptyGeometryPoints));
it->second.push_back(newIndex);
auto it = layerContainer.insert(layerContainer.begin(), ObjectContainer(GLObject));
it->geometryPoints.push_back(newIndex);
} else {
auto &layerContainer = myElementsUnderCursor[GLObject->getType() * -1];
auto it = layerContainer.insert(layerContainer.begin(), std::make_pair(GLObject, myEmptyGeometryPoints));
it->second.push_back(newIndex);
auto it = layerContainer.insert(layerContainer.begin(), ObjectContainer(GLObject));
it->geometryPoints.push_back(newIndex);
}
return true;
}
Expand Down
6 changes: 5 additions & 1 deletion src/utils/gui/settings/GUIObjectsInPosition.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class GUIObjectsInPosition {
/// @brief object container
struct ObjectContainer {

/// @brief parameter constructor
ObjectContainer(const GUIGlObject* object_) :
object(object_) {}

/// @brief object
const GUIGlObject* object = nullptr;

Expand Down Expand Up @@ -111,7 +115,7 @@ class GUIObjectsInPosition {
GLObjectsSortedContainer myElementsUnderCursor;

/// @brief empty geometry points
GeometryPointsContainer myEmptyGeometryPoints;
std::vector<int> myEmptyGeometryPoints;

/// @brief add element into list of elements under cursor
bool addElementUnderCursor(const GUIGlObject* GLObject);
Expand Down

0 comments on commit 2e164f5

Please sign in to comment.