fd718143e6
- in Lua in tutte le operazioni con creazione di più entità restituisco Id prima e numero - in Lua aggiunto oggetto BBox3d (non ancora con tutte le funzionalità) - in Lua aggiunta creazione superficie da BBox3d - in Lua aggiunte funzioni per avere BBox3d di oggetti - in Lua aggiunta OutBox - in Lua aggiunte funzioni per MachMgr.
436 lines
13 KiB
C++
436 lines
13 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : LUA_MachMgr.cpp Data : 24.03.15 Versione : 1.6c8
|
|
// Contenuto : Funzioni Machining Manager per LUA.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 24.03.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "API.h"
|
|
#include "LUA.h"
|
|
#include "LUA_Base.h"
|
|
#include "LUA_Aux.h"
|
|
#include "AuxTools.h"
|
|
#include "/EgtDev/Include/EInAPI.h"
|
|
#include "/EgtDev/Include/EgnStringUtils.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetMachGroupNbr( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// recupero il numero di macchinate
|
|
int nTot = EgtGetMachGroupNbr() ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, nTot) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetFirstMachGroup( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// recupero l'identificativo della prima macchinata
|
|
int nId = EgtGetFirstMachGroup() ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, nId) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetNextMachGroup( lua_State* L)
|
|
{
|
|
// 1 parametro : identificativo di una macchinata
|
|
int nId ;
|
|
LuaCheckParam( L, 1, nId)
|
|
LuaClearStack( L) ;
|
|
// recupero l'identificativo della successiva macchinata
|
|
int nNextId = EgtGetNextMachGroup( nId) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, nNextId) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddMachGroup( lua_State* L)
|
|
{
|
|
// 2 parametri : nome del gruppo, nome della macchina da utilizzare
|
|
string sName ;
|
|
LuaCheckParam( L, 1, sName)
|
|
string sMachineName ;
|
|
LuaCheckParam( L, 2, sMachineName)
|
|
LuaClearStack( L) ;
|
|
// aggiungo la macchinata
|
|
int nId = EgtAddMachGroup( sName, sMachineName) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, nId) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRemoveMachGroup( lua_State* L)
|
|
{
|
|
// 1 parametro : identificativo del gruppo
|
|
int nMGroupInd ;
|
|
LuaCheckParam( L, 1, nMGroupInd)
|
|
LuaClearStack( L) ;
|
|
// rimuovo la macchinata
|
|
bool bOk = ( EgtRemoveMachGroup( nMGroupInd) != FALSE) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetMachGroupName( lua_State* L)
|
|
{
|
|
// 1 parametro : identificativo del gruppo
|
|
int nMGroupInd ;
|
|
LuaCheckParam( L, 1, nMGroupInd)
|
|
LuaClearStack( L) ;
|
|
// recupero il nome della macchinata
|
|
string sName ;
|
|
bool bOk = EgtGetMachGroupName( nMGroupInd, sName) ;
|
|
// restituisco il risultato
|
|
if ( bOk)
|
|
LuaSetReturn( L, sName) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetMachGroupId( lua_State* L)
|
|
{
|
|
// 1 parametro : nome del gruppo
|
|
string sGroupName ;
|
|
LuaCheckParam( L, 1, sGroupName)
|
|
LuaClearStack( L) ;
|
|
// recupero l'identificativo della macchinata
|
|
int nId = EgtGetMachGroupId( sGroupName) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaSetCurrMachGroup( lua_State* L)
|
|
{
|
|
// 1 parametro : identificativo del gruppo
|
|
int nMGroupInd ;
|
|
LuaCheckParam( L, 1, nMGroupInd)
|
|
LuaClearStack( L) ;
|
|
// imposto il gruppo corrente
|
|
bool bOk = ( EgtSetCurrMachGroup( nMGroupInd) != FALSE) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaResetCurrMachGroup( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// imposto il gruppo corrente
|
|
bool bOk = ( EgtResetCurrMachGroup() != FALSE) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetCurrMachGroup( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// recupero l'identificativo del gruppo corrente
|
|
int nId = EgtGetCurrMachGroup() ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddRawPart( lua_State* L)
|
|
{
|
|
// 5 parametri : Pto origine, dWidth, dLen, dH, Color
|
|
Point3d ptOrig ;
|
|
LuaCheckParam( L, 1, ptOrig)
|
|
double dWidth ;
|
|
LuaCheckParam( L, 2, dWidth)
|
|
double dLength ;
|
|
LuaCheckParam( L, 3, dLength)
|
|
double dHeight ;
|
|
LuaCheckParam( L, 4, dHeight)
|
|
Color cCol ;
|
|
LuaCheckParam( L, 5, cCol)
|
|
LuaClearStack( L) ;
|
|
// inserisco il grezzo nella macchinata corrente
|
|
int nInd = EgtAddRawPart( ptOrig, dWidth, dLength, dHeight, cCol) ;
|
|
// restituisco il risultato
|
|
if ( nInd != GDB_ID_NULL)
|
|
LuaSetReturn( L, nInd) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddRawPartWithPart( lua_State* L)
|
|
{
|
|
// 4 parametri : nPartId, nCrvId, dOverMat, Color
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
int nCrvId ;
|
|
LuaCheckParamDef( L, 2, nCrvId, GDB_ID_NULL)
|
|
double dOverMat ;
|
|
LuaCheckParam( L, 3, dOverMat)
|
|
Color cCol ;
|
|
LuaCheckParam( L, 4, cCol)
|
|
LuaClearStack( L) ;
|
|
// inserisco il grezzo nella macchinata corrente
|
|
int nInd = EgtAddRawPartWithPart( nPartId, nCrvId, dOverMat, cCol) ;
|
|
// restituisco il risultato
|
|
if ( nInd != GDB_ID_NULL)
|
|
LuaSetReturn( L, nInd) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddPartToRawPart( lua_State* L)
|
|
{
|
|
// 3 parametri : nPartId, ptPos, nRawId
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
Point3d ptPos ;
|
|
LuaCheckParam( L, 2, ptPos)
|
|
int nRawId ;
|
|
LuaCheckParam( L, 3, nRawId)
|
|
LuaClearStack( L) ;
|
|
// inserisco il grezzo nella macchinata corrente
|
|
bool bOk = EgtAddPartToRawPart( nPartId, ptPos, nRawId) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaModifyRawPartHeight( lua_State* L)
|
|
{
|
|
// 2 parametri : nRawId, dHeight
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
double dHeight ;
|
|
LuaCheckParam( L, 2, dHeight)
|
|
LuaClearStack( L) ;
|
|
// modifico lo spessore del grezzo
|
|
bool bOk = EgtModifyRawPartHeight( nRawId, dHeight) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRemoveRawPart( lua_State* L)
|
|
{
|
|
// 1 parametro : nRawId
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
LuaClearStack( L) ;
|
|
// elimino il grezzo dalla macchinata corrente
|
|
bool bOk = EgtRemoveRawPart( nRawId) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaTranslateRawPart( lua_State* L)
|
|
{
|
|
// 2 parametri : nRawId, vtMove
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
Vector3d vtMove ;
|
|
LuaCheckParam( L, 2, vtMove)
|
|
LuaClearStack( L) ;
|
|
// traslo il grezzo
|
|
bool bOk = EgtTranslateRawPart( nRawId, vtMove) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRotateRawPart( lua_State* L)
|
|
{
|
|
// 3 parametri : nRawId, vtAx, dAngRotDeg
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
Vector3d vtAx ;
|
|
LuaCheckParam( L, 2, vtAx)
|
|
double dAngRotDeg ;
|
|
LuaCheckParam( L, 3, dAngRotDeg)
|
|
LuaClearStack( L) ;
|
|
// ruoto il grezzo
|
|
bool bOk = EgtRotateRawPart( nRawId, vtAx, dAngRotDeg) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaMoveToCornerRawPart( lua_State* L)
|
|
{
|
|
// 3 parametri : nRawId, ptCorner, nFlag
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
Point3d ptCorner ;
|
|
LuaCheckParam( L, 2, ptCorner)
|
|
string sFlag ;
|
|
LuaCheckParam( L, 3, sFlag)
|
|
LuaClearStack( L) ;
|
|
// sposto il grezzo nel corner
|
|
bool bOk = EgtMoveToCornerRawPart( nRawId, ptCorner, StringToRawPartCornerPos( sFlag)) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaMoveToCenterRawPart( lua_State* L)
|
|
{
|
|
// 3 parametri : nRawId, ptCenter, nFlag
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
Point3d ptCenter ;
|
|
LuaCheckParam( L, 2, ptCenter)
|
|
string sFlag ;
|
|
LuaCheckParam( L, 3, sFlag)
|
|
LuaClearStack( L) ;
|
|
// sposto il grezzo nel corner
|
|
bool bOk = EgtMoveToCenterRawPart( nRawId, ptCenter, StringToRawPartCenterPos( sFlag)) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRemovePartFromRawPart( lua_State* L)
|
|
{
|
|
// 1 parametro : nPartId
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
LuaClearStack( L) ;
|
|
// elimino il grezzo dalla macchinata corrente
|
|
bool bOk = EgtRemovePartFromRawPart( nPartId) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaTranslatePartInRawPart( lua_State* L)
|
|
{
|
|
// 2 parametri : nPartId, vtMove
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
Vector3d vtMove ;
|
|
LuaCheckParam( L, 2, vtMove)
|
|
LuaClearStack( L) ;
|
|
// traslo il pezzo nel grezzo
|
|
bool bOk = EgtTranslatePartInRawPart( nPartId, vtMove) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRotatePartInRawPart( lua_State* L)
|
|
{
|
|
// 3 parametri : nPartId, vtAx, dAngRotDeg
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
Vector3d vtAx ;
|
|
LuaCheckParam( L, 2, vtAx)
|
|
double dAngRotDeg ;
|
|
LuaCheckParam( L, 3, dAngRotDeg)
|
|
LuaClearStack( L) ;
|
|
// ruoto il pezzo nel grezzo
|
|
bool bOk = EgtRotatePartInRawPart( nPartId, vtAx, dAngRotDeg) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
LuaInstallMachMgr( void)
|
|
{
|
|
bool bOk = true ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupNbr", LuaGetMachGroupNbr) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtGetFirstMachGroup", LuaGetFirstMachGroup) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtGetNextMachGroup", LuaGetNextMachGroup) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtAddMachGroup", LuaAddMachGroup) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtRemoveMachGroup", LuaRemoveMachGroup) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupName", LuaGetMachGroupName) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupId", LuaGetMachGroupId) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtSetCurrMachGroup", LuaSetCurrMachGroup) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtResetCurrMachGroup", LuaResetCurrMachGroup) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtGetCurrMachGroup", LuaGetCurrMachGroup) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtAddRawPart", LuaAddRawPart) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtAddRawPartWithPart", LuaAddRawPartWithPart) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtAddPartToRawPart", LuaAddPartToRawPart) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtModifyRawPartHeight", LuaModifyRawPartHeight) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtRemoveRawPart", LuaRemoveRawPart) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtMoveRawPart", LuaTranslateRawPart) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtRotateRawPart", LuaRotateRawPart) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtMoveToCornerRawPart", LuaMoveToCornerRawPart) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtMoveToCenterRawPart", LuaMoveToCenterRawPart) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtRemovePartFromRawPart", LuaRemovePartFromRawPart) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtMovePartInRawPart", LuaTranslatePartInRawPart) ;
|
|
bOk = bOk && LuaRegisterFunction( "EgtRotatePartInRawPart", LuaRotatePartInRawPart) ;
|
|
|
|
return bOk ;
|
|
}
|