1 #ifndef VOGLEDITOR_STATETREEPROGRAMITEM_H
2 #define VOGLEDITOR_STATETREEPROGRAMITEM_H
4 #include "vogleditor_statetreeitem.h"
5 #include "vogl_program_state.h"
7 class vogleditor_stateTreeProgramDiffableItem : public vogleditor_stateTreeItem
10 vogleditor_stateTreeProgramDiffableItem(QString name, QString value, vogleditor_stateTreeItem* parent, const vogl_program_state& state)
11 : vogleditor_stateTreeItem(name, value, parent),
13 m_pDiffBaseState(NULL)
17 virtual void set_diff_base_state(const vogl_program_state* pBaseState) {
18 m_pDiffBaseState = pBaseState;
21 const vogl_program_state* get_current_state() const { return m_pState; }
22 const vogl_program_state* get_base_state() const { return m_pDiffBaseState; }
24 virtual bool hasChanged() const = 0;
27 const vogl_program_state* m_pState;
28 const vogl_program_state* m_pDiffBaseState;
31 class vogleditor_stateTreeProgramBoolItem : public vogleditor_stateTreeProgramDiffableItem
34 vogleditor_stateTreeProgramBoolItem(QString name, bool (vogl_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_program_state& state);
35 virtual ~vogleditor_stateTreeProgramBoolItem() { m_pState = NULL; }
37 virtual bool hasChanged() const;
38 virtual QString getDiffedValue() const;
41 bool (vogl_program_state::* m_pFunc)(void) const;
44 class vogleditor_stateTreeProgramUIntItem : public vogleditor_stateTreeProgramDiffableItem
47 vogleditor_stateTreeProgramUIntItem(QString name, uint (vogl_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_program_state& state);
48 virtual ~vogleditor_stateTreeProgramUIntItem() { m_pState = NULL; }
50 virtual bool hasChanged() const;
51 virtual QString getDiffedValue() const;
54 uint (vogl_program_state::* m_pFunc)(void) const;
57 class vogleditor_stateTreeProgramEnumItem : public vogleditor_stateTreeProgramDiffableItem
60 vogleditor_stateTreeProgramEnumItem(QString name, GLenum (vogl_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_program_state& state);
61 virtual ~vogleditor_stateTreeProgramEnumItem() { m_pState = NULL; }
63 virtual bool hasChanged() const;
64 virtual QString getDiffedValue() const;
67 GLenum (vogl_program_state::* m_pFunc)(void) const;
70 class vogleditor_stateTreeProgramLogItem : public vogleditor_stateTreeProgramDiffableItem
73 vogleditor_stateTreeProgramLogItem(QString name, const vogl::dynamic_string& (vogl_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_program_state& state);
74 virtual ~vogleditor_stateTreeProgramLogItem() { m_pState = NULL; }
76 virtual bool hasChanged() const;
77 virtual QString getDiffedValue() const;
80 const vogl::dynamic_string& (vogl_program_state::* m_pFunc)(void) const;
83 class vogleditor_stateTreeProgramStringItem : public vogleditor_stateTreeProgramDiffableItem
86 vogleditor_stateTreeProgramStringItem(QString name, const vogl::dynamic_string& (vogl_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_program_state& state);
87 virtual ~vogleditor_stateTreeProgramStringItem() { m_pState = NULL; }
89 virtual bool hasChanged() const;
90 virtual QString getDiffedValue() const;
93 dynamic_string m_value;
94 const vogl::dynamic_string& (vogl_program_state::* m_pFunc)(void) const;
97 class vogleditor_stateTreeProgramAttribItem : public vogleditor_stateTreeItem
100 vogleditor_stateTreeProgramAttribItem(QString name, vogleditor_stateTreeItem* parent, const vogl_program_attrib_state& state);
101 virtual ~vogleditor_stateTreeProgramAttribItem() { m_pState = NULL; }
103 virtual void set_diff_base_state(const vogl_attrib_state_vec* pBaseState) {
104 m_pDiffBaseState = pBaseState;
107 virtual bool hasChanged() const;
108 virtual QString getDiffedValue() const;
110 const dynamic_string& get_name() const { return m_pState->m_name; }
113 const vogl_program_attrib_state* m_pState;
114 const vogl_attrib_state_vec* m_pDiffBaseState;
117 class vogleditor_stateTreeProgramUniformItem : public vogleditor_stateTreeItem
120 vogleditor_stateTreeProgramUniformItem(QString name, vogleditor_stateTreeItem* parent, const vogl_program_uniform_state& state);
121 virtual ~vogleditor_stateTreeProgramUniformItem() { m_pState = NULL; }
123 virtual void set_diff_base_state(const vogl_uniform_state_vec* pBaseState) {
124 m_pDiffBaseState = pBaseState;
127 virtual bool hasChanged() const;
128 virtual QString getDiffedValue() const;
130 const dynamic_string& get_name() const { return m_pState->m_name; }
133 const vogl_program_uniform_state* m_pState;
134 const vogl_uniform_state_vec* m_pDiffBaseState;
137 class vogleditor_stateTreeProgramItem : public vogleditor_stateTreeItem
140 vogleditor_stateTreeProgramItem(QString name, QString value, vogleditor_stateTreeItem* parent, vogl_program_state& state, const vogl_context_info& info);
141 virtual ~vogleditor_stateTreeProgramItem() { m_pState = NULL; m_pDiffBaseState = NULL; }
142 virtual state_tree_type getStateType() const { return vogleditor_stateTreeItem::cPROGRAM; }
144 vogl_program_state* get_current_state() const { return m_pState; }
145 const vogl_program_state* get_base_state() const { return m_pDiffBaseState; }
147 void add_diffable_child(vogleditor_stateTreeProgramDiffableItem* pItem);
149 void set_diff_base_state(const vogl_program_state* pBaseState) {
150 m_pDiffBaseState = pBaseState;
151 for (vogleditor_stateTreeProgramDiffableItem** iter = m_diffableItems.begin(); iter != m_diffableItems.end(); iter++)
153 (*iter)->set_diff_base_state(pBaseState);
156 for (vogleditor_stateTreeProgramAttribItem** iter = m_attribItems.begin(); iter != m_attribItems.end(); iter++)
158 (*iter)->set_diff_base_state(&(pBaseState->get_attrib_state_vec()));
161 for (vogleditor_stateTreeProgramUniformItem** iter = m_uniformItems.begin(); iter != m_uniformItems.end(); iter++)
163 (*iter)->set_diff_base_state(&(pBaseState->get_uniform_state_vec()));
168 vogl_program_state* m_pState;
169 const vogl_program_state* m_pDiffBaseState;
170 vogl::vector<vogleditor_stateTreeProgramDiffableItem*> m_diffableItems;
171 vogl::vector<vogleditor_stateTreeProgramAttribItem*> m_attribItems;
172 vogl::vector<vogleditor_stateTreeProgramUniformItem*> m_uniformItems;
174 #endif // VOGLEDITOR_STATETREEPROGRAMITEM_H