From eb4c2f51929f025fe38be68f7bc830b37adb3eea Mon Sep 17 00:00:00 2001 From: Richard Powell Date: Sat, 11 Jan 2025 12:33:29 -0800 Subject: [PATCH] Some tidying up of the calchart sheets. (#592) --- src/CalChartDoc.cpp | 4 +- src/CalChartDrawing.cpp | 2 +- src/core/CalChartAnimation.cpp | 2 +- src/core/CalChartPrintShowToPS.cpp | 6 +- src/core/CalChartSheet.cpp | 141 ++++++++++++------------- src/core/CalChartSheet.h | 69 ++++++------ src/core/CalChartShow.cpp | 28 ++--- src/core/e7_transition_solver.cpp | 17 ++- tests/CalChartContinuityTokenTests.cpp | 4 +- 9 files changed, 132 insertions(+), 141 deletions(-) diff --git a/src/CalChartDoc.cpp b/src/CalChartDoc.cpp index fdafffa9..309609eb 100644 --- a/src/CalChartDoc.cpp +++ b/src/CalChartDoc.cpp @@ -472,11 +472,11 @@ auto CalChartDoc::GeneratePhatomPointsDrawCommands( | std::views::transform([this, sheet](auto&& whichPosition) { auto [which, position] = whichPosition; // because points draw their position, we remove it then add the new position. - return sheet->GetPoint(which).GetDrawCommands( + return sheet->GetMarcher(which).GetDrawCommands( GetPointLabel(which), mConfig) + position - - sheet->GetPoint(which).GetPos(); + - sheet->GetMarcher(which).GetPos(); }) | std::views::join; return { diff --git a/src/CalChartDrawing.cpp b/src/CalChartDrawing.cpp index b79dc9c0..b06173dd 100644 --- a/src/CalChartDrawing.cpp +++ b/src/CalChartDrawing.cpp @@ -425,7 +425,7 @@ namespace { { // Print the field: // create a field for drawing: - const auto pts = sheet.GetPoints(); + const auto pts = sheet.GetAllMarchers(); auto boundingBox = GetMarcherBoundingBox(pts); auto mode = show.GetShowMode().CreateFieldForPrinting(CalChart::CoordUnits2Int(boundingBox.first.x), CalChart::CoordUnits2Int(boundingBox.second.x), landscape); auto drawCmds = CalChart::CreateModeDrawCommandsWithBorder(config, mode, CalChart::HowToDraw::Printing); diff --git a/src/core/CalChartAnimation.cpp b/src/core/CalChartAnimation.cpp index 46e25712..55c20a08 100644 --- a/src/core/CalChartAnimation.cpp +++ b/src/core/CalChartAnimation.cpp @@ -79,7 +79,7 @@ auto AnimateShow(const Show& show) -> Sheets return CalChart::Animate::CreateCompileResult( AnimationData{ static_cast(whichMarcher), - curr_sheet->GetPoint(whichMarcher), + curr_sheet->GetMarcher(whichMarcher), endPosition, numBeats, isLastSheet }, diff --git a/src/core/CalChartPrintShowToPS.cpp b/src/core/CalChartPrintShowToPS.cpp index 21659c74..e1a0a243 100644 --- a/src/core/CalChartPrintShowToPS.cpp +++ b/src/core/CalChartPrintShowToPS.cpp @@ -221,7 +221,7 @@ namespace { auto fmax = mode.FieldSize().x + fmin; /* find bounds */ - auto allX = sheet.GetAllPoints() + auto allX = sheet.GetAllMarchers() | std::views::transform([](auto&& point) { return point.GetPos().x; }); auto [max_s, max_n] = std::accumulate(allX.begin(), allX.end(), std::pair{ fmax, fmin }, [](auto acc, auto x) { return std::pair{ std::min(x, std::get<0>(acc)), std::max(x, std::get<1>(acc)) }; @@ -614,7 +614,7 @@ auto PrintShowToPS::GenerateStandard(Sheet const& sheet, bool split_sheet) const + std::format("/slinew {:.4f} def\n", dot_w * mSLineRatio) + std::format("/numberfont findfont {:.2f} scalefont setfont\n", dot_w * 2 * mNumRatio); - auto pointsOfInterest = CalChart::Ranges::enumerate_view(sheet.GetAllPoints()) + auto pointsOfInterest = CalChart::Ranges::enumerate_view(sheet.GetAllMarchers()) | std::views::filter([clip_s = clip_s, clip_n = clip_n](auto&& enumPoint) { return std::get<1>(enumPoint).GetPos().x >= clip_s && std::get<1>(enumPoint).GetPos().x <= clip_n; }); @@ -651,7 +651,7 @@ auto PrintShowToPS::GenerateOverview(Sheet const& sheet) const -> std::string auto fieldheight = CoordUnits2Float(fieldsize.y); - auto allBoxes = sheet.GetAllPoints() + auto allBoxes = sheet.GetAllMarchers() | std::views::transform([](auto&& point) { return point.GetPos(); }) | std::views::transform([this, fieldoff, fieldwidth, fieldheight](auto&& position) { return std::format("{:.2f} {:.2f} dotbox\n", diff --git a/src/core/CalChartSheet.cpp b/src/core/CalChartSheet.cpp index bcbfd982..82535bf7 100644 --- a/src/core/CalChartSheet.cpp +++ b/src/core/CalChartSheet.cpp @@ -36,11 +36,11 @@ namespace CalChart { -std::string const contnames[MAX_NUM_SYMBOLS] = { +std::array const contnames = { "Plain", "Sol", "Bksl", "Sl", "X", "Solbksl", "Solsl", "Solx" }; -std::string const long_contnames[MAX_NUM_SYMBOLS] = { +std::array const long_contnames = { "Plain", "Solid", "Backslash", "Slash", "Crossed", "Solid Backslash", "Solid Slash", "Solid Crossed" }; @@ -51,36 +51,35 @@ Sheet::Sheet(size_t numPoints) { } -Sheet::Sheet(size_t numPoints, std::string const& newname) +Sheet::Sheet(size_t numPoints, std::string name) : mAnimationContinuity(MAX_NUM_SYMBOLS) , mBeats(1) , mPoints(numPoints) - , mName(newname) + , mName(std::move(name)) { } -// -=-=-=-=-=- LEGACY CODE -=-=-=-=-=- -// Recommend that you don't touch this unless you know what you are doing. -bool are_equal_helper(std::string const& a, std::string const& b) -{ - auto p = std::mismatch(a.begin(), a.end(), b.begin(), [](char c1, char c2) { - return std::tolower(c1) == std::tolower(c2); - }); - return (p.first == a.end() && p.second == b.end()); -} +namespace { + auto are_equal_helper(std::string const& a, std::string const& b) -> bool + { + auto p = std::mismatch(a.begin(), a.end(), b.begin(), [](char c1, char c2) { + return std::tolower(c1) == std::tolower(c2); + }); + return (p.first == a.end() && p.second == b.end()); + } + + auto are_equal(std::string const& a, std::string const& b) -> bool + { + return a.size() <= b.size() ? are_equal_helper(a, b) : are_equal_helper(b, a); + } -bool are_equal(std::string const& a, std::string const& b) -{ - return a.size() <= b.size() ? are_equal_helper(a, b) : are_equal_helper(b, a); } -SYMBOL_TYPE GetSymbolForName(std::string const& name) +auto GetSymbolForName(std::string const& name) -> SYMBOL_TYPE { - for (auto i = contnames; - i != (contnames + sizeof(contnames) / sizeof(contnames[0])); ++i) { - - if (are_equal(name, *i)) { - return static_cast(std::distance(contnames, i)); + for (auto [index, symbolName] : CalChart::Ranges::enumerate_view(contnames)) { + if (are_equal(name, symbolName)) { + return static_cast(index); } } // what do we do here? give larger one for now... @@ -88,7 +87,7 @@ SYMBOL_TYPE GetSymbolForName(std::string const& name) return MAX_NUM_SYMBOLS; } -std::string GetNameForSymbol(SYMBOL_TYPE which) +auto GetNameForSymbol(SYMBOL_TYPE which) -> std::string { if (which > MAX_NUM_SYMBOLS) { return ""; @@ -96,7 +95,7 @@ std::string GetNameForSymbol(SYMBOL_TYPE which) return contnames[which]; } -std::string GetLongNameForSymbol(SYMBOL_TYPE which) +auto GetLongNameForSymbol(SYMBOL_TYPE which) -> std::string { if (which > MAX_NUM_SYMBOLS) { return ""; @@ -104,43 +103,47 @@ std::string GetLongNameForSymbol(SYMBOL_TYPE which) return long_contnames[which]; } -static void -CheckInconsistancy(SYMBOL_TYPE symbol, uint8_t cont_index, - std::map& continity_for_symbol, - std::map& symbol_for_continuity, - std::string const& sheet_name, uint32_t pointNum) -{ - // need to check for symbol inconsistency here. - if (continity_for_symbol.count(symbol) == 0) { - // we haven't seen this symbol->cont_index yet - continity_for_symbol[symbol] = cont_index; - } else { - if (continity_for_symbol[symbol] != cont_index) { - std::stringstream buf; - buf << "Error, symbol inconsistency on sheet \"" << sheet_name << "\".\n"; - buf << "Symbol " << GetNameForSymbol(symbol) - << " previously used continuity " - << (uint32_t)continity_for_symbol[symbol] << " but point " << pointNum - << " on uses continuity " << (uint32_t)cont_index - << ", which is used by symbol " - << GetNameForSymbol(symbol_for_continuity[cont_index]) << ".\n"; - buf << "Try opening this file on CalChart v3.3.5 or earlier.\n"; - throw CC_FileException(buf.str()); - } - } - if (symbol_for_continuity.count(cont_index) == 0) { - symbol_for_continuity[cont_index] = symbol; - } else { - if (symbol_for_continuity[cont_index] != symbol) { - std::stringstream buf; - buf << "Error, symbol inconsistency on sheet \"" << sheet_name << "\".\n"; - buf << "Continuity index " << (uint32_t)cont_index - << " previously used symbol " - << GetNameForSymbol(symbol_for_continuity[cont_index]) - << " but point " << pointNum << " on uses symbol " - << GetNameForSymbol(symbol) << ".\n"; - buf << "Try opening this file on CalChart v3.3.5 or earlier.\n"; - throw CC_FileException(buf.str()); +// -=-=-=-=-=- LEGACY CODE -=-=-=-=-=- +// Recommend that you don't touch this unless you know what you are doing. +namespace { + void + CheckInconsistancy(SYMBOL_TYPE symbol, uint8_t cont_index, + std::map& continity_for_symbol, + std::map& symbol_for_continuity, + std::string const& sheet_name, uint32_t pointNum) + { + // need to check for symbol inconsistency here. + if (continity_for_symbol.count(symbol) == 0) { + // we haven't seen this symbol->cont_index yet + continity_for_symbol[symbol] = cont_index; + } else { + if (continity_for_symbol[symbol] != cont_index) { + std::stringstream buf; + buf << "Error, symbol inconsistency on sheet \"" << sheet_name << "\".\n"; + buf << "Symbol " << GetNameForSymbol(symbol) + << " previously used continuity " + << (uint32_t)continity_for_symbol[symbol] << " but point " << pointNum + << " on uses continuity " << (uint32_t)cont_index + << ", which is used by symbol " + << GetNameForSymbol(symbol_for_continuity[cont_index]) << ".\n"; + buf << "Try opening this file on CalChart v3.3.5 or earlier.\n"; + throw CC_FileException(buf.str()); + } + } + if (symbol_for_continuity.count(cont_index) == 0) { + symbol_for_continuity[cont_index] = symbol; + } else { + if (symbol_for_continuity[cont_index] != symbol) { + std::stringstream buf; + buf << "Error, symbol inconsistency on sheet \"" << sheet_name << "\".\n"; + buf << "Continuity index " << (uint32_t)cont_index + << " previously used symbol " + << GetNameForSymbol(symbol_for_continuity[cont_index]) + << " but point " << pointNum << " on uses symbol " + << GetNameForSymbol(symbol) << ".\n"; + buf << "Try opening this file on CalChart v3.3.5 or earlier.\n"; + throw CC_FileException(buf.str()); + } } } } @@ -507,8 +510,6 @@ auto Sheet::SerializeSheet() const -> std::vector return result; } -Sheet::~Sheet() = default; - // Find point at certain coords auto Sheet::FindMarcher(Coord where, Coord::units searchBound, unsigned ref) const -> std::optional { @@ -602,10 +603,6 @@ std::string Sheet::GetRawPrintContinuity() const return mPrintableContinuity.GetOriginalLine(); } -unsigned short Sheet::GetBeats() const { return mBeats; } - -void Sheet::SetBeats(unsigned short b) { mBeats = b; } - // Get position of point Coord Sheet::GetPosition(unsigned i, unsigned ref) const { @@ -646,19 +643,13 @@ Textline_list Sheet::GetPrintableContinuity() const return mPrintableContinuity.GetChunks(); } -Point const& Sheet::GetPoint(unsigned i) const { return mPoints[i]; } - -Point& Sheet::GetPoint(unsigned i) { return mPoints[i]; } - -SYMBOL_TYPE Sheet::GetSymbol(unsigned i) const { return mPoints[i].GetSymbol(); } +auto Sheet::GetMarcher(unsigned i) const -> Point { return mPoints[i]; } void Sheet::SetSymbol(unsigned i, SYMBOL_TYPE sym) { mPoints[i].SetSymbol(sym); } -std::vector Sheet::GetPoints() const { return mPoints; } - std::vector Sheet::GetSymbols() const { std::vector result; @@ -817,7 +808,7 @@ namespace { // we want sheets to print in landscape when the width exceeds the height auto Sheet::ShouldPrintLandscape() const -> bool { - auto boundingBox = GetMarcherBoundingBox(GetPoints()); + auto boundingBox = GetMarcherBoundingBox(GetAllMarchers()); return (boundingBox.second.x - boundingBox.first.x) > CalChart::Int2CoordUnits(CalChart::kFieldStepSizeNorthSouth[0]); } diff --git a/src/core/CalChartSheet.h b/src/core/CalChartSheet.h index 5be01696..d609a0a0 100644 --- a/src/core/CalChartSheet.h +++ b/src/core/CalChartSheet.h @@ -28,16 +28,20 @@ * */ -#include "CalChartAnimation.h" +#include "CalChartConstants.h" #include "CalChartContinuity.h" +#include "CalChartCoord.h" #include "CalChartFileFormat.h" #include "CalChartImage.h" #include "CalChartPoint.h" #include "CalChartText.h" #include "CalChartTypes.h" +#include +#include #include -#include +#include +#include #include #include @@ -50,22 +54,21 @@ struct ParseErrorHandlers; // error occurred on parsing. First arg is what went wrong, second is the values that need to be fixed. class Sheet { public: - Sheet(size_t numPoints); - Sheet(size_t numPoints, std::string const& newname); + explicit Sheet(size_t numPoints); + Sheet(size_t numPoints, std::string name); // intentionally a reference to Reader. Sheet(Version_3_3_and_earlier, size_t numPoints, Reader&, ParseErrorHandlers const* correction = nullptr); Sheet(size_t numPoints, Reader, ParseErrorHandlers const* correction = nullptr); - ~Sheet(); private: - auto SerializeAllPoints() const -> std::vector; - auto SerializeContinuityData() const -> std::vector; - auto SerializePrintContinuityData() const -> std::vector; - auto SerializeBackgroundImageInfo() const -> std::vector; - auto SerializeSheetData() const -> std::vector; + [[nodiscard]] auto SerializeAllPoints() const -> std::vector; + [[nodiscard]] auto SerializeContinuityData() const -> std::vector; + [[nodiscard]] auto SerializePrintContinuityData() const -> std::vector; + [[nodiscard]] auto SerializeBackgroundImageInfo() const -> std::vector; + [[nodiscard]] auto SerializeSheetData() const -> std::vector; public: - auto SerializeSheet() const -> std::vector; + [[nodiscard]] auto SerializeSheet() const -> std::vector; // continuity Functions [[nodiscard]] auto GetContinuityBySymbol(SYMBOL_TYPE i) const @@ -85,44 +88,42 @@ class Sheet { // print continuity void SetPrintableContinuity(std::string const& name, std::string const& lines); - Textline_list GetPrintableContinuity() const; - std::string GetPrintNumber() const; - std::string GetRawPrintContinuity() const; - auto GetPrintContinuity() const { return mPrintableContinuity; } + [[nodiscard]] auto GetPrintableContinuity() const -> Textline_list; + [[nodiscard]] auto GetPrintNumber() const -> std::string; + [[nodiscard]] auto GetRawPrintContinuity() const -> std::string; + [[nodiscard]] auto GetPrintContinuity() const { return mPrintableContinuity; } // beats - unsigned short GetBeats() const; - void SetBeats(unsigned short b); - bool IsInAnimation() const { return (GetBeats() != 0); } + [[nodiscard]] auto GetBeats() const { return mBeats; } + void SetBeats(beats_t b) { mBeats = b; } + [[nodiscard]] auto IsInAnimation() const { return (GetBeats() != 0); } - // points - Point const& GetPoint(unsigned i) const; - Point& GetPoint(unsigned i); + // Marchers + [[nodiscard]] auto GetMarcher(unsigned i) const -> Point; + [[nodiscard]] auto GetAllMarchers() const { return mPoints; } - auto GetAllPoints() const { return mPoints; } + [[nodiscard]] auto GetSymbol(unsigned i) const { return mPoints[i].GetSymbol(); } - SYMBOL_TYPE GetSymbol(unsigned i) const; void SetSymbol(unsigned i, SYMBOL_TYPE sym); - std::vector GetPoints() const; - auto GetNumberPoints() const { return mPoints.size(); } - std::vector GetSymbols() const; + [[nodiscard]] auto GetNumberPoints() const { return mPoints.size(); } + [[nodiscard]] auto GetSymbols() const -> std::vector; void SetPoints(std::vector const& points); [[nodiscard]] auto FindMarcher(Coord where, Coord::units searchBound, unsigned ref = 0) const -> std::optional; - std::vector RemapPoints(std::vector const& table) const; - Coord GetPosition(unsigned i, unsigned ref = 0) const; + [[nodiscard]] auto RemapPoints(std::vector const& table) const -> std::vector; + [[nodiscard]] auto GetPosition(unsigned i, unsigned ref = 0) const -> Coord; void SetAllPositions(Coord val, unsigned i); void SetPosition(Coord val, unsigned i, unsigned ref = 0); void SetAllPoints(std::vector const& newpts); - SelectionList MakeSelectPointsBySymbol(SYMBOL_TYPE i) const; - std::vector NewNumPointsPositions(int num, int columns, Coord new_march_position) const; + [[nodiscard]] auto MakeSelectPointsBySymbol(SYMBOL_TYPE i) const -> SelectionList; + [[nodiscard]] auto NewNumPointsPositions(int num, int columns, Coord new_march_position) const -> std::vector; void DeletePoints(SelectionList const& sl); // titles - std::string GetName() const; + [[nodiscard]] auto GetName() const -> std::string; void SetName(std::string const& newname); // image - std::vector const& GetBackgroundImages() const; + [[nodiscard]] auto GetBackgroundImages() const -> std::vector const&; void AddBackgroundImage(ImageInfo const& image, size_t where); void RemoveBackgroundImage(size_t which); void MoveBackgroundImage(size_t which, int left, int top, int scaled_width, int scaled_height); @@ -140,12 +141,12 @@ class Sheet { * @return A JSON which could represent this sheet in * a '.viewer' file. */ - nlohmann::json toOnlineViewerJSON(unsigned sheetNum, std::vector dotLabels, std::map> const& movements) const; + [[nodiscard]] auto toOnlineViewerJSON(unsigned sheetNum, std::vector dotLabels, std::map> const& movements) const -> nlohmann::json; private: std::vector mAnimationContinuity; PrintContinuity mPrintableContinuity; - unsigned short mBeats; + beats_t mBeats; std::vector mPoints; std::string mName; std::vector mBackgroundImages; diff --git a/src/core/CalChartShow.cpp b/src/core/CalChartShow.cpp index e97e63fe..cfaab327 100644 --- a/src/core/CalChartShow.cpp +++ b/src/core/CalChartShow.cpp @@ -357,7 +357,7 @@ namespace { auto TransformIndexToDrawCommands(CalChart::Sheet const& sheet, std::vector const& labels, int ref, CalChart::Configuration const& config) { return std::views::transform([&sheet, ref, labels, &config](int i) { - return sheet.GetPoint(i).GetDrawCommands(ref, labels.at(i), config); + return sheet.GetMarcher(i).GetDrawCommands(ref, labels.at(i), config); }) | std::ranges::views::join; } @@ -447,7 +447,7 @@ auto Show::GenerateFieldWithMarchersDrawCommands(CalChart::Configuration const& field, CalChart::Draw::withBrushAndPen( config.Get_CalChartBrushAndPen(CalChart::Colors::POINT_ANIM_FRONT), - GeneratePointDrawCommand(sheet.GetPoints())), + GeneratePointDrawCommand(sheet.GetAllMarchers())), } + mMode.Offset(); })); @@ -721,7 +721,7 @@ namespace { requires(std::is_convertible_v, CalChart::Sheet>) auto GetAllPointPositions(Range&& sheets) { - return sheets | std::views::transform([](auto&& sheet) { return sheet.GetPoints(); }); + return sheets | std::views::transform([](auto&& sheet) { return sheet.GetAllMarchers(); }); } } @@ -788,7 +788,7 @@ Show_command_pair Show::Create_SetupMarchersCommand(std::vector> old_points; for (auto&& sheet : mSheets) { - old_points.emplace_back(sheet.GetPoints()); + old_points.emplace_back(sheet.GetAllMarchers()); } auto reaction = [old_labels, old_points](Show& show) { for (auto i = 0ul; i < show.mSheets.size(); ++i) { @@ -849,7 +849,7 @@ Show_command_pair Show::Create_ApplyRelabelMapping(int sheet_num_first, std::vec { std::vector> current_pos; for (auto s = GetNthSheet(sheet_num_first); s != GetSheetEnd(); ++s) { - current_pos.emplace_back(s->GetPoints()); + current_pos.emplace_back(s->GetAllMarchers()); } // first gather where all the points are; auto action = [sheet_num_first, mapping](Show& show) { @@ -926,7 +926,7 @@ Show_command_pair Show::Create_DeletePointsCommand() const auto old_labels = mDotLabelAndInstrument; std::vector> old_points; for (auto&& sheet : mSheets) { - old_points.emplace_back(sheet.GetPoints()); + old_points.emplace_back(sheet.GetAllMarchers()); } auto reaction = [old_labels, old_points](Show& show) { for (auto i = 0ul; i < show.mSheets.size(); ++i) { @@ -1022,18 +1022,18 @@ Show_command_pair Show::Create_SetLabelFlipCommand(std::map const& ne auto sheet = GetCurrentSheet(); std::map original_flip; for (auto&& index : new_flip) { - original_flip[index.first] = sheet->GetPoint(index.first).GetFlip(); + original_flip[index.first] = sheet->GetMarcher(index.first).GetFlip(); } auto action = [sheet_num = mSheetNum, new_flip](Show& show) { auto sheet = show.GetNthSheet(sheet_num); for (auto&& i : new_flip) { - sheet->GetPoint(i.first).Flip(i.second); + sheet->GetMarcher(i.first).Flip(i.second); } }; auto reaction = [sheet_num = mSheetNum, original_flip](Show& show) { auto sheet = show.GetNthSheet(sheet_num); for (auto&& i : original_flip) { - sheet->GetPoint(i.first).Flip(i.second); + sheet->GetMarcher(i.first).Flip(i.second); } }; return { action, reaction }; @@ -1053,7 +1053,7 @@ Show_command_pair Show::Create_ToggleLabelFlipCommand() const std::map flips; auto sheet = GetCurrentSheet(); for (auto&& i : mSelectionList) { - flips[i] = !sheet->GetPoint(i).GetFlip(); + flips[i] = !sheet->GetMarcher(i).GetFlip(); } return Create_SetLabelFlipCommand(flips); } @@ -1063,18 +1063,18 @@ Show_command_pair Show::Create_SetLabelVisiblityCommand(std::map cons auto sheet = GetCurrentSheet(); std::map original_visibility; for (auto&& index : new_visibility) { - original_visibility[index.first] = sheet->GetPoint(index.first).LabelIsVisible(); + original_visibility[index.first] = sheet->GetMarcher(index.first).LabelIsVisible(); } auto action = [sheet_num = mSheetNum, new_visibility](Show& show) { auto sheet = show.GetNthSheet(sheet_num); for (auto&& i : new_visibility) { - sheet->GetPoint(i.first).SetLabelVisibility(i.second); + sheet->GetMarcher(i.first).SetLabelVisibility(i.second); } }; auto reaction = [sheet_num = mSheetNum, original_visibility](Show& show) { auto sheet = show.GetNthSheet(sheet_num); for (auto&& i : original_visibility) { - sheet->GetPoint(i.first).SetLabelVisibility(i.second); + sheet->GetMarcher(i.first).SetLabelVisibility(i.second); } }; return { action, reaction }; @@ -1094,7 +1094,7 @@ Show_command_pair Show::Create_ToggleLabelVisibilityCommand() const std::map visible; auto sheet = GetCurrentSheet(); for (auto&& i : mSelectionList) { - visible[i] = !sheet->GetPoint(i).LabelIsVisible(); + visible[i] = !sheet->GetMarcher(i).LabelIsVisible(); } return Create_SetLabelVisiblityCommand(visible); } diff --git a/src/core/e7_transition_solver.cpp b/src/core/e7_transition_solver.cpp index abeeca68..4504810e 100644 --- a/src/core/e7_transition_solver.cpp +++ b/src/core/e7_transition_solver.cpp @@ -521,7 +521,7 @@ class CollisionSpace { /*! * @brief Clips the movement schedule for a marcher, such no movement * occurs on or after the specified beat. - * @param movement The original movement schedule for a marcher. This + * @param movement The original movement schedule for a marcher. This * is the schedule that will be clipped. * @param beat The beat to which the schedule shall be clipped. * @return The adjusted movement schedule, with no movement phase persisting @@ -582,7 +582,7 @@ class CollisionSpace { */ const std::set& getMarchersAt(unsigned gridX, unsigned gridY, unsigned beat) const; /*! - * @brief Returns the indices of all marchers present at a particular + * @brief Returns the indices of all marchers present at a particular * location at a particular * time. * @param gridX The x coordinate of the position containing the returned @@ -641,7 +641,7 @@ class CollisionSpace { * marcher at a particular time. * @param marcher The index of the marcher being placed in the collision space * at a particular moment. - * @param gridX The x coordinate at which the marcher is being placed, where the + * @param gridX The x coordinate at which the marcher is being placed, where the * coordinate system matches the coordinate system understood by SolverCoords. * @param gridY The y coordinate at which the marcher is being placed, where the * coordinate system matches the coordinate system understood by SolverCoords. @@ -1059,9 +1059,8 @@ std::set CollisionSpace::getMarchersWithMovePattern(unsigned startBeat */ void convertPositionsOnSheetToSolverSpace(const CalChart::Sheet& sheet, std::vector& positions) { - auto points = sheet.GetPoints(); - for (size_t i = 0; i < points.size(); i++) { - positions.push_back(SolverCoord::fromShowSpace(points[i].GetPos())); + for (auto&& point : sheet.GetAllMarchers()) { + positions.push_back(SolverCoord::fromShowSpace(point.GetPos())); } } @@ -1095,7 +1094,7 @@ Matrix makeHungarianDistanceMatrix(const std::vector& start auto diff = startPositions.at(j) - endPositions.at(i); unsigned manhattanDist = abs(diff.x) + abs(diff.y); if (manhattanDist > numBeats) { - matrix(j, i) = std::numeric_limits::max(); //std::numeric_limits::infinity(); + matrix(j, i) = std::numeric_limits::max(); // std::numeric_limits::infinity(); } else { matrix(j, i) = manhattanDist + 1; } @@ -2134,11 +2133,11 @@ std::vector validateSheetForTransitionSolver(const CalChart::Sheet& std::vector errors; // Verify that all points are in the grid, and that all of them can be converted to and from solver space - for (unsigned i = 0; i < sheet.GetPoints().size(); i++) { + for (unsigned i = 0; i < sheet.GetAllMarchers().size(); i++) { CalChart::Coord showPosition; SolverCoord solverPosition; - showPosition = sheet.GetPoint(i).GetPos(); + showPosition = sheet.GetMarcher(i).GetPos(); solverPosition = SolverCoord::fromShowSpace(showPosition); if (solverPosition.x % 2 != 0 || solverPosition.y % 2 != 0) { diff --git a/tests/CalChartContinuityTokenTests.cpp b/tests/CalChartContinuityTokenTests.cpp index 3ebd5476..67fc2e63 100644 --- a/tests/CalChartContinuityTokenTests.cpp +++ b/tests/CalChartContinuityTokenTests.cpp @@ -34,8 +34,8 @@ auto GetCompiledResults(Sheets const& sheets, Conts const& proc) Animate::Variables vars{}; auto animationData = Animate::AnimationData{ 0, - sheets.begin()->GetPoint(0), - (sheets.begin() + 1)->GetPoint(0).GetPos(), + sheets.begin()->GetMarcher(0), + (sheets.begin() + 1)->GetMarcher(0).GetPos(), sheets.begin()->GetBeats(), true };