-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix tooltips at high zooms #365
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 && |
There was a problem hiding this comment.
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 && |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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;
^
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. |
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.