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

A few vrv utility improvements #3920

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/vrv/vrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ LogLevel StrToLogLevel(const std::string &level);
/**
* Utility for comparing doubles
*/
bool AreEqual(double dFirstVal, double dSecondVal);
bool AreNearlyEqual(double dFirstVal, double dSecondVal);
Copy link
Contributor

Choose a reason for hiding this comment

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

ApproximatelyEqual or AboutEqual might be better name for AreNearlyEqual (two words rather than three).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, sounds great.


/**
* Utility to check if the string is a valid integer for std::stoi
Expand Down
4 changes: 2 additions & 2 deletions src/bboxdevicecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void BBoxDeviceContext::EndResumedGraphic(Object *object, View *view)

void BBoxDeviceContext::RotateGraphic(Point const &orig, double angle)
{
assert(AreEqual(m_rotationAngle, 0.0));
assert(AreNearlyEqual(m_rotationAngle, 0.0));

m_rotationAngle = angle;
m_rotationOrigin = orig;
Expand Down Expand Up @@ -401,7 +401,7 @@ void BBoxDeviceContext::UpdateBB(int x1, int y1, int x2, int y2, char32_t glyph)
return;
}

if (!AreEqual(m_rotationAngle, 0.0)) {
if (!AreNearlyEqual(m_rotationAngle, 0.0)) {
Point p1 = BoundingBox::CalcPositionAfterRotation(Point(x1, y1), DegToRad(m_rotationAngle), m_rotationOrigin);
Point p2 = BoundingBox::CalcPositionAfterRotation(Point(x2, y2), DegToRad(m_rotationAngle), m_rotationOrigin);
x1 = p1.x;
Expand Down
2 changes: 1 addition & 1 deletion src/horizontalaligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ TimestampAttr *TimestampAligner::GetTimestampAtTime(double time)
assert(timestampAttr);

double alignmentTime = timestampAttr->GetActualDurPos();
if (AreEqual(alignmentTime, time)) {
if (AreNearlyEqual(alignmentTime, time)) {
return timestampAttr;
}
// nothing found, do not go any further but keep the index
Expand Down
2 changes: 1 addition & 1 deletion src/vrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ std::string StringFormatVariable(const char *format, va_list arg)
return str;
}

bool AreEqual(double dFirstVal, double dSecondVal)
bool AreNearlyEqual(double dFirstVal, double dSecondVal)
{
return std::fabs(dFirstVal - dSecondVal) < 1E-3;
}
Expand Down