From d63fa552c6fa0fed1f10fab9e3b705f5e4dc64dd Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 25 Apr 2015 20:39:16 +0000 Subject: [PATCH] EgtInterface 1.6d4 : - in selezione tutto si considerano solo i pezzi (non le parti per le lavorazioni) - aggiunte EgtIsPart e EgtIsLayer a API e LUA - migliorati controlli per riconoscimento pezzi e layer - corretto errore in VerifySameFrame per GeoTransforms - ImportDxf e Stl ora accettano anche fattore di scala API e LUA. --- API.h | 4 +-- API_Exchange.cpp | 22 +++++++------- API_GdbObjSelection.cpp | 4 +-- API_GdbPartLayers.cpp | 62 +++++++++++++++++++++++++++++----------- EgtInterface.rc | Bin 11718 -> 11718 bytes GeoTools.cpp | 2 +- LUA_Exchange.cpp | 12 +++++--- LUA_GdbPartLayers.cpp | 32 +++++++++++++++++++++ 8 files changed, 102 insertions(+), 36 deletions(-) diff --git a/API.h b/API.h index e7a8c12..b6cdb2d 100644 --- a/API.h +++ b/API.h @@ -176,8 +176,8 @@ bool EgtSetWinRectAttribs( bool bOutline, Color WrCol) ; //--------------------------- Exchange --------------------------------------- int EgtGetFileType( const std::string& sFilePath) ; -bool EgtImportDxf( const std::string& sFilePath) ; -bool EgtImportStl( const std::string& sFilePath) ; +bool EgtImportDxf( const std::string& sFilePath, double dScaleFactor) ; +bool EgtImportStl( const std::string& sFilePath, double dScaleFactor) ; bool EgtImportCnc( const std::string& sFilePath) ; bool EgtExportDxf( int nId, const std::string& sFilePath) ; bool EgtExportStl( int nId, const std::string& sFilePath) ; diff --git a/API_Exchange.cpp b/API_Exchange.cpp index e9af731..e7d6b55 100644 --- a/API_Exchange.cpp +++ b/API_Exchange.cpp @@ -72,14 +72,14 @@ EgtGetFileType( const string& sFilePath) //----------------------------------------------------------------------------- BOOL -__stdcall EgtImportDxf( const wchar_t* wsFilePath) +__stdcall EgtImportDxf( const wchar_t* wsFilePath, double dScaleFactor) { - return ( EgtImportDxf( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; + return ( EgtImportDxf( wstrztoA( wsFilePath), dScaleFactor) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- bool -EgtImportDxf( const string& sFilePath) +EgtImportDxf( const string& sFilePath, double dScaleFactor) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) @@ -91,7 +91,7 @@ EgtImportDxf( const string& sFilePath) PtrOwner pImpDxf( MyCreateImportDxf()) ; bOk = bOk && ! IsNull( pImpDxf) ; // eseguo l'importazione - bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId) ; + bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, dScaleFactor) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; pGseCtx->m_bModified = true ; @@ -99,7 +99,8 @@ EgtImportDxf( const string& sFilePath) if ( IsCmdLog()) { string sLuaPath = sFilePath ; ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtImportDxf('" + sLuaPath + "')" + + string sLua = "EgtImportDxf('" + sLuaPath + "'," + + ToString( dScaleFactor) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -109,14 +110,14 @@ EgtImportDxf( const string& sFilePath) //----------------------------------------------------------------------------- BOOL -__stdcall EgtImportStl( const wchar_t* wsFilePath) +__stdcall EgtImportStl( const wchar_t* wsFilePath, double dScaleFactor) { - return ( EgtImportStl( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; + return ( EgtImportStl( wstrztoA( wsFilePath), dScaleFactor) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- bool -EgtImportStl( const string& sFilePath) +EgtImportStl( const string& sFilePath, double dScaleFactor) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) @@ -129,7 +130,7 @@ EgtImportStl( const string& sFilePath) PtrOwner pImpStl( MyCreateImportStl()) ; bOk = bOk && ! IsNull( pImpStl) ; // eseguo l'importazione - bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId) ; + bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, dScaleFactor) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; pGseCtx->m_bModified = true ; @@ -137,7 +138,8 @@ EgtImportStl( const string& sFilePath) if ( IsCmdLog()) { string sLuaPath = sFilePath ; ReplaceString( sLuaPath, "\\", "\\\\") ; - string sLua = "EgtImportStl('" + sLuaPath + "')" + + string sLua = "EgtImportStl('" + sLuaPath + "'," + + ToString( dScaleFactor) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/API_GdbObjSelection.cpp b/API_GdbObjSelection.cpp index a964fa2..885a1d1 100644 --- a/API_GdbObjSelection.cpp +++ b/API_GdbObjSelection.cpp @@ -66,7 +66,7 @@ __stdcall EgtSelectAll( bool bOnlyIfVisible) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) // seleziono tutto - int nId1 = pGeomDB->GetFirstInGroup( GDB_ID_ROOT) ; + int nId1 = EgtGetFirstPart( bOnlyIfVisible) ; while ( nId1 != GDB_ID_NULL) { // ciclo sugli oggetti del pezzo int nId2 = pGeomDB->GetFirstInGroup( nId1) ; @@ -81,7 +81,7 @@ __stdcall EgtSelectAll( bool bOnlyIfVisible) nId2 = pGeomDB->GetNext( nId2) ; } // passo al successivo - nId1 = pGeomDB->GetNext( nId1) ; + nId1 = EgtGetNextPart( nId1, bOnlyIfVisible) ; } // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { diff --git a/API_GdbPartLayers.cpp b/API_GdbPartLayers.cpp index c4a5a1f..473c833 100644 --- a/API_GdbPartLayers.cpp +++ b/API_GdbPartLayers.cpp @@ -51,6 +51,36 @@ EgtVerifyOrNext( IGeomDB* pGeomDB, int nId, bool bOnlyVisible) return GDB_ID_NULL ; } +//------------------------------------------------------------------------------- +int +__stdcall EgtIsPart( int nPartId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // verifico sia un pezzo (gruppo sotto la radice con livello utente) + if ( pGeomDB->GetGdbType( nPartId) == GDB_TY_GROUP && + pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT && + EgtIsUserObj( pGeomDB, nPartId)) + return TRUE ; + else + return FALSE ; +} + +//------------------------------------------------------------------------------- +int +__stdcall EgtIsLayer( int nLayerId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // verifico sia un layer (gruppo sotto un pezzo con livello utente) + if ( pGeomDB->GetGdbType( nLayerId) == GDB_TY_GROUP && + EgtIsPart( pGeomDB->GetParentId( nLayerId)) != FALSE && + EgtIsUserObj( pGeomDB, nLayerId)) + return TRUE ; + else + return FALSE ; +} + //------------------------------------------------------------------------------- int __stdcall EgtGetCurrPart( void) @@ -80,7 +110,9 @@ __stdcall EgtSetCurrPartLayer( int nPartId, int nLayerId) IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; bool bOk = true ; // verifico validità e visibilità pezzo - if ( pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT && EgtIsVisibleObj( pGeomDB, nPartId)) { + if ( pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT && + EgtIsUserObj( pGeomDB, nPartId) && + EgtIsVisibleObj( pGeomDB, nPartId)) { if ( nPartId != pGseCtx->m_nCurrPart) pGseCtx->m_nCurrLayer = GDB_ID_NULL ; pGseCtx->m_nCurrPart = nPartId ; @@ -93,7 +125,9 @@ __stdcall EgtSetCurrPartLayer( int nPartId, int nLayerId) bOk = false ; } // verifico validità e visibilità layer - if ( pGeomDB->GetParentId( nLayerId) == nPartId && EgtIsVisibleObj( pGeomDB, nLayerId)) { + if ( pGeomDB->GetParentId( nLayerId) == nPartId && + EgtIsUserObj( pGeomDB, nLayerId) && + EgtIsVisibleObj( pGeomDB, nLayerId)) { pGseCtx->m_nCurrLayer = nLayerId ; } else { @@ -225,9 +259,8 @@ __stdcall EgtSelectPartObjs( int nPartId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; - // verifico sia veramente un pezzo (gruppo sotto la radice) - if ( pGeomDB->GetGdbType( nPartId) == GDB_TY_GROUP && - pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT) { + // verifico sia veramente un pezzo + if ( EgtIsPart( nPartId) != FALSE) { // ciclo sugli oggetti del pezzo int nId = pGeomDB->GetFirstInGroup( nPartId) ; while ( nId != GDB_ID_NULL) { @@ -260,9 +293,8 @@ __stdcall EgtDeselectPartObjs( int nPartId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; - // verifico sia veramente un pezzo (gruppo sotto la radice) - if ( pGeomDB->GetGdbType( nPartId) == GDB_TY_GROUP && - pGeomDB->GetParentId( nPartId) == GDB_ID_ROOT) { + // verifico sia veramente un pezzo + if ( EgtIsPart( nPartId) != FALSE) { // ciclo sugli oggetti del pezzo int nId = pGeomDB->GetFirstInGroup( nPartId) ; while ( nId != GDB_ID_NULL) { @@ -295,9 +327,8 @@ __stdcall EgtSelectLayerObjs( int nLayerId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; - // verifico sia veramente un layer (gruppo senza sottogruppi) - if ( pGeomDB->GetGdbType( nLayerId) == GDB_TY_GROUP && - pGeomDB->GetFirstGroupInGroup( nLayerId) == GDB_ID_NULL) { + // verifico sia veramente un layer + if ( EgtIsLayer( nLayerId) != FALSE) { // ciclo sugli oggetti del layer int nId = pGeomDB->GetFirstInGroup( nLayerId) ; while ( nId != GDB_ID_NULL) { @@ -326,9 +357,8 @@ __stdcall EgtDeselectLayerObjs( int nLayerId) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; - // verifico sia veramente un layer (gruppo senza sottogruppi) - if ( pGeomDB->GetGdbType( nLayerId) == GDB_TY_GROUP && - pGeomDB->GetFirstGroupInGroup( nLayerId) == GDB_ID_NULL) { + // verifico sia veramente un layer + if ( EgtIsLayer( nLayerId) != FALSE) { // ciclo sugli oggetti del layer int nId = pGeomDB->GetFirstInGroup( nLayerId) ; while ( nId != GDB_ID_NULL) { @@ -356,12 +386,10 @@ __stdcall EgtSelectPathObjs( int nId, BOOL bHaltOnFork) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; // verifico appartenga ad un layer int nIdLayer = pGeomDB->GetParentId( nId) ; int nIdPart = pGeomDB->GetParentId( nIdLayer) ; - int nIdRoot = pGeomDB->GetParentId( nIdPart) ; - bOk = bOk && ( nIdLayer != GDB_ID_NULL && nIdPart != GDB_ID_NULL && nIdRoot == GDB_ID_ROOT) ; + bool bOk = ( nIdLayer != GDB_ID_NULL && nIdPart != GDB_ID_NULL && ( EgtIsLayer( nIdLayer) != FALSE)) ; // seleziono percorso a partire da entità indicata usando tutte le curve del pezzo const int CHAIN_SIZE = 1000 ; const double CHAIN_TOLER = 10 * EPS_SMALL ; diff --git a/EgtInterface.rc b/EgtInterface.rc index eb013b21c52831a1cfc87170cf2746e2e19f8bdc..f7c498113fdfeed3d8570aaae3e2c3cd6f17da0b 100644 GIT binary patch delta 111 zcmX>WeJpyzFE&P#%^&$rGEF|hS;uHH`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o07@$;z5oCK delta 111 zcmX>WeJpyzFE&Qw%^&$rGEF|hS;uHR`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o07yS5wg3PC diff --git a/GeoTools.cpp b/GeoTools.cpp index 0543738..225b966 100644 --- a/GeoTools.cpp +++ b/GeoTools.cpp @@ -75,7 +75,7 @@ VerifySameFrame( IGeomDB* pGeomDB, const INTVECTOR& vIds) return false ; if ( bFirst) { frFirst = frLoc ; - return false ; + bFirst = false ; } else { if ( ! AreSameFrame( frFirst, frLoc)) diff --git a/LUA_Exchange.cpp b/LUA_Exchange.cpp index 4c52b3b..c1788ff 100644 --- a/LUA_Exchange.cpp +++ b/LUA_Exchange.cpp @@ -27,12 +27,14 @@ using namespace std ; static int LuaImportDxf( lua_State* L) { - // 1 parametro : path del file da importare + // 1 o 2 parametri : path del file da importare [, Fattore di scala] string sFilePath ; LuaCheckParam( L, 1, sFilePath) + double dScaleFactor = 1.0 ; + LuaGetParam( L, 2, dScaleFactor) ; LuaClearStack( L) ; // apro il file - bool bOk = EgtImportDxf( sFilePath) ; + bool bOk = EgtImportDxf( sFilePath, dScaleFactor) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; @@ -42,12 +44,14 @@ LuaImportDxf( lua_State* L) static int LuaImportStl( lua_State* L) { - // 1 parametro : path del file da importare + // 1 o 2 parametri : path del file da importare [, Fattore di scala] string sFilePath ; LuaCheckParam( L, 1, sFilePath) + double dScaleFactor = 1.0 ; + LuaGetParam( L, 2, dScaleFactor) ; LuaClearStack( L) ; // apro il file - bool bOk = EgtImportStl( sFilePath) ; + bool bOk = EgtImportStl( sFilePath, dScaleFactor) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; diff --git a/LUA_GdbPartLayers.cpp b/LUA_GdbPartLayers.cpp index be740a2..afa0289 100644 --- a/LUA_GdbPartLayers.cpp +++ b/LUA_GdbPartLayers.cpp @@ -22,6 +22,36 @@ using namespace std ; +//------------------------------------------------------------------------------- +static int +LuaIsPart( lua_State* L) +{ + // 1 parametro : nIdPart + int nIdPart ; + LuaCheckParam( L, 1, nIdPart) + LuaClearStack( L) ; + // verifico sia un pezzo + bool bOk = ( EgtIsPart( nIdPart) != FALSE) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaIsLayer( lua_State* L) +{ + // 1 parametro : nIdLayer + int nIdLayer ; + LuaCheckParam( L, 1, nIdLayer) + LuaClearStack( L) ; + // verifico sia un layer + bool bOk = ( EgtIsPart( nIdLayer) != FALSE) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaGetCurrPart( lua_State* L) @@ -254,6 +284,8 @@ LuaInstallGdbPartLayer( void) { bool bOk = true ; bOk = bOk && LuaRegisterFunction( "EgtGetCurrPart", LuaGetCurrPart) ; + bOk = bOk && LuaRegisterFunction( "EgtIsPart", LuaIsPart) ; + bOk = bOk && LuaRegisterFunction( "EgtIsLayer", LuaIsLayer) ; bOk = bOk && LuaRegisterFunction( "EgtGetCurrLayer", LuaGetCurrLayer) ; bOk = bOk && LuaRegisterFunction( "EgtSetCurrPartLayer", LuaSetCurrPartLayer) ; bOk = bOk && LuaRegisterFunction( "EgtResetCurrPartLayer", LuaResetCurrPartLayer) ;