]> git.cworth.org Git - vogl/blob - src/vogleditor/vogleditor_statetreepolygonstippleitem.cpp
Initial vogl checkin
[vogl] / src / vogleditor / vogleditor_statetreepolygonstippleitem.cpp
1 #include "vogleditor_statetreepolygonstippleitem.h"
2
3 vogleditor_stateTreePolygonStippleRowItem::vogleditor_stateTreePolygonStippleRowItem(QString name, unsigned int rowIndex, vogleditor_stateTreeItem* parent, const vogl_polygon_stipple_state& state)
4     : vogleditor_stateTreeItem(name, "", parent),
5       m_rowIndex(rowIndex),
6       m_pState(&state),
7       m_pDiffBaseState(NULL)
8 {
9     setValue(uint32_to_bits(m_pState->get_pattern_row(m_rowIndex)));
10 }
11
12 bool vogleditor_stateTreePolygonStippleRowItem::hasChanged() const
13 {
14     if (m_pDiffBaseState == NULL)
15     {
16         return false;
17     }
18
19     if (m_rowIndex >= m_pDiffBaseState->get_num_pattern_rows())
20         return true;
21
22     uint32 curRow = m_pState->get_pattern_row(m_rowIndex);
23     uint32 baseRow = m_pDiffBaseState->get_pattern_row(m_rowIndex);
24
25     return curRow != baseRow;
26 }
27
28 QString vogleditor_stateTreePolygonStippleRowItem::getDiffedValue() const
29 {
30     if (m_pDiffBaseState == NULL)
31     {
32         return "";
33     }
34
35     if (m_rowIndex >= m_pDiffBaseState->get_num_pattern_rows())
36         return "non-existent";
37
38     uint32 baseRow = m_pDiffBaseState->get_pattern_row(m_rowIndex);
39
40     return uint32_to_bits(baseRow);
41 }
42
43 vogleditor_stateTreePolygonStippleItem::vogleditor_stateTreePolygonStippleItem(QString name, vogleditor_stateTreeItem* parent, const vogl_polygon_stipple_state& state)
44     : vogleditor_stateTreeItem(name, "", parent),
45       m_pState(&state),
46       m_pDiffBaseState(NULL)
47 {
48     QString tmp;
49     for (uint i = 0; i < m_pState->get_num_pattern_rows(); i++)
50     {
51         vogleditor_stateTreePolygonStippleRowItem* pRowNode = new vogleditor_stateTreePolygonStippleRowItem(tmp.sprintf("Row %u", i), i, this, state);
52         m_rowItems.push_back(pRowNode);
53         this->appendChild(pRowNode);
54     }
55 }