From 5338bc53e3af09a5872972a82b538b79d1e3f0c3 Mon Sep 17 00:00:00 2001 From: Dmitry Krivoruchko <144147209+UmbrellaLeaf5@users.noreply.github.com> Date: Sun, 14 Apr 2024 19:31:03 +0300 Subject: [PATCH] THE RETURN OF REMOVE # this commit sounds like film name, doesn't it?) # this method unused in PlotArea but needed in DataManager --- data_tools/data_manager/data_manager.cpp | 24 ++++++++++++++++++++++++ data_tools/data_manager/data_manager.h | 7 +++++++ 2 files changed, 31 insertions(+) diff --git a/data_tools/data_manager/data_manager.cpp b/data_tools/data_manager/data_manager.cpp index 8aeaa42..fe5e832 100644 --- a/data_tools/data_manager/data_manager.cpp +++ b/data_tools/data_manager/data_manager.cpp @@ -4,6 +4,30 @@ namespace data_tools { +void DataManager::Remove(gui::ObjectType obj_type, size_t index) { + switch (obj_type) { + case gui::ObjectType::Targets: { + targets_.erase(targets_.begin() + index); + break; + } + + case gui::ObjectType::Hills: { + hills_.erase(hills_.begin() + index); + break; + } + + case gui::ObjectType::TrappyCircles: { + tr_circles_.erase(tr_circles_.begin() + index); + break; + } + + case gui::ObjectType::TrappyLines: { + tr_lines_.erase(tr_lines_.begin() + index); + break; + } + } +} + void DataManager::Clear() { targets_.clear(); tr_circles_.clear(); diff --git a/data_tools/data_manager/data_manager.h b/data_tools/data_manager/data_manager.h index b8aaf72..5e8db18 100644 --- a/data_tools/data_manager/data_manager.h +++ b/data_tools/data_manager/data_manager.h @@ -12,6 +12,13 @@ class DataManager { public: DataManager() = default; + /** + * @brief удаляет объект из менеджера по индексу + * @param obj_type: тип объекта + * @param index: индекс объекта в его векторе + */ + void Remove(gui::ObjectType obj_type, size_t index); + /// @brief очищает все вектора объектов void Clear();