From 404105518f31793697e93335f9ce6a8ec09f8b13 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 5 Jul 2019 10:47:31 +0000 Subject: [PATCH] EgtMachKernel 2.1g1 : - corretto problema lavorazioni e disposizioni che potevano non essere cancellate (specie da OmagCUT). --- EgtMachKernel.rc | Bin 11774 -> 11774 bytes MachMgr.h | 2 ++ MachMgrOperations.cpp | 26 +++++++++++++++++++++++++- MachMgrPhases.cpp | 6 +++++- Operation.cpp | 5 +++-- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 12e591bdfe6c950b6b0bc984a4ca8b94bf4fba73..1915a1c02d490c4baddc935b55331f1a4e20ac56 100644 GIT binary patch delta 121 zcmewt{V#gMH#Syt1|0^&&A-{KnVHiW3@1O7)ZLuM)x!c8zsNNCgkT;*P6$a3MUMyL R=2g-z%(yjz6ex#q0RVBoCa3@a delta 121 zcmewt{V#gMH#Sx?1|0^I&A-{KnVHiVOeQ~+)ZLuM)x!c8zsNNCgkT;*P6$a3MUMyL R=2g-z%(yjz6ex#q0RVNYCb$3q diff --git a/MachMgr.h b/MachMgr.h index a53ab1c..7a11b29 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -450,6 +450,8 @@ class MachMgr : public IMachMgr int UpdateCustomToolDraw( const ToolData* pTdata, int nGenCtx, int nToolCtx, bool bToSave) const ; std::string GetToolMakerKeyFromType( int nType) const ; std::string GetToolHolderPath( const std::string& sHeadName, int nExit, int nType) const ; + // Operations : general + bool InitOperation( int nId) ; // Operations : dispositions int AddDisposition( const std::string& sName) ; diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index 952231b..a665ea9 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -276,6 +276,16 @@ MachMgr::IsOperationEmpty( int nId) const return pOpe->IsEmpty() ; } +//---------------------------------------------------------------------------- +bool +MachMgr::InitOperation(int nId) +{ + Operation* pOpe = GetOperation( m_pGeomDB->GetUserObj( nId)) ; + if ( pOpe == nullptr) + return false ; + return pOpe->Init( this) ; +} + //---------------------------------------------------------------------------- bool MachMgr::RemoveOperation( int nId) @@ -284,6 +294,12 @@ MachMgr::RemoveOperation( int nId) int nType = GetOperationType( nId) ; if ( nType == OPER_NULL || nType == OPER_DISP) return false ; + // verifico appartenga al gruppo delle operazioni della macchinata corrente + int nOperGrpId = GetCurrOperId() ; + if ( nOperGrpId == GDB_ID_NULL || m_pGeomDB->GetParentId( nId) != nOperGrpId) + return false ; + // garantisco l'inizializzazione dell'operazione + InitOperation( nId) ; // se lavorazione corrente, resetto if ( m_nCurrMachiningId == nId) m_nCurrMachiningId = GDB_ID_NULL ; @@ -305,8 +321,12 @@ MachMgr::RemoveAllPhaseOperations( int nPhase) while ( nOperId != GDB_ID_NULL) { int nNextOperId = m_pGeomDB->GetNext( nOperId) ; if ( GetOperationPhase( nOperId) == nPhase) { + // garantisco l'inizializzazione dell'operazione + InitOperation( nOperId) ; + // se lavorazione corrente, resetto if ( m_nCurrMachiningId == nOperId) m_nCurrMachiningId = GDB_ID_NULL ; + // eseguo la rimozione m_pGeomDB->Erase( nOperId) ; } else @@ -325,6 +345,8 @@ MachMgr::RemoveAllOperations( void) // rimuovo tutte le operazioni a partire dalla fine int nId = GetLastOperation() ; while ( nId != GDB_ID_NULL && nId != nStopId) { + // garantisco l'inizializzazione dell'operazione + InitOperation( nId) ; // se disposizione, elimino la fase if ( GetOperationType( nId) == OPER_DISP) RemoveLastPhase() ; @@ -543,8 +565,10 @@ MachMgr::AddDisposition( const string& sName) m_pGeomDB->SetName( nId, sName) ; // installo il gestore della disposizione Disposition* pDisp = new(nothrow) Disposition ; - if ( pDisp == nullptr) + if ( pDisp == nullptr) { + m_pGeomDB->Erase( nId) ; return GDB_ID_NULL ; + } m_pGeomDB->SetUserObj( nId, pDisp) ; pDisp->Init( this) ; pDisp->SetPhase( m_nCurrPhase) ; diff --git a/MachMgrPhases.cpp b/MachMgrPhases.cpp index 90f3925..64d18d6 100644 --- a/MachMgrPhases.cpp +++ b/MachMgrPhases.cpp @@ -175,6 +175,7 @@ MachMgr::RemoveLastPhase( void) // cancello le eventuali lavorazioni della fase int nOperId = GetLastOperation() ; while ( nOperId != GDB_ID_NULL) { + InitOperation( nOperId) ; if ( GetOperationType( nOperId) != OPER_DISP && GetOperationPhase( nOperId) == m_nPhasesCount) { if ( m_nCurrMachiningId == nOperId) m_nCurrMachiningId = GDB_ID_NULL ; @@ -182,7 +183,10 @@ MachMgr::RemoveLastPhase( void) } else break ; - nOperId = GetLastOperation() ; + int nPrevId = GetLastOperation() ; + if ( nPrevId == nOperId) + break ; + nOperId = nPrevId ; } // aggiorno i grezzi ed elimino quelli appartenenti a questa sola fase int nRawId = GetFirstRawPart() ; diff --git a/Operation.cpp b/Operation.cpp index 07ebff3..54b8513 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -71,10 +71,11 @@ IsActiveOperation( int nId, IGeomDB* pGDB) //---------------------------------------------------------------------------- bool -Operation::Removing(int nParentId, int nNextId) +Operation::Removing( int nParentId, int nNextId) { + // acconsento alla rimozione anche se non inizializzato if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) - return false ; + return true ; // imposto da verificare operazione attiva successiva int nActId = nNextId ; while ( nActId != GDB_ID_NULL && ! IsActiveOperation( nActId, m_pGeomDB))