diff --git a/Disposition.cpp b/Disposition.cpp index ed8e763..616a827 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -86,6 +86,8 @@ Disposition::Clone( void) const // eseguo copia dei dati if ( pDisp != nullptr) { try { pDisp->m_sTabName = m_sTabName ; + pDisp->m_pMchMgr = m_pMchMgr ; + pDisp->m_nPhase = m_nPhase ; pDisp->m_ptRef1 = m_ptRef1 ; pDisp->m_b3Area1 = m_b3Area1 ; pDisp->m_dAreaOffset = m_dAreaOffset ; @@ -1205,6 +1207,23 @@ Disposition::InsertMoveInfoInList( int nRawId, int nType, const Point3d& ptP, in return true ; } +//---------------------------------------------------------------------------- +bool +Disposition::UpdateRawPartId( int nRawId, int nNewRawId) +{ + // aggiorno i movimenti registrati per questo grezzo + while ( true) { + auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(), + [ nRawId]( const MoveRawData& Mrv) + { return ( Mrv.nRawId == nRawId) ; }) ; + if ( iIter == m_vMvrData.end()) + break ; + else + iIter->nRawId = nNewRawId ; + } + return true ; +} + //---------------------------------------------------------------------------- bool Disposition::RemoveRawPart( int nRawId) diff --git a/Disposition.h b/Disposition.h index 7ce4cd9..1accd12 100644 --- a/Disposition.h +++ b/Disposition.h @@ -102,6 +102,7 @@ class Disposition : public Operation bool MoveRawPart( int nRawId, const Vector3d& vtMove) ; bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ; bool ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADeg, double dAngC1Deg, bool bAddToList = true) ; + bool UpdateRawPartId( int nRawId, int nNewRawId) ; bool RemoveRawPart( int nRawId) ; bool GetFixtureData( int nInd, std::string& sName, int& nId, Point3d& ptPos, double& dAngDeg, double& dMov) const ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 511367b..0d7108e 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachMgr.h b/MachMgr.h index 45469e3..33dea73 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2015-2022 +// EgalTech 2015-2023 //---------------------------------------------------------------------------- -// File : MachMgr.h Data : 21.09.22 Versione : 2.4i4 +// File : MachMgr.h Data : 25.08.23 Versione : 2.5h3 // Contenuto : Dichiarazione della classe MachMgr. // // @@ -11,6 +11,7 @@ // 17.08.20 DS Aggiunte GetAxisMin e GetAxisMax. // 17.03.21 DS Aggiunte funzioni per import/export utensili. // 21.09.22 DS Aggiunta GetAxisOffset. +// 25.08.23 DS Aggiunta CopyMachGroup. // //---------------------------------------------------------------------------- @@ -95,6 +96,7 @@ class MachMgr : public IMachMgr int GetPrevMachGroup( int nId) const override ; bool GetMachGroupNewName( std::string& sName) const override ; int AddMachGroup( const std::string& sName, const std::string& sMachineName) override ; + int CopyMachGroup( const std::string& sSouName, const std::string& sName) override ; bool RemoveMachGroup( int nId) override ; std::string GetMachGroupName( int nId) const override ; std::string GetMachGroupMachineName( int nId) const override ; diff --git a/MachMgrMachGroups.cpp b/MachMgrMachGroups.cpp index 217076a..d0fb732 100644 --- a/MachMgrMachGroups.cpp +++ b/MachMgrMachGroups.cpp @@ -182,6 +182,52 @@ MachMgr::AddMachGroup( const string& sName, const string& sMachineName) return nNewId ; } +//---------------------------------------------------------------------------- +int +MachMgr::CopyMachGroup( const string& sSouName, const string& sName) +{ + // recupero il gruppo sorgente + int nSouMGrpId = GetMachGroupId( sSouName) ; + if ( nSouMGrpId == GDB_ID_NULL) + return GDB_ID_NULL ; + // verifico esista la sua macchina + string sMachineName ; + m_pGeomDB->GetInfo( nSouMGrpId, MACH_MACHINE_KEY, sMachineName) ; + if ( sMachineName.empty() || ! LoadMachine( sMachineName)) + return GDB_ID_NULL ; + // verifico nome nuovo gruppo (non deve essere vuoto e non deve esserci già un gruppo con questo nome) + if ( &sName == nullptr || sName.empty() || GetMachGroupId( sName) != GDB_ID_NULL) + return GDB_ID_NULL ; + // reset gruppo corrente + ResetCurrMachGroup() ; + // eseguo la copia del gruppo sorgente e la metto in coda + int nNewMGrpId = m_pGeomDB->Copy( nSouMGrpId, GDB_ID_NULL, m_nMachBaseId) ; + if ( nNewMGrpId == GDB_ID_NULL) + return GDB_ID_NULL ; + // assegno il nome + m_pGeomDB->SetName( nNewMGrpId, sName) ; + // converto opportunamente gli indicativi dei grezzi nelle disposizioni + int nSouRawPartId = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( nSouMGrpId, MACH_RAW_GROUP)) ; + int nNewRawPartId = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( nNewMGrpId, MACH_RAW_GROUP)) ; + while ( nSouRawPartId != GDB_ID_NULL && nNewRawPartId != GDB_ID_NULL) { + // ciclo sulle disposizioni del nuovo gruppo di lavoro + int nOperId = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( nNewMGrpId, MACH_OPER_GROUP)) ; + while ( nOperId != GDB_ID_NULL) { + Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( nOperId)) ; + if ( pDisp != nullptr) + pDisp->UpdateRawPartId( nSouRawPartId, nNewRawPartId) ; + nOperId = m_pGeomDB->GetNextGroup( nOperId) ; + } + // passo alla coppia successiva + nSouRawPartId = m_pGeomDB->GetNextGroup( nSouRawPartId) ; + nNewRawPartId = m_pGeomDB->GetNextGroup( nNewRawPartId) ; + } + // lo rendo corrente + SetCurrMachGroup( nNewMGrpId) ; + // restituisco l'identificativo del gruppo + return nNewMGrpId ; +} + //---------------------------------------------------------------------------- bool MachMgr::RemoveMachGroup( int nId) @@ -298,14 +344,14 @@ MachMgr::GetMachGroupId( const string& sName) const { // verifica dei parametri if ( &sName == nullptr || sName.empty()) - return false ; + return GDB_ID_NULL ; // verifica del gruppo base per le lavorazioni if ( ! VerifyMachBase()) - return false ; + return GDB_ID_NULL ; // recupero l'identificativo del gruppo con il nome indicato PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; if ( IsNull( pIter)) - return false ; + return GDB_ID_NULL ; bool bIter = pIter->GoToFirstGroupInGroup( m_nMachBaseId) ; while( bIter) { // verifico il nome