diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-02-10 18:31:48 -0200 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-02-10 18:31:48 -0200 |
commit | b45a21976bece19da81166324dc1cc4260a0e0f4 (patch) | |
tree | 2f21da285edb214766fa559081b76a6754cfa8b0 /projectionhistory.cpp | |
parent | 8d4e5ff43fd9d51dc05d8d2dd87f69ab35bee423 (diff) |
Added ProjectionHistory object for history tracking.
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); +} |