Files
EgtExecutor/LUA_GdbObjSelection.cpp
Dario Sassi 1917a21a7c EgtExecutor 2.1h2 :
- aggiunte funzioni ExeSetSelInfo, ExeGetLastSelInfo e ExeGetPrevSelInfo
- aggiunte funzioni lua EgtGetLastSelInfo, EgtGetPrevSelInfo e EgtSurfTmFacetFromTria.
2019-08-29 08:59:52 +00:00

299 lines
8.6 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : LUA_GdbObjSelection.cpp Data : 08.01.15 Versione : 1.6a1
// Contenuto : Funzioni di selezione oggetti del DB geometrico per LUA.
//
//
//
// Modifiche : 08.01.15 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
LuaSetObjFilterForSelect( lua_State* L)
{
// 5 parametri : bZerodim, bCurve, bSurf, bVolume, bExtra
bool bZerodim ;
LuaCheckParam( L, 1, bZerodim)
bool bCurve ;
LuaCheckParam( L, 2, bCurve)
bool bSurf ;
LuaCheckParam( L, 3, bSurf)
bool bVolume ;
LuaCheckParam( L, 4, bVolume)
bool bExtra ;
LuaCheckParam( L, 5, bExtra)
LuaClearStack( L) ;
// eseguo la selezione
bool bOk = ExeSetObjFilterForSelect( bZerodim, bCurve, bSurf, bVolume, bExtra) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSelectObj( lua_State* L)
{
// 1 parametro : Id
int nId ;
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// eseguo la selezione
bool bOk = ExeSelectObj( nId) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaDeselectObj( lua_State* L)
{
// 1 parametro : Id
int nId ;
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// eseguo la selezione
bool bOk = ExeDeselectObj( nId) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSelectAll( lua_State* L)
{
// 1 parametro : bOnlyIfVisible
bool bOnlyIfVisible ;
LuaCheckParam( L, 1, bOnlyIfVisible)
LuaClearStack( L) ;
// eseguo la selezione
bool bOk = ExeSelectAll( bOnlyIfVisible) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaDeselectAll( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// eseguo la selezione
bool bOk = ExeDeselectAll() ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSelectGroupObjs( lua_State* L)
{
// 1 parametro : GroupId
int GroupId ;
LuaCheckParam( L, 1, GroupId)
LuaClearStack( L) ;
// eseguo la selezione
bool bOk = ExeSelectGroupObjs( GroupId) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaDeselectGroupObjs( lua_State* L)
{
// 1 parametro : GroupId
int GroupId ;
LuaCheckParam( L, 1, GroupId)
LuaClearStack( L) ;
// eseguo la deselezione
bool bOk = ExeDeselectGroupObjs( GroupId) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaIsSelectedObj( lua_State* L)
{
// 1 parametro : Id
int nId ;
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// eseguo la selezione
bool bOk = ExeIsSelectedObj( nId) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetSelectedObjCount( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// eseguo la selezione
int nNbr = ExeGetSelectedObjCount() ;
// restituisco il risultato
LuaSetParam( L, nNbr) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetFirstSelectedObj( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// recupero il primo oggetto selezionato
int nId = ExeGetFirstSelectedObj() ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetNextSelectedObj( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// recupero il successivo oggetto selezionato
int nId = ExeGetNextSelectedObj() ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetLastSelectedObj( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// recupero l'ultimo oggetto selezionato
int nId = ExeGetLastSelectedObj() ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetPrevSelectedObj( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// recupero il precedente oggetto selezionato
int nId = ExeGetPrevSelectedObj() ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetLastSelInfo( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// recupero le informazioni di selezione sull'ultimo oggetto selezionato
int nLastId ;
int nLastSub ;
Point3d ptLastSel ;
bool bOk = ExeGetLastSelInfo( nLastId, nLastSub, ptLastSel) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, nLastId) ;
LuaSetParam( L, nLastSub) ;
LuaSetParam( L, ptLastSel) ;
}
else {
LuaSetParam( L) ;
LuaSetParam( L) ;
LuaSetParam( L) ;
}
return 3 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetPrevSelInfo( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// recupero le informazioni di selezione sul penultimo oggetto selezionato
int nPrevId ;
int nPrevSub ;
Point3d ptPrevSel ;
bool bOk = ExeGetPrevSelInfo( nPrevId, nPrevSub, ptPrevSel) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, nPrevId) ;
LuaSetParam( L, nPrevSub) ;
LuaSetParam( L, ptPrevSel) ;
}
else {
LuaSetParam( L) ;
LuaSetParam( L) ;
LuaSetParam( L) ;
}
return 3 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbObjSelection( LuaMgr& luaMgr)
{
bool bOk = ( &luaMgr != nullptr) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetObjFilterForSelect", LuaSetObjFilterForSelect) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSelectObj", LuaSelectObj) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtDeselectObj", LuaDeselectObj) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSelectAll", LuaSelectAll) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtDeselectAll", LuaDeselectAll) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSelectGroupObjs", LuaSelectGroupObjs) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtDeselectGroupObjs", LuaDeselectGroupObjs) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtIsSelectedObj", LuaIsSelectedObj) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetSelectedObjCount", LuaGetSelectedObjCount) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstSelectedObj", LuaGetFirstSelectedObj) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextSelectedObj", LuaGetNextSelectedObj) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetLastSelectedObj", LuaGetLastSelectedObj) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetPrevSelectedObj", LuaGetPrevSelectedObj) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetLastSelInfo", LuaGetLastSelInfo) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetPrevSelInfo", LuaGetPrevSelInfo) ;
return bOk ;
}