Files
EgtInterface/LUA_GdbModify.cpp
T
Dario Sassi 1e24540dc1 EgtInterface 1.6b2 :
- razionalizzazione
- modificati comandi per creazione superfici per gestione piani di regioni con buchi
- aggiunta SplitCurve.
2015-02-11 11:46:14 +00:00

215 lines
6.0 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : LUA_GdbModify.cpp Data : 06.10.14 Versione : 1.5i5
// Contenuto : Funzioni di modifica geometrica per LUA.
//
//
//
// Modifiche : 06.10.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "LUA.h"
#include "API.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EInConst.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
using namespace std ;
//-------------------------------------------------------------------------------
static int
LuaChangeGroupFrame( lua_State* L)
{
// 2 o 3 parametri : Id, frNewRef [, sRefType]
int nId ;
LuaCheckParam( L, 1, nId)
Frame3d frNewRef ;
LuaCheckParam( L, 2, frNewRef)
int nRefType = RTY_DEFAULT ;
LuaGetRefType( L, 3, nRefType) ;
LuaClearStack( L) ;
// modifica del riferimento
bool bOk = ( EgtChangeGroupFrame( nId, frNewRef, nRefType) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaChangeVectorBase( lua_State* L)
{
// 2 o 3 parametri : Id, ptBase [, sRefType]
int nId ;
LuaCheckParam( L, 1, nId)
Point3d ptBase ;
LuaCheckParam( L, 2, ptBase)
int nRefType = RTY_DEFAULT ;
LuaGetRefType( L, 3, nRefType) ;
LuaClearStack( L) ;
// modifica del punto base
bool bOk = ( EgtChangeVectorBase( nId, ptBase.v, nRefType) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaInvertSurf( lua_State* L)
{
// 1 parametro : Id/s
INTVECTOR vId ;
LuaCheckParam( L, 1, vId)
LuaClearStack( L) ;
// eseguo inversione superfici
bool bOk = true ;
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
if ( EgtInvertSurface( vId[i]) == FALSE)
bOk = false ;
}
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaSurfTmDoSewing( lua_State* L)
{
// 1 o 2 parametri : Id/s [, bErase]
INTVECTOR vId ;
LuaCheckParam( L, 1, vId)
bool bErase = true ;
if ( lua_gettop( L) >= 2)
LuaCheckParam( L, 2, bErase) ;
LuaClearStack( L) ;
// eseguo cucitura superfici
bool bOk = EgtSurfTmDoSewing( vId, bErase) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaModifyText( lua_State* L)
{
// 2 parametri : Id, sNewText
int nId ;
LuaCheckParam( L, 1, nId)
string sNewText ;
LuaCheckParam( L, 2, sNewText)
LuaClearStack( L) ;
// modifica del testo
bool bOk = EgtModifyText( nId, sNewText) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaChangeTextFont( lua_State* L)
{
// 2 parametri : Id, sNewFont
int nId ;
LuaCheckParam( L, 1, nId)
string sNewFont ;
LuaCheckParam( L, 2, sNewFont)
LuaClearStack( L) ;
// modifica del testo
bool bOk = EgtChangeTextFont( nId, sNewFont) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaFlipText( lua_State* L)
{
// 1 parametro : Id
int nId ;
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// flip del testo
bool bOk = ( EgtFlipText( nId) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaMirrorText( lua_State* L)
{
// 1 o 2 parametri : Id [, sOnL]
int nId ;
LuaCheckParam( L, 1, nId)
bool bOnL = true ;
if ( lua_gettop( L) >= 2) {
string sLorH ;
LuaCheckParam( L, 2, sLorH) ;
ToUpper( sLorH) ;
if ( sLorH == "H")
bOnL = false ;
}
LuaClearStack( L) ;
// flip del testo
bool bOk = ( EgtMirrorText( nId, bOnL) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaExplodeText( lua_State* L)
{
// 1 parametro : Id
int nId ;
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// esplosione del testo
bool bOk = ( EgtExplodeText( nId) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSplitText( lua_State* L)
{
// 1 parametro : Id
int nId ;
LuaCheckParam( L, 1, nId)
LuaClearStack( L) ;
// esplosione del testo in più testi, uno per riga
bool bOk = ( EgtSplitText( nId) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbModify( lua_State* L)
{
try {
lua_register( L, "EgtChangeGroupFrame", LuaChangeGroupFrame) ;
lua_register( L, "EgtChangeVectorBase", LuaChangeVectorBase) ;
lua_register( L, "EgtInvertSurf", LuaInvertSurf) ;
lua_register( L, "EgtSurfTmDoSewing", LuaSurfTmDoSewing) ;
lua_register( L, "EgtModifyText", LuaModifyText) ;
lua_register( L, "EgtChangeTextFont", LuaChangeTextFont) ;
lua_register( L, "EgtFlipText", LuaFlipText) ;
lua_register( L, "EgtMirrorText", LuaMirrorText) ;
lua_register( L, "EgtExplodeText", LuaExplodeText) ;
lua_register( L, "EgtSplitText", LuaSplitText) ;
}
catch ( ...) {
return false ;
}
return true ;
}