Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tooltips at high zooms #365

Merged
merged 3 commits into from
Feb 14, 2025

Conversation

AdenKoperczak
Copy link
Contributor

Check if all points given to scwx::qt::util::maplibre::IsPointInPolygon are the same, and if they are, fall back to a point check, rather than a polygon check. I can think of a few other ways to fix this, but this may be the simplest. The tooltips do not fully align with the icon when zoomed in, but I think that is way better than having the tooltip always pop up.

The clang-tidy warning is all over this section of code. I think it should either be disabled, or NOLINT'ed.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@@ -55,6 +56,8 @@ bool IsPointInPolygon(const std::vector<glm::vec2>& vertices,
const auto& p2 =
(i == vertices.size() - 1) ? vertices[0] : vertices[i + 1];

allSame = allSame && p1.x == p2.x && p1.y == p2.y;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

      allSame = allSame && p1.x == p2.x && p1.y == p2.y;
                                                      ^

@@ -55,6 +56,8 @@
const auto& p2 =
(i == vertices.size() - 1) ? vertices[0] : vertices[i + 1];

allSame = allSame && p1.x == p2.x && p1.y == p2.y;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

      allSame = allSame && p1.x == p2.x && p1.y == p2.y;
                                              ^

@@ -55,6 +56,8 @@
const auto& p2 =
(i == vertices.size() - 1) ? vertices[0] : vertices[i + 1];

allSame = allSame && p1.x == p2.x && p1.y == p2.y;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

      allSame = allSame && p1.x == p2.x && p1.y == p2.y;
                                      ^

@@ -55,6 +56,8 @@
const auto& p2 =
(i == vertices.size() - 1) ? vertices[0] : vertices[i + 1];

allSame = allSame && p1.x == p2.x && p1.y == p2.y;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

      allSame = allSame && p1.x == p2.x && p1.y == p2.y;
                              ^

@@ -70,6 +73,12 @@
}
}

if (allSame)
{
inPolygon = vertices.size() > 0 && vertices[0].x == point.x &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

      inPolygon = vertices.size() > 0 && vertices[0].x == point.x &&
                                                                ^

@@ -70,6 +73,12 @@
}
}

if (allSame)
{
inPolygon = vertices.size() > 0 && vertices[0].x == point.x &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

      inPolygon = vertices.size() > 0 && vertices[0].x == point.x &&
                                                     ^

if (allSame)
{
inPolygon = vertices.size() > 0 && vertices[0].x == point.x &&
vertices[0].y == point.y;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

                  vertices[0].y == point.y;
                                         ^

if (allSame)
{
inPolygon = vertices.size() > 0 && vertices[0].x == point.x &&
vertices[0].y == point.y;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

                  vertices[0].y == point.y;
                              ^

@dpaulat
Copy link
Owner

dpaulat commented Feb 14, 2025

The code change looks good to me. I recommend a NOLINT block around the function to suppress the clang-tidy findings. The use of unions here does not violate type safety as clang-tidy suggests.

@dpaulat dpaulat merged commit efb54b1 into dpaulat:develop Feb 14, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants