From deae5b2de2e25d424196ef0cf2294bd149f100e2 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Fri, 4 Dec 2020 12:06:26 -0500 Subject: [PATCH] Keyframe: Replace pair vector w/ CoordinateVector --- src/KeyFrame.cpp | 6 +++--- src/KeyFrame.h | 6 ++++-- tests/KeyFrame_Tests.cpp | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/KeyFrame.cpp b/src/KeyFrame.cpp index 2cc1021e..eaafcb1f 100644 --- a/src/KeyFrame.cpp +++ b/src/KeyFrame.cpp @@ -129,9 +129,9 @@ Keyframe::Keyframe(double value) { Keyframe::Keyframe(const std::vector& points) : Points(points) {}; // Constructor which takes a vector of std::pair tuples (and adds them all) -Keyframe::Keyframe(const std::vector>& coordinates) { - for (const auto& pair : coordinates) { - AddPoint(Point(pair.first, pair.second)); +Keyframe::Keyframe(const std::vector& coordinates) { + for (const auto& co : coordinates) { + AddPoint(Point(co)); } } diff --git a/src/KeyFrame.h b/src/KeyFrame.h index 7245a5d1..82a21204 100644 --- a/src/KeyFrame.h +++ b/src/KeyFrame.h @@ -61,6 +61,8 @@ namespace openshot { std::vector Points; ///< Vector of all Points public: + using CoordinateVector = std::vector; + using PointsVector = std::vector; /// Default constructor for the Keyframe class Keyframe() = default; @@ -69,10 +71,10 @@ namespace openshot { Keyframe(double value); /// Constructor which adds a supplied vector of Points - Keyframe(const std::vector& points); + Keyframe(const PointsVector& points); /// Constructor which takes a vector of std::pair tuples - Keyframe(const std::vector>& coordinates); + Keyframe(const CoordinateVector& coordinates); /// Add a new point on the key-frame. Each point has a primary coordinate, a left handle, and a right handle. void AddPoint(Point p); diff --git a/tests/KeyFrame_Tests.cpp b/tests/KeyFrame_Tests.cpp index 0cb8be36..aaf2a38a 100644 --- a/tests/KeyFrame_Tests.cpp +++ b/tests/KeyFrame_Tests.cpp @@ -506,10 +506,10 @@ TEST(Point_Vector_Constructor) CHECK_CLOSE(30.0f, k1.GetValue(10), 0.0001); } -TEST(Pair_Vector_Constructor) +TEST(Coordinate_Vector_Constructor) { - std::vector> coordinates{ - {1, 100}, {10, 500}, {1000, 80000} + std::vector coordinates{ + Coordinate(1, 100), Coordinate(10, 500), Coordinate(1000, 80000) }; Keyframe k1(coordinates);