]> git.cworth.org Git - vogl/blob - src/vogleditor/vogleditor_statetreepolygonstippleitem.h
Initial vogl checkin
[vogl] / src / vogleditor / vogleditor_statetreepolygonstippleitem.h
1 #ifndef VOGLEDITOR_STATETREEPOLYGONSTIPPLEITEM_H
2 #define VOGLEDITOR_STATETREEPOLYGONSTIPPLEITEM_H
3
4 #include "vogleditor_statetreeitem.h"
5 #include "vogl_general_context_state.h"
6
7 class vogleditor_stateTreePolygonStippleRowItem: public vogleditor_stateTreeItem
8 {
9 public:
10     vogleditor_stateTreePolygonStippleRowItem(QString name, unsigned int rowIndex, vogleditor_stateTreeItem* parent, const vogl_polygon_stipple_state& state);
11
12     virtual ~vogleditor_stateTreePolygonStippleRowItem()
13     {
14         m_pState = NULL;
15         m_pDiffBaseState = NULL;
16     }
17
18     void set_diff_base_state(const vogl_polygon_stipple_state* pBaseState) { m_pDiffBaseState = pBaseState; }
19
20     virtual bool hasChanged() const;
21     virtual QString getDiffedValue() const;
22
23 private:
24     unsigned int m_rowIndex;
25     const vogl_polygon_stipple_state* m_pState;
26     const vogl_polygon_stipple_state* m_pDiffBaseState;
27
28     QString uint32_to_bits(uint32 id) const
29     {
30        QString tmp;
31        QString tmp2;
32        uint32 size = sizeof(uint32);
33        uint32 maxPow = 1<<(size*8-1);
34        for(uint32 i = 0; i < size * 8; ++i)
35        {
36            // print last bit and shift left.
37            tmp += tmp2.sprintf("%u", id & maxPow ? 1 : 0);
38            id = id<<1;
39        }
40        return tmp;
41     }
42 };
43
44 class vogleditor_stateTreePolygonStippleItem: public vogleditor_stateTreeItem
45 {
46 public:
47     vogleditor_stateTreePolygonStippleItem(QString name, vogleditor_stateTreeItem* parent, const vogl_polygon_stipple_state& state);
48
49     virtual ~vogleditor_stateTreePolygonStippleItem()
50     {
51         m_pState = NULL;
52         m_pDiffBaseState = NULL;
53     }
54
55     void set_diff_base_state(const vogl_polygon_stipple_state* pBaseState)
56     {
57         m_pDiffBaseState = pBaseState;
58
59         for (vogleditor_stateTreePolygonStippleRowItem** iter = m_rowItems.begin(); iter != m_rowItems.end(); iter++)
60         {
61             (*iter)->set_diff_base_state(pBaseState);
62         }
63     }
64
65 private:
66     const vogl_polygon_stipple_state* m_pState;
67     const vogl_polygon_stipple_state* m_pDiffBaseState;
68     vogl::vector<vogleditor_stateTreePolygonStippleRowItem*> m_rowItems;
69 };
70
71 #endif // VOGLEDITOR_STATETREEPOLYGONSTIPPLEITEM_H