Skip to content

Commit

Permalink
Updated GNEContour. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 6655e32 commit d7d7347
Show file tree
Hide file tree
Showing 53 changed files with 239 additions and 250 deletions.
7 changes: 0 additions & 7 deletions src/netedit/elements/GNEAttributeCarrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const std::string GNEAttributeCarrier::False = toString(false);

GNEAttributeCarrier::GNEAttributeCarrier(const SumoXMLTag tag, GNENet* net) :
myTagProperty(getTagProperty(tag)),
myContour(this),
myNet(net),
mySelected(false),
myIsTemplate(false) {
Expand Down Expand Up @@ -632,12 +631,6 @@ GNEAttributeCarrier::isTemplate() const {
}


const GNEContour&
GNEAttributeCarrier::getContour() const {
return myContour;
}


const GNETagProperties&
GNEAttributeCarrier::getTagProperty() const {
return myTagProperty;
Expand Down
7 changes: 0 additions & 7 deletions src/netedit/elements/GNEAttributeCarrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <netedit/GNEReferenceCounter.h>

#include "GNETagProperties.h"
#include "GNEContour.h"


// ===========================================================================
Expand Down Expand Up @@ -232,9 +231,6 @@ class GNEAttributeCarrier : public GNEReferenceCounter {
/// @brief check if this AC is template
bool isTemplate() const;

/// @brief get contour
const GNEContour& getContour() const;

/// @brief get tagProperty associated with this Attribute Carrier
const GNETagProperties& getTagProperty() const;

Expand Down Expand Up @@ -324,9 +320,6 @@ class GNEAttributeCarrier : public GNEReferenceCounter {
/// @brief reference to tagProperty associated with this attribute carrier
const GNETagProperties& myTagProperty;

/// @brief variable used for draw contours
GNEContour myContour;

/// @brief pointer to net
GNENet* myNet;

Expand Down
52 changes: 25 additions & 27 deletions src/netedit/elements/GNEContour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ GUIDottedGeometry::DottedGeometryColor GNEContour::myDottedGeometryColor;
// member method definitions
// ===========================================================================

GNEContour::GNEContour(GNEAttributeCarrier* AC) :
myAC(AC),
GNEContour::GNEContour() :
myDottedGeometries(new std::vector<GUIDottedGeometry>(4)),
myContourBoundary(new Boundary) {
}
Expand All @@ -62,64 +61,63 @@ GNEContour::getContourBoundary() const {

void
GNEContour::calculateContourClosedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double scale) const {
const GUIGlObject* glObject, const PositionVector& shape, const double scale) const {
// check if we're in drawForObjectUnderCursor
if (s.drawForObjectUnderCursor) {
// calculate closed shape contour
const auto closedShape = buildContourClosedShape(s, d, shape, scale);
// check if position or bondary is within closed shape
gViewObjectsHandler.checkShapeElement(d, myAC->getGUIGlObject(), closedShape);
gViewObjectsHandler.checkShapeElement(d, glObject, closedShape);
}
}


void
GNEContour::calculateContourExtrudedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double extrusionWidth, const double scale,
const bool closeFirstExtrem, const bool closeLastExtrem, const double offset) const {
const GUIGlObject* glObject, const PositionVector& shape, const double extrusionWidth,
const double scale, const bool closeFirstExtrem, const bool closeLastExtrem,
const double offset) const {
// check if we're in drawForObjectUnderCursor
if (s.drawForObjectUnderCursor) {
// calculate extruded shape
const auto extrudedShape = buildContourExtrudedShape(s, d, shape, extrusionWidth, scale, closeFirstExtrem, closeLastExtrem, offset);
// check if position or bondary is within extruded shape
gViewObjectsHandler.checkShapeElement(d, myAC->getGUIGlObject(), extrudedShape);
gViewObjectsHandler.checkShapeElement(d, glObject, extrudedShape);
}
}


void
GNEContour::calculateContourRectangleShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const Position& pos, const double width, const double height, const double offsetX,
const double offsetY, const double rot, const double scale) const {
const GUIGlObject* glObject, const Position& pos, const double width, const double height,
const double offsetX, const double offsetY, const double rot, const double scale) const {
// check if we're in drawForObjectUnderCursor
if (s.drawForObjectUnderCursor) {
// calculate rectangle shape
const auto rectangleShape = buildContourRectangle(s, d, pos, width, height, offsetX, offsetY, rot, scale);
// check if position or bondary is within rectangle shape
gViewObjectsHandler.checkShapeElement(d, myAC->getGUIGlObject(), rectangleShape);
gViewObjectsHandler.checkShapeElement(d, glObject, rectangleShape);
}
}


void
GNEContour::calculateContourCircleShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const Position& pos, double radius, const double scale) const {
const GUIGlObject* glObject, const Position& pos, double radius, const double scale) const {
// check if we're in drawForObjectUnderCursor
if (s.drawForObjectUnderCursor) {
// calculate circle shape
buildContourCircle(s, d, pos, radius, scale);
// check if position or bondary is within circle shape
gViewObjectsHandler.checkCircleElement(d, myAC->getGUIGlObject(), pos, (radius * scale));
gViewObjectsHandler.checkCircleElement(d, glObject, pos, (radius * scale));
}
}


void
GNEContour::calculateContourGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, GeometryPoint geometryPoints, double radius,
const double scale, const double lineWidth) const {
// get object
const auto &glObject = myAC->getGUIGlObject();
const GUIGlObject* glObject, const PositionVector& shape, GeometryPoint geometryPoints,
double radius, const double scale, const double lineWidth) const {
// declare distance
const auto scaledRadius = (radius * scale);
// check if we're calculating the mouse position over geometry or drawing dotted geometry
Expand Down Expand Up @@ -170,13 +168,13 @@ GNEContour::calculateContourGeometryPoints(const GUIVisualizationSettings& s, co

void
GNEContour::calculateContourEdge(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const GNEEdge* edge, const bool closeFirstExtrem, const bool closeLastExtrem) const {
const GNEEdge* edge, const bool closeFirstExtrem, const bool closeLastExtrem) const {
// check if mouse is within two lines (only in rectangle selection mode)
if (s.drawForObjectUnderCursor) {
// calculate contour edge shape
const auto contourShape = buildContourEdge(s, d, edge, closeFirstExtrem, closeLastExtrem);
// check if position or bondary is within contour shape
gViewObjectsHandler.checkShapeElement(d, myAC->getGUIGlObject(), contourShape);
gViewObjectsHandler.checkShapeElement(d, edge, contourShape);
}
}

Expand All @@ -191,36 +189,36 @@ GNEContour::calculateContourEdges(const GUIVisualizationSettings& s, const GUIVi

void
GNEContour::drawDottedContours(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const double lineWidth, const bool addOffset) const {
const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const {
// first check if draw dotted contour
if (!s.disableDottedContours && (d <= GUIVisualizationSettings::Detail::DottedContours)) {
// basic contours
if (myAC->checkDrawFromContour()) {
if (AC->checkDrawFromContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::FROM, lineWidth, addOffset);
}
if (myAC->checkDrawToContour()) {
if (AC->checkDrawToContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::TO, lineWidth, addOffset);
}
if (myAC->checkDrawRelatedContour()) {
if (AC->checkDrawRelatedContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::RELATED, lineWidth, addOffset);
}
if (myAC->checkDrawOverContour()) {
if (AC->checkDrawOverContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::OVER, lineWidth, addOffset);
}
// inspect contour
if (myAC->checkDrawInspectContour()) {
if (AC->checkDrawInspectContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::INSPECT, lineWidth, addOffset);
}
// front contour
if (myAC->checkDrawFrontContour()) {
if (AC->checkDrawFrontContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::FRONT, lineWidth, addOffset);
}
// delete contour
if (myAC->checkDrawDeleteContour()) {
if (AC->checkDrawDeleteContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::REMOVE, lineWidth, addOffset);
}
// select contour
if (myAC->checkDrawSelectContour()) {
if (AC->checkDrawSelectContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::SELECT, lineWidth, addOffset);
}
}
Expand Down
41 changes: 18 additions & 23 deletions src/netedit/elements/GNEContour.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GNEContour {
};

/// @brief Constructor
GNEContour(GNEAttributeCarrier* AC);
GNEContour();

/// @brief destructor
~GNEContour();
Expand All @@ -57,34 +57,35 @@ class GNEContour {
/// @brief calculate contours
/// @{

/// @brief draw dotted contour (for closed shapes)
/// @brief calculate contour (for closed shapes)
void calculateContourClosedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double scale) const;
const GUIGlObject* glObject, const PositionVector& shape, const double scale) const;

/// @brief draw dotted contour extruded (used in elements formed by a central shape)
/// @brief calculate contour extruded (used in elements formed by a central shape)
void calculateContourExtrudedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double extrusionWidth, const double scale,
const bool closeFirstExtrem, const bool closeLastExtrem, const double offset) const;
const GUIGlObject* glObject, const PositionVector& shape, const double extrusionWidth,
const double scale, const bool closeFirstExtrem, const bool closeLastExtrem,
const double offset) const;

/// @brief draw dotted contour (for rectangled elements)
/// @brief calculate contour (for rectangled elements)
void calculateContourRectangleShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const Position& pos, const double width, const double height, const double offsetX,
const double offsetY, const double rot, const double scale) const;
const GUIGlObject* glObject, const Position& pos, const double width, const double height,
const double offsetX, const double offsetY, const double rot, const double scale) const;

