Skip to content

Commit

Permalink
Removed GUIVisualizationDetailSettings and added GUIVisualizationSett…
Browse files Browse the repository at this point in the history
…ings::DetailLevel. Refs #13894
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 628b285 commit be55aeb
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 189 deletions.
4 changes: 2 additions & 2 deletions src/guisim/GUIBusStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ GUIBusStop::drawGL(const GUIVisualizationSettings& s) const {
const double signRot = s2 ? myFGSignRot2 : myFGSignRot;
const Position& signPos = s2 ? myFGSignPos2 : myFGSignPos;
// draw details unless zoomed out to far
if (s.drawDetail(s.detailSettings.stoppingPlaceDetails, exaggeration)) {
if (s.drawDetail(10, exaggeration)) {
GLHelper::pushMatrix();
// draw the lines
const double rotSign = MSGlobals::gLefthand ? 1 : -1;
Expand Down Expand Up @@ -236,7 +236,7 @@ GUIBusStop::drawGL(const GUIVisualizationSettings& s) const {
glTranslated(0, 0, .1);
GLHelper::setColor(colorSign);
GLHelper::drawFilledCircle((double) 0.9, noPoints);
if (s.drawDetail(s.detailSettings.stoppingPlaceText, exaggeration)) {
if (s.drawDetail(10, exaggeration)) {
if (myElement == SUMO_TAG_CONTAINER_STOP) {
GLHelper::drawText("C", Position(), .1, 1.6, color, signRot);
} else if (myElement == SUMO_TAG_TRAIN_STOP) {
Expand Down
4 changes: 2 additions & 2 deletions src/guisim/GUIChargingStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ GUIChargingStation::drawGL(const GUIVisualizationSettings& s) const {
GLHelper::drawBoxLines(myFGShape, myFGShapeRotations, myFGShapeLengths, MIN2(1.0, exaggeration));

// draw details unless zoomed out to far
if (s.drawDetail(s.detailSettings.stoppingPlaceDetails, exaggeration)) {
if (s.drawDetail(10, exaggeration)) {

// push charging power matrix
GLHelper::pushMatrix();
Expand All @@ -176,7 +176,7 @@ GUIChargingStation::drawGL(const GUIVisualizationSettings& s) const {
GLHelper::setColor(s.colorSettings.chargingStationColorSign);
GLHelper::drawFilledCircle((double) 0.9, noPoints);

if (s.drawDetail(s.detailSettings.stoppingPlaceText, exaggeration)) {
if (s.drawDetail(10, exaggeration)) {
GLHelper::drawText("C", Position(), .1, 1.6, s.colorSettings.chargingStationColor, myFGSignRot);
}

Expand Down
2 changes: 1 addition & 1 deletion src/guisim/GUIParkingArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ GUIParkingArea::drawGL(const GUIVisualizationSettings& s) const {
glTranslated(0, 0, .1);
GLHelper::setColor(grey);
GLHelper::drawFilledCircle((double) 0.9, noPoints);
if (s.drawDetail(s.detailSettings.stoppingPlaceText, exaggeration)) {
if (s.drawDetail(10, exaggeration)) {
GLHelper::drawText("P", Position(), .1, 1.6, blue, mySignRot);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5361,7 +5361,7 @@ GNEViewNet::drawTemporalJunction() const {
GLHelper::setColor(bubbleColor);
// draw outline circle
const double circleWidth = myVisualizationSettings->neteditSizeSettings.junctionBubbleRadius * junctionExaggeration;
GLHelper::drawOutlineCircle(circleWidth, circleWidth * 0.75, myVisualizationSettings->getCircleResolution());
GLHelper::drawOutlineCircle(circleWidth, circleWidth * 0.75, 32);
// pop junction matrix
GLHelper::popMatrix();
// draw temporal edge
Expand Down Expand Up @@ -5433,9 +5433,9 @@ GNEViewNet::drawTemporalSplitJunction() const {
GLHelper::setColor(bubbleColor);
// draw outline circle
const double circleWidth = myVisualizationSettings->neteditSizeSettings.junctionBubbleRadius * junctionExaggeration;
GLHelper::drawOutlineCircle(circleWidth, circleWidth * 0.75, myVisualizationSettings->getCircleResolution());
GLHelper::drawOutlineCircle(circleWidth, circleWidth * 0.75, 32);
// draw filled circle
GLHelper::drawFilledCircle(0.5, myVisualizationSettings->getCircleResolution());
GLHelper::drawFilledCircle(0.5, 32);
// pop junction matrix
GLHelper::popMatrix();
// pop layer matrix
Expand All @@ -5462,7 +5462,7 @@ GNEViewNet::drawTemporalRoundabout() const {
GLHelper::setColor(RGBColor::GREEN);
// draw outline circle
const double circleWidth = (junction->getNBNode()->getRadius() < 0) ? 4.0 : junction->getNBNode()->getRadius();
GLHelper::drawOutlineCircle(circleWidth * 1.30, circleWidth, myVisualizationSettings->getCircleResolution());
GLHelper::drawOutlineCircle(circleWidth * 1.30, circleWidth, 32);
// pop junction matrix
GLHelper::popMatrix();
// pop layer matrix
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/GNEViewNetHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3933,7 +3933,7 @@ GNEViewNetHelper::LockIcon::checkDrawing(const GNEAttributeCarrier* AC, GUIGlObj
return false;
}
// check detail
if (!s.drawDetail(s.detailSettings.lockIcon, exaggeration)) {
if (!s.drawDetail(10, exaggeration)) {
return false;
}
// all ok, then draw
Expand Down
81 changes: 66 additions & 15 deletions src/utils/gui/div/GLHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,40 +495,91 @@ GLHelper::drawLine(const Position& beg, const Position& end) {


void
GLHelper::drawFilledCircle(double width, int steps) {
drawFilledCircle(width, steps, 0, 360);
GLHelper::drawFilledCircleDetailled(const GUIVisualizationSettings::DetailLevel d,const double radius,
double beg, double end) {
// get current resolution level
switch (d) {
case GUIVisualizationSettings::DetailLevel::Level0:
drawFilledCircle(radius, 32, beg, end);
break;
case GUIVisualizationSettings::DetailLevel::Level1:
drawFilledCircle(radius, 8, beg, end);
break;
case GUIVisualizationSettings::DetailLevel::Level2:
drawFilledCircleDetailled(d, radius);
break;
default:
// nothing to draw
break;
}
}


void
GLHelper::drawFilledCircleDetailled(const GUIVisualizationSettings::DetailLevel d, const double radius) {
// get current resolution level
switch (d) {
case GUIVisualizationSettings::DetailLevel::Level0:
drawFilledCircle(radius, 32);
break;
case GUIVisualizationSettings::DetailLevel::Level1:
drawFilledCircle(radius, 8);
break;
case GUIVisualizationSettings::DetailLevel::Level2:
// draw only a square
GLHelper::pushMatrix();
glBegin(GL_QUADS);
glVertex2d(-radius, 0);
glVertex2d(-radius, -radius);
glVertex2d(radius, -radius);
glVertex2d(radius, 0);
glEnd();
GLHelper::popMatrix();
#ifdef CHECK_ELEMENTCOUNTER
myVertexCounter += 4;
#endif
break;
default:
// nothing to draw
break;
}
}

void
GLHelper::drawFilledCircle(double const radius, int const steps) {
drawFilledCircle(radius, steps, 0, 360);
}


void
GLHelper::drawFilledCircle(double width, int steps, double beg, double end) {
GLHelper::drawFilledCircle(double radius, int steps, double beg, double end) {
const double inc = (end - beg) / (double)steps;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
std::pair<double, double> p1 = getCircleCoords().at(angleLookup(beg));

for (int i = 0; i <= steps; ++i) {
const std::pair<double, double>& p2 = getCircleCoords().at(angleLookup(beg + i * inc));
glBegin(GL_TRIANGLES);
glVertex2d(p1.first * width, p1.second * width);
glVertex2d(p2.first * width, p2.second * width);
glVertex2d(p1.first * radius, p1.second * radius);
glVertex2d(p2.first * radius, p2.second * radius);
glVertex2d(0, 0);
glEnd();
p1 = p2;
#ifdef CHECK_ELEMENTCOUNTER
myVertexCounter += 2;
myVertexCounter += 3;
#endif
}
}


void
GLHelper::drawOutlineCircle(double width, double iwidth, int steps) {
drawOutlineCircle(width, iwidth, steps, 0, 360);
GLHelper::drawOutlineCircle(double radius, double iRadius, int steps) {
drawOutlineCircle(radius, iRadius, steps, 0, 360);
}


void
GLHelper::drawOutlineCircle(double width, double iwidth, int steps,
GLHelper::drawOutlineCircle(double radius, double iRadius, int steps,
double beg, double end) {
const double inc = (end - beg) / (double)steps;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
Expand All @@ -537,13 +588,13 @@ GLHelper::drawOutlineCircle(double width, double iwidth, int steps,
for (int i = 0; i <= steps; ++i) {
const std::pair<double, double>& p2 = getCircleCoords().at(angleLookup(beg + i * inc));
glBegin(GL_TRIANGLES);
glVertex2d(p1.first * width, p1.second * width);
glVertex2d(p2.first * width, p2.second * width);
glVertex2d(p2.first * iwidth, p2.second * iwidth);
glVertex2d(p1.first * radius, p1.second * radius);
glVertex2d(p2.first * radius, p2.second * radius);
glVertex2d(p2.first * iRadius, p2.second * iRadius);

glVertex2d(p2.first * iwidth, p2.second * iwidth);
glVertex2d(p1.first * iwidth, p1.second * iwidth);
glVertex2d(p1.first * width, p1.second * width);
glVertex2d(p2.first * iRadius, p2.second * iRadius);
glVertex2d(p1.first * iRadius, p1.second * iRadius);
glVertex2d(p1.first * radius, p1.second * radius);

glEnd();
p1 = p2;
Expand Down
39 changes: 28 additions & 11 deletions src/utils/gui/div/GLHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,53 +248,70 @@ class GLHelper {
*/
static void drawLine(const Position& beg, const Position& end);

/** @brief Draws a filled circle around (0,0) depending of level of detail
*
* The circle is drawn by calling drawFilledCircle(width, steps, 0, 360).
*
* @param[in] radius The radius of the circle
*/
static void drawFilledCircleDetailled(const GUIVisualizationSettings::DetailLevel d, const double radius);

/** @brief Draws a filled circle around (0,0) depending of level of detail
*
* The circle is drawn by calling drawFilledCircle(width, steps, 0, 360).
* @param[in] beg The begin angle in degrees
* @param[in] end The end angle in degrees
*
* @param[in] radius The radius of the circle
*/
static void drawFilledCircleDetailled(const GUIVisualizationSettings::DetailLevel d, const double radius,
double beg, double end);

/** @brief Draws a filled circle around (0,0)
*
* The circle is drawn by calling drawFilledCircle(width, steps, 0, 360).
*
* @param[in] width The width of the circle
* @param[in] radius The radius of the circle
* @param[in] steps The number of steps to divide the circle into
*/
static void drawFilledCircle(double width, int steps = 8);

static void drawFilledCircle(const double widradiusth, const int steps = 8);

/** @brief Draws a filled circle around (0,0)
*
* The circle is drawn use GL_TRIANGLES.
*
* @param[in] width The width of the circle
* @param[in] radius The radius of the circle
* @param[in] steps The number of steps to divide the circle into
* @param[in] beg The begin angle in degrees
* @param[in] end The end angle in degrees
*/
static void drawFilledCircle(double width, int steps,
static void drawFilledCircle(double radius, int steps,
double beg, double end);


/** @brief Draws an unfilled circle around (0,0)
*
* The circle is drawn by calling drawOutlineCircle(width, iwidth, steps, 0, 360).
*
* @param[in] width The (outer) width of the circle
* @param[in] iwidth The inner width of the circle
* @param[in] radius The (outer) radius of the circle
* @param[in] iRadius The inner radius of the circle
* @param[in] steps The number of steps to divide the circle into
*/
static void drawOutlineCircle(double width, double iwidth,
static void drawOutlineCircle(double radius, double iRadius,
int steps = 8);


/** @brief Draws an unfilled circle around (0,0)
*
* The circle is drawn use GL_TRIANGLES.
*
* @param[in] width The (outer) width of the circle
* @param[in] iwidth The inner width of the circle
* @param[in] radius The (outer) radius of the circle
* @param[in] iRadius The inner radius of the circle
* @param[in] steps The number of steps to divide the circle into
* @param[in] beg The begin angle in degrees
* @param[in] end The end angle in degrees
*/
static void drawOutlineCircle(double width, double iwidth,
static void drawOutlineCircle(double radius, double iRadius,
int steps, double beg, double end);


Expand Down

0 comments on commit be55aeb

Please sign in to comment.