diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index 8622d99..46043d3 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -1124,7 +1124,16 @@ MachMgr::RemovePreviewMachiningTool( void) const int MachMgr::GetPreviewMachiningToolStepCount( void) const { - return -1 ; + // recupero la lavorazione corrente + int nCurrMchId = GetCurrMachining() ; + if ( nCurrMchId == GDB_ID_NULL) + return 0 ; + // ne recupero il gestore + Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; + if ( pMch == nullptr) + return 0 ; + // eseguo + return pMch->GetToolPreviewStepCount() ; } //---------------------------------------------------------------------------- diff --git a/Machining.cpp b/Machining.cpp index c7ecaad..11393f6 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -178,7 +178,36 @@ Machining::RemoveToolPreview( void) const int Machining::GetToolPreviewStepCount( void) const { - return -1 ; + // verifico validità gestori DB geometrico e CAM + if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr) + return 0 ; + // recupero gruppo per geometria di lavorazione (Cutter Location) + int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; + if ( nClId == GDB_ID_NULL) + return 0 ; + // determino il numero di entità di tutti i sottogruppi, escludendo CLIMB e RISE + int nCount = 0 ; + int nPxId = m_pGeomDB->GetFirstGroupInGroup( nClId) ; + while ( nPxId != GDB_ID_NULL) { + // aggiungo tutte le entità del truppo + nCount += m_pGeomDB->GetGroupObjs( nPxId) ; + // tolgo le entità CLIMB + int nClimbId = m_pGeomDB->GetFirstNameInGroup( nPxId, MCH_CL_CLIMB) ; + while ( nClimbId != GDB_ID_NULL) { + -- nCount ; + nClimbId = m_pGeomDB->GetNextName( nClimbId, MCH_CL_CLIMB) ; + } + // tolgo le entità RISE + int nRiseId = m_pGeomDB->GetFirstNameInGroup( nPxId, MCH_CL_RISE) ; + while ( nRiseId != GDB_ID_NULL) { + -- nCount ; + nRiseId = m_pGeomDB->GetNextName( nRiseId, MCH_CL_RISE) ; + } + // passo al successivo sottogruppo + nPxId = m_pGeomDB->GetNextGroup( nPxId) ; + } + + return nCount ; } //---------------------------------------------------------------------------- @@ -270,11 +299,29 @@ Machining::ToolPreview( int nEntId, int nStep) const nParentId = m_pGeomDB->GetParentId( nEntId) ; if ( m_pGeomDB->GetParentId( nParentId) == nClId) { // se richiesta successiva - if ( nStep > 0) - nEntId = GetToolPreviewNext( m_pGeomDB, nEntId, nParentId) ; + if ( nStep > 0) { + while ( nStep > 0) { + int nOldId = nEntId ; + nEntId = GetToolPreviewNext( m_pGeomDB, nEntId, nParentId) ; + -- nStep ; + if ( nEntId == GDB_ID_NULL) { + nEntId = nOldId ; + break ; + } + } + } // se richiesta precedente - else if ( nStep < 0) - nEntId = GetToolPreviewPrev( m_pGeomDB, nEntId, nParentId) ; + else if ( nStep < 0) { + while ( nStep < 0) { + int nOldId = nEntId ; + nEntId = GetToolPreviewPrev( m_pGeomDB, nEntId, nParentId) ; + ++ nStep ; + if ( nEntId == GDB_ID_NULL) { + nEntId = nOldId ; + break ; + } + } + } } else nEntId = GDB_ID_NULL ;