/// @brief draw dotted contour (circle elements)
/// @brief calculate contour (circle elements)
void calculateContourCircleShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const Position& pos, double radius, const double scale) const;
const GUIGlObject* glObject, const Position& pos, double radius, const double scale) const;

/// @brief draw dotted contour (geometry points elements)
/// @brief calculate contour (geometry points elements)
void calculateContourGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, GeometryPoint geometryPoints, double radius, const double scale,
const double lineWidth) const;
const GUIGlObject* glObject, const PositionVector& shape, GeometryPoint geometryPoints,
double radius, const double scale, const double lineWidth) const;

/// @brief draw dotted contour edge
/// @brief calculate contour edge
void calculateContourEdge(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const GNEEdge* edge, const bool closeFirstExtrem, const bool closeLastExtrem) const;

/// @brief draw dotted contour between two consecutive edges
/// @brief calculate contour between two consecutive edges
void calculateContourEdges(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const GNEEdge* fromEdge, const GNEEdge* toEdge) const;

Expand All @@ -95,17 +96,14 @@ class GNEContour {

/// @brief draw dotted contours (basics, select, delete, inspect...)
void drawDottedContours(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const double lineWidth, const bool addOffset) const;
const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const;

/// @brief draw innen contour (currently used only in walkingAreas)
void drawInnenContourClosed(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double scale, const double lineWidth) const;
/// @}

private:
/// @brief pointer to AC
GNEAttributeCarrier* myAC;

/// @brief dotted geometries
std::vector<GUIDottedGeometry>* myDottedGeometries;

Expand Down Expand Up @@ -153,9 +151,6 @@ class GNEContour {
void drawDottedContour(const GUIVisualizationSettings& s, GUIDottedGeometry::DottedContourType type,
const double lineWidth, const bool addOffset) const;

/// @brief invalidate default constructor
GNEContour() = delete;

/// @brief Invalidated copy constructor.
GNEContour(const GNEContour&) = delete;

Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/additional/GNEAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ GNEAccess::drawGL(const GUIVisualizationSettings& s) const {
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), myAdditionalGeometry.getShape().front(), accessExaggeration, 0.3);
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidthSmall, true);
myAdditionalContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidthSmall, true);
}
// calculate contour
myContour.calculateContourCircleShape(s, d, myAdditionalGeometry.getShape().front(), 1, accessExaggeration);
myAdditionalContour.calculateContourCircleShape(s, d, this, myAdditionalGeometry.getShape().front(), 1, accessExaggeration);
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/netedit/elements/additional/GNEAdditional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ GNEAdditional::getCenteringBoundary() const {
if (myAdditionalBoundary.isInitialised()) {
return myAdditionalBoundary;
} else {
return myContour.getContourBoundary();
return myAdditionalContour.getContourBoundary();
}
}

