Skip to content

Commit

Permalink
Updated GNEJunction. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent b7cdf43 commit a87744f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 60 deletions.
84 changes: 33 additions & 51 deletions src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ GNEJunction::GNEJunction(GNENet* net, NBNode* nbn, bool loaded) :
GUIIconSubSys::getIcon(GUIIcon::JUNCTION), {}, {}, {}, {}, {}, {}),
myNBNode(nbn),
myJunctionInGrid(true),
myMaxDrawingSize(1),
myAmCreateEdgeSource(false),
myLogicStatus(loaded ? FEATURE_LOADED : FEATURE_GUESSED),
myAmResponsible(false),
Expand Down Expand Up @@ -129,8 +128,6 @@ GNEJunction::updateGeometry() {

void
GNEJunction::updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings) {
// recalc max drawing size
myMaxDrawingSize = MAX2(getCenteringBoundary().getWidth(), getCenteringBoundary().getHeight());
// rebuild crossings
rebuildGNECrossings(rebuildNBNodeCrossings);
// clear walking areas
Expand Down Expand Up @@ -631,38 +628,30 @@ GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
const bool junctionBubble = drawAsBubble(s);
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// get mouse position
const Position mousePosition = myNet->getViewNet()->getPositionInformation();
// push junction name
GLHelper::pushName(getGlID());
// push layer matrix
GLHelper::pushMatrix();
// translate to front
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, GLO_JUNCTION);
// push name
if (s.scale * junctionExaggeration * myMaxDrawingSize < 1.) {
// draw something simple so that selection still works
GLHelper::drawBoxLine(myNBNode->getPosition(), 0, 1, 1);
} else {
// draw junction as shape
if (junctionShape) {
drawJunctionAsShape(s, d, junctionExaggeration, mousePosition);
}
// draw junction as bubble
if (junctionBubble) {
drawJunctionAsBubble(s, d, junctionExaggeration, mousePosition);
}
// draw TLS
drawTLSIcon(s, d);
// draw elevation
if (!s.drawForRectangleSelection && myNet->getViewNet()->getNetworkViewOptions().editingElevation()) {
GLHelper::pushMatrix();
// Translate to center of junction
glTranslated(myNBNode->getPosition().x(), myNBNode->getPosition().y(), 0.1);
// draw Z value
GLHelper::drawText(toString(myNBNode->getPosition().z()), Position(), GLO_MAX - 5, s.junctionID.scaledSize(s.scale), s.junctionID.color);
GLHelper::popMatrix();
}
// draw junction as shape
if (junctionShape) {
drawJunctionAsShape(s, d, junctionExaggeration);
}
// draw junction as bubble
if (junctionBubble) {
drawJunctionAsBubble(s, d, junctionExaggeration);
}
// draw TLS
drawTLSIcon(s, d);
// draw elevation
if (!s.drawForRectangleSelection && myNet->getViewNet()->getNetworkViewOptions().editingElevation()) {
GLHelper::pushMatrix();
// Translate to center of junction
glTranslated(myNBNode->getPosition().x(), myNBNode->getPosition().y(), 0.1);
// draw Z value
GLHelper::drawText(toString(myNBNode->getPosition().z()), Position(), GLO_MAX - 5, s.junctionID.scaledSize(s.scale), s.junctionID.color);
GLHelper::popMatrix();
}
// pop layer Matrix
GLHelper::popMatrix();
Expand All @@ -672,11 +661,11 @@ GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), getPositionInView(), 1);
// draw junction name
drawJunctionName(s, d);
// draw Junction childs
drawJunctionChildren(s, d);
// draw path additional elements
myNet->getPathManager()->drawJunctionPathElements(s, d, this);
}
// draw Junction childs
drawJunctionChildren(s, d);
// draw path additional elements
myNet->getPathManager()->drawJunctionPathElements(s, d, this);
// continue depending of shapes
if (junctionShape) {
// draw dotted contour
Expand Down Expand Up @@ -1209,12 +1198,6 @@ GNEJunction::setJunctionType(const std::string& value, GNEUndoList* undoList) {
}


double
GNEJunction::getMaxDrawingSize() const {
return myMaxDrawingSize;
}


void
GNEJunction::clearWalkingAreas() {
// delete non retrieved GNEWalkingAreas (we don't need to extract if from Tree two times)
Expand Down Expand Up @@ -1630,9 +1613,9 @@ GNEJunction::drawAsBubble(const GUIVisualizationSettings& s) const {

void
GNEJunction::drawJunctionAsBubble(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const double junctionExaggeration, const Position mousePosition) const {
const double exaggeration) const {
// calculate bubble radius
const double bubbleRadius = s.neteditSizeSettings.junctionBubbleRadius * junctionExaggeration;
const double bubbleRadius = s.neteditSizeSettings.junctionBubbleRadius * exaggeration;
// set bubble color
const RGBColor bubbleColor = setColor(s, true);
// push matrix
Expand All @@ -1649,8 +1632,7 @@ GNEJunction::drawJunctionAsBubble(const GUIVisualizationSettings& s, GUIVisualiz


void
GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const double junctionExaggeration, const Position mousePosition) const {
GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d, const double exaggeration) const {
// check if draw tesselation or or polygon
if (d <= GUIVisualizationSettings::DetailLevel::Level3) {
// check if draw start und end
Expand All @@ -1661,11 +1643,11 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualiza
// set color
GLHelper::setColor(junctionShapeColor);
// adjust shape to exaggeration (check)
if ((junctionExaggeration > 1 || myExaggeration > 1) && junctionExaggeration != myExaggeration) {
myExaggeration = junctionExaggeration;
if ((exaggeration > 1 || myExaggeration > 1) && exaggeration != myExaggeration) {
myExaggeration = exaggeration;
myTesselation.setShape(myNBNode->getShape());
myTesselation.getShapeRef().closePolygon();
myTesselation.getShapeRef().scaleRelative(junctionExaggeration);
myTesselation.getShapeRef().scaleRelative(exaggeration);
myTesselation.myTesselation.clear();
}
// check if draw tesselation or or polygon
Expand All @@ -1683,7 +1665,7 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualiza
}
// draw shape points only in Network supermode
if (myShapeEdited && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
s.drawMovingGeometryPoint(junctionExaggeration, s.neteditSizeSettings.junctionGeometryPointRadius)) {
s.drawMovingGeometryPoint(exaggeration, s.neteditSizeSettings.junctionGeometryPointRadius)) {
// get mouse position
const auto mousePos = myNet->getViewNet()->getPositionInformation();
// set color
Expand All @@ -1693,8 +1675,8 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualiza
// obtain junction Shape
PositionVector junctionOpenShape = myNBNode->getShape();
// adjust shape to exaggeration
if (junctionExaggeration > 1) {
junctionOpenShape.scaleRelative(junctionExaggeration);
if (exaggeration > 1) {
junctionOpenShape.scaleRelative(exaggeration);
}
// update geometry
junctionGeometry.updateGeometry(junctionOpenShape);
Expand All @@ -1704,12 +1686,12 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualiza
GUIGeometry::drawGeometry(s, mousePos, junctionGeometry, s.neteditSizeSettings.junctionGeometryPointRadius * 0.5);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, d, this, mousePos, junctionOpenShape, darkerColor, RGBColor::BLACK,
s.neteditSizeSettings.junctionGeometryPointRadius, junctionExaggeration,
s.neteditSizeSettings.junctionGeometryPointRadius, exaggeration,
myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
// draw moving hint
if (myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE) {
GUIGeometry::drawMovingHint(s, this, mousePos, junctionOpenShape, darkerColor,
s.neteditSizeSettings.junctionGeometryPointRadius, junctionExaggeration);
s.neteditSizeSettings.junctionGeometryPointRadius, exaggeration);
}
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/netedit/elements/network/GNEJunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {
/// @brief set junction Type (using undo/redo)
void setJunctionType(const std::string& value, GNEUndoList* undoList);

/// @brief get the maximum size (in either x-, or y-dimension) for determining whether to draw or not
double getMaxDrawingSize() const;

/// @brief clear walking areas
void clearWalkingAreas();

Expand Down Expand Up @@ -323,9 +320,6 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {
/// @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;

/// @brief whether this junction is the first junction for a newly creatededge
/// @see GNEApplicationWindow::createEdgeSource)
bool myAmCreateEdgeSource;
Expand Down Expand Up @@ -357,11 +351,11 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {

/// @brief draw junction as bubble
void drawJunctionAsBubble(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const double junctionExaggeration, const Position mousePosition) const;
const double exaggerration) const;

/// @brief draw junction as bubble
void drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const double junctionExaggeration, const Position mousePosition) const;
const double exaggerration) const;

/// @brief draw TLS icon
void drawTLSIcon(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const;
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNEWalkingArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ GNEWalkingArea::drawTesselatedWalkingArea(const GUIVisualizationSettings& s, GUI
// set color
GLHelper::setColor(color);
// check if draw polygon or tesselation
if ((s.scale * exaggeration * myParentJunction->getMaxDrawingSize()) >= 40) {
if (true /*temporal */) {
// draw shape with high detail
myTesselation.drawTesselation(myTesselation.getShape());
} else {
Expand Down

0 comments on commit a87744f

Please sign in to comment.