diff options
Diffstat (limited to 'projectionhistory.cpp')
-rw-r--r-- | projectionhistory.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/projectionhistory.cpp b/projectionhistory.cpp new file mode 100644 index 0000000..b8ffb57 --- /dev/null +++ b/projectionhistory.cpp @@ -0,0 +1,45 @@ +#include "projectionhistory.h" + +ProjectionHistory::ProjectionHistory(QObject *parent) + : QObject(parent) + , m_hasFirst(false) + , m_hasPrev(false) +{ +} + +inline void ProjectionHistory::undo() +{ + if (m_hasPrev) { + m_hasPrev = false; + m_Y = m_prevY; + + emit historyChanged(m_Y); + } +} + +inline void ProjectionHistory::undoAll() +{ + if (m_hasFirst) { + m_hasPrev = false; + m_Y = m_firstY; + + emit historyChanged(m_Y); + } +} + +void ProjectionHistory::addMap(const arma::mat &Y) +{ + if (m_hasFirst) { + m_hasPrev = true; + m_prevY = m_Y; + } + + m_Y = Y; + + if (!m_hasFirst) { + m_hasFirst = true; + m_firstY = m_Y; + } + + emit historyChanged(m_Y); +} |