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.
This commit is contained in:
Dario Sassi
2015-04-25 20:39:16 +00:00
parent 9d3dc5e537
commit d63fa552c6
8 changed files with 102 additions and 36 deletions
+2 -2
View File
@@ -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) ;
+12 -10
View File
@@ -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<IImportDxf> 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<IImportStl> 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()) ;
}
+2 -2
View File
@@ -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()) {
+45 -17
View File
@@ -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 ;
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -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))
+8 -4
View File
@@ -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 ;
+32
View File
@@ -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) ;