Skip to content

Commit

Permalink
updated demand elements. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent e7195b1 commit 0170f27
Show file tree
Hide file tree
Showing 12 changed files with 564 additions and 502 deletions.
27 changes: 17 additions & 10 deletions src/netedit/elements/network/GNEConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,8 @@ GNEConnection::drawGL(const GUIVisualizationSettings& s) const {
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidth, true);
}
// calculate contour and draw dotted geometry
myContour.calculateContourExtrudedShape2(s, d, shapeSuperposed, s.connectionSettings.connectionWidth, connectionExaggeration, true, true, 0,
s.dottedContourSettings.segmentWidthSmall);
// check geometry points if we're editing shape
if (myShapeEdited) {
myContour.calculateContourGeometryPoints2(s, d, shapeSuperposed, GNEContour::GeometryPoint::ALL,
s.neteditSizeSettings.connectionGeometryPointRadius, connectionExaggeration,
s.dottedContourSettings.segmentWidthSmall);
}
// calculate contour
calculateConnectionContour(s, d, shapeSuperposed, connectionExaggeration);
}
}

Expand Down Expand Up @@ -676,7 +669,7 @@ GNEConnection::getConnectionColor(const GUIVisualizationSettings& s) const {

void
GNEConnection::drawConnection(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector &shape, const double exaggeration) const {
const PositionVector &shape, const double exaggeration) const {
// get color
RGBColor connectionColor = getConnectionColor(s);
// Push layer matrix
Expand Down Expand Up @@ -754,6 +747,20 @@ GNEConnection::drawEdgeValues(const GUIVisualizationSettings& s, const PositionV
}


void
GNEConnection::calculateConnectionContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector &shape, const double exaggeration) const {
// calculate connection shape contour
myContour.calculateContourExtrudedShape(s, d, shape, s.connectionSettings.connectionWidth, exaggeration, true, true, 0);
// calculate geometry points contour if we're editing shape
if (myShapeEdited) {
myContour.calculateContourGeometryPoints(s, d, shape, GNEContour::GeometryPoint::ALL,
s.neteditSizeSettings.connectionGeometryPointRadius, exaggeration,
s.dottedContourSettings.segmentWidthSmall);
}
}


bool
GNEConnection::isValid(SumoXMLAttr key, const std::string& value) {
// Currently ignored before implementation to avoid warnings
Expand Down
7 changes: 6 additions & 1 deletion src/netedit/elements/network/GNEConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,19 @@ class GNEConnection : public GNENetworkElement {
RGBColor getConnectionColor(const GUIVisualizationSettings& s) const;

/// @brief draw connection
void drawConnection(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const PositionVector &shape, const double exaggeration) const;
void drawConnection(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector &shape, const double exaggeration) const;

/// @brief draw arrows over connections
void drawConnectionArrows(const GUIVisualizationSettings& s, const RGBColor &color) const;

/// @brief draw edge value
void drawEdgeValues(const GUIVisualizationSettings& s, const PositionVector &shape) const;

/// @brief calculate connection contour
void calculateConnectionContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector &shape, const double exaggeration) const;

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

Expand Down
114 changes: 65 additions & 49 deletions src/netedit/elements/network/GNECrossing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@
GNECrossing::GNECrossing(GNENet* net) :
GNENetworkElement(net, "", GLO_CROSSING, SUMO_TAG_CROSSING, GUIIconSubSys::getIcon(GUIIcon::CROSSING), {}, {}, {}, {}, {}, {}),
myParentJunction(nullptr),
myTemplateNBCrossing(new NBNode::Crossing(nullptr, {}, 0, false, 0, 0, {})) {
myTemplateNBCrossing(new NBNode::Crossing(nullptr, {}, 0, false, 0, 0, {})) {
// reset default values
resetDefaultValues();
}

GNECrossing::GNECrossing(GNEJunction* parentJunction, std::vector<NBEdge*> crossingEdges) :
GNENetworkElement(parentJunction->getNet(), parentJunction->getNBNode()->getCrossing(crossingEdges)->id, GLO_CROSSING,
SUMO_TAG_CROSSING, GUIIconSubSys::getIcon(GUIIcon::CROSSING), {}, {}, {}, {}, {}, {}),
myParentJunction(parentJunction),
myCrossingEdges(crossingEdges),
myTemplateNBCrossing(nullptr) {
myParentJunction(parentJunction),
myCrossingEdges(crossingEdges),
myTemplateNBCrossing(nullptr) {
// update centering boundary without updating grid
updateCenteringBoundary(false);
}
Expand Down Expand Up @@ -221,36 +221,8 @@ GNECrossing::drawGL(const GUIVisualizationSettings& s) const {
const auto d = s.getDetailLevel(crossingExaggeration);
// check if draw geometry
if (!s.drawForObjectUnderCursor) {
// get color
RGBColor crossingColor = getCrossingColor(s, NBCrossing);
// don't draw crossing in TLS Mode (but draw the TLS links)
if (myNet->getViewNet()->getEditModes().networkEditMode != NetworkEditMode::NETWORK_TLS) {
// push layer matrix
GLHelper::pushMatrix();
// translate to front
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, GLO_CROSSING);
// set color
GLHelper::setColor(crossingColor);
// draw depending of level of detail
if (d <= GUIVisualizationSettings::Detail::JunctionElementDetails) {
drawCrossingDetailed(crossingExaggeration, crossingWidth);
} else {
GLHelper::drawBoxLines(myCrossingGeometry.getShape(), crossingWidth);
}
// draw shape points only in Network supemode
if (myShapeEdited && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
s.drawMovingGeometryPoint(crossingExaggeration, s.neteditSizeSettings.crossingGeometryPointRadius)) {
// color
const RGBColor darkerColor = crossingColor.changedBrightness(-32);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, d, this, myCrossingGeometry.getShape(), darkerColor,
s.neteditSizeSettings.crossingGeometryPointRadius, crossingExaggeration,
myNet->getViewNet()->getNetworkViewOptions().editingElevation(),
myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE);
}
// pop layer matrix
GLHelper::popMatrix();
}
// draw crossing
drawCrossing(s, d, NBCrossing, crossingWidth, crossingExaggeration);
// draw TLS Links No
drawTLSLinkNo(s, NBCrossing);
// draw crossing name
Expand All @@ -262,15 +234,8 @@ GNECrossing::drawGL(const GUIVisualizationSettings& s) const {
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidth, true);
}
// calculate contour and draw dotted geometry
myContour.calculateContourExtrudedShape2(s, d, myCrossingGeometry.getShape(), crossingWidth, crossingExaggeration, true, true, 0,
s.dottedContourSettings.segmentWidth);
// check geometry points if we're editing shape
if (myShapeEdited) {
myContour.calculateContourGeometryPoints2(s, d, myCrossingGeometry.getShape(), GNEContour::GeometryPoint::ALL,
s.neteditSizeSettings.connectionGeometryPointRadius, crossingExaggeration,
s.dottedContourSettings.segmentWidth);
}
// calculate contour
calculateCrossingContour(s, d, crossingWidth, crossingExaggeration);
}
}

Expand Down Expand Up @@ -499,6 +464,9 @@ GNECrossing::checkEdgeBelong(const std::vector<GNEEdge*>& edges) const {
return false;
}

// ===========================================================================
// private
// ===========================================================================

bool
GNECrossing::checkDrawCrossing(const GUIVisualizationSettings& s) const {
Expand All @@ -518,6 +486,42 @@ GNECrossing::checkDrawCrossing(const GUIVisualizationSettings& s) const {
}


void
GNECrossing::drawCrossing(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const NBNode::Crossing* crossing, const double width, const double exaggeration) const {
// don't draw crossing in TLS Mode
if (myNet->getViewNet()->getEditModes().networkEditMode != NetworkEditMode::NETWORK_TLS) {
// get color
RGBColor crossingColor = getCrossingColor(s, crossing);
// push layer matrix
GLHelper::pushMatrix();
// translate to front
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, GLO_CROSSING);
// set color
GLHelper::setColor(crossingColor);
// draw depending of level of detail
if (d <= GUIVisualizationSettings::Detail::JunctionElementDetails) {
drawCrossingDetailed(width, exaggeration);
} else {
GLHelper::drawBoxLines(myCrossingGeometry.getShape(), width);
}
// draw shape points only in Network supemode
if (myShapeEdited && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
s.drawMovingGeometryPoint(exaggeration, s.neteditSizeSettings.crossingGeometryPointRadius)) {
// color
const RGBColor darkerColor = crossingColor.changedBrightness(-32);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, d, this, myCrossingGeometry.getShape(), darkerColor,
s.neteditSizeSettings.crossingGeometryPointRadius, exaggeration,
myNet->getViewNet()->getNetworkViewOptions().editingElevation(),
myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE);
}
// pop layer matrix
GLHelper::popMatrix();
}
}


