aboutsummaryrefslogtreecommitdiff
path: root/projectionhistory.cpp
blob: b8ffb574f6306d200286d80556aa0709c1df35b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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);
}