Expand Down Expand Up @@ -718,10 +718,10 @@ GNEAdditional::drawSquaredAdditional(const GUIVisualizationSettings& s, const Po
// draw additional name
drawAdditionalName(s);
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidth, true);
myAdditionalContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
}
// calculate contour
myContour.calculateContourRectangleShape(s, d, pos, size, size, 0, 0, 0, exaggeration);
myAdditionalContour.calculateContourRectangleShape(s, d, this, pos, size, size, 0, 0, 0, exaggeration);
}
}

Expand Down Expand Up @@ -818,10 +818,10 @@ GNEAdditional::drawListedAdditional(const GUIVisualizationSettings& s, const Pos
GLHelper::popMatrix();
}
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidth, true);
myAdditionalContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
}
// calculate contour
myContour.calculateContourRectangleShape(s, d, signPosition, 0.56, 2.75, 0, -2.3, 0, 1);
myAdditionalContour.calculateContourRectangleShape(s, d, this, signPosition, 0.56, 2.75, 0, -2.3, 0, 1);
}
}

Expand Down Expand Up @@ -996,9 +996,9 @@ GNEAdditional::calculateContourPolygons(const GUIVisualizationSettings& s, const
const double exaggeration, const bool contouredShape) const {
// calculate contour depenidng of contoured shape
if (contouredShape) {
myContour.calculateContourClosedShape(s, d, myAdditionalGeometry.getShape(), 1);
myAdditionalContour.calculateContourClosedShape(s, d, this, myAdditionalGeometry.getShape(), 1);
} else {
myContour.calculateContourExtrudedShape(s, d, myAdditionalGeometry.getShape(), s.neteditSizeSettings.polylineWidth,
myAdditionalContour.calculateContourExtrudedShape(s, d, this, myAdditionalGeometry.getShape(), s.neteditSizeSettings.polylineWidth,
exaggeration, true, true, 0);
}
// get edit modes
Expand All @@ -1008,8 +1008,8 @@ GNEAdditional::calculateContourPolygons(const GUIVisualizationSettings& s, const
// get geometry point radius (size depends if we're in move mode)
const double geometryPointRaidus = s.neteditSizeSettings.additionalGeometryPointRadius * ((editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE)? 1 : 0.5);
// calculate contour geometry points
myContour.calculateContourGeometryPoints(s, d, myAdditionalGeometry.getShape(), GNEContour::GeometryPoint::ALL,
geometryPointRaidus, exaggeration, s.dottedContourSettings.segmentWidth);
myAdditionalContour.calculateContourGeometryPoints(s, d, this, myAdditionalGeometry.getShape(), GNEContour::GeometryPoint::ALL,
geometryPointRaidus, exaggeration, s.dottedContourSettings.segmentWidth);
}
}

Expand Down

0 comments on commit d7d7347

Please sign in to comment.