diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 9d89ae6..d6167a9 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachMgrRawParts.cpp b/MachMgrRawParts.cpp index ea93d4e..af78fbb 100644 --- a/MachMgrRawParts.cpp +++ b/MachMgrRawParts.cpp @@ -619,14 +619,16 @@ MachMgr::RemoveRawPart( int nRawId) bool MachMgr::VerifyRawPart( int nRawId) const { - // recupero il gruppo dei grezzi nella macchinata corrente + // se il grezzo fa parte del gruppo dei grezzi, va bene int nRawGroupId = GetCurrRawGroupId() ; - if ( nRawGroupId == GDB_ID_NULL) - return false ; - // verifico che questo grezzo ne faccia parte - if ( m_pGeomDB->GetParentId( nRawId) != nRawGroupId) - return false ; - return true ; + if ( nRawGroupId != GDB_ID_NULL && m_pGeomDB->GetParentId( nRawId) == nRawGroupId) + return true ; + // se il grezzo è linkato ad un gruppo della macchina corrente, va bene + Machine* pMch = GetCurrMachine() ; + if ( pMch != nullptr && pMch->IsLinkedRawPart( nRawId)) + return true ; + // altrimenti errore + return false ; } //---------------------------------------------------------------------------- diff --git a/Machine.cpp b/Machine.cpp index 8fc6ad1..490a781 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -894,6 +894,13 @@ Machine::LinkRawPartToGroup( int nRawPartId, const std::string& sGroupName) return true ; } +//---------------------------------------------------------------------------- +bool +Machine::IsLinkedRawPart( int nRawId) const +{ + return ( find( m_vLinkedRawParts.begin(), m_vLinkedRawParts.end(), nRawId) != m_vLinkedRawParts.end()) ; +} + //---------------------------------------------------------------------------- bool Machine::UnlinkRawPartFromGroup( int nRawPartId) @@ -909,8 +916,9 @@ Machine::UnlinkRawPartFromGroup( int nRawPartId) auto iIter = find( m_vLinkedRawParts.begin(), m_vLinkedRawParts.end(), nRawPartId) ; if ( iIter == m_vLinkedRawParts.end()) return false ; - // riporto il grezzo nel gruppo dei grezzi - if ( ! m_pGeomDB->RelocateGlob( nRawPartId, nRawGrpId)) + // riporto il grezzo nel gruppo dei grezzi (se appartiene alla prima fase in testa) + int nInsPos = ( m_pMchMgr->VerifyRawPartPhase( nRawPartId, 1) ? GDB_FIRST_SON : GDB_LAST_SON) ; + if ( ! m_pGeomDB->RelocateGlob( nRawPartId, nRawGrpId, nInsPos)) return false ; // tolgo il grezzo dall'elenco dei linkati m_vLinkedRawParts.erase( iIter) ; diff --git a/Machine.h b/Machine.h index a31767e..1691276 100644 --- a/Machine.h +++ b/Machine.h @@ -93,6 +93,7 @@ class Machine const std::string& GetOutstrokeInfo( void) const { return m_sOutstrokeInfo ; } bool LinkRawPartToGroup( int nRawPartId, const std::string& sGroupName) ; + bool IsLinkedRawPart( int nRawId) const ; bool UnlinkRawPartFromGroup( int nRawPartId) ; bool UnlinkAllRawPartsFromGroups( void) ; bool LuaExistsFunction( const std::string& sFun) ;