Skip to content

Commit

Permalink
Added call to function myContour.drawDottedContours() in all elements…
Browse files Browse the repository at this point in the history
… with contours. Refs #13894
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent cff4f77 commit 49f537d
Show file tree
Hide file tree
Showing 42 changed files with 533 additions and 467 deletions.
90 changes: 45 additions & 45 deletions src/netedit/elements/GNEContour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ GNEContour::getContourBoundary() const {


void
GNEContour::calculateContourClosedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
GNEContour::calculateContourClosedShape2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double scale, const bool addOffset,
const double lineWidth) const {
// check if mouse is within geometry (only in rectangle selection mode)
Expand All @@ -76,7 +76,7 @@ GNEContour::calculateContourClosedShape(const GUIVisualizationSettings& s, const


void
GNEContour::calculateContourExtrudedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
GNEContour::calculateContourExtrudedShape2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double extrusionWidth, const double scale, const bool drawFirstExtrem,
const bool drawLastExtrem, const double offset, const double lineWidth) const {
// check if mouse is within two lines (only in rectangle selection mode)
Expand All @@ -91,7 +91,7 @@ GNEContour::calculateContourExtrudedShape(const GUIVisualizationSettings& s, con


void
GNEContour::calculateContourRectangleShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
GNEContour::calculateContourRectangleShape2(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 double lineWidth) const {
// check if mouse is within geometry (only in rectangle selection mode)
Expand All @@ -106,7 +106,7 @@ GNEContour::calculateContourRectangleShape(const GUIVisualizationSettings& s, co


void
GNEContour::calculateContourCircleShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
GNEContour::calculateContourCircleShape2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const Position& pos, double radius, const double scale, const double lineWidth) const {
// check if mouse is within geometry (only in rectangle selection mode)
if (s.drawForObjectUnderCursor) {
Expand All @@ -120,7 +120,7 @@ GNEContour::calculateContourCircleShape(const GUIVisualizationSettings& s, const


void
GNEContour::calculateContourGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
GNEContour::calculateContourGeometryPoints2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, GeometryPoint geometryPoints, double radius,
const double scale, const double lineWidth) const {
// get object
Expand Down Expand Up @@ -174,7 +174,7 @@ GNEContour::calculateContourGeometryPoints(const GUIVisualizationSettings& s, co


void
GNEContour::calculateContourEdge(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
GNEContour::calculateContourEdge2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const GNEEdge* edge, const bool drawFirstExtrem, const bool drawLastExtrem,
const double lineWidth) const {
// check if mouse is within two lines (only in rectangle selection mode)
Expand All @@ -189,7 +189,7 @@ GNEContour::calculateContourEdge(const GUIVisualizationSettings& s, const GUIVis


void
GNEContour::calculateContourEdges(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
GNEContour::calculateContourEdges2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const GNEEdge* fromEdge, const GNEEdge* toEdge, const double lineWidth) const {
// first build dotted contour (only in rectangle selection mode)
buildContourEdges(s, d, fromEdge, toEdge);
Expand All @@ -198,6 +198,44 @@ GNEContour::calculateContourEdges(const GUIVisualizationSettings& s, const GUIVi
}


void
GNEContour::drawDottedContours(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
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()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::FROM, lineWidth, addOffset);
}
if (myAC->checkDrawToContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::TO, lineWidth, addOffset);
}
if (myAC->checkDrawRelatedContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::RELATED, lineWidth, addOffset);
}
if (myAC->checkDrawOverContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::OVER, lineWidth, addOffset);
}
// inspect contour
if (myAC->checkDrawInspectContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::INSPECT, lineWidth, addOffset);
}
// front contour
if (myAC->checkDrawFrontContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::FRONT, lineWidth, addOffset);
}
// delete contour
if (myAC->checkDrawDeleteContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::REMOVE, lineWidth, addOffset);
}
// select contour
if (myAC->checkDrawSelectContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::SELECT, lineWidth, addOffset);
}
}
}


void
GNEContour::drawInnenContourClosed(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double scale, const double lineWidth) const {
Expand Down Expand Up @@ -392,44 +430,6 @@ GNEContour::updateContourBondary() const {
}


void
GNEContour::drawDottedContours(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
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()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::FROM, lineWidth, addOffset);
}
if (myAC->checkDrawToContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::TO, lineWidth, addOffset);
}
if (myAC->checkDrawRelatedContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::RELATED, lineWidth, addOffset);
}
if (myAC->checkDrawOverContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::OVER, lineWidth, addOffset);
}
// inspect contour
if (myAC->checkDrawInspectContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::INSPECT, lineWidth, addOffset);
}
// front contour
if (myAC->checkDrawFrontContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::FRONT, lineWidth, addOffset);
}
// delete contour
if (myAC->checkDrawDeleteContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::REMOVE, lineWidth, addOffset);
}
// select contour
if (myAC->checkDrawSelectContour()) {
drawDottedContour(s, GUIDottedGeometry::DottedContourType::SELECT, lineWidth, addOffset);
}
}
}


void
GNEContour::drawDottedContour(const GUIVisualizationSettings& s, GUIDottedGeometry::DottedContourType type,
const double lineWidth, const bool addOffset) const {
Expand Down
29 changes: 12 additions & 17 deletions src/netedit/elements/GNEContour.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,44 +58,48 @@ class GNEContour {
/// @{

/// @brief draw dotted contour (for closed shapes)
void calculateContourClosedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
void calculateContourClosedShape2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double scale, const bool addOffset,
const double lineWidth) const;

/// @brief draw dotted contour extruded (used in elements formed by a central shape)
void calculateContourExtrudedShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
void calculateContourExtrudedShape2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double extrusionWidth, const double scale,
const bool drawFirstExtrem, const bool drawLastExtrem, const double offset,
const double lineWidth) const;

/// @brief draw dotted contour (for rectangled elements)
void calculateContourRectangleShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
void calculateContourRectangleShape2(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 double lineWidth) const;

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

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

/// @brief draw dotted contour edge
void calculateContourEdge(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
void calculateContourEdge2(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const GNEEdge* edge, const bool drawFirstExtrem, const bool drawLastExtrem,
const double lineWidth) const;

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

/// @}

/// @brief innen contours
/// @brief drawing contour functions
/// @{

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

/// @brief draw innen contour (for closed shapes)
void drawInnenContourClosed(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector& shape, const double scale, const double lineWidth) const;
Expand Down Expand Up @@ -148,19 +152,10 @@ class GNEContour {

/// @}

/// @name drawing functions
/// @{

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

/// @brief draw dotted contour
void drawDottedContour(const GUIVisualizationSettings& s, GUIDottedGeometry::DottedContourType type,
const double lineWidth, const bool addOffset) const;

/// @}

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

Expand Down
24 changes: 10 additions & 14 deletions src/netedit/elements/additional/GNEAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,16 @@ GNEAccess::getParentName() const {

void
GNEAccess::drawGL(const GUIVisualizationSettings& s) const {
// Obtain exaggeration
const double accessExaggeration = getExaggeration(s);
// first check if additional has to be drawn
if (myNet->getViewNet()->getDataViewOptions().showAdditionals()) {
// get distance squared between mouse and access
const double distanceSquared = getPositionInView().distanceSquaredTo2D(myNet->getViewNet()->getPositionInformation());
// declare radius
const double radius = (distanceSquared <= 1) ? 1 : 0.5;
// Obtain exaggeration
const double accessExaggeration = getExaggeration(s);
// get detail level
const auto d = s.getDetailLevel(1);
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// radius depends if mouse is over element
const double radius = gViewObjectsHandler.isElementSelected(this)? 1 : 0.5;
// get color
RGBColor accessColor;
if (drawUsingSelectColor()) {
Expand All @@ -232,19 +230,17 @@ GNEAccess::drawGL(const GUIVisualizationSettings& s) const {
// translate to geometry position
glTranslated(myAdditionalGeometry.getShape().front().x(), myAdditionalGeometry.getShape().front().y(), 0);
// draw circle
if (s.drawForRectangleSelection) {
GLHelper::drawFilledCircle(radius * accessExaggeration, 8);
} else {
GLHelper::drawFilledCircle(radius * accessExaggeration, 16);
}
GLHelper::drawFilledCircleDetailled(d, radius);
// pop layer matrix
GLHelper::popMatrix();
// 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);
}
// draw dotted contour
myContour.calculateContourCircleShape(s, d, myAdditionalGeometry.getShape().front(), radius, accessExaggeration,
s.dottedContourSettings.segmentWidthSmall);
// check object in view
myContour.calculateContourCircleShape2(s, d, myAdditionalGeometry.getShape().front(), 1, accessExaggeration,
s.dottedContourSettings.segmentWidthSmall);
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/netedit/elements/additional/GNEAdditional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,11 @@ GNEAdditional::drawSquaredAdditional(const GUIVisualizationSettings& s, const Po
drawAdditionalID(s);
// draw additional name
drawAdditionalName(s);
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidth, true);
}
// draw squared shape
myContour.calculateContourRectangleShape(s, d, pos, size, size, 0, 0, 0, exaggeration,
myContour.calculateContourRectangleShape2(s, d, pos, size, size, 0, 0, 0, exaggeration,
s.dottedContourSettings.segmentWidth);
}
}
Expand Down Expand Up @@ -816,9 +818,11 @@ GNEAdditional::drawListedAdditional(const GUIVisualizationSettings& s, const Pos
// pop layer matrix
GLHelper::popMatrix();
}
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidth, true);
}
// draw squared shape
myContour.calculateContourRectangleShape(s, d, signPosition, 0.56, 2.75, 0, -2.3, 0, 1,
myContour.calculateContourRectangleShape2(s, d, signPosition, 0.56, 2.75, 0, -2.3, 0, 1,
s.dottedContourSettings.segmentWidth);
}
}
Expand Down
24 changes: 6 additions & 18 deletions src/netedit/elements/additional/GNEBusStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ GNEBusStop::updateGeometry() {

void
GNEBusStop::drawGL(const GUIVisualizationSettings& s) const {
// Obtain exaggeration of the draw
const double busStopExaggeration = getExaggeration(s);
// check if additional has to be drawn
if (myNet->getViewNet()->getDataViewOptions().showAdditionals()) {
// Obtain exaggeration of the draw
const double busStopExaggeration = getExaggeration(s);
// check if draw moving geometry points
const int movingGeometryPoints = drawMovingGeometryPoints(false);
// get width
Expand Down Expand Up @@ -184,25 +184,13 @@ GNEBusStop::drawGL(const GUIVisualizationSettings& s) const {
drawAdditionalID(s);
// draw additional name
drawAdditionalName(s);
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidth, true);
}
// draw stoppingPlace children
drawStoppingPlaceChildren(s);
// calculate contour and draw dotted geometry (don't exaggerate contour)
if (movingGeometryPoints) {
if (myStartPosition != INVALID_DOUBLE) {
myContour.calculateContourGeometryPoints(s, d, myAdditionalGeometry.getShape(), GNEContour::GeometryPoint::FROM,
s.neteditSizeSettings.additionalGeometryPointRadius, 1,
s.dottedContourSettings.segmentWidth);
}
if (movingGeometryPoints && (myEndPosition != INVALID_DOUBLE)) {
myContour.calculateContourGeometryPoints(s, d, myAdditionalGeometry.getShape(), GNEContour::GeometryPoint::TO,
s.neteditSizeSettings.additionalGeometryPointRadius, 1,
s.dottedContourSettings.segmentWidth);
}
} else {
myContour.calculateContourExtrudedShape(s, d, myAdditionalGeometry.getShape(), stopWidth, 1, true, true, 0,
s.dottedContourSettings.segmentWidth);
}
// check object in view
checkViewObject(s, d, stopWidth, movingGeometryPoints);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/netedit/elements/additional/GNECalibrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,11 @@ GNECalibrator::drawCalibratorSymbol(const GUIVisualizationSettings& s, const GUI
}
// pop layer matrix
GLHelper::popMatrix();
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidth, true);
}
// draw dotted contour
myContour.calculateContourRectangleShape(s, d, pos, s.additionalSettings.calibratorWidth, s.additionalSettings.calibratorHeight * 0.5, 0,
myContour.calculateContourRectangleShape2(s, d, pos, s.additionalSettings.calibratorWidth, s.additionalSettings.calibratorHeight * 0.5, 0,
s.additionalSettings.calibratorHeight * 0.5, rot, exaggeration, s.dottedContourSettings.segmentWidth);
}

Expand Down

0 comments on commit 49f537d

Please sign in to comment.