6131010957
- aggiunte funzioni Exe e Lua SetCurrDimensionStyle e ResetCurrDimensionStyle.
366 lines
11 KiB
C++
366 lines
11 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)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( 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)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( 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)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( 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)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateText( lua_State* L)
|
|
{
|
|
// 4 o 5 parametri : ParentId, ptP, Text, H [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptP ;
|
|
LuaCheckParam( L, 2, ptP) ;
|
|
string sText ;
|
|
LuaCheckParam( L, 3, sText)
|
|
double dH ;
|
|
LuaCheckParam( L, 4, dH) ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo il testo
|
|
int nId = ExeCreateText( nParentId, ptP, sText, dH, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateTextEx( lua_State* L)
|
|
{
|
|
// 7 o 8 parametri : ParentId, ptP, dAngRotDeg, Text, Font, bItalic, 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)
|
|
string sFont ;
|
|
LuaCheckParam( L, 5, sFont) ;
|
|
string sItalic ;
|
|
LuaCheckParam( L, 6, sItalic)
|
|
ToUpper( sItalic) ;
|
|
bool bItalic = ( sItalic == "I") ;
|
|
double dH ;
|
|
LuaCheckParam( L, 7, dH) ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 8, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo il testo in modo esteso
|
|
int nId = ExeCreateTextEx( nParentId, ptP, dAngRotDeg, sText, sFont, bItalic, dH, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateTextAdv( lua_State* L)
|
|
{
|
|
// 11 o 12 parametri : ParentId, ptP, dAngRotDeg, Text, Font, W, sItalic, H, Rat, AddAdv, InsPos [, 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)
|
|
string sFont ;
|
|
LuaCheckParam( L, 5, sFont)
|
|
int nW ;
|
|
LuaCheckParam( L, 6, nW)
|
|
string sItalic ;
|
|
LuaCheckParam( L, 7, sItalic)
|
|
ToUpper( sItalic) ;
|
|
bool bItalic = ( sItalic == "I") ;
|
|
double dH ;
|
|
LuaCheckParam( L, 8, dH)
|
|
double dRat ;
|
|
LuaCheckParam( L, 9, dRat)
|
|
double dAddAdv ;
|
|
LuaCheckParam( L, 10, dAddAdv)
|
|
int nInsPos ;
|
|
LuaCheckParam( L, 11, nInsPos)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 12, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo il testo in modo avanzato
|
|
int nId = ExeCreateTextAdv( nParentId, ptP, dAngRotDeg,
|
|
sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaSetCurrDimensionStyle( lua_State* L)
|
|
{
|
|
// 7 parametri : dExtLineLen, dArrowLen, dTextDist, nLenIsMM, nDecDigit, sFont, dTextHeight
|
|
double dExtLineLen ;
|
|
LuaCheckParam( L, 1, dExtLineLen)
|
|
double dArrowLen ;
|
|
LuaCheckParam( L, 2, dArrowLen)
|
|
double dTextDist ;
|
|
LuaCheckParam( L, 3, dTextDist)
|
|
int nLenIsMM ;
|
|
LuaCheckParam( L, 4, nLenIsMM)
|
|
int nDecDigit ;
|
|
LuaCheckParam( L, 5, nDecDigit)
|
|
string sFont ;
|
|
LuaCheckParam( L, 6, sFont)
|
|
double dTextHeight ;
|
|
LuaCheckParam( L, 7, dTextHeight)
|
|
LuaClearStack( L) ;
|
|
// imposto lo stile di quotatura corrente (per il contesto corrente)
|
|
bool bOk = ExeSetCurrDimensionStyle( dExtLineLen, dArrowLen, dTextDist, nLenIsMM, nDecDigit, sFont, dTextHeight) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaResetCurrDimensionStyle( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// resetto lo stile di quotatura corrente (per il contesto corrente)
|
|
bool bOk = ExeResetCurrDimensionStyle() ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateHorizontalDimension( lua_State* L)
|
|
{
|
|
// 5 o 6 parametri : ParentId, ptP1, ptP2, ptDim, Text [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptP1 ;
|
|
LuaCheckParam( L, 2, ptP1) ;
|
|
Point3d ptP2 ;
|
|
LuaCheckParam( L, 3, ptP2) ;
|
|
Point3d ptDim ;
|
|
LuaCheckParam( L, 4, ptDim) ;
|
|
string sText ;
|
|
LuaCheckParam( L, 5, sText) ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 6, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo la quota orizzontale
|
|
int nId = ExeCreateHorizontalDimension( nParentId, ptP1, ptP2, ptDim, sText, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateVerticalDimension( lua_State* L)
|
|
{
|
|
// 5 o 6 parametri : ParentId, ptP1, ptP2, ptDim, Text [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptP1 ;
|
|
LuaCheckParam( L, 2, ptP1) ;
|
|
Point3d ptP2 ;
|
|
LuaCheckParam( L, 3, ptP2) ;
|
|
Point3d ptDim ;
|
|
LuaCheckParam( L, 4, ptDim) ;
|
|
string sText ;
|
|
LuaCheckParam( L, 5, sText) ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 6, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo la quota verticale
|
|
int nId = ExeCreateVerticalDimension( nParentId, ptP1, ptP2, ptDim, sText, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaCreateAlignedDimension( lua_State* L)
|
|
{
|
|
// 5 o 6 parametri : ParentId, ptP1, ptP2, ptDim, Text [, nRefType]
|
|
int nParentId ;
|
|
LuaCheckParam( L, 1, nParentId)
|
|
Point3d ptP1 ;
|
|
LuaCheckParam( L, 2, ptP1) ;
|
|
Point3d ptP2 ;
|
|
LuaCheckParam( L, 3, ptP2) ;
|
|
Point3d ptDim ;
|
|
LuaCheckParam( L, 4, ptDim) ;
|
|
string sText ;
|
|
LuaCheckParam( L, 5, sText) ;
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 6, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// creo la quota allineata
|
|
int nId = ExeCreateAlignedDimension( nParentId, ptP1, ptP2, ptDim, sText, nRefType) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( 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) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSetCurrDimensionStyle", LuaSetCurrDimensionStyle) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtResetCurrDimensionStyle", LuaResetCurrDimensionStyle) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtHorizontalDimension", LuaCreateHorizontalDimension) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtVerticalDimension", LuaCreateVerticalDimension) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtAlignedDimension", LuaCreateAlignedDimension) ;
|
|
return bOk ;
|
|
}
|