From a8d57a13fa7a8fdb5986e89d0fe3908565e8e3a9 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 31 Mar 2015 13:16:36 +0000 Subject: [PATCH] EgtInterface 1.6c10 : - gestione macchinate (gruppi di lavorazione). --- API.h | 4 ++ API_GeomDB.cpp | 29 +++++++++++- API_MachMgr.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++++- EgtInterface.rc | Bin 11718 -> 11734 bytes LUA_MachMgr.cpp | 117 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 259 insertions(+), 3 deletions(-) diff --git a/API.h b/API.h index ad14370..a7c8260 100644 --- a/API.h +++ b/API.h @@ -135,7 +135,11 @@ bool EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtDir, double dCoeff, int nRefType) ; //--------------------------- Machining -------------------------------------- +bool EgtUpdateMachMgr( void) ; +bool EgtInsertMachMgr( int nInsGrp) ; int EgtAddMachGroup( const std::string& sName, const std::string& sMachineName) ; +bool EgtGetMachGroupName( int nMGroupInd, std::string& sName) ; +bool EgtGetMachGroupInd( const std::string& sName, int& nInd) ; //--------------------------- Scene ------------------------------------------ bool EgtSetBackground( Color TopCol, Color BottomCol, bool bRedraw) ; diff --git a/API_GeomDB.cpp b/API_GeomDB.cpp index 6271386..42e5e29 100644 --- a/API_GeomDB.cpp +++ b/API_GeomDB.cpp @@ -285,6 +285,8 @@ __stdcall EgtNewFile( void) // aggiorno stato file corrente pGseCtx->m_sFilePath.clear() ; pGseCtx->m_bModified = false ; + // aggiornamento gestore lavorazioni + EgtUpdateMachMgr() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtNewFile()" @@ -313,10 +315,12 @@ EgtOpenFile( const string& sFilePath) bOk = bOk && pGseCtx->m_pGeomDB->Init() ; bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; // carico il file - bOk = bOk && GetCurrGeomDB()->Load( sFilePath) ; + bOk = bOk && pGseCtx->m_pGeomDB->Load( sFilePath) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; pGseCtx->m_bModified = false ; + // aggiornamento gestore lavorazioni + EgtUpdateMachMgr() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLuaPath = sFilePath ; @@ -342,8 +346,29 @@ EgtInsertFile( const string& sFilePath) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) + IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; + // creo gruppo temporaneo di parcheggio + int nGrp = pGeomDB->InsertGroup( GDB_ID_NULL, GDB_ID_ROOT, GDB_FIRST_SON, GLOB_FRM) ; + bool bOk = ( nGrp != GDB_ID_NULL) ; + bOk = bOk && pGeomDB->SetLevel( nGrp, GDB_LV_TEMP) ; // carico il file - bool bOk = pGseCtx->m_pGeomDB->Load( sFilePath) ; + bOk = bOk && pGeomDB->Load( sFilePath, nGrp) ; + // sposto i pezzi sotto la radice + int nId = pGeomDB->GetFirstGroupInGroup( nGrp) ; + while ( bOk && nId != GDB_ID_NULL) { + // prossimo gruppo + int nNextId = pGeomDB->GetNextGroup( nId) ; + // se il gruppo corrente è un pezzo, lo sposto + int nLevel ; + if ( ! pGeomDB->GetLevel( nId, nLevel) || nLevel == GDB_LV_USER) + bOk = pGeomDB->Relocate( nId, GDB_ID_ROOT, GDB_LAST_SON) ; + // passo al prossimo + nId = nNextId ; + } + // sistemo le lavorazioni + bOk = bOk && EgtInsertMachMgr( nGrp) ; + // cancello il gruppo temporaneo + pGeomDB->Erase( nGrp) ; // aggiorno stato file corrente pGseCtx->m_bModified = true ; // se richiesto, salvo il comando Lua equivalente diff --git a/API_MachMgr.cpp b/API_MachMgr.cpp index 9fa2fab..a8b1db6 100644 --- a/API_MachMgr.cpp +++ b/API_MachMgr.cpp @@ -40,6 +40,36 @@ __stdcall EgtInitMachMgr( void) return TRUE ; } +//----------------------------------------------------------------------------- +bool +EgtUpdateMachMgr( void) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, FALSE) + // aggiornamento gestore lavorazioni + return pMachMgr->Update() ; +} + +//----------------------------------------------------------------------------- +bool +EgtInsertMachMgr( int nInsGrp) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, 0) + // sposto le macchinate dal gruppo di inserimento alla base macchinate + return pMachMgr->Insert( nInsGrp) ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtGetMachGroupNbr( void) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, 0) + // recupero il numero di macchinate + return pMachMgr->GetMachGroupNbr() ; +} + //----------------------------------------------------------------------------- int __stdcall EgtAddMachGroup( const wchar_t* wsName, const wchar_t* wsMachineName) @@ -52,7 +82,87 @@ int EgtAddMachGroup( const string& sName, const string& sMachineName) { IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL) + VERIFY_MACHMGR( pMachMgr, 0) // aggiungo la macchinata (gruppo di lavorazione) return pMachMgr->AddMachGroup( sName, sMachineName) ; } + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtRemoveMachGroup( int nMGroupInd) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, FALSE) + // rimuovo la macchinata (gruppo di lavorazione) + return ( pMachMgr->RemoveMachGroup( nMGroupInd) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetMachGroupName( int nMGroupInd, wchar_t*& wsName) +{ + if ( &wsName == nullptr) + return FALSE ; + string sName ; + if ( ! EgtGetMachGroupName( nMGroupInd, sName)) + return FALSE ; + wsName = _wcsdup( stringtoW( sName)) ; + return (( wsName == nullptr) ? FALSE : TRUE) ; +} + +//----------------------------------------------------------------------------- +bool +EgtGetMachGroupName( int nMGroupInd, string& sName) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, false) + // recupero il nome della macchinata + return pMachMgr->GetMachGroupName( nMGroupInd, sName) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetMachGroupInd( const wchar_t* wsName, int* pnInd) +{ + return ( EgtGetMachGroupInd( wstrztoA( wsName), *pnInd) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +bool +EgtGetMachGroupInd( const string& sName, int& nInd) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, false) + // recupero l'indice della macchinata + return pMachMgr->GetMachGroupInd( sName, nInd) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetCurrMachGroup( int nMGroupInd) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, FALSE) + // imposto la macchinata corrente + return ( pMachMgr->SetCurrMachGroup( nMGroupInd) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtResetCurrMachGroup( void) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, FALSE) + // reset macchinata corrente + return ( pMachMgr->ResetCurrMachGroup() ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetCurrMachGroup( int* pnInd) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, FALSE) + // reset macchinata corrente + return ( pMachMgr->GetCurrMachGroup( *pnInd) ? TRUE : FALSE) ; +} diff --git a/EgtInterface.rc b/EgtInterface.rc index cbf9b2a4bb31ebbf00899120487cfed7e8538e38..703f4bf23253da8d04aa2440a6351d62f6c890ea 100644 GIT binary patch delta 127 zcmX>WeJy&!FE(aF27}EX`A#xTKEhcC;!J)hsJppeJpyzFE&QY&G+R_GEH75DKPmOXC9;FJhoWbevJDpi*U>JY diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index 5f255a7..7278021 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -22,6 +22,18 @@ 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 @@ -40,11 +52,116 @@ LuaAddMachGroup( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaRemoveMachGroup( lua_State* L) +{ + // 1 parametro : indice 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 : indice 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 +LuaGetMachGroupInd( lua_State* L) +{ + // 1 parametro : nome del gruppo + string sGroupName ; + LuaCheckParam( L, 1, sGroupName) + LuaClearStack( L) ; + // recupero l'indice della macchinata + int nInd ; + bool bOk = EgtGetMachGroupInd( sGroupName, nInd) ; + // restituisco il risultato + if ( bOk) + LuaSetReturn( L, nInd) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSetCurrMachGroup( lua_State* L) +{ + // 1 parametro : indice 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 il gruppo corrente + int nInd ; + bool bOk = ( EgtGetCurrMachGroup( &nInd) != FALSE) ; + // restituisco il risultato + if ( bOk) + LuaSetReturn( L, nInd) ; + else + LuaSetReturn( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallMachMgr( void) { bool bOk = true ; + bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupNbr", LuaGetMachGroupNbr) ; bOk = bOk && LuaRegisterFunction( "EgtAddMachGroup", LuaAddMachGroup) ; + bOk = bOk && LuaRegisterFunction( "EgtRemoveMachGroup", LuaRemoveMachGroup) ; + bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupName", LuaGetMachGroupName) ; + bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupInd", LuaGetMachGroupInd) ; + bOk = bOk && LuaRegisterFunction( "EgtSetCurrMachGroup", LuaSetCurrMachGroup) ; + bOk = bOk && LuaRegisterFunction( "EgtResetCurrMachGroup", LuaResetCurrMachGroup) ; + bOk = bOk && LuaRegisterFunction( "EgtGetCurrMachGroup", LuaGetCurrMachGroup) ; return bOk ; }