Files
EgtExecutor/LUA_Scene.cpp
Dario Sassi f90534e36e EgtExecutor :
- aggiunta funzione Exe e Lua GetBackground per colori top e bottom dello sfondo della scena.
2019-09-19 13:48:57 +00:00

276 lines
8.2 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : LUA_Scene.cpp Data : 29.09.14 Versione : 1.5i5
// Contenuto : Funzioni di visualizzazione per LUA.
//
//
//
// Modifiche : 29.09.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "LUA.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGkLuaAux.h"
using namespace std ;
//-------------------------------------------------------------------------------
static int
LuaSetBackground( lua_State* L)
{
// 2 o 3 parametri : colore top, colore bottom [, bRedraw]
Color colTop ;
LuaCheckParam( L, 1, colTop)
Color colBot ;
LuaCheckParam( L, 2, colBot)
bool bRedraw ;
LuaGetParam( L, 3, bRedraw) ;
LuaClearStack( L) ;
// imposto lo sfondo
bool bOk = ExeSetBackground( colTop, colBot, bRedraw) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetBackground( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// recupero lo sfondo
Color colTop ;
Color colBot ;
bool bOk = ExeGetBackground( colTop, colBot) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, colTop) ;
LuaSetParam( L, colBot) ;
}
else {
LuaSetParam( L) ;
LuaSetParam( L) ;
}
return 2 ;
}
//-------------------------------------------------------------------------------
static int
LuaDraw( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// eseguo ridisegno
bool bOk = ExeDraw() ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetShowMode( lua_State* L)
{
// 1 o 2 parametri : nShowMode [, bRedraw]
int nShowMode ;
LuaCheckParam( L, 1, nShowMode)
bool bRedraw = true ;
LuaGetParam( L, 2, bRedraw) ;
LuaClearStack( L) ;
// imposto il modo di visualizzazione
bool bOk = ExeSetShowMode( nShowMode, bRedraw) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetShowCurveDirection( lua_State* L)
{
// 1 o 2 parametri : bool bShowCrvDir [, bRedraw]
bool bShowCrvDir ;
LuaCheckParam( L, 1, bShowCrvDir)
bool bRedraw = true ;
LuaGetParam( L, 2, bRedraw) ;
LuaClearStack( L) ;
// imposto visualizzazione direzione curve
bool bOk = ExeSetShowCurveDirection( bShowCrvDir, bRedraw) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetShowTriaAdv( lua_State* L)
{
// 1 o 2 parametri : flag bAdvanced [, bRedraw]
bool bAdvanced ;
LuaCheckParam( L, 1, bAdvanced)
bool bRedraw = true ;
LuaGetParam( L, 2, bRedraw) ,
LuaClearStack( L) ;
// imposto visualizzazione direzione curve
bool bOk = ExeSetShowTriaAdv( bAdvanced, bRedraw) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaZoomRadius( lua_State* L)
{
// 1 o 2 parametri : dRadius [, bRedraw]
double dRadius ;
LuaCheckParam( L, 1, dRadius)
bool bRedraw = true ;
LuaGetParam( L, 2, bRedraw) ;
LuaClearStack( L) ;
// imposto zoom
bool bOk = ExeZoomRadius( dRadius, bRedraw) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaZoom( lua_State* L)
{
// 1 o 2 parametri : nZoomType [, bRedraw]
int nZoomType ;
LuaCheckParam( L, 1, nZoomType)
bool bRedraw = true ;
LuaGetParam( L, 2, bRedraw) ;
LuaClearStack( L) ;
// imposto zoom
bool bOk = ExeZoom( nZoomType, bRedraw) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaZoomObject( lua_State* L)
{
// 1 o 2 parametri : nId [, bRedraw]
int nId ;
LuaCheckParam( L, 1, nId)
bool bRedraw = true ;
LuaGetParam( L, 2, bRedraw) ;
LuaClearStack( L) ;
// imposto zoom
bool bOk = ExeZoomObject( nId, bRedraw) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetView( lua_State* L)
{
// 1 o 2 parametri : nViewDir [, bRedraw]
int nViewDir ;
LuaCheckParam( L, 1, nViewDir)
bool bRedraw = true ;
LuaGetParam( L, 2, bRedraw) ;
LuaClearStack( L) ;
// imposto direzione di vista
bool bOk = ExeSetView( nViewDir, bRedraw) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetGenericView( lua_State* L)
{
// 2 o 3 parametri : dAngVertDeg, dAngHorizDeg [, bRedraw]
double dAngVertDeg ;
LuaCheckParam( L, 1, dAngVertDeg)
double dAngHorizDeg ;
LuaCheckParam( L, 2, dAngHorizDeg)
bool bRedraw = true ;
LuaGetParam( L, 3, bRedraw) ;
LuaClearStack( L) ;
// imposto direzione di vista
bool bOk = ExeSetGenericView( dAngVertDeg, dAngHorizDeg, bRedraw) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetViewCenter( lua_State* L)
{
// 1 o 2 parametri : ptCen [, bRedraw]
Point3d ptCen ;
LuaCheckParam( L, 1, ptCen)
bool bRedraw = true ;
LuaGetParam( L, 2, bRedraw) ;
LuaClearStack( L) ;
// imposto centro di vista
bool bOk = ExeSetViewCenter( ptCen, bRedraw) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetImage( lua_State* L)
{
// 6 argomenti : nShowMode, colBackTop, colBackBottom, nWidth, nHeight, sFile
int nShowMode ;
LuaCheckParam( L, 1, nShowMode)
Color colBackTop ;
LuaCheckParam( L, 2, colBackTop)
Color colBackBottom ;
LuaCheckParam( L, 3, colBackBottom)
int nWidth ;
LuaCheckParam( L, 4, nWidth)
int nHeight ;
LuaCheckParam( L, 5, nHeight)
string sFile ;
LuaCheckParam( L, 6, sFile)
LuaClearStack( L) ;
// creo e salvo una immagine della scena
bool bOk = ExeGetImage( nShowMode, colBackTop, colBackBottom, nWidth, nHeight, sFile) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallScene( LuaMgr& luaMgr)
{
bool bOk = ( &luaMgr != nullptr) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetBackground", LuaSetBackground) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetBackground", LuaGetBackground) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtDraw", LuaDraw) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetShowMode", LuaSetShowMode) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetShowCurveDirection", LuaSetShowCurveDirection) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetShowTriaAdv", LuaSetShowTriaAdv) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtZoomRadius", LuaZoomRadius) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtZoom", LuaZoom) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtZoomObject", LuaZoomObject) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetView", LuaSetView) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetGenericView", LuaSetGenericView) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetViewCenter", LuaSetViewCenter) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetImage", LuaGetImage) ;
return bOk ;
}