# -*- coding: utf-8 -*-

import logging

from copy import deepcopy
from tools import trace, timer

from PyQt5.QtWidgets import (
    QMessageBox, QUndoCommand, QUndoStack,
)

from Model.Geometry.Reach import Reach
from Model.Geometry.Profile import Profile
from Model.SedimentLayer.SedimentLayer import SedimentLayer
from Model.SedimentLayer.SedimentLayerList import SedimentLayerList

logger = logging.getLogger()


class SetSLCommand(QUndoCommand):
    def __init__(self, profile, index, new_value):
        QUndoCommand.__init__(self)

        self._profile = profile
        self._index = index
        self._old = self._profile.point(self._index).sl
        self._new = new_value

    def undo(self):
        self._profile.point(self._index).sl = self._old

    def redo(self):
        self._profile.point(self._index).sl = self._new
