Ejemplo n.º 1
0
ProgramValue::ProgramValue (std::string name, std::string type,std::string context,std::string valueof, int id, bool inSpecML) : m_Cardinality (0)
{
	int attr;
	nau::Enums::DataType dt;
	m_Values = NULL;
//	m_IntValue = NULL;
	m_InSpecML = inSpecML;
	m_TypeString = type;

	m_Name = name;
	m_Context = context;
	m_Id = id;
	std::string what;

	//if (type == "CURRENT")
	//	what = context;
	//else
		what = type;

	AttribSet *attrSet = NAU->getAttribs(what);
	if (attrSet == NULL)
		NAU_THROW("Exception creating a program value. name=%s, type=%s, context=%s, component=%s, int=%d", name.c_str(), type.c_str(), context.c_str(), valueof.c_str(), id);
	
	attrSet->getPropTypeAndId(valueof, &dt, &attr);
	m_ValueOf = attr;
	m_ValueType = dt;
	m_Cardinality = Enums::getCardinality(dt);
	void *def = attrSet->getDefault(attr, dt);
	if (def != NULL)
		m_Values = def;
	else
		m_Values = (void *)malloc(Enums::getSize(dt));
}
Ejemplo n.º 2
0
void
Nau::getValidObjectComponents(const std::string &type, std::vector<std::string> *v) {

	if (m_Attributes.count(type) == 0)
		return;

	AttribSet *as = m_Attributes[type];
	for (auto &attr : as->getAttributes())
		v->push_back(attr.first);
}
Ejemplo n.º 3
0
bool
Nau::validateObjectComponent(const std::string &type, const std::string & component) {

	if (m_Attributes.count(type) == 0)
		return false;

	AttribSet *as = m_Attributes[type];
	if (as->getID(component) == -1)
		return false;

	return true;
}
Ejemplo n.º 4
0
bool 
Nau::validateUserAttribName(std::string context, std::string name) {

	AttribSet *attribs = getAttribs(context);

 // invalid context
	if (attribs == NULL)
		return false;

	std::unique_ptr<Attribute> &a = attribs->get(name);
	if (a->getName() == "NO_ATTR")
		return true;
	else
		return false;
}
Ejemplo n.º 5
0
bool
ToolBar::addDir(const std::string &windowName, const std::string &varLabel,
	const std::string &varType, const std::string &varContext,
	const std::string &component, int id) {

	// window does not exist
	if (m_Windows.count(windowName) == 0)
		return false;

	AttribSet *attrSet = NAU->getAttribs(varType);
	// type is not valid
	if (attrSet == NULL)
		return false;

	Enums::DataType dt;
	int attr;

	attrSet->getPropTypeAndId(component, &dt, &attr);
	// component is not valid
	if (attr == -1)
		return false;

	if (dt != Enums::VEC4)
		return false;

	NauVar *clientData = new NauVar();
	clientData->type = varType;
	clientData->context = varContext;
	clientData->component = component;

	std::string name = varLabel;
	name.erase(remove_if(name.begin(), name.end(), [](char c) { return !isalpha(c); }), name.end());
	char s[256];
	if (name != varLabel) {
		sprintf(s, " label='%s' ", varLabel.c_str());
	}
	else
		s[0] = '\0';

	if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
		return (TwAddVarCB(m_Windows[windowName].second, varLabel.c_str(), TW_TYPE_DIR3F, SetDirCallBack, GetDirCallBack, clientData, s) == 1);
	else
		return (TwAddVarCB(m_Windows[windowName].second, varLabel.c_str(), TW_TYPE_DIR3F, NULL, GetDirCallBack, clientData, s) == 1);

}
Ejemplo n.º 6
0
int
luaGet(lua_State *l) {

	const char *tipo = lua_tostring(l, -5);
	const char *context = lua_tostring(l, -4);
	const char *component = lua_tostring(l, -3);
	int number = (int)lua_tointeger(l, -2);
	void *arr;
	AttribSet *attr;

	if (!strcmp(context, "CURRENT")) {
		
		attr = NAU->getCurrentObjectAttributes(tipo)->getAttribSet();
		if (attr == NULL)
			NAU_THROW("Lua set: Invalid context: %s", context);
	}
	else {
		attr = NAU->getAttribs(tipo);
		if (attr == NULL)
			NAU_THROW("Lua get: invalid type: %s", tipo);
	}

	std::string s = component;
	Enums::DataType dt, bdt;
	int id;
	attr->getPropTypeAndId(s, &dt, &id);
	if (id == -1) {
		NAU_THROW("Lua get: invalid attribute: %s", component);
	}

	int card = Enums::getCardinality(dt);
	bdt = Enums::getBasicType(dt);
	arr = NAU->getAttributeValue(tipo, context, component, number);
	if (arr == NULL) {
		NAU_THROW("Lua get: Invalid context or number: %s %d", context, number);
	}
	if (!Enums::isBasicType(dt)) {
		arr = ((Data *)(arr))->getPtr();
	}
	luaGetValues(l, arr, card, bdt);

	return 0;
}
Ejemplo n.º 7
0
ProgramBlockValue::ProgramBlockValue (std::string name, std::string block, std::string type, std::string context,std::string valueof, int id, bool inSpecML) : m_Cardinality (0) {

	IUniformBlock *aBlock = UNIFORMBLOCKMANAGER->getBlock(name);
	//if (aBlock == NULL) {
	//	NAU_THROW("Uniform Block %s is not defined", block.c_str());
	//}
	//if (!aBlock->hasUniform(name))
	//	NAU_THROW("Uniform Block %s does not hava a uniform named %s", block.c_str(), name.c_str());

	//if (!aBlock->getUniformType(name) != Enums::getType(type))
	//	NAU_THROW("Uniform Block %s, uniform %s - type does not match", block.c_str(), name.c_str());

	int attr;
	nau::Enums::DataType dt;
	m_InSpecML = inSpecML;
	m_TypeString = type;
	m_ValueOfString = valueof;

	m_Name = name;
	m_Block = block;
	m_Context = context;
	m_Id = id;
	std::string what;

	//if (type == "CURRENT")
	//	what = context;
	//else
		what = type;

	AttribSet *attrSet = NAU->getAttribs(what);
	if (attrSet == NULL)
		NAU_THROW("Exception creating a program value. name=%s, type=%s, context=%s, component=%s, int=%d", name.c_str(), type.c_str(), context.c_str(), valueof.c_str(), id);
	
	attrSet->getPropTypeAndId(valueof, &dt, &attr);
	m_ValueOf = attr;
	m_ValueType = dt;
	m_Cardinality = Enums::getCardinality(dt);
	void *def = (void *)attrSet->get(attr, dt)->getDefault().get();
	if (def != NULL)
		m_Values = def;
	else
		m_Values = (void *)malloc(Enums::getSize(dt));
}
Ejemplo n.º 8
0
int 
luaSet(lua_State *l) {

	const char *tipo = lua_tostring(l, -5);
	const char *context = lua_tostring(l, -4);
	const char *component = lua_tostring(l, -3);
	int number = (int)lua_tointeger(l, - 2);
	Data *arr = NULL;
	AttribSet *attr;

	if (!strcmp(context, "CURRENT")) {

		AttributeValues *av = NAU->getCurrentObjectAttributes(tipo);
		attr = av->getAttribSet();
		if (attr == NULL)
			NAU_THROW("Lua set: Invalid type: %s", tipo);
	}
	else {
		attr = NAU->getAttribs(tipo);
		if (attr == NULL)
			NAU_THROW("Lua set: invalid type: %s", tipo);
	}
	std::string s = component;
	Enums::DataType dt, bdt;
	int id;
	attr->getPropTypeAndId(s, &dt, &id);
	if (id == -1)
		NAU_THROW("Lua set: invalid component: %s", component);
	int card = Enums::getCardinality(dt);
	bdt = Enums::getBasicType(dt);
	float *arrF;
	int *arrI; 
	unsigned int *arrUI;

	switch (bdt) {

	case Enums::FLOAT:
		arrF = (float *)malloc(sizeof(float) * card);
		lua_pushnil(l);
		for (int i = 0; i < card && lua_next(l,-2) != 0; ++i) {
			arrF[i] = (float)lua_tonumber(l, -1);
			lua_pop(l, 1);
		}
		switch (dt) {
		case Enums::FLOAT:
			arr = new NauFloat(*arrF); break;
		case Enums::VEC2:
			arr = new vec2(arrF[0], arrF[1]); break;
		case Enums::VEC3:
			arr = new vec3(arrF[0], arrF[1], arrF[2]); break;
		case Enums::VEC4:
			arr = new vec4(arrF[0], arrF[1], arrF[2], arrF[3]); break;
		case Enums::MAT4:
		case Enums::MAT3:
			arr = new mat4(arrF); break;
		default:
			NAU_THROW("Lua set: Type %s not supported", Enums::DataTypeToString[dt].c_str());
		}
		free (arrF);
		break;
	case Enums::INT:
	case Enums::BOOL:
		arrI = (int *)malloc(sizeof(int) * card);
		lua_pushnil(l);
		for (int i = 0; i < card && lua_next(l, -2) != 0; ++i) {
			arrI[i] = (int)lua_tointeger(l, -1);
			lua_pop(l, 1);
		}
		switch (dt) {
		case Enums::BOOL:
		case Enums::INT:
			arr = new NauInt(arrI[0]); break;
		case Enums::IVEC2:
		case Enums::BVEC2:
			arr = new ivec2(arrI[0], arrI[1]); break;
		case Enums::IVEC3:
		case Enums::BVEC3:
			arr = new ivec3(arrI[0], arrI[1], arrI[2]); break;
		case Enums::IVEC4:
		case Enums::BVEC4:
			arr = new ivec4(arrI[0], arrI[1], arrI[2], arrI[3]); break;
		default:
			NAU_THROW("Lua set: Type %s not supported", Enums::DataTypeToString[dt].c_str());
		}
		free(arrI);
		break;
	case Enums::UINT :
		arrUI = (unsigned int *)malloc(sizeof(unsigned int) * card);
		lua_pushnil(l);
		for (int i = 0; i < card && lua_next(l, -2) != 0; ++i) {
			arrUI[i] = (unsigned int)lua_tointeger(l, -1);
			lua_pop(l, 1);
		}
		switch (dt) {
		case Enums::UINT:
			arr = new NauUInt(arrUI[0]); break;
		case Enums::UIVEC2:
			arr = new uivec2(arrUI[0], arrUI[1]); break;
		case Enums::UIVEC3:
			arr = new uivec3(arrUI[0], arrUI[1], arrUI[2]); break;
		case Enums::UIVEC4:
			arr = new uivec4(arrUI[0], arrUI[1], arrUI[2], arrUI[3]); break;
		default:
			NAU_THROW("Lua set: Type %s not supported", Enums::DataTypeToString[dt].c_str());
		}
		free(arrUI);
		break;
	default:
		NAU_THROW("Lua set: Type %s not supported", Enums::DataTypeToString[bdt].c_str());
	}

	if (!NAU->setAttributeValue(tipo, context, component, number, arr))
		NAU_THROW("Lua set: Invalid context: %s", context);

	delete arr;
	return 0;
}
Ejemplo n.º 9
0
void
PropertyManager::updateProp(wxPropertyGridManager *pg, std::string prop, AttribSet &attribs, AttributeValues *attribVal) {

	std::unique_ptr<Attribute> &a = attribs.get(prop);
	Enums::DataType dt;
	wxPGProperty *pgProp;
	int id,i;
	unsigned int ui; uivec2 uiv2; uivec3 uiv3;
	bool b;
	std::string s;
	attribs.getPropTypeAndId(prop, &dt, &id);
	float f;
	vec2 v; vec3 v3; vec4 v4;
	bvec4 b4;
	mat3 m3; mat4 m4;
	Attribute::Semantics sem = a->getSemantics();
	wxColour col;
	wxVariant variant;
	
	switch (dt) {

	case Enums::ENUM:

		pgProp = pg->GetProperty(wxString(prop));
		i = pgProp->GetValue().GetInteger();
		attribVal->setPrope((AttributeValues::EnumProperty)id, i);
		break;

	case Enums::BOOL:

		pgProp = pg->GetProperty(wxString(prop));
		b = pgProp->GetValue().GetBool();
		attribVal->setPropb((AttributeValues::BoolProperty)id, b);
		break;

	case Enums::BVEC4:

		s = prop + "." + "x";
		pgProp = pg->GetProperty(wxString(s));
		b4.x = pgProp->GetValue().GetBool();

		s = prop + "." + "y";
		pgProp = pg->GetProperty(wxString(s));
		b4.y = pgProp->GetValue().GetBool();

		s = prop + "." + "z";
		pgProp = pg->GetProperty(wxString(s));
		b4.z = pgProp->GetValue().GetBool();

		s = prop + "." + "w";
		pgProp = pg->GetProperty(wxString(s));
		b4.w = pgProp->GetValue().GetBool();
		
		attribVal->setPropb4((AttributeValues::Bool4Property)id, b4);
		break;

	case Enums::INT:

		pgProp = pg->GetProperty(wxString(prop));
		i = pgProp->GetValue().GetInteger();
		attribVal->setPropi((AttributeValues::IntProperty)id, i);
		break;

	case Enums::UINT:

		pgProp = pg->GetProperty(wxString(prop));
		ui = pgProp->GetValue().GetInteger();
		attribVal->setPropui((AttributeValues::UIntProperty)id, ui);
		break;

	case Enums::UIVEC2:

		s = prop + "." + "x";
		pgProp = pg->GetProperty(wxString(s));
		uiv2.x = pgProp->GetValue().GetDouble();
		s = prop + "." + "y";
		pgProp = pg->GetProperty(wxString(s));
		uiv2.y = pgProp->GetValue().GetDouble();
		attribVal->setPropui2((AttributeValues::UInt2Property)id, uiv2);
		break;

	case Enums::UIVEC3:

		s = prop + "." + "x";
		pgProp = pg->GetProperty(wxString(s));
		uiv3.x = pgProp->GetValue().GetDouble();
		s = prop + "." + "y";
		pgProp = pg->GetProperty(wxString(s));
		uiv3.y = pgProp->GetValue().GetDouble();
		s = prop + "." + "w";
		pgProp = pg->GetProperty(wxString(s));
		uiv3.z = pgProp->GetValue().GetDouble();
		attribVal->setPropui3((AttributeValues::UInt3Property)id, uiv3);
		break;

	case Enums::FLOAT:

		pgProp = pg->GetProperty(wxString(prop));
		f = pgProp->GetValue().GetDouble();
		attribVal->setPropf((AttributeValues::FloatProperty)id, f);
		break;

	case Enums::VEC2:

		s = prop + "." + "x";
		pgProp = pg->GetProperty(wxString(s));
		v.x = pgProp->GetValue().GetDouble();
		s = prop + "." + "y";
		pgProp = pg->GetProperty(wxString(s));
		v.y = pgProp->GetValue().GetDouble();
		attribVal->setPropf2((AttributeValues::Float2Property)id, v);
		break;

	case Enums::VEC3:

		s = prop + "." + "x";
		pgProp = pg->GetProperty(wxString(s));
		v3.x = pgProp->GetValue().GetDouble();
		s = prop + "." + "y";
		pgProp = pg->GetProperty(wxString(s));
		v3.y = pgProp->GetValue().GetDouble();
		s = prop + "." + "w";
		pgProp = pg->GetProperty(wxString(s));
		v3.z = pgProp->GetValue().GetDouble();
		attribVal->setPropf3((AttributeValues::Float3Property)id, v3);
		break;

	case Enums::VEC4:
		if (sem == Attribute::COLOR) {
			s = prop + ".RGB";
			variant = pg->GetPropertyValue(wxString(s));
			col << variant;
			v4.x = col.Red()/255.0; v4.y = col.Green() / 255.0; v4.z = col.Blue() / 255.0;
			s = prop + ".Alpha" ;
			pgProp = pg->GetProperty(wxString(s));
			v4.w = pgProp->GetValue().GetDouble();
		}
		else {
			s = prop + "." + "x";
			pgProp = pg->GetProperty(wxString(s));
			v4.x = pgProp->GetValue().GetDouble();
			s = prop + "." + "y";
			pgProp = pg->GetProperty(wxString(s));
			v4.y = pgProp->GetValue().GetDouble();
			s = prop + "." + "z";
			pgProp = pg->GetProperty(wxString(s));
			v4.z = pgProp->GetValue().GetDouble();
			s = prop + "." + "w";
			pgProp = pg->GetProperty(wxString(s));
			v4.w = pgProp->GetValue().GetDouble();
		}
		attribVal->setPropf4((AttributeValues::Float4Property)id, v4);
		break;

	case Enums::MAT3:

		s = prop + "." + "Row0.x";
		pgProp = pg->GetProperty(wxString(s));
		m3.set(0,0, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row0.y";
		pgProp = pg->GetProperty(wxString(s));
		m3.set(0, 1, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row0.z";
		pgProp = pg->GetProperty(wxString(s));
		m3.set(0, 2, pgProp->GetValue().GetDouble());

		s = prop + "." + "Row1.x";
		pgProp = pg->GetProperty(wxString(s));
		m3.set(1, 0, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row1.y";
		pgProp = pg->GetProperty(wxString(s));
		m3.set(1, 1, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row1.z";
		pgProp = pg->GetProperty(wxString(s));
		m3.set(1, 2, pgProp->GetValue().GetDouble());

		s = prop + "." + "Row2.x";
		pgProp = pg->GetProperty(wxString(s));
		m3.set(2, 0, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row2.y";
		pgProp = pg->GetProperty(wxString(s));
		m3.set(2, 1, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row2.z";
		pgProp = pg->GetProperty(wxString(s));
		m3.set(2, 2, pgProp->GetValue().GetDouble());

		attribVal->setPropm3((AttributeValues::Mat3Property)id, m3);
		break;

	case Enums::MAT4:

		s = prop + "." + "Row0.x";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(0, 0, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row0.y";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(0, 1, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row0.z";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(0, 2, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row0.w";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(0, 3, pgProp->GetValue().GetDouble());

		s = prop + "." + "Row1.x";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(1, 0, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row1.y";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(1, 1, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row1.z";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(1, 2, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row1.w";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(1, 3, pgProp->GetValue().GetDouble());

		s = prop + "." + "Row2.x";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(2, 0, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row2.y";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(2, 1, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row2.z";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(2, 2, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row2.w";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(2, 3, pgProp->GetValue().GetDouble());

		s = prop + "." + "Row3.x";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(3, 0, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row3.y";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(3, 1, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row3.z";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(3, 2, pgProp->GetValue().GetDouble());
		s = prop + "." + "Row3.w";
		pgProp = pg->GetProperty(wxString(s));
		m4.set(3, 3, pgProp->GetValue().GetDouble());

		attribVal->setPropm4((AttributeValues::Mat4Property)id, m4);
		break;
	default:
		assert(false && "Missing data type on property manager: updateProp");
	}
}
Ejemplo n.º 10
0
bool 
ToolBar::addVar(const std::string &windowName, const std::string &varLabel,
	const std::string &varType, const std::string &varContext,
	const std::string &component, int id, const std::string def) {

	// window does not exist
	if (m_Windows.count(windowName) == 0)
		return false;

	AttribSet *attrSet = NAU->getAttribs(varType);
	// type is not valid
	if (attrSet == NULL)
		return false;

	Enums::DataType dt;
	int attr;

	attrSet->getPropTypeAndId(component, &dt, &attr);
	// component is invalid
	if (attr == -1)
		return false;

	std::unique_ptr<Attribute> &attribute = NAU->getAttribute(varType, component);
	std::shared_ptr<math::Data> &max = attribute->getMax();
	std::shared_ptr<math::Data> &min = attribute->getMin();

	std::string defLocal = "";
	if (min)
		defLocal += " min=" + Enums::pointerToString(dt, min->getPtr()) + " ";
	if (max)
		defLocal += "max=" + Enums::pointerToString(dt, max->getPtr());

	defLocal = def + defLocal;

	NauVar *clientData = new NauVar();
	clientData->type = varType;
	clientData->context = varContext;
	clientData->component = component;

	m_ClientDataVec.push_back(clientData);

	TwBar *t = m_Windows[windowName].second;

	std::string name = varLabel;
	name.erase(remove_if(name.begin(), name.end(), [](char c) { return !isalpha(c); }), name.end());
	char s[256]; s[0] = '\0';
	if (name != varLabel) {
		sprintf(s, " label='%s' ", varLabel.c_str());
	}
	if (defLocal != "") {
		sprintf(s, "%s%s ", s, defLocal.c_str());
	}
	//else
	//	s[0] = '\0';

	switch (dt)
	{
	case nau::Enums::INT:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), TW_TYPE_INT32, SetIntCallBack, GetIntCallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), TW_TYPE_INT32, NULL, GetIntCallBack, clientData, s) == 1);
		break;
	case nau::Enums::UINT:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), TW_TYPE_UINT32, SetUIntCallBack, GetUIntCallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), TW_TYPE_UINT32, NULL, GetUIntCallBack, clientData, s) == 1);
		break;
	case nau::Enums::UIVEC2:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), UIVec2, SetCallBack, GetUIVec2CallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), UIVec2, NULL, GetUIVec2CallBack, clientData, s) == 1);
		break;
	case nau::Enums::UIVEC3:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), UIVec3, SetCallBack, GetUIVec3CallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), UIVec3, NULL, GetUIVec3CallBack, clientData, s) == 1);
		break;
	case nau::Enums::BOOL:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), TW_TYPE_BOOLCPP, SetBoolCallBack, GetBoolCallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), TW_TYPE_BOOLCPP, NULL, GetBoolCallBack, clientData, s) == 1);
		break;
	case nau::Enums::BVEC4:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), BVec4, SetCallBack, GetBVec4CallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), BVec4, NULL, GetBVec4CallBack, clientData, s) == 1);
		break;
	case nau::Enums::FLOAT:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), TW_TYPE_FLOAT, SetFloatCallBack, GetFloatCallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), TW_TYPE_FLOAT, NULL, GetFloatCallBack, clientData, s) == 1);
		break;
	case nau::Enums::VEC2:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), Vec2, SetCallBack, GetVec2CallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), Vec2, NULL, GetVec2CallBack, clientData, s) == 1);
		break;
	case nau::Enums::VEC3:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), Vec3, SetCallBack, GetVec3CallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), Vec3, NULL, GetVec3CallBack, clientData, s) == 1);
		break;
	case nau::Enums::VEC4:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), Vec4, SetCallBack, GetVec4CallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), Vec4, NULL, GetVec4CallBack, clientData, s) == 1);
		break;
	case nau::Enums::MAT3:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), Mat3, SetCallBack, GetMat3CallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), Mat3, NULL, GetMat3CallBack, clientData, s) == 1);
		break;
	case nau::Enums::MAT4:
		if (attrSet->get(attr, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), Mat4, SetCallBack, GetMat4CallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), Mat4, NULL, GetMat4CallBack, clientData, s) == 1);
		break;
	case nau::Enums::ENUM: 
	{
		const std::vector<std::string> &vs = NAU->getAttribs(varType)->getListString(id);
		const std::vector<int> &vi = NAU->getAttribs(varType)->getListValues(id);
		TwEnumVal *enums;
		enums = (TwEnumVal *)malloc(vi.size() * sizeof(TwEnumVal));
		for (int i = 0; i < vi.size(); ++i) {
			enums[i].Label = vs[i].c_str();
			enums[i].Value = vi[i];
		}
		TwType options = TwDefineEnum(name.c_str(), enums, (unsigned int)vi.size());
		if (attrSet->get(id, dt)->getReadOnlyFlag() == false)
			return (TwAddVarCB(t, name.c_str(), options, SetIntCallBack, GetIntCallBack, clientData, s) == 1);
		else
			return (TwAddVarCB(t, name.c_str(), options, NULL, GetIntCallBack, clientData, s) == 1);
	}
		break;
	default:
		assert(false && "Missing type in ToolBar::addVar");
		return false;
	}
	return true;
}