]> git.cworth.org Git - vogl/blob - src/vogleditor/vogleditor_statetreecontextinfoitem.cpp
Initial vogl checkin
[vogl] / src / vogleditor / vogleditor_statetreecontextinfoitem.cpp
1 #include "vogleditor_statetreecontextinfoitem.h"
2
3 vogleditor_stateTreeContextInfoBoolItem::vogleditor_stateTreeContextInfoBoolItem(QString name, bool (vogl_context_info::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_context_info& info)
4     : vogleditor_stateTreeContextInfoDiffableItem(name, "", parent),
5       m_pState(&info),
6       m_pFunc(func)
7 {
8     bool val = (info.*func)();
9     setValue(getValueFromBools(&val, 1));
10 }
11
12 bool vogleditor_stateTreeContextInfoBoolItem::hasChanged() const
13 {
14     if (m_pDiffBaseState == NULL)
15         return false;
16     else
17         return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
18 }
19
20 QString vogleditor_stateTreeContextInfoBoolItem::getDiffedValue() const
21 {
22     if (m_pDiffBaseState == NULL)
23         return "";
24
25     bool val = (m_pDiffBaseState->*m_pFunc)();
26     return getValueFromBools(&val, 1);
27 }
28
29 //=============================================================================
30
31 vogleditor_stateTreeContextInfoUIntItem::vogleditor_stateTreeContextInfoUIntItem(QString name, uint (vogl_context_info::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_context_info& info)
32     : vogleditor_stateTreeContextInfoDiffableItem(name, "", parent),
33       m_pState(&info),
34       m_pFunc(func)
35 {
36     uint val = (info.*func)();
37     setValue(getValueFromUints(&val, 1));
38 }
39
40 bool vogleditor_stateTreeContextInfoUIntItem::hasChanged() const
41 {
42     if (m_pDiffBaseState == NULL)
43         return false;
44     else
45         return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
46 }
47
48 QString vogleditor_stateTreeContextInfoUIntItem::getDiffedValue() const
49 {
50     if (m_pDiffBaseState == NULL)
51         return "";
52
53     uint val = (m_pDiffBaseState->*m_pFunc)();
54     return getValueFromUints(&val, 1);
55 }
56
57 //=============================================================================
58
59 vogleditor_stateTreeContextInfoStringItem::vogleditor_stateTreeContextInfoStringItem(QString name, const vogl::dynamic_string& (vogl_context_info::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_context_info& info)
60     : vogleditor_stateTreeContextInfoDiffableItem(name, "", parent),
61       m_pState(&info),
62       m_pFunc(func)
63 {
64     m_value = (info.*func)();
65     setValue(m_value.c_str());
66 }
67
68 bool vogleditor_stateTreeContextInfoStringItem::hasChanged() const
69 {
70     if (m_pDiffBaseState == NULL)
71     {
72         return false;
73     }
74     else
75     {
76         return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
77     }
78 }
79
80 QString vogleditor_stateTreeContextInfoStringItem::getDiffedValue() const
81 {
82     if (m_pDiffBaseState == NULL)
83         return "";
84
85     vogl::dynamic_string val = (m_pDiffBaseState->*m_pFunc)();
86     return QString(val.c_str());
87 }
88
89 //=============================================================================
90
91 bool vogleditor_stateTreeContextInfoItem::hasChanged() const
92 {
93     if (m_pDiffBaseState == NULL)
94         return false;
95
96     for (vogleditor_stateTreeContextInfoDiffableItem* const * iter = m_diffableItems.begin(); iter != m_diffableItems.end(); iter++)
97     {
98         if ((*iter)->hasChanged())
99         {
100             return true;
101         }
102     }
103
104     return false;
105 }
106
107 vogleditor_stateTreeContextInfoItem::vogleditor_stateTreeContextInfoItem(QString name, QString value, vogleditor_stateTreeItem* parent, const vogl_context_info& info)
108     : vogleditor_stateTreeItem(name, value, parent),
109       m_pState(&info),
110       m_pDiffBaseState(NULL)
111 {
112     QString tmp;
113
114     if (info.is_valid())
115     {
116        tmp = "valid";
117     }
118     else
119     {
120        tmp = "Never made current";
121     }
122
123     this->setValue(tmp);
124
125     if (info.is_valid())
126     {
127         { vogleditor_stateTreeContextInfoBoolItem* pItem = new vogleditor_stateTreeContextInfoBoolItem("Forward compatible", &vogl_context_info::is_forward_compatible, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
128         { vogleditor_stateTreeContextInfoBoolItem* pItem = new vogleditor_stateTreeContextInfoBoolItem("Core profile", &vogl_context_info::is_core_profile, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
129         { vogleditor_stateTreeContextInfoBoolItem* pItem = new vogleditor_stateTreeContextInfoBoolItem("Compatibility Profile", &vogl_context_info::is_compatibility_profile, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
130         { vogleditor_stateTreeContextInfoBoolItem* pItem = new vogleditor_stateTreeContextInfoBoolItem("Debug context", &vogl_context_info::is_debug_context, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
131
132         { vogleditor_stateTreeContextInfoStringItem* pItem = new vogleditor_stateTreeContextInfoStringItem("GL_RENDERER", &vogl_context_info::get_renderer_str, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
133         { vogleditor_stateTreeContextInfoStringItem* pItem = new vogleditor_stateTreeContextInfoStringItem("GL_VENDOR", &vogl_context_info::get_vendor_str, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
134         { vogleditor_stateTreeContextInfoStringItem* pItem = new vogleditor_stateTreeContextInfoStringItem("GL_VERSION", &vogl_context_info::get_version_str, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
135         { vogleditor_stateTreeContextInfoStringItem* pItem = new vogleditor_stateTreeContextInfoStringItem("GL_SHADING_LANGUAGE_VERSION", &vogl_context_info::get_glsl_version_str, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
136
137         vogleditor_stateTreeItem* pExtNode = new vogleditor_stateTreeItem("GL_EXTENSIONS", "", this);
138         this->appendChild(pExtNode);
139         const dynamic_string_array& extList = info.get_extensions();
140         for (uint e = 0; e < extList.size(); e++)
141         {
142             vogleditor_stateTreeContextInfoExtensionItem* pItem = new vogleditor_stateTreeContextInfoExtensionItem(tmp.sprintf("%d", e), extList[e].c_str(), pExtNode, info);
143             m_diffableItems.push_back(pItem);
144             pExtNode->appendChild(pItem);
145         }
146         pExtNode->setValue(tmp.sprintf("[%d]", pExtNode->childCount()));
147
148         { vogleditor_stateTreeContextInfoUIntItem* pItem = new vogleditor_stateTreeContextInfoUIntItem("GL_MAX_PROGRAM_ENV_PARAMETERS_ARB GL_VERTEX_PROGRAM_ARB", &vogl_context_info::get_max_arb_vertex_program_env_params, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
149         { vogleditor_stateTreeContextInfoUIntItem* pItem = new vogleditor_stateTreeContextInfoUIntItem("GL_MAX_PROGRAM_ENV_PARAMETERS_ARB GL_FRAGMENT_PROGRAM_ARB", &vogl_context_info::get_max_arb_fragment_program_env_params, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
150         { vogleditor_stateTreeContextInfoUIntItem* pItem = new vogleditor_stateTreeContextInfoUIntItem("GL_MAX_PROGRAM_MATRICES_ARB", &vogl_context_info::get_max_arb_program_matrices, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
151         { vogleditor_stateTreeContextInfoUIntItem* pItem = new vogleditor_stateTreeContextInfoUIntItem("GL_MAX_COMBINED_TEXTURE_COORDS", &vogl_context_info::get_max_combined_texture_coords, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
152         { vogleditor_stateTreeContextInfoUIntItem* pItem = new vogleditor_stateTreeContextInfoUIntItem("GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", &vogl_context_info::get_max_transform_feedback_separate_attribs, this, info); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
153
154
155 //       this->appendChild(new vogleditor_stateTreeItem("GL_MAX_DRAW_BUFFERS", STR_INT(info.get_max_draw_buffers()), this));
156 //       this->appendChild(new vogleditor_stateTreeItem("GL_MAX_LIGHTS", STR_INT(info.get_max_lights()), this));
157 //       this->appendChild(new vogleditor_stateTreeItem("GL_MAX_TEXTURE_COORDS", STR_INT(info.get_max_texture_coords()), this));
158 //       this->appendChild(new vogleditor_stateTreeItem("GL_MAX_TEXTURE_IMAGE_UNITS", STR_INT(info.get_max_texture_image_units()), this));
159 //       this->appendChild(new vogleditor_stateTreeItem("GL_MAX_TEXTURE_UNITS", STR_INT(info.get_max_texture_units()), this));
160 //       this->appendChild(new vogleditor_stateTreeItem("GL_MAX_UNIFORM_BUFFER_BINDINGS", STR_INT(info.get_max_uniform_buffer_bindings()), this));
161 //       this->appendChild(new vogleditor_stateTreeItem("GL_MAX_VERTEX_ATTRIBS", STR_INT(info.get_max_vertex_attribs()), this));
162     }
163 }