EgtInterface 1.6a4 :

- completamento modifiche per registrazione comandi in lua e per gestione RefType e RefId.
This commit is contained in:
Dario Sassi
2015-01-26 07:53:04 +00:00
parent 4e5a81c493
commit a45c3fca8a
25 changed files with 1574 additions and 1254 deletions
+144 -28
View File
@@ -16,7 +16,9 @@
#include "stdafx.h"
#include "API.h"
#include "API_Macro.h"
#include "AuxTools.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EInConst.h"
#include "/EgtDev/Include/EgkGeoPoint3d.h"
#include "/EgtDev/Include/EgkGeoVector3d.h"
#include "/EgtDev/Include/EgkSurfTriMesh.h"
@@ -30,35 +32,87 @@ using namespace std ;
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtChangeGroupFrame( int nId,
double ptOrig[3], double vtX[3], double vtY[3], double vtZ[3])
__stdcall EgtChangeGroupFrame( int nId, double ptOrig[3],
double vtX[3], double vtY[3], double vtZ[3], int nRefType)
{
// costruisco il riferimento
Frame3d frFrame ;
if ( ! frFrame.Set( ptOrig, vtX, vtY, vtZ))
return FALSE ;
// eseguo
return ( EgtChangeGroupFrame( nId, frFrame, nRefType) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
bool
EgtChangeGroupFrame( int nId, const Frame3d& frNewRef, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
VERIFY_GEOMDB( pGeomDB, false)
bool bOk = true ;
// recupero il riferimento del gruppo
Frame3d* pFrame = pGeomDB->GetGroupFrame( nId) ;
if ( pFrame == nullptr)
return FALSE ;
// imposto il nuovo riferimento
Frame3d frNew ;
if ( ! frNew.Set( ptOrig, vtX, vtY, vtZ))
return FALSE ;
*pFrame = frNew ;
return TRUE ;
bOk = bOk && ( pFrame != nullptr) ;
// porto il nuovo riferimento in locale
Frame3d frNewL = frNewRef ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ;
if ( nRefType == RTY_GLOB)
frNewL.ToLoc( frLoc) ;
else /* RTY_GRID */
frNewL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
// aggiorno il gruppo
if ( bOk)
*pFrame = frNewL ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtChangeGroupFrame(" + ToString( nId) + ",{" +
ToString( frNewRef.Orig()) + "},{" +
ToString( frNewRef.VersX()) + "},{" +
ToString( frNewRef.VersY()) + "},{" +
ToString( frNewRef.VersZ()) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtChangeVectorBase( int nId, const double ptB[3])
__stdcall EgtChangeVectorBase( int nId, const double ptB[3], int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
bool bOk = true ;
// recupero il vettore
IGeoVector3d* pGVect = GetGeoVector3d( pGeomDB->GetGeoObj( nId)) ;
if ( pGVect == nullptr)
return FALSE ;
bOk = bOk && ( pGVect != nullptr) ;
// porto il nuovo punto base in locale
Point3d ptBL( ptB) ;
if ( nRefType != RTY_LOC) {
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ;
if ( nRefType == RTY_GLOB)
ptBL.ToLoc( frLoc) ;
else /* RTY_GRID */
ptBL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ;
}
// imposto il nuovo punto di base
return ( pGVect->ChangeBase( ptB) ? TRUE : FALSE) ;
bOk = bOk && pGVect->ChangeBase( ptBL) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtChangeVectorBase(" + ToString( nId) + ",{" +
ToString( Point3d( ptB)) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
@@ -97,46 +151,108 @@ __stdcall EgtInvertSurface( int nId)
return ( bOk ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
//----------------------------------------------------------------------------
BOOL
__stdcall EgtModifyText( int nId, const wchar_t* wsNewText)
__stdcall EgtSurfTmDoSewing( int nNumId, const int nIds[], BOOL bErase)
{
return EgtModifyText( nId, wstrztoA( wsNewText)) ;
INTVECTOR vIds ;
vIds.reserve( nNumId) ;
for ( int i = 0 ; i < nNumId ; ++i) {
vIds.push_back( nIds[i]) ;
}
return ( EgtSurfTmDoSewing( vIds, ( bErase != FALSE)) ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
bool
EgtSurfTmDoSewing( const INTVECTOR& vIds, bool bErase)
{
// --- tutte le superfici vengono cucite alla prima ---
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// almeno un oggetto nell'elenco
bool bOk = ( vIds.size() > 0) ;
// recupero la prima superficie
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( vIds[0])) ;
bOk = bOk && ( pStm != nullptr) ;
// ne recupero il riferimento
Frame3d frStm ;
bOk = bOk && pGeomDB->GetGlobFrame( vIds[0], frStm) ;
// esecuzione
for ( size_t i = 1 ; bOk && i < vIds.size() ; ++ i) {
// recupero la superficie da cucire
const ISurfTriMesh* pStmS = GetSurfTriMesh( pGeomDB->GetGeoObj( vIds[i])) ;
bOk = bOk && ( pStmS != nullptr) ;
// recupero il riferimento
Frame3d frStmS ;
bOk = bOk && pGeomDB->GetGlobFrame( vIds[i], frStmS) ;
// lo esprimo rispetto a quello della prima superficie
frStmS.ToLoc( frStm) ;
// eseguo la cucitura
bOk = bOk && pStm->DoSewing( *pStmS, frStm) ;
}
// se richiesto, cancello le superfici cucite alla prima
if ( bOk && bErase) {
for ( size_t i = 1 ; i < vIds.size() ; ++ i)
pGeomDB->Erase( vIds[i]) ;
}
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sIds ;
for ( size_t i = 0 ; i < vIds.size() ; ++ i) {
if ( i > 0)
sIds += "," ;
sIds += vIds[i] ;
}
string sLua = "EgtSurfTmDoSewing({" + sIds + "}," +
( bErase ? "true" : "false") + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco il risultato
return bOk ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtModifyText( int nId, const string& sNewText)
__stdcall EgtModifyText( int nId, const wchar_t* wsNewText)
{
return ( EgtModifyText( nId, wstrztoA( wsNewText)) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
bool
EgtModifyText( int nId, const string& sNewText)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
VERIFY_GEOMDB( pGeomDB, false)
// recupero il testo
IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ;
if ( pTXT == nullptr)
return FALSE ;
return false ;
// eseguo l'operazione
return ( pTXT->ModifyText( sNewText) ? TRUE : FALSE) ;
return pTXT->ModifyText( sNewText) ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtChangeTextFont( int nId, const wchar_t* wsNewFont)
{
return EgtChangeTextFont( nId, wstrztoA( wsNewFont)) ;
return ( EgtChangeTextFont( nId, wstrztoA( wsNewFont)) ? TRUE : FALSE) ;
}
//-------------------------------------------------------------------------------
BOOL
__stdcall EgtChangeTextFont( int nId, const string& sNewFont)
bool
EgtChangeTextFont( int nId, const string& sNewFont)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
VERIFY_GEOMDB( pGeomDB, false)
// recupero il testo
IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ;
if ( pTXT == nullptr)
return FALSE ;
return false ;
// eseguo l'operazione
return ( pTXT->ChangeFont( sNewFont) ? TRUE : FALSE) ;
return pTXT->ChangeFont( sNewFont) ;
}
//-------------------------------------------------------------------------------