//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : MachMgrOperations.cpp Data : 21.05.15 Versione : 1.6e7 // Contenuto : Implementazione gestione operazioni della classe MachMgr. // // // // Modifiche : 16.04.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "DllMain.h" #include "MachMgr.h" #include "MachConst.h" #include "Disposition.h" #include "MachiningCreate.h" #include "SetTempPhase.h" #include "/EgtDev/Include/EMkOperationConst.h" #include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; //---------------------------------------------------------------------------- int MachMgr::GetOperationCount( void) const { // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) return 0 ; // ritorno numero di operazioni return m_pGeomDB->GetGroupObjs( nOperGrpId) ; } //---------------------------------------------------------------------------- int MachMgr::GetFirstOperation( void) const { // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) return GDB_ID_NULL ; // recupero il primo sottogruppo int nId = m_pGeomDB->GetFirstGroupInGroup( nOperGrpId) ; return nId ; } //---------------------------------------------------------------------------- int MachMgr::GetNextOperation( int nId) const { // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) return GDB_ID_NULL ; // verifico che il gruppo ricevuto sia corretto if ( m_pGeomDB->GetParentId( nId) != nOperGrpId) return GDB_ID_NULL ; // recupero il successivo sottogruppo int nNextId = m_pGeomDB->GetNextGroup( nId) ; return nNextId ; } //---------------------------------------------------------------------------- int MachMgr::GetLastOperation( void) const { // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) return GDB_ID_NULL ; // recupero l'ultimo sottogruppo int nId = m_pGeomDB->GetLastGroupInGroup( nOperGrpId) ; return nId ; } //---------------------------------------------------------------------------- int MachMgr::GetPrevOperation( int nId) const { // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) return GDB_ID_NULL ; // verifico che il gruppo ricevuto sia corretto if ( m_pGeomDB->GetParentId( nId) != nOperGrpId) return GDB_ID_NULL ; // recupero il precedente sottogruppo int nPrevId = m_pGeomDB->GetPrevGroup( nId) ; return nPrevId ; } //---------------------------------------------------------------------------- int MachMgr::GetFirstActiveOperation( void) const { int nId = GetFirstOperation() ; int nMode ; while ( nId != GDB_ID_NULL && m_pGeomDB->GetCalcMode( nId, nMode) && nMode == GDB_MD_HIDDEN) nId = GetNextOperation( nId) ; return nId ; } //---------------------------------------------------------------------------- int MachMgr::GetNextActiveOperation( int nId) const { int nNextId = GetNextOperation( nId) ; int nMode ; while ( nNextId != GDB_ID_NULL && m_pGeomDB->GetCalcMode( nNextId, nMode) && nMode == GDB_MD_HIDDEN) nNextId = GetNextOperation( nNextId) ; return nNextId ; } //---------------------------------------------------------------------------- int MachMgr::GetLastActiveOperation( void) const { int nId = GetLastOperation() ; int nMode ; while ( nId != GDB_ID_NULL && m_pGeomDB->GetCalcMode( nId, nMode) && nMode == GDB_MD_HIDDEN) nId = GetPrevOperation( nId) ; return nId ; } //---------------------------------------------------------------------------- int MachMgr::GetPrevActiveOperation( int nId) const { int nPrevId = GetPrevOperation( nId) ; int nMode ; while ( nPrevId != GDB_ID_NULL && m_pGeomDB->GetCalcMode( nPrevId, nMode) && nMode == GDB_MD_HIDDEN) nPrevId = GetPrevOperation( nPrevId) ; return nPrevId ; } //---------------------------------------------------------------------------- int MachMgr::GetOperationType( int nId) const { // recupero l'operazione PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; if ( IsNull( pIter) || ! pIter->GoTo( nId)) return OPER_NULL ; // verifico che il gruppo ricevuto sia corretto if ( pIter->GetParentId() != GetCurrOperId()) return OPER_NULL ; // recupero user object IUserObj* pUserObj = pIter->GetUserObj() ; if ( pUserObj == nullptr) return OPER_NULL ; // recupero il tipo di UserObj const string& sUserObj = pUserObj->GetClassName() ; if ( sUserObj == USEROBJ_GETNAME( Disposition)) return OPER_DISP ; else if ( sUserObj == USEROBJ_GETNAME( Drilling)) return OPER_DRILLING ; else if ( sUserObj == USEROBJ_GETNAME( Sawing)) return OPER_SAWING ; else if ( sUserObj == USEROBJ_GETNAME( Milling)) return OPER_MILLING ; else if ( sUserObj == USEROBJ_GETNAME( SawRoughing)) return OPER_SAWROUGHING ; else if ( sUserObj == USEROBJ_GETNAME( SawFinishing)) return OPER_SAWFINISHING ; else return OPER_NULL ; } //---------------------------------------------------------------------------- int MachMgr::GetOperationPhase( int nId) const { // recupero l'operazione PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; if ( IsNull( pIter) || ! pIter->GoTo( nId)) return 0 ; // verifico che il gruppo ricevuto sia corretto if ( pIter->GetParentId() != GetCurrOperId()) return 0 ; // recupero user object IUserObj* pUserObj = pIter->GetUserObj() ; if ( pUserObj == nullptr) return 0 ; // se disposizione if ( pUserObj->GetClassName() == USEROBJ_GETNAME( Disposition)) { const Disposition* pDisp = ::GetDisposition( pUserObj) ; if ( pDisp != nullptr) return pDisp->GetPhase() ; } // altrimenti lavorazione else { const Machining* pMch = GetMachining( pUserObj) ; if ( pMch != nullptr) return pMch->GetPhase() ; } // errore return 0 ; } //---------------------------------------------------------------------------- bool MachMgr::GetOperationNewName( string& sName) const { // il parametro nome deve essere valido if ( &sName == nullptr) return false ; // il gruppo per le operazioni deve essere presente nella macchinata corrente if ( GetCurrOperId() == GDB_ID_NULL) return false ; // se nome vuoto, assegno radice standard if ( sName.empty()) sName = "Oper" ; // se presenti caratteri vietati, li sostituisco ValidateName( sName) ; // verifico che il nome sia unico int nCount = 0 ; string sOrigName = sName ; if ( sOrigName.length() > 2 && sOrigName.rfind( "_1") == sOrigName.length() - 2) sOrigName.erase( sOrigName.length() - 2) ; while ( GetOperationId( sName) != GDB_ID_NULL) { ++ nCount ; sName = sOrigName + "_" + ToString( nCount) ; } return true ; } //---------------------------------------------------------------------------- std::string MachMgr::GetOperationName( int nId) const { // recupero l'operazione PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; if ( IsNull( pIter) || ! pIter->GoTo( nId)) return 0 ; // verifico che il gruppo ricevuto sia corretto if ( pIter->GetParentId() != GetCurrOperId()) return 0 ; // recupero il nome dell'operazione riferita string sName ; pIter->GetName( sName) ; return sName ; } //---------------------------------------------------------------------------- int MachMgr::GetOperationId( const string& sName) const { // verifica dei parametri if ( &sName == nullptr || sName.empty()) return false ; // recupero l'identificativo dell'operazione con il nome indicato PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; if ( IsNull( pIter)) return false ; bool bIter = pIter->GoToFirstInGroup( GetCurrOperId()) ; while ( bIter) { // verifico il nome string sOperName ; if ( pIter->GetName( sOperName) && EqualNoCase( sOperName, sName)) return pIter->GetId() ; // passo al successivo bIter = pIter->GoToNext() ; } return GDB_ID_NULL ; } //---------------------------------------------------------------------------- bool MachMgr::IsOperationEmpty( int nId) const { // recupero l'operazione PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; if ( IsNull( pIter) || ! pIter->GoTo( nId)) return true ; // verifico che il gruppo ricevuto sia corretto if ( pIter->GetParentId() != GetCurrOperId()) return true ; // recupero user object IUserObj* pUserObj = pIter->GetUserObj() ; if ( pUserObj == nullptr) return true ; // se disposizione if ( pUserObj->GetClassName() == USEROBJ_GETNAME( Disposition)) { const Disposition* pDisp = ::GetDisposition( pUserObj) ; if ( pDisp != nullptr) return pDisp->IsEmpty() ; } // altrimenti lavorazione else { const Machining* pMch = GetMachining( pUserObj) ; if ( pMch != nullptr) return pMch->IsEmpty() ; } // errore return true ; } //---------------------------------------------------------------------------- bool MachMgr::RemoveOperation( int nId) { // verifico sia una Operazione diversa da Disposizione int nType = GetOperationType( nId) ; if ( nType == OPER_NULL || nType == OPER_DISP) return false ; // se lavorazione corrente, resetto if ( m_nCurrMachiningId == nId) m_nCurrMachiningId = GDB_ID_NULL ; // eseguo la rimozione m_pGeomDB->Erase( nId) ; return true ; } //---------------------------------------------------------------------------- bool MachMgr::RemoveAllPhaseOperations( int nPhase) { // recupero la disposizione di inizio fase int nDispId = GetPhaseDisposition( nPhase) ; if ( nDispId == GDB_ID_NULL) return true ; // elimino tutte le operazioni successive della stessa fase int nOperId = m_pGeomDB->GetNext( nDispId) ; while ( nOperId != GDB_ID_NULL) { int nNextOperId = m_pGeomDB->GetNext( nOperId) ; if ( GetOperationPhase( nOperId) == nPhase) { if ( m_nCurrMachiningId == nOperId) m_nCurrMachiningId = GDB_ID_NULL ; m_pGeomDB->Erase( nOperId) ; } else break ; nOperId = nNextOperId ; } return true ; } //---------------------------------------------------------------------------- bool MachMgr::RemoveAllOperations( void) { // indice terminazione ciclo int nStopId = GetFirstOperation() ; // rimuovo tutte le operazioni a partire dalla fine int nId = GetLastOperation() ; while ( nId != GDB_ID_NULL && nId != nStopId) { // se disposizione, elimino la fase if ( GetOperationType( nId) == OPER_DISP) RemoveLastPhase() ; // altrimenti... else { // se lavorazione corrente, resetto if ( m_nCurrMachiningId == nId) m_nCurrMachiningId = GDB_ID_NULL ; // eseguo la rimozione m_pGeomDB->Erase( nId) ; } // recupero la nuova ultima (deve essere diversa dalla precedente) int nPrevId = GetLastOperation() ; if ( nPrevId == nId) return false ; nId = nPrevId ; } return true ; } //---------------------------------------------------------------------------- bool MachMgr::SetOperationMode( int nId, bool bActive) { // verifico sia una Operazione if ( GetOperationType( nId) == OPER_NULL) return false ; // eseguo attivazione/disattivazione m_pGeomDB->SetMode( nId, ( bActive ? GDB_MD_STD : GDB_MD_HIDDEN)) ; return true ; } //---------------------------------------------------------------------------- bool MachMgr::GetOperationMode( int nId, bool& bActive) const { // verifico sia una Operazione if ( GetOperationType( nId) == OPER_NULL) return false ; // recupero stato di attivazione/disattivazione int nMode ; if ( ! m_pGeomDB->GetMode( nId, nMode)) return false ; bActive = ( nMode == GDB_MD_STD) ; return true ; } //---------------------------------------------------------------------------- bool MachMgr::SetAllOperationsMode( bool bExceptFirstDisp, bool bActive) { // modifico lo stato di tutte le operazioni int nId = ( bExceptFirstDisp ? GetNextOperation( GetFirstOperation()) : GetFirstOperation()) ; while ( nId != GDB_ID_NULL) { // eseguo attivazione/disattivazione m_pGeomDB->SetMode( nId, ( bActive ? GDB_MD_STD : GDB_MD_HIDDEN)) ; // passo alla successiva nId = GetNextOperation( nId) ; } return true ; } //---------------------------------------------------------------------------- bool MachMgr::SetOperationStatus( int nId, bool bShow) { // verifico sia una Operazione if ( GetOperationType( nId) == OPER_NULL) return false ; // eseguo cambio di stato di visualizzazione m_pGeomDB->SetStatus( nId, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ; return true ; } //---------------------------------------------------------------------------- bool MachMgr::GetOperationStatus( int nId, bool& bShow) const { // verifico sia una Operazione if ( GetOperationType( nId) == OPER_NULL) return false ; // recupero stato di visualizzazione int nStat ; if ( ! m_pGeomDB->GetStatus( nId, nStat)) return false ; bShow = ( nStat == GDB_ST_ON) ; return true ; } //---------------------------------------------------------------------------- bool MachMgr::SetAllOperationsStatus( bool bExceptFirstDisp, bool bShow) { // modifico lo stato di tutte le operazioni int nId = ( bExceptFirstDisp ? GetNextOperation( GetFirstOperation()) : GetFirstOperation()) ; while ( nId != GDB_ID_NULL) { // eseguo cambio di stato di visualizzazione m_pGeomDB->SetStatus( nId, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ; // passo alla successiva nId = GetNextOperation( nId) ; } return true ; } //---------------------------------------------------------------------------- bool MachMgr::ChangeOperationPhase( int nMchId, int nNewPhase) { // l'operazione deve esistere e non essere una disposizione int nType = GetOperationType( nMchId) ; if ( nType == OPER_NULL || nType == OPER_DISP) return false ; // verifico che la nuova fase esista if ( nNewPhase > m_nPhasesCount) return false ; // se la fase dell'operazione è già giusta, esco subito con successo if ( GetOperationPhase( nMchId) == nNewPhase) return true ; // cerco l'ultima operazione della nuova fase int nRefId = GDB_ID_NULL ; int nCurrId = GetFirstOperation() ; while ( nCurrId != GDB_ID_NULL) { int nPhase = GetOperationPhase( nCurrId) ; if ( nPhase == nNewPhase) nRefId = nCurrId ; else if ( nPhase > nNewPhase) break ; nCurrId = GetNextOperation( nCurrId) ; } if ( nRefId == GDB_ID_NULL) return false ; // recupero la lavorazione Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nMchId)) ; if ( pMch == nullptr) return false ; // sposto la lavorazione if ( ! m_pGeomDB->Relocate( nMchId, nRefId, GDB_AFTER)) return false ; // assegno nuova fase return pMch->SetPhase( nNewPhase) ; } //---------------------------------------------------------------------------- bool MachMgr::RemoveOperationHome( int nId) { // l'operazione deve esistere int nType = GetOperationType( nId) ; if ( nType == OPER_NULL) return false ; // ne recupero il gestore Operation* pOper = GetOperation( m_pGeomDB->GetUserObj( nId)) ; if ( pOper == nullptr) return false ; // rimuovo il posizionamento finale in home return pOper->RemoveHome() ; } //---------------------------------------------------------------------------- // Dispositions //---------------------------------------------------------------------------- int MachMgr::AddDisposition( const string& sName) { // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) return GDB_ID_NULL ; // recupero nome originale, partendo da quello proposto string sNewName = sName ; if ( ! GetOperationNewName( sNewName)) return GDB_ID_NULL ; // inserisco il gruppo int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ; if ( nId == GDB_ID_NULL) return GDB_ID_NULL ; // assegno il nome m_pGeomDB->SetName( nId, sName) ; // installo il gestore della disposizione Disposition* pDisp = new(nothrow) Disposition ; if ( pDisp == nullptr) return GDB_ID_NULL ; m_pGeomDB->SetUserObj( nId, pDisp) ; pDisp->Init( this) ; pDisp->SetPhase( m_nCurrPhase) ; return nId ; } //---------------------------------------------------------------------------- int MachMgr::GetPhaseDisposition( int nPhase) const { // verifico esista la fase if ( nPhase > m_nPhasesCount) return GDB_ID_NULL ; // cerco la disposizione nel gruppo delle operazioni PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; if ( IsNull( pIter)) return GDB_ID_NULL ; bool bIter = pIter->GoToFirstInGroup( GetCurrOperId()) ; while ( bIter) { const Disposition* pDisp = ::GetDisposition( pIter->GetUserObj()) ; if ( pDisp != nullptr && pDisp->GetPhase() == nPhase) return pIter->GetId() ; bIter = pIter->GoToNext() ; } return GDB_ID_NULL ; } //---------------------------------------------------------------------------- bool MachMgr::DispositionSpecialApply( int nId, bool bRecalc) { // recupero la disposizione Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( nId)) ; if ( pDisp == nullptr) return false ; // lancio l'azione return pDisp->SpecialApply( bRecalc) ; } //---------------------------------------------------------------------------- // Machinings //---------------------------------------------------------------------------- bool MachMgr::SetCurrMachining( int nId) { // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) return false ; // verifico che il gruppo di indice nId appartenga a questo gruppo if ( m_pGeomDB->GetParentId( nId) != nOperGrpId) return false ; // verifico che questo gruppo sia realmente una lavorazione Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nId)) ; if ( pMch == nullptr) return false ; // gli imposto il manager generale delle lavorazioni pMch->Init( this) ; // imposto la lavorazione corrente m_nCurrMachiningId = nId ; return true ; } //---------------------------------------------------------------------------- bool MachMgr::ResetCurrMachining( void) { m_nCurrMachiningId = GDB_ID_NULL ; return true ; } //---------------------------------------------------------------------------- int MachMgr::GetCurrMachining( void) const { // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) return GDB_ID_NULL ; // verifico che la lavorazione corrente appartenga a questo gruppo if ( m_pGeomDB->GetParentId( m_nCurrMachiningId) == nOperGrpId) return m_nCurrMachiningId ; else return GDB_ID_NULL ; } //---------------------------------------------------------------------------- int MachMgr::AddMachining( const string& sName, const string& sMachining) { // nessuna lavorazione corrente m_nCurrMachiningId = GDB_ID_NULL ; // recupero il gestore delle lavorazioni della macchina corrente MachiningsMgr* pMMgr = GetCurrMachiningsMgr() ; if ( pMMgr == nullptr) return GDB_ID_NULL ; // recupero il tipo di lavorazione const MachiningData* pMd = pMMgr->GetMachining( sMachining) ; if ( pMd == nullptr) { string sOut = "AddMachining error : " + sMachining + " not found" ; LOG_INFO( GetEMkLogger(), sOut.c_str()) return GDB_ID_NULL ; } int nMchType = pMd->GetType() ; // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) return GDB_ID_NULL ; // recupero nome originale, partendo da quello proposto string sNewName = sName ; if ( ! GetOperationNewName( sNewName)) return GDB_ID_NULL ; // inserisco il gruppo int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ; if ( nId == GDB_ID_NULL) return GDB_ID_NULL ; // assegno il nome if ( ! m_pGeomDB->SetName( nId, sNewName)) { string sOut = "AddMachining error : " + sNewName + " invalid name " ; LOG_INFO( GetEMkLogger(), sOut.c_str()) m_pGeomDB->Erase( nId) ; return GDB_ID_NULL ; } // installo il gestore della lavorazione Machining* pMch = CreateMachining( nMchType) ; m_pGeomDB->SetUserObj( nId, pMch) ; if ( pMch == nullptr || ! pMch->Init( this) || ! pMch->SetPhase( m_nCurrPhase) || ! pMch->Prepare( sMachining)) { string sOut = "AddMachining error : " + sMachining + " on " + sName ; LOG_INFO( GetEMkLogger(), sOut.c_str()) m_pGeomDB->Erase( nId) ; return GDB_ID_NULL ; } // la dichiaro lavorazione corrente m_nCurrMachiningId = nId ; return nId ; } //---------------------------------------------------------------------------- int MachMgr::AddMachining( const string& sName, int nMchType, const string& sTool) { // nessuna lavorazione corrente m_nCurrMachiningId = GDB_ID_NULL ; // recupero il gestore delle lavorazioni della macchina corrente MachiningsMgr* pMMgr = GetCurrMachiningsMgr() ; if ( pMMgr == nullptr) return GDB_ID_NULL ; // recupero il gruppo delle operazioni nella macchinata corrente int nOperGrpId = GetCurrOperId() ; if ( nOperGrpId == GDB_ID_NULL) return GDB_ID_NULL ; // recupero nome originale, partendo da quello proposto string sNewName = sName ; if ( ! GetOperationNewName( sNewName)) return GDB_ID_NULL ; // inserisco il gruppo int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ; if ( nId == GDB_ID_NULL) return GDB_ID_NULL ; // assegno il nome if ( ! m_pGeomDB->SetName( nId, sNewName)) { string sOut = "AddMachining error : " + sNewName + " invalid name " ; LOG_INFO( GetEMkLogger(), sOut.c_str()) m_pGeomDB->Erase( nId) ; return GDB_ID_NULL ; } // installo il gestore della lavorazione Machining* pMch = CreateMachining( nMchType) ; m_pGeomDB->SetUserObj( nId, pMch) ; if ( pMch == nullptr || ! pMch->Init( this) || ! pMch->SetPhase( m_nCurrPhase) || ! pMch->SetParam( MPA_TOOL, sTool)) { string sOut = "AddMachining error : " + GetMachiningTitle( nMchType) + "/" + sTool + " on " + sName ; LOG_INFO( GetEMkLogger(), sOut.c_str()) m_pGeomDB->Erase( nId) ; return GDB_ID_NULL ; } // la dichiaro lavorazione corrente m_nCurrMachiningId = nId ; return nId ; } //---------------------------------------------------------------------------- bool MachMgr::SetMachiningParam( int nType, bool bVal) { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // imposto il parametro return pMch->SetParam( nType, bVal) ; } //---------------------------------------------------------------------------- bool MachMgr::SetMachiningParam( int nType, int nVal) { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // imposto il parametro return pMch->SetParam( nType, nVal) ; } //---------------------------------------------------------------------------- bool MachMgr::SetMachiningParam( int nType, double dVal) { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // imposto il parametro return pMch->SetParam( nType, dVal) ; } //---------------------------------------------------------------------------- bool MachMgr::SetMachiningParam( int nType, const string& sVal) { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // imposto il parametro return pMch->SetParam( nType, sVal) ; } //---------------------------------------------------------------------------- bool MachMgr::SetMachiningGeometry( const SELVECTOR& vIds) { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // imposto fase della lavorazione come temporaneamente corrente SetTempPhase TmpPhase( this, pMch->GetPhase()) ; // imposto la geometria return pMch->SetGeometry( vIds) ; } //---------------------------------------------------------------------------- bool MachMgr::MachiningPreview( bool bRecalc) { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // imposto fase della lavorazione come temporaneamente corrente SetTempPhase TmpPhase( this, pMch->GetPhase()) ; // calcolo l'anteprima della lavorazione return pMch->Preview( bRecalc) ; } //---------------------------------------------------------------------------- bool MachMgr::ExistsMachiningPreview( void) { // recupero la lavorazione corrente (verifica anche GeomDB) int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // se esiste gruppo di preview, lo svuoto int nPvId = m_pGeomDB->GetFirstNameInGroup( nCurrMchId, MCH_PV) ; if ( nPvId == GDB_ID_NULL) return false ; return ( m_pGeomDB->GetGroupObjs( nPvId) > 0) ; } //---------------------------------------------------------------------------- bool MachMgr::RemoveMachiningPreview( void) { // recupero la lavorazione corrente (verifica anche GeomDB) int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // se esiste gruppo di preview, lo svuoto int nPvId = m_pGeomDB->GetFirstNameInGroup( nCurrMchId, MCH_PV) ; if ( nPvId == GDB_ID_NULL) return true ; return m_pGeomDB->EmptyGroup( nPvId) ; } //---------------------------------------------------------------------------- bool MachMgr::MachiningApply( bool bRecalc) { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // imposto fase della lavorazione come temporaneamente corrente SetTempPhase TmpPhase( this, pMch->GetPhase()) ; // calcolo la lavorazione return pMch->Apply( bRecalc) ; } //---------------------------------------------------------------------------- bool MachMgr::GetMachiningParam( int nType, bool& bVal) const { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // recupero il parametro return pMch->GetParam( nType, bVal) ; } //---------------------------------------------------------------------------- bool MachMgr::GetMachiningParam( int nType, int& nVal) const { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // recupero il parametro return pMch->GetParam( nType, nVal) ; } //---------------------------------------------------------------------------- bool MachMgr::GetMachiningParam( int nType, double& dVal) const { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // recupero il parametro return pMch->GetParam( nType, dVal) ; } //---------------------------------------------------------------------------- bool MachMgr::GetMachiningParam( int nType, string& sVal) const { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // recupero il parametro return pMch->GetParam( nType, sVal) ; } //---------------------------------------------------------------------------- const ToolData* MachMgr::GetMachiningToolData( void) const { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return nullptr ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return nullptr ; // recupero il parametro return &( pMch->GetToolData()) ; } //---------------------------------------------------------------------------- bool MachMgr::GetMachiningGeometry( SELVECTOR& vIds) const { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return false ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return false ; // restituisco la geometria originale return pMch->GetGeometry( vIds) ; } //---------------------------------------------------------------------------- bool MachMgr::IsMachiningEmpty( void) const { // recupero la lavorazione corrente int nCurrMchId = GetCurrMachining() ; if ( nCurrMchId == GDB_ID_NULL) return true ; // ne recupero il gestore Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; if ( pMch == nullptr) return true ; // restituisco lo stato return pMch->IsEmpty() ; }