Skip to content

Commit

Permalink
Added checkBoundarySizeDrawing() function. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 3860229 commit 6686b51
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 68 deletions.
20 changes: 1 addition & 19 deletions src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,24 +1364,6 @@ GNEViewNet::doPaintGL(int mode, const Boundary& bound) {
myNet->drawGL(*myVisualizationSettings);
// draw all GL elements
int hits = drawGLElements(bound);
// force draw inspected and front elements (due parent/child lines)
if (!myVisualizationSettings->drawForRectangleSelection) {
// iterate over all inspected ACs
for (const auto& inspectedAC : myInspectedAttributeCarriers) {
// check that inspected AC has an associated GUIGLObject
if (inspectedAC->getTagProperty().isAdditionalElement() && inspectedAC->getGUIGlObject()) {
inspectedAC->getGUIGlObject()->drawGL(*myVisualizationSettings);
}
}
// draw front element
if (myFrontAttributeCarrier && myFrontAttributeCarrier->getGUIGlObject()) {
myFrontAttributeCarrier->getGUIGlObject()->drawGL(*myVisualizationSettings);
}
}
// re-draw marked route
if (gViewObjectsHandler.markedRoute && !myVisualizationSettings->drawForRectangleSelection) {
myNet->getPathManager()->forceDrawPath(*myVisualizationSettings, gViewObjectsHandler.markedRoute);
}
// draw temporal split junction
drawTemporalSplitJunction();
// draw temporal roundabout
Expand Down Expand Up @@ -3298,7 +3280,7 @@ GNEViewNet::drawGLElements(const Boundary& bound) const {
// calculate boundary extremes
const float minB[2] = { (float)bound.xmin(), (float)bound.ymin() };
const float maxB[2] = { (float)bound.xmax(), (float)bound.ymax() };
// reset gl line to 2
// reset gl line to 1
glLineWidth(1);
// set drawing modes
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
Expand Down
93 changes: 48 additions & 45 deletions src/netedit/elements/network/GNEEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,52 +558,54 @@ GNEEdge::getOppositeEdges() const {

void
GNEEdge::drawGL(const GUIVisualizationSettings& s) const {
// draw boundary
GLHelper::drawBoundary(s, getCenteringBoundary());
// get detail level from the first lane
const auto d = myLanes.front()->getDrawingConstants()->getDetail();
if (s.checkShapeSizeDrawing(myLanes.front()->getLaneShapeLength())) {
// draw draw lanes
for (const auto& lane : myLanes) {
lane->drawGL(s);
}
}
// draw junctions
getFromJunction()->drawGL(s);
getToJunction()->drawGL(s);
// draw geometry points
drawEdgeGeometryPoints(s, d);
// check if draw details
if (!s.drawForObjectUnderCursor) {
// draw edge shape (a red line only visible if lane shape is strange)
drawEdgeShape(s, d);
// draw edge stopOffset
drawLaneStopOffset(s, d);
// draw edge name
drawEdgeName(s, d);
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), getPositionInView(), 1);
}
// draw childrens
drawChildrens(s, d);
// calculate contour and draw dotted geometry
myContour.calculateContourEdge(s, d, this, true, true, s.dottedContourSettings.segmentWidth);
const auto radius = getSnapRadius(false);
// draw geometry points
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.calculateContourGeometryPoints(s, d, myNBEdge->getGeometry(), GNEContour::GeometryPoint::FROM,
radius, 1, s.dottedContourSettings.segmentWidth);
}
if (forceDrawExtrems || (myNBEdge->getGeometry().back() != getParentJunctions().back()->getPositionInView())) {
myContour.calculateContourGeometryPoints(s, d, myNBEdge->getGeometry(), GNEContour::GeometryPoint::TO,
// only draw depending of size boundary
if (s.checkBoundarySizeDrawing(myEdgeBoundary.getWidth(), myEdgeBoundary.getHeight())) {
// draw boundary
GLHelper::drawBoundary(s, getCenteringBoundary());
// get detail level from the first lane
const auto d = myLanes.front()->getDrawingConstants()->getDetail();
if (s.checkShapeSizeDrawing(myLanes.front()->getLaneShapeLength())) {
// draw draw lanes
for (const auto& lane : myLanes) {
lane->drawGL(s);
}
}
// draw junctions
getFromJunction()->drawGL(s);
getToJunction()->drawGL(s);
// draw geometry points
drawEdgeGeometryPoints(s, d);
// check if draw details
if (!s.drawForObjectUnderCursor) {
// draw edge shape (a red line only visible if lane shape is strange)
drawEdgeShape(s, d);
// draw edge stopOffset
drawLaneStopOffset(s, d);
// draw edge name
drawEdgeName(s, d);
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), getPositionInView(), 1);
}
// draw childrens
drawChildrens(s, d);
// calculate contour and draw dotted geometry
myContour.calculateContourEdge(s, d, this, true, true, s.dottedContourSettings.segmentWidth);
const auto radius = getSnapRadius(false);
// draw geometry points
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.calculateContourGeometryPoints(s, d, myNBEdge->getGeometry(), GNEContour::GeometryPoint::FROM,
radius, 1, s.dottedContourSettings.segmentWidth);
}
if (forceDrawExtrems || (myNBEdge->getGeometry().back() != getParentJunctions().back()->getPositionInView())) {
myContour.calculateContourGeometryPoints(s, d, myNBEdge->getGeometry(), GNEContour::GeometryPoint::TO,
radius, 1, s.dottedContourSettings.segmentWidth);
}
}

}


