Files
EgtMachKernel/MachMgrFixtures.cpp
T
Dario Sassi d682572702 EgtMachKernel 1.6v7 :
- modifiche per bloccaggi su più fasi
2016-10-15 10:06:51 +00:00

236 lines
7.9 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : MachMgrFixtures.cpp Data : 13.05.15 Versione : 1.6e6
// Contenuto : Implementazione gestione ventose e morse della classe MachMgr.
//
//
//
// Modifiche : 13.05.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "MachMgr.h"
#include "MachConst.h"
#include "Disposition.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
MachMgr::SetTable( const string& sTable)
{
// imposto la tavola per la prima disposizione ( e il calcolo)
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( GetFirstOperation())) ;
return ( pDisp != nullptr && pDisp->SetTable( sTable)) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetTable( string& sTable)
{
// recupero la prima operazione, deve essere la prima disposizione
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( GetFirstOperation())) ;
if ( pDisp == nullptr)
return false ;
// recupero la tavola
return pDisp->GetTable( sTable) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetTableRef( int nInd, Point3d& ptPos)
{
// attualmente previsto solo il riferimento 1
if ( nInd != 1)
return false ;
// recupero la prima operazione, deve essere la prima disposizione
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( GetFirstOperation())) ;
if ( pDisp == nullptr)
return false ;
// recupero il punto
return pDisp->GetTableRef1( ptPos) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetTableArea( int nInd, BBox3d& b3Area1)
{
// attualmente prevista solo l'area 1
if ( nInd != 1)
return false ;
// recupero la prima operazione, deve essere la prima disposizione
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( GetFirstOperation())) ;
if ( pDisp == nullptr)
return false ;
// recupero il bounding box
return pDisp->GetTableArea1( b3Area1) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ShowOnlyTable( bool bVal)
{
// verifico DB geometrico
if ( m_pGeomDB == nullptr)
return false ;
// recupero la macchina corrente
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
// imposto visualizzazione della sola tavola o di tutto
return pMch->SetLook( bVal ? MCH_LOOK_TAB : MCH_LOOK_ALL) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::VerifyFixture( int nFxtId, bool bLinkedAllowed) const
{
// se il bloccaggio fa parte del gruppo dei bloccaggi, va bene
int nFxtGroupId = GetCurrFixtGroupId() ;
if ( nFxtGroupId != GDB_ID_NULL && m_pGeomDB->GetParentId( nFxtId) == nFxtGroupId)
return true ;
// se consentito linkaggio ed il bloccaggio è linkato ad un gruppo della macchina corrente, va bene
if ( bLinkedAllowed) {
Machine* pMch = GetCurrMachine() ;
if ( pMch != nullptr && pMch->IsLinkedFixture( nFxtId))
return true ;
}
// altrimenti errore
return false ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetFixturePhases( int nFxtId, INTVECTOR& vPhase) const
{
// pulisco parametro di ritorno
vPhase.clear() ;
// verifica validità bloccaggio
if ( ! VerifyFixture( nFxtId))
return false ;
// recupero le fasi in cui è presente la fixture (se manca è fase 1)
if ( ! m_pGeomDB->GetInfo( nFxtId, MACH_FXT_PHASE, vPhase) || vPhase.empty())
vPhase.emplace_back( 1) ;
return true ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetUnusedFixture( const string& sName, int nPhase)
{
// Verifico validità nome
if ( IsEmptyOrSpaces( sName))
return false ;
// Recupero il gruppo dei bloccaggi
int nFxtGroupId = GetCurrFixtGroupId() ;
// Cerco i bloccaggi non usati nella fase indicata
int nId = m_pGeomDB->GetFirstNameInGroup( nFxtGroupId, sName) ;
while ( nId != GDB_ID_NULL) {
// recupero le fasi in cui è già usato
INTVECTOR vPhase ;
if ( ! m_pGeomDB->GetInfo( nId, MACH_FXT_PHASE, vPhase) || vPhase.empty())
vPhase.emplace_back( 1) ;
// se non c'è la fase corrente, è libero
if ( find( vPhase.begin(), vPhase.end(), nPhase) == vPhase.end())
return nId ;
// passo al successivo
nId = m_pGeomDB->GetNextName( nId, sName) ;
}
// non trovato
return GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
int
MachMgr::AddFixture( const string& sName, const Point3d& ptPos, double dAngRotDeg, double dMov)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return GDB_ID_NULL ;
// eseguo l'operazione
return pDisp->AddFixture( sName, ptPos, dAngRotDeg, dMov) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::RemoveFixture( int nFxtId)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return false ;
// eseguo l'operazione
return pDisp->RemoveFixture( nFxtId) ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetFirstFixture( void)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return GDB_ID_NULL ;
// eseguo l'operazione
return pDisp->GetFirstFixture() ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetNextFixture( int nFxtId)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return GDB_ID_NULL ;
// eseguo l'operazione
return pDisp->GetNextFixture( nFxtId) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MoveFixture( int nId, const Vector3d& vtMove)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return false ;
// eseguo l'operazione
return pDisp->MoveFixture( nId, vtMove) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::RotateFixture( int nId, double dDeltaAngDeg)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return false ;
// eseguo l'operazione
return pDisp->RotateFixture( nId, dDeltaAngDeg) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MoveFixtureMobile( int nId, double dDeltaMov)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return false ;
// eseguo l'operazione
return pDisp->MoveFixtureMobile( nId, dDeltaMov) ;
}