1 #include "vogleditor_statetreematrixitem.h"
2 #include "vogl_matrix.h"
4 vogleditor_stateTreeMatrixRowItem::vogleditor_stateTreeMatrixRowItem(QString name, unsigned int rowIndex, vogleditor_stateTreeItem* parent, const matrix44D& matrix)
5 : vogleditor_stateTreeItem(name, "", parent),
10 const matrix44D::row_vec& row = matrix.get_row(rowIndex);
12 setValue(tmp.sprintf("%lf, %lf, %lf, %lf", row[0], row[1], row[2], row[3]));
15 bool vogleditor_stateTreeMatrixRowItem::hasChanged() const
17 if (m_pDiffBaseState == NULL)
22 const matrix44D::row_vec& curRow = m_pState->get_row(m_rowIndex);
23 const matrix44D::row_vec& baseRow = m_pDiffBaseState->get_row(m_rowIndex);
24 if ((curRow[0] != baseRow[0]) ||
25 (curRow[1] != baseRow[1]) ||
26 (curRow[2] != baseRow[2]) ||
27 (curRow[3] != baseRow[3]))
35 QString vogleditor_stateTreeMatrixRowItem::getDiffedValue() const
37 if (m_pDiffBaseState == NULL)
42 const matrix44D::row_vec& baseRow = m_pDiffBaseState->get_row(m_rowIndex);
44 return getValueFromDoubles(baseRow.get_ptr(), 4);
47 vogleditor_stateTreeMatrixItem::vogleditor_stateTreeMatrixItem(QString name, vogleditor_stateTreeItem* parent, const matrix44D& matrix, unsigned int stackIndex)
48 : vogleditor_stateTreeItem(name, "", parent),
49 m_stackIndex(stackIndex),
51 m_pDiffBaseState(NULL)
53 { vogleditor_stateTreeMatrixRowItem* pItem = new vogleditor_stateTreeMatrixRowItem("row 0", 0, this, matrix); m_rowItems.push_back(pItem); this->appendChild(pItem); }
54 { vogleditor_stateTreeMatrixRowItem* pItem = new vogleditor_stateTreeMatrixRowItem("row 1", 1, this, matrix); m_rowItems.push_back(pItem); this->appendChild(pItem); }
55 { vogleditor_stateTreeMatrixRowItem* pItem = new vogleditor_stateTreeMatrixRowItem("row 2", 2, this, matrix); m_rowItems.push_back(pItem); this->appendChild(pItem); }
56 { vogleditor_stateTreeMatrixRowItem* pItem = new vogleditor_stateTreeMatrixRowItem("row 3", 3, this, matrix); m_rowItems.push_back(pItem); this->appendChild(pItem); }
59 vogleditor_stateTreeMatrixStackItem::vogleditor_stateTreeMatrixStackItem(QString name, GLenum target, unsigned int index, vogleditor_stateTreeItem* parent, const vogl_matrix_state& state)
60 : vogleditor_stateTreeItem(name, "", parent),
64 m_pDiffBaseState(NULL)
66 uint stack_depth = m_pState->get_matrix_stack_depth(m_target, m_index);
67 for (uint i = 0; i < stack_depth; i++)
70 tmpName = tmpName.sprintf("%d", i);
71 if (i == stack_depth - 1) { tmpName = tmpName.append(" (top)"); }
72 if (i == 0) { tmpName = tmpName.append(" (bottom)"); }
74 const matrix44D* pMatrix = m_pState->get_matrix(m_target, m_index, i);
77 vogleditor_stateTreeMatrixItem* pItem = new vogleditor_stateTreeMatrixItem(tmpName, this, *pMatrix, i);
78 m_matrixItems.push_back(pItem);
79 this->appendChild(pItem);