Expand Down Expand Up @@ -2811,7 +2813,8 @@ GNEEdge::drawTAZElements(const GUIVisualizationSettings& s) const {
void
GNEEdge::drawEdgeShape(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
// avoid draw for railways
if ((gViewObjectsHandler.markedFirstGeometryPoint == this) && (s.laneWidthExaggeration >= 1) && !myLanes.front()->getDrawingConstants()->drawAsRailway()) {
if ((d <= GUIVisualizationSettings::Detail::LaneDetails) && !myLanes.front()->getDrawingConstants()->drawAsRailway() &&
(gViewObjectsHandler.markedFirstGeometryPoint == this)) {
// push draw matrix
GLHelper::pushMatrix();
// translate to front depending of big points
Expand Down
6 changes: 3 additions & 3 deletions src/utils/gui/div/GUIViewObjectsHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ class GUIViewObjectsHandler {
/// @brief set with selected elements (used only to avoid double seletions)
std::set<const GUIGlObject*> mySelectedObjets;

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

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

Expand All @@ -148,6 +145,9 @@ class GUIViewObjectsHandler {
/// @brief position
Position mySelectionPosition;

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

private:
/// @brief set copy constructor private
GUIViewObjectsHandler(const GUIViewObjectsHandler&) = default;
Expand Down
13 changes: 13 additions & 0 deletions src/utils/gui/settings/GUIVisualizationSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2371,6 +2371,7 @@ GUIVisualizationSettings::getTextAngle(double objectAngle) const {
return objectAngle;
}


bool
GUIVisualizationSettings::flippedTextAngle(double objectAngle) const {
double viewAngle = objectAngle - angle;
Expand All @@ -2383,6 +2384,18 @@ GUIVisualizationSettings::flippedTextAngle(double objectAngle) const {
}


bool
GUIVisualizationSettings::checkBoundarySizeDrawing(const double w, const double h) const {
const double size = MAX2(w, h);
if (drawForObjectUnderCursor) {
return true;
} else {
// for low computers 20. for high 10
return (scale * size) > 15;
}
}


bool
GUIVisualizationSettings::checkShapeSizeDrawing(const double shapeLenght) const {
if (drawForObjectUnderCursor) {
Expand Down
5 changes: 4 additions & 1 deletion src/utils/gui/settings/GUIVisualizationSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ class GUIVisualizationSettings {
GeometryPoint = 1, // draw geometry points
JunctionElement = 1, // crossings, walking area, connections and internal lanes
DottedContoursResampled = 1, // resample dotted contours
PreciseSelection = 1, // precise selection using boundaries
PreciseSelection = 1, // precise selection using boundaries

Level2 = 2,
CircleResolution8 = 2, // circle resolution = 8
Expand Down Expand Up @@ -623,6 +623,9 @@ class GUIVisualizationSettings {
/// @brief return wether the text was flipped for reading at the given angle
bool flippedTextAngle(double objectAngle) const;

/// @brief check if draw element depending of boundarySize
bool checkBoundarySizeDrawing(const double w, const double h) const;

/// @brief check if draw element depending of shapeSize
bool checkShapeSizeDrawing(const double shapeLenght) const;

Expand Down

0 comments on commit 6686b51

Please sign in to comment.