10 #include <argos3/core/utility/logging/argos_log.h>
11 #include <argos3/core/wrappers/lua/lua_utility.h>
12 #include <argos3/core/wrappers/lua/lua_vector2.h>
13 #include <argos3/core/wrappers/lua/lua_vector3.h>
14 #include <argos3/core/wrappers/lua/lua_quaternion.h>
24 bool b_remove_empty_tables,
26 QAbstractItemModel(pc_parent),
28 m_bRemoveEmptyTables(b_remove_empty_tables) {
44 if(!c_index.isValid()) {
47 if(n_role != Qt::DisplayRole) {
51 return pcItem->
GetData(c_index.column());
58 if (!c_index.isValid()) {
59 return Qt::NoItemFlags;
62 return Qt::ItemIsEnabled;
71 const QModelIndex& c_parent)
const {
72 if(!hasIndex(n_row, n_column, c_parent)) {
76 if(!c_parent.isValid()) {
77 pcParentItem = m_pcDataRoot;
84 return createIndex(n_row, n_column, pcChildItem);
95 if (!c_index.isValid()) {
100 if (pcParentItem == m_pcDataRoot) {
101 return QModelIndex();
104 return createIndex(pcParentItem->
GetRow(), 0, pcParentItem);
113 if(c_parent.column() > 0) {
116 if(!c_parent.isValid()) {
117 pcParentItem = m_pcDataRoot;
129 m_ptState = pt_state;
140 lua_pushnil(m_ptState);
141 lua_getglobal(m_ptState,
"_G");
144 lua_pop(m_ptState, 2);
160 QList<QVariant> cData;
161 switch(lua_type(pt_state, -2)) {
163 cData << lua_toboolean(pt_state, -2);
166 cData << lua_tonumber(pt_state, -2);
169 cData << lua_tostring(pt_state, -2);
173 if(lua_istable(pt_state, -1)) {
176 lua_pushnil(pt_state);
177 while(lua_next(pt_state, -2)) {
181 lua_pop(pt_state, 1);
183 if(m_bRemoveEmptyTables) {
189 else if(lua_isuserdata(pt_state, -1)) {
190 std::ostringstream cBuffer;
191 cBuffer << std::fixed;
192 void *pvUserdatum = lua_touserdata(pt_state, -1);
193 if (lua_getmetatable(pt_state, -1)) {
195 if (lua_rawequal(pt_state, -1, -2)) {
197 lua_pop(pt_state, 2);
200 cBuffer << std::setprecision(3)
201 << pcVector2->
GetX() <<
", "
202 << pcVector2->
GetY();
203 cData << cBuffer.str().c_str();
208 lua_pop(pt_state, 1);
210 if (lua_rawequal(pt_state, -1, -2)) {
212 lua_pop(pt_state, 2);
215 cBuffer << std::setprecision(3)
216 << pcVector3->
GetX() <<
", "
217 << pcVector3->
GetY() <<
", "
218 << pcVector3->
GetZ();
219 cData << cBuffer.str().c_str();
224 lua_pop(pt_state, 1);
226 if (lua_rawequal(pt_state, -1, -2)) {
228 lua_pop(pt_state, 2);
233 cBuffer << std::setprecision(1)
237 cData << cBuffer.str().c_str();
245 switch(lua_type(pt_state, -1)) {
247 cData << lua_toboolean(pt_state, -1);
251 cData << lua_tonumber(pt_state, -1);
255 cData << lua_tostring(pt_state, -1);
259 cData[0] = cData[0].toString() + tr(
"()");
272 bool b_remove_empty_tables,
273 QObject* pc_parent) :
280 Qt::Orientation e_orientation,
282 if(e_orientation != Qt::Horizontal ||
283 n_role != Qt::DisplayRole ||
288 return n_section == 0 ? tr(
"Variable") : tr(
"Value");
303 int nValueType = lua_type(pt_state, -1);
304 int nKeyType = lua_type(pt_state, -2);
305 if(nValueType == LUA_TSTRING || nValueType == LUA_TNUMBER || nValueType == LUA_TBOOLEAN || nValueType == LUA_TUSERDATA) {
306 if(nKeyType != LUA_TSTRING) {
309 else if(nKeyType == LUA_TSTRING) {
310 return std::string(lua_tostring(pt_state, -2)) !=
"_VERSION";
313 else if(nValueType == LUA_TTABLE) {
314 if(nKeyType == LUA_TNUMBER) {
317 else if(nKeyType == LUA_TSTRING) {
319 std::string(lua_tostring(pt_state, -2)) !=
"_G" &&
320 std::string(lua_tostring(pt_state, -2)) !=
"coroutine" &&
321 std::string(lua_tostring(pt_state, -2)) !=
"debug" &&
322 std::string(lua_tostring(pt_state, -2)) !=
"io" &&
323 std::string(lua_tostring(pt_state, -2)) !=
"os" &&
324 std::string(lua_tostring(pt_state, -2)) !=
"package" &&
325 std::string(lua_tostring(pt_state, -2)) !=
"string" &&
326 std::string(lua_tostring(pt_state, -2)) !=
"table";
336 bool b_remove_empty_tables,
337 QObject* pc_parent) :
344 Qt::Orientation e_orientation,
360 int nValueType = lua_type(pt_state, -1);
361 int nKeyType = lua_type(pt_state, -2);
362 if(nValueType == LUA_TFUNCTION && nKeyType == LUA_TSTRING) {
364 std::string(lua_tostring(pt_state, -2)) !=
"assert" &&
365 std::string(lua_tostring(pt_state, -2)) !=
"collectgarbage" &&
366 std::string(lua_tostring(pt_state, -2)) !=
"dofile" &&
367 std::string(lua_tostring(pt_state, -2)) !=
"error" &&
368 std::string(lua_tostring(pt_state, -2)) !=
"gcinfo" &&
369 std::string(lua_tostring(pt_state, -2)) !=
"getfenv" &&
370 std::string(lua_tostring(pt_state, -2)) !=
"getmetatable" &&
371 std::string(lua_tostring(pt_state, -2)) !=
"ipairs" &&
372 std::string(lua_tostring(pt_state, -2)) !=
"load" &&
373 std::string(lua_tostring(pt_state, -2)) !=
"loadfile" &&
374 std::string(lua_tostring(pt_state, -2)) !=
"loadstring" &&
375 std::string(lua_tostring(pt_state, -2)) !=
"module" &&
376 std::string(lua_tostring(pt_state, -2)) !=
"newproxy" &&
377 std::string(lua_tostring(pt_state, -2)) !=
"next" &&
378 std::string(lua_tostring(pt_state, -2)) !=
"pairs" &&
379 std::string(lua_tostring(pt_state, -2)) !=
"pcall" &&
380 std::string(lua_tostring(pt_state, -2)) !=
"rawequal" &&
381 std::string(lua_tostring(pt_state, -2)) !=
"rawget" &&
382 std::string(lua_tostring(pt_state, -2)) !=
"rawset" &&
383 std::string(lua_tostring(pt_state, -2)) !=
"require" &&
384 std::string(lua_tostring(pt_state, -2)) !=
"select" &&
385 std::string(lua_tostring(pt_state, -2)) !=
"setfenv" &&
386 std::string(lua_tostring(pt_state, -2)) !=
"setmetatable" &&
387 std::string(lua_tostring(pt_state, -2)) !=
"unpack" &&
388 std::string(lua_tostring(pt_state, -2)) !=
"xpcall";
390 else if(nValueType == LUA_TTABLE) {
391 if(nKeyType == LUA_TNUMBER) {
394 else if(nKeyType == LUA_TSTRING) {
396 std::string(lua_tostring(pt_state, -2)) !=
"_G" &&
397 std::string(lua_tostring(pt_state, -2)) !=
"coroutine" &&
398 std::string(lua_tostring(pt_state, -2)) !=
"debug" &&
399 std::string(lua_tostring(pt_state, -2)) !=
"io" &&
400 std::string(lua_tostring(pt_state, -2)) !=
"os" &&
401 std::string(lua_tostring(pt_state, -2)) !=
"package";
The namespace containing all the ARGoS related code.
CDegrees ToDegrees(const CRadians &c_radians)
Converts CRadians to CDegrees.
It defines the basic type CRadians, used to store an angle value in radians.
Real GetValue() const
Returns the value in degrees.
void ToEulerAngles(CRadians &c_z_angle, CRadians &c_y_angle, CRadians &c_x_angle) const
Real GetY() const
Returns the y coordinate of this vector.
Real GetX() const
Returns the x coordinate of this vector.
Real GetX() const
Returns the x coordinate of this vector.
Real GetY() const
Returns the y coordinate of this vector.
Real GetZ() const
Returns the z coordinate of this vector.
static const std::string & GetTypeId()
static const std::string & GetTypeId()
static const std::string & GetTypeId()
void AddChild(CQTOpenGLLuaStateTreeItem *pc_child)
size_t GetNumChildren() const
QVariant GetData(int n_col) const
void RemoveChild(CQTOpenGLLuaStateTreeItem *pc_child)
CQTOpenGLLuaStateTreeItem * GetParent()
CQTOpenGLLuaStateTreeItem * GetChild(size_t un_idx)
virtual int rowCount(const QModelIndex &c_parent=QModelIndex()) const
virtual ~CQTOpenGLLuaStateTreeModel()
virtual QVariant data(const QModelIndex &c_index, int n_role) const
void ProcessLuaState(lua_State *pt_state, CQTOpenGLLuaStateTreeItem *pc_item)
void SetLuaState(lua_State *pt_state)
CQTOpenGLLuaStateTreeModel(lua_State *pt_state, bool b_remove_empty_tables, QObject *pc_parent=0)
virtual bool IsTypeVisitable(lua_State *pt_state)=0
virtual QModelIndex parent(const QModelIndex &c_index) const
virtual QModelIndex index(int n_row, int n_column, const QModelIndex &c_parent=QModelIndex()) const
virtual Qt::ItemFlags flags(const QModelIndex &c_index) const
CQTOpenGLLuaStateTreeVariableModel(lua_State *pt_state, bool b_remove_empty_tables, QObject *pc_parent=0)
virtual int columnCount(const QModelIndex &c_parent=QModelIndex()) const
virtual QVariant headerData(int n_section, Qt::Orientation e_orientation, int n_role=Qt::DisplayRole) const
virtual bool IsTypeVisitable(lua_State *pt_state)
virtual int columnCount(const QModelIndex &c_parent=QModelIndex()) const
virtual bool IsTypeVisitable(lua_State *pt_state)
CQTOpenGLLuaStateTreeFunctionModel(lua_State *pt_state, bool b_remove_empty_tables, QObject *pc_parent=0)
virtual QVariant headerData(int n_section, Qt::Orientation e_orientation, int n_role=Qt::DisplayRole) const