966885645e
- primo rilascio (esecutore e lua da EgtInterface).
187 lines
5.5 KiB
C++
187 lines
5.5 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : LUA_General.cpp Data : 27.09.14 Versione : 1.5i5
|
|
// Contenuto : Funzioni generali per LUA.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 27.09.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "LUA.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EGkGdbConst.h"
|
|
#include "/EgtDev/Include/EGkLuaAux.h"
|
|
|
|
using namespace std ;
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaSetDefaultMaterial( lua_State* L)
|
|
{
|
|
// un solo parametro, il colore
|
|
Color colDef ;
|
|
if ( ! LuaGetParam( L, 1, colDef))
|
|
return luaL_error( L, "Invalide first parameter") ;
|
|
LuaClearStack( L) ;
|
|
// imposto il colore di default
|
|
int vCol[4] ;
|
|
colDef.GetInt( vCol) ;
|
|
bool bOk = ( ExeSetDefaultMaterial( vCol) != FALSE) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaSetGridFrame( lua_State* L)
|
|
{
|
|
// 1 parametro : Frame
|
|
Frame3d frFrame ;
|
|
LuaCheckParam( L, 1, frFrame) ;
|
|
LuaClearStack( L) ;
|
|
// imposto il riferimento della Griglia (o CPlane)
|
|
bool bOk = ( ExeSetGridFrame( frFrame)) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetGridFrame( lua_State* L)
|
|
{
|
|
// 1 o nessun parametro : [nRefId]
|
|
int nRefId = GDB_ID_ROOT ;
|
|
if ( lua_gettop( L) >= 1)
|
|
LuaCheckParam( L, 1, nRefId)
|
|
LuaClearStack( L) ;
|
|
// recupero il riferimento della griglia
|
|
Frame3d frFrame ;
|
|
ExeGetGridFrame( nRefId, frFrame) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, frFrame) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetGridVersZ( lua_State* L)
|
|
{
|
|
// 1 o nessun parametro : [nRefId]
|
|
int nRefId = GDB_ID_ROOT ;
|
|
if ( lua_gettop( L) >= 1)
|
|
LuaCheckParam( L, 1, nRefId)
|
|
LuaClearStack( L) ;
|
|
// recupero il versore Z della griglia e lo restituisco
|
|
Vector3d vtVersZ ;
|
|
if ( ExeGetGridVersZ( nRefId, vtVersZ))
|
|
LuaSetReturn( L, vtVersZ) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaNewFile( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// nuovo progetto
|
|
bool bOk = ExeNewFile() ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaOpenFile( lua_State* L)
|
|
{
|
|
// 1 parametro : path del file da aprire
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ExeOpenFile( sFilePath) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaInsertFile( lua_State* L)
|
|
{
|
|
// 1 parametro : path del file da importare
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
LuaClearStack( L) ;
|
|
// apro il file
|
|
bool bOk = ExeInsertFile( sFilePath) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaSaveFile( lua_State* L)
|
|
{
|
|
// 1 o 2 parametri : path del file [, flag]
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 1, sFilePath)
|
|
int nFlag = GDB_SV_CMPTXT ;
|
|
LuaGetParam( L, 2, nFlag) ;
|
|
LuaClearStack( L) ;
|
|
// salvo il file
|
|
bool bOk = ExeSaveFile( sFilePath, nFlag) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaSaveObjToFile( lua_State* L)
|
|
{
|
|
// 2 o 3 parametri : nId, path del file [, flag]
|
|
int nId ;
|
|
LuaCheckParam( L, 1, nId)
|
|
string sFilePath ;
|
|
LuaCheckParam( L, 2, sFilePath)
|
|
int nFlag = GDB_SV_CMPTXT ;
|
|
LuaGetParam( L, 3, nFlag) ;
|
|
LuaClearStack( L) ;
|
|
// copio il gruppo nel file
|
|
bool bOk = ExeSaveObjToFile( nId, sFilePath, nFlag) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
LuaInstallGeomDB( LuaMgr& luaMgr)
|
|
{
|
|
bool bOk = ( &luaMgr != nullptr) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSetDefaultMaterial", LuaSetDefaultMaterial) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSetGridFrame", LuaSetGridFrame) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetGridFrame", LuaGetGridFrame) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetGridVersZ", LuaGetGridVersZ) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtNewFile", LuaNewFile) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtOpenFile", LuaOpenFile) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtInsertFile", LuaInsertFile) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSaveFile", LuaSaveFile) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSaveObjToFile", LuaSaveObjToFile) ;
|
|
return bOk ;
|
|
}
|