From b45a21976bece19da81166324dc1cc4260a0e0f4 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Wed, 10 Feb 2016 18:31:48 -0200 Subject: Added ProjectionHistory object for history tracking. --- projectionhistory.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 projectionhistory.cpp (limited to 'projectionhistory.cpp') 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); +} -- cgit v1.2.3