Esempio n. 1
0
int LuaPeak::getAssig(lua_State *L)
{
	Peak* obj = RefBinding<Peak>::check( L, 1);
	const Peak::Assig& a = obj->getAssig();
	{
		for( int i = 0; i < obj->getDimCount(); i++ )
			lua_pushnumber( L, a[ i ] );
	}
	return obj->getDimCount();
}
Esempio n. 2
0
int LuaPeak::setAssig(lua_State *L)
{
	Peak* obj = RefBinding<Peak>::check( L, 1);
	const int n = lua_gettop(L);  /* number of arguments */
	if( n != ( obj->getDimCount() + 1 ) )
		luaL_error( L, "Expecting %d arguments", int( obj->getDimCount() + 1 ) );
	Peak::Assig a;
	for( int i = 2; i <= n; i++ )
		a[ i-1 ] = luaL_checknumber( L, i ); // TEST
	obj->getOwner()->setAssig( obj, a );
	return 0;
}
Esempio n. 3
0
int LuaPeak::getPos(lua_State *L)
{
	Peak* obj = RefBinding<Peak>::check( L, 1);
	Spectrum* spec = 0;
	if( lua_gettop( L ) > 1 )
	{
		spec = RefBinding<Spectrum>::cast( L, 2 );
	}
	const PeakPos& a = obj->getPos( spec );
	for( int i = 0; i < obj->getDimCount(); i++ )
		lua_pushnumber( L, a[ i ] );
	return obj->getDimCount();
}
Esempio n. 4
0
int LuaPeak::setPos(lua_State *L)
{
	Peak* obj = RefBinding<Peak>::check( L, 1);
	const int n = lua_gettop(L);  /* number of arguments */
	const int dim = obj->getDimCount();
	if( n < dim + 1 )
		luaL_error( L, "Expecting at least %d arguments", dim );
	PpmPoint a;
	for( int i = 1; i <= dim; i++ )
		a.push_back( luaL_checknumber( L, i + 1 ) );
	Spectrum* spec = 0;
	if( n > ( dim + 1 ) )
	{
		spec = RefBinding<Spectrum>::cast( L, n );
	}
	obj->getOwner()->setPos( obj, a, spec );
	return 0;
}