RGBColor
GNECrossing::getCrossingColor(const GUIVisualizationSettings& s, const NBNode::Crossing* crossing) const {
if (myShapeEdited) {
Expand All @@ -540,15 +544,12 @@ GNECrossing::getCrossingColor(const GUIVisualizationSettings& s, const NBNode::C
}
}

// ===========================================================================
// private
// ===========================================================================

void
GNECrossing::drawCrossingDetailed(const double selectionScale, const double width) const {
GNECrossing::drawCrossingDetailed(const double width, const double exaggeration) const {
// geet lenght and spacing
const double length = 0.5 * selectionScale;
const double spacing = 1.0 * selectionScale;
const double length = 0.5 * exaggeration;
const double spacing = 1.0 * exaggeration;
// push rail matrix
GLHelper::pushMatrix();
// draw on top of of the white area between the rails
Expand All @@ -575,6 +576,21 @@ GNECrossing::drawCrossingDetailed(const double selectionScale, const double widt
GLHelper::popMatrix();
}


void
GNECrossing::calculateCrossingContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const double width, const double exaggeration) const {
// calculate contour
myContour.calculateContourExtrudedShape(s, d, myCrossingGeometry.getShape(), width, exaggeration, true, true, 0);
// check if calculate contour for geometry points
if (myShapeEdited) {
myContour.calculateContourGeometryPoints(s, d, myCrossingGeometry.getShape(), GNEContour::GeometryPoint::ALL,
s.neteditSizeSettings.crossingGeometryPointRadius, exaggeration,
s.dottedContourSettings.segmentWidth);
}
}


void
GNECrossing::setAttribute(SumoXMLAttr key, const std::string& value) {
const auto crossing = getNBCrossing();
Expand Down
10 changes: 9 additions & 1 deletion src/netedit/elements/network/GNECrossing.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,19 @@ class GNECrossing : public GNENetworkElement {
/// @brief check if draw crossing
bool checkDrawCrossing(const GUIVisualizationSettings& s) const;

/// @brief draw crossing
void drawCrossing(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const NBNode::Crossing* crossing, const double width, const double exaggeration) const;

/// @brief get crossing color
RGBColor getCrossingColor(const GUIVisualizationSettings& s, const NBNode::Crossing* crossing) const;

/// @brief draw crossing with hight detail
void drawCrossingDetailed(const double selectionScale, const double width) const;
void drawCrossingDetailed(const double width, const double exaggeration) const;

/// @brief calculate contour
void calculateCrossingContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const double width, const double exaggeration) const;

/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)
void setAttribute(SumoXMLAttr key, const std::string& value);
Expand Down
8 changes: 4 additions & 4 deletions src/netedit/elements/network/GNEEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2735,21 +2735,21 @@ GNEEdge::drawChildrens(const GUIVisualizationSettings& s, const GUIVisualization
void
GNEEdge::calculateContours(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
// calculate contour and draw dotted geometry
myContour.calculateContourEdge2(s, d, this, true, true, s.dottedContourSettings.segmentWidth);
myContour.calculateContourEdge(s, d, this, true, true);
// get snap radius
const auto radius = getSnapRadius(false);
// draw geometry points
myContour.calculateContourGeometryPoints2(s, d, myNBEdge->getGeometry(), GNEContour::GeometryPoint::MIDDLE,
myContour.calculateContourGeometryPoints(s, d, myNBEdge->getGeometry(), GNEContour::GeometryPoint::MIDDLE,
radius, myLanes.front()->getDrawingConstants()->getExaggeration(),
s.dottedContourSettings.segmentWidth);
// extrems depending if has custom from-to
const bool forceDrawExtrems = myNet->getViewNet()->getViewParent()->getMoveFrame()->getNetworkModeOptions()->getForceDrawGeometryPoints();
if (forceDrawExtrems || (myNBEdge->getGeometry().front() != getParentJunctions().front()->getPositionInView())) {
myContour.calculateContourGeometryPoints2(s, d, myNBEdge->getGeometry(), GNEContour::GeometryPoint::FROM,
myContour.calculateContourGeometryPoints(s, d, myNBEdge->getGeometry(), GNEContour::GeometryPoint::FROM,
radius, 1, s.dottedContourSettings.segmentWidth);
}
if (forceDrawExtrems || (myNBEdge->getGeometry().back() != getParentJunctions().back()->getPositionInView())) {
myContour.calculateContourGeometryPoints2(s, d, myNBEdge->getGeometry(), GNEContour::GeometryPoint::TO,
myContour.calculateContourGeometryPoints(s, d, myNBEdge->getGeometry(), GNEContour::GeometryPoint::TO,
radius, 1, s.dottedContourSettings.segmentWidth);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/netedit/elements/network/GNEInternalLane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ GNEInternalLane::drawGL(const GUIVisualizationSettings& s) const {
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidth, true);
}
// calculate contour and draw dotted geometry
myContour.calculateContourExtrudedShape2(s, d, myInternalLaneGeometry.getShape(), s.connectionSettings.connectionWidth, 1,
true, true, 0, s.dottedContourSettings.segmentWidthSmall);
// calculate contour
myContour.calculateContourExtrudedShape(s, d, myInternalLaneGeometry.getShape(), s.connectionSettings.connectionWidth,
1, true, true, 0);
}
}

Expand Down

0 comments on commit 0170f27

Please sign in to comment.