diff --git a/MachMgr.h b/MachMgr.h index ed48c93..8ee94cc 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -215,6 +215,7 @@ class MachMgr : public IMachMgr bool ResetAllAxesPos( void) override ; bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) override ; bool ResetHeadSet( const std::string& sHead) override ; + bool SetMachineLook( int nFlag) override ; public : MachMgr( void) ; diff --git a/MachMgrFixtures.cpp b/MachMgrFixtures.cpp index cfc5932..26872c3 100644 --- a/MachMgrFixtures.cpp +++ b/MachMgrFixtures.cpp @@ -93,26 +93,7 @@ MachMgr::ShowOnlyTable( bool bVal) Machine* pMch = GetCurrMachine() ; if ( pMch == nullptr) return false ; - // recupero l'identificativo del gruppo della macchina - int nMGeoId = pMch->GetMGeoId() ; - // recupero la tavola corrente - int nTabId = pMch->GetCurrTable() ; - if ( nTabId == GDB_ID_NULL) - return false ; - // nascondo o visualizzo i fratelli e tutti i fratelli degli ascendenti - int nCurrId = nTabId ; - int nParentId = m_pGeomDB->GetParentId( nCurrId) ; - while ( nParentId != GDB_ID_NULL && nParentId != nMGeoId) { - int nId = m_pGeomDB->GetFirstInGroup( nParentId) ; - while ( nId != GDB_ID_NULL) { - if ( nId != nCurrId) - m_pGeomDB->SetStatus( nId, ( bVal ? GDB_ST_OFF : GDB_ST_ON)) ; - nId = m_pGeomDB->GetNext( nId) ; - } - nCurrId = nParentId ; - nParentId = m_pGeomDB->GetParentId( nParentId) ; - } - - return true ; + // imposto visualizzazione della sola tavola o di tutto + return pMch->SetLook( bVal ? MCH_LOOK_TAB : MCH_LOOK_ALL) ; } diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index a1f7f32..7fc1f53 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -361,3 +361,14 @@ MachMgr::GetOutstrokeInfo( void) const } return m_vMachines[m_nCurrMch].pMachine->GetOutstrokeInfo() ; } + +//---------------------------------------------------------------------------- +bool +MachMgr::SetMachineLook( int nFlag) +{ + if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || + m_vMachines[m_nCurrMch].pMachine == nullptr) { + return false ; + } + return m_vMachines[m_nCurrMch].pMachine->SetLook( nFlag) ; +} diff --git a/Machine.cpp b/Machine.cpp index 0da90fb..ac3e9c9 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -441,6 +441,22 @@ Machine::GetAxis( int nGroup) const return ( dynamic_cast( m_pGeomDB->GetUserObj( nGroup))) ; } +//---------------------------------------------------------------------------- +bool +Machine::IsLinearAxisGroup( int nGroup) const +{ + Axis* pAx = GetAxis( nGroup) ; + return ( pAx != nullptr && pAx->GetType() == MCH_AT_LINEAR) ; +} + +//---------------------------------------------------------------------------- +bool +Machine::IsRotaryAxisGroup( int nGroup) const +{ + Axis* pAx = GetAxis( nGroup) ; + return ( pAx != nullptr && pAx->GetType() == MCH_AT_ROTARY) ; +} + //---------------------------------------------------------------------------- Table* Machine::GetTable( int nGroup) const @@ -575,3 +591,72 @@ Machine::CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit) } return true ; } + +//---------------------------------------------------------------------------- +bool +Machine::SetLook( int nFlag) +{ + // verifico DB geometrico + if ( m_pGeomDB == nullptr) + return false ; + + // recupero l'identificativo del gruppo di base della macchina + int nMBaseId = m_pGeomDB->GetFirstInGroup( GetMGeoId()) ; + + // recupero la tavola corrente + int nTabId = GetCurrTable() ; + if ( nTabId == GDB_ID_NULL) + return false ; + // nascondo o visualizzo i fratelli e tutti i fratelli degli ascendenti della tavola + bool bTabOnly = ( nFlag != MCH_LOOK_ALL) ; + int nTabCurrId = nTabId ; + int nParentId = m_pGeomDB->GetParentId( nTabCurrId) ; + while ( nParentId != GDB_ID_NULL && nParentId != nMBaseId) { + int nId = m_pGeomDB->GetFirstInGroup( nParentId) ; + while ( nId != GDB_ID_NULL) { + if ( nId != nTabCurrId) + m_pGeomDB->SetStatus( nId, ( bTabOnly ? GDB_ST_OFF : GDB_ST_ON)) ; + nId = m_pGeomDB->GetNext( nId) ; + } + nTabCurrId = nParentId ; + nParentId = m_pGeomDB->GetParentId( nParentId) ; + } + + // recupero l'utensile corrente + int nToolId = GetCurrTool() ; + // nascondo o visualizzo i fratelli e tutti i fratelli degli ascendenti + bool bToolOnly = ( nFlag > MCH_LOOK_TAB && nFlag < MCH_LOOK_ALL) ; + int nToolCurrId = nToolId ; + nParentId = m_pGeomDB->GetParentId( nToolCurrId) ; + while ( nParentId != GDB_ID_NULL && nParentId != nMBaseId) { + bool bHide = bToolOnly ; + if ( nFlag == MCH_LOOK_TAB_HEAD) { + if ( IsHeadGroup( nParentId) || IsRotaryAxisGroup( nParentId)) + bHide = false ; + } + int nId = m_pGeomDB->GetFirstInGroup( nParentId) ; + while ( nId != GDB_ID_NULL) { + if ( nId != nToolCurrId) + m_pGeomDB->SetStatus( nId, ( bHide ? GDB_ST_OFF : GDB_ST_ON)) ; + else + m_pGeomDB->SetStatus( nId, GDB_ST_ON) ; + nId = m_pGeomDB->GetNext( nId) ; + } + nToolCurrId = nParentId ; + nParentId = m_pGeomDB->GetParentId( nParentId) ; + } + + // sistemo gli oggetti del gruppo di base + int nId = m_pGeomDB->GetFirstInGroup( nMBaseId) ; + while ( nId != GDB_ID_NULL) { + if ( nId != nTabCurrId && nId != nToolCurrId) + m_pGeomDB->SetStatus( nId, ( nFlag != MCH_LOOK_ALL ? GDB_ST_OFF : GDB_ST_ON)) ; + else if ( nId == nTabCurrId) + m_pGeomDB->SetStatus( nId, GDB_ST_ON) ; + else + m_pGeomDB->SetStatus( nId, ( nFlag == MCH_LOOK_TAB ? GDB_ST_OFF : GDB_ST_ON)) ; + nId = m_pGeomDB->GetNext( nId) ; + } + + return true ; +} diff --git a/Machine.h b/Machine.h index f5f4550..ee3aebd 100644 --- a/Machine.h +++ b/Machine.h @@ -40,6 +40,7 @@ class Machine { return m_sName ; } Table* GetTable( const std::string& sTable) const { return GetTable( GetGroup( sTable)) ; } + bool SetLook( int nFlag) ; bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ; bool ResetHeadSet( const std::string& sHead) ; bool SetAxisPos( const std::string& sAxis, double dVal) ; @@ -104,6 +105,8 @@ class Machine Axis* GetAxis( int nGroup) const ; bool IsAxisGroup( int nGroup) const { return ( GetAxis( nGroup) != nullptr) ; } + bool IsLinearAxisGroup( int nGroup) const ; + bool IsRotaryAxisGroup( int nGroup) const ; Table* GetTable( int nGroup) const ; bool IsTableGroup( int nGroup) const { return ( GetTable( nGroup) != nullptr) ; }