Loading [MathJax]/extensions/tex2jax.js
MeshKernel
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages Concepts
CurvilinearFrozenLinesDeleteUndoAction.hpp
1//---- GPL ---------------------------------------------------------------------
2//
3// Copyright (C) Stichting Deltares, 2011-2024.
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation version 3.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//
17// contact: delft3d.support@deltares.nl
18// Stichting Deltares
19// P.O. Box 177
20// 2600 MH Delft, The Netherlands
21//
22// All indications and logos of, and references to, "Delft3D" and "Deltares"
23// are registered trademarks of Stichting Deltares, and remain the property of
24// Stichting Deltares. All rights reserved.
25//
26//------------------------------------------------------------------------------
27
28#pragma once
29
30#include "MeshKernel/UndoActions/UndoAction.hpp"
31#include "MeshKernelApi/State.hpp"
32
33namespace meshkernelapi
34{
35
37 class CurvilinearFrozenLinesDeleteUndoAction : public meshkernel::UndoAction
38 {
39 public:
44 int frozenLineId,
45 const std::pair<meshkernel::Point, meshkernel::Point>& frozenLinePoints) : m_mkStateReference(mkState),
46 m_frozenLinesCounter(frozenLineId),
47 m_frozenLinePoints(frozenLinePoints)
48 {
49 }
50
51 private:
53 void DoCommit() override
54 {
55 if (!m_mkStateReference.m_frozenLines.contains(m_frozenLinesCounter))
56 {
57 throw meshkernel::MeshKernelError("Frozen line counter in meshkernel state should exist when committing a deletion of a frozen line");
58 }
59
60 m_mkStateReference.m_frozenLines.erase(m_frozenLinesCounter);
61 }
62
64 void DoRestore() override
65 {
66 if (m_mkStateReference.m_frozenLines.contains(m_frozenLinesCounter))
67 {
68 throw meshkernel::MeshKernelError("Frozen line counter in meshkernel state should not exist when restoring a deletion frozen line");
69 }
70 m_mkStateReference.m_frozenLines[m_frozenLinesCounter] = m_frozenLinePoints;
71 }
72
74 MeshKernelState& m_mkStateReference;
75
77 int m_frozenLinesCounter;
78
80 std::pair<meshkernel::Point, meshkernel::Point> m_frozenLinePoints;
81 };
82
83} // namespace meshkernelapi
A class for throwing general MeshKernel exceptions.
Definition Exceptions.hpp:142
Undo action for deleting a frozen lines.
Definition CurvilinearFrozenLinesDeleteUndoAction.hpp:38
CurvilinearFrozenLinesDeleteUndoAction(MeshKernelState &mkState, int frozenLineId, const std::pair< meshkernel::Point, meshkernel::Point > &frozenLinePoints)
Constructor.
Definition CurvilinearFrozenLinesDeleteUndoAction.hpp:43
Contains all structs and functions exposed at the API level.
Definition BoundingBox.hpp:33
The class holding the state of the C API library.
Definition State.hpp:58
std::unordered_map< meshkernel::UInt, std::pair< meshkernel::Point, meshkernel::Point > > m_frozenLines
Map for string the frozen lines.
Definition State.hpp:87