Files
EgtExecutor/LUA_GdbCreate.cpp
T
Dario Sassi 966885645e EgtExecutor 1.6e2 :
- primo rilascio (esecutore e lua da EgtInterface).
2015-05-05 22:14:04 +00:00

243 lines
7.2 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : LUA_GdbCreate.cpp Data : 30.09.14 Versione : 1.5i5
// Contenuto : Funzioni di creazione geometrica per LUA.
//
//
//
// Modifiche : 30.09.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "LUA.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGkLuaAux.h"
#include "/EgtDev/Include/EGnStringUtils.h"
using namespace std ;
//-------------------------------------------------------------------------------
static int
LuaCreateGroup( lua_State* L)
{
// 1 o 2 o 3 parametri : ParentId [, Frame] [, nRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Frame3d frFrame ;
int nRefType = RTY_DEFAULT ;
if ( LuaGetParam( L, 2, frFrame))
LuaGetParam( L, 3, nRefType) ;
else
LuaGetParam( L, 2, nRefType) ;
LuaClearStack( L) ;
// creo il gruppo
int nId = ExeCreateGroup( nParentId, frFrame, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateGeoPoint( lua_State* L)
{
// 2 o 3 parametri : ParentId, PtP [, nRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Point3d ptP ;
LuaCheckParam( L, 2, ptP)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 3, nRefType) ;
LuaClearStack( L) ;
// creo il punto
int nId = ExeCreateGeoPoint( nParentId, ptP, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateGeoVector( lua_State* L)
{
// 2 o 3 o 4 parametri : ParentId, VtV [, PtB] [, nRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Vector3d vtV ;
LuaCheckParam( L, 2, vtV)
Point3d ptB ;
int nRefType = RTY_DEFAULT ;
if ( LuaGetParam( L, 3, ptB))
LuaGetParam( L, 4, nRefType) ;
else
LuaGetParam( L, 3, nRefType) ;
LuaClearStack( L) ;
// creo il vettore
int nId = ExeCreateGeoVector( nParentId, vtV, ptB, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateGeoFrame( lua_State* L)
{
// 2 o 3 parametri : ParentId, Frame [, nRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Frame3d frFrame ;
LuaCheckParam( L, 2, frFrame) ;
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 3, nRefType) ;
LuaClearStack( L) ;
// creo il gruppo
int nId = ExeCreateGeoFrame( nParentId, frFrame, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateText( lua_State* L)
{
// 5 o 6 parametri : ParentId, ptP, AngRotDeg, Text, H [, nRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Point3d ptP ;
LuaCheckParam( L, 2, ptP) ;
double dAngRotDeg ;
LuaCheckParam( L, 3, dAngRotDeg) ;
string sText ;
LuaCheckParam( L, 4, sText)
double dH ;
LuaCheckParam( L, 5, dH) ;
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 6, nRefType) ;
LuaClearStack( L) ;
// creo il testo
int nId = ExeCreateText( nParentId, ptP, dAngRotDeg, sText, dH, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateTextEx( lua_State* L)
{
// 8 o 9 parametri : ParentId, ptP, vtN, vtD, Text, Font, bItalic, H [, nRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Point3d ptP ;
LuaCheckParam( L, 2, ptP) ;
Vector3d vtN ;
LuaCheckParam( L, 3, vtN) ;
Vector3d vtD ;
LuaCheckParam( L, 4, vtD) ;
string sText ;
LuaCheckParam( L, 5, sText)
string sFont ;
LuaCheckParam( L, 6, sFont) ;
string sItalic ;
LuaCheckParam( L, 7, sItalic)
ToUpper( sItalic) ;
bool bItalic = ( sItalic == "I") ;
double dH ;
LuaCheckParam( L, 8, dH) ;
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 9, nRefType) ;
LuaClearStack( L) ;
// creo il testo in modo esteso
int nId = ExeCreateTextEx( nParentId, ptP, vtN, vtD, sText, sFont, bItalic, dH, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateTextAdv( lua_State* L)
{
// 12 o 13 parametri : ParentId, ptP, vtN, vtD, Text, Font, W, sItalic, H, Rat, AddAdv, InsPos [, nRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
Point3d ptP ;
LuaCheckParam( L, 2, ptP) ;
Vector3d vtN ;
LuaCheckParam( L, 3, vtN) ;
Vector3d vtD ;
LuaCheckParam( L, 4, vtD) ;
string sText ;
LuaCheckParam( L, 5, sText)
string sFont ;
LuaCheckParam( L, 6, sFont)
int nW ;
LuaCheckParam( L, 7, nW)
string sItalic ;
LuaCheckParam( L, 8, sItalic)
ToUpper( sItalic) ;
bool bItalic = ( sItalic == "I") ;
double dH ;
LuaCheckParam( L, 9, dH)
double dRat ;
LuaCheckParam( L, 10, dRat)
double dAddAdv ;
LuaCheckParam( L, 11, dAddAdv)
int nInsPos ;
LuaCheckParam( L, 12, nInsPos)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 13, nRefType) ;
LuaClearStack( L) ;
// creo il testo in modo avanzato
int nId = ExeCreateTextAdv( nParentId, ptP, vtN, vtD,
sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbCreate( LuaMgr& luaMgr)
{
bool bOk = ( &luaMgr != nullptr) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGroup", LuaCreateGroup) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtPoint", LuaCreateGeoPoint) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVector", LuaCreateGeoVector) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtFrame", LuaCreateGeoFrame) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtText", LuaCreateText) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTextEx", LuaCreateTextEx) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTextAdv", LuaCreateTextAdv) ;
return bOk ;
}