int LuaPeak::setLabel(lua_State *L) { Peak* obj = RefBinding<Peak>::check( L, 1); const char* str = ""; if( lua_gettop(L) > 1 ) str = luaL_checkstring( L, 2 ); obj->getOwner()->setTag( obj, str ); return 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; }
int LuaPeak::setModel(lua_State *L) { Peak* obj = RefBinding<Peak>::check( L, 1); const int n = lua_gettop(L); /* number of arguments */ int id = 0; if( n > 1 ) id = luaL_checknumber( L, 2 ); Spectrum* spec = 0; if( n > 2 ) { spec = RefBinding<Spectrum>::cast( L, 3 ); } obj->getOwner()->setModel( obj, id, spec ); return 0; }
int LuaPeak::setAmp(lua_State *L) { Peak* obj = RefBinding<Peak>::check( L, 1); int n = lua_gettop(L); /* number of arguments */ Amplitude a = 0; if( n > 1 ) a = luaL_checknumber( L, 2 ); Spectrum* spec = 0; if( n > 2 ) { spec = RefBinding<Spectrum>::cast( L, 3 ); } obj->getOwner()->setAmp( obj, a, spec ); return 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; }
int LuaPeak::setGuess(lua_State *L) { Peak* obj = RefBinding<Peak>::check( L, 1); int n = lua_gettop(L); /* number of arguments */ Peak::Guess* g = RefBinding<Peak::Guess>::check( L, 2 ); float f = 0.0; Peak::Assig a; if( n > 2 ) { f = luaL_checknumber( L, 3 ); if( f < 0.0 || f > 1.0 ) luaL_error( L, "Invalid probability value" ); const int off = 4; for( int i = off; i <= n; i++ ) { if( i - off >= Peak::Assig::MAX_DIM ) luaL_error( L, "Invalid number of dimensions" ); a[ i - off ] = luaL_checknumber( L, i ); } } obj->getOwner()->setGuess( obj, g->getId(), a, f ); return 0; }
int LuaPeak::setColor(lua_State *L) { Peak* obj = RefBinding<Peak>::check( L, 1); obj->getOwner()->setColor( obj, luaL_checknumber( L, 2 ) ); return 0; }