EgtExecutor 1.8k2 :
- aggiunta funzione Exe e Lua Transform che porta gli oggetti nel globale de riferimento indicato.
This commit is contained in:
@@ -23,6 +23,65 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTransform( INTVECTOR& vIds, const Frame3d& frRef, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
bool bOk = true ;
|
||||
// se trasformazione espressa in locale
|
||||
if ( nRefType == RTY_LOC) {
|
||||
// verifico che tutti gli oggetti siano nello stesso riferimento
|
||||
bOk = bOk && VerifySameFrame( pGeomDB, vIds) ;
|
||||
// ciclo sul vettore degli identificativi
|
||||
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
|
||||
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
// eseguo trasformazione
|
||||
IGeoObj* pGObj = pGeomDB->GetGeoObj( nId) ;
|
||||
if ( pGObj == nullptr || ! pGObj->ToGlob( frRef))
|
||||
bOk = false ;
|
||||
// passo alla successiva
|
||||
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// altrimenti in globale o in griglia
|
||||
else {
|
||||
Frame3d frRefG = frRef ;
|
||||
// se griglia, porto il vettore in globale
|
||||
if ( nRefType == RTY_GRID)
|
||||
frRefG.ToGlob( pGeomDB->GetGridFrame()) ;
|
||||
// ciclo sul vettore degli identificativi
|
||||
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
|
||||
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
// eseguo trasformazione
|
||||
IGeoObj* pGObj = pGeomDB->GetGeoObj( nId) ;
|
||||
if ( pGObj == nullptr || ! pGObj->ToGlob( frRefG))
|
||||
bOk = false ;
|
||||
// passo alla successiva
|
||||
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTransform({" + IdListToString( vIds) + "},{{" +
|
||||
ToString( frRef.Orig()) + "},{" +
|
||||
ToString( frRef.VersX()) + "},{" +
|
||||
ToString( frRef.VersY()) + "},{" +
|
||||
ToString( frRef.VersZ()) + "}}," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeMove( INTVECTOR& vIds, const Vector3d& vtMove, int nRefType)
|
||||
|
||||
Binary file not shown.
@@ -20,6 +20,25 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTransform( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id/s, Frame [, nRefType]
|
||||
INTVECTOR vId ;
|
||||
LuaCheckParam( L, 1, vId)
|
||||
Frame3d frRef ;
|
||||
LuaCheckParam( L, 2, frRef)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 3, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo trasformazione
|
||||
bool bOk = ExeTransform( vId, frRef, nRefType) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaMove( lua_State* L)
|
||||
@@ -241,6 +260,7 @@ bool
|
||||
LuaInstallGeoTransform( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTransform", LuaTransform) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtMove", LuaMove) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtRotate", LuaRotate) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtScale", LuaScale) ;
|
||||
|
||||
Reference in New Issue
Block a user