a8c34397be
- prima versione della gestione delle fasi di lavorazione.
719 lines
23 KiB
C++
719 lines
23 KiB
C++
//----------------------------------------------------------------------------
|
|
// 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 "Drilling.h"
|
|
#include "Sawing.h"
|
|
#include "Milling.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 il gruppo delle operazioni nella macchinata corrente
|
|
int nOperGrpId = GetCurrOperId() ;
|
|
if ( nOperGrpId == GDB_ID_NULL)
|
|
return OPER_NULL ;
|
|
// verifico che il gruppo ricevuto sia corretto
|
|
if ( m_pGeomDB->GetParentId( nId) != nOperGrpId)
|
|
return OPER_NULL ;
|
|
// recupero user object
|
|
IUserObj* pUserObj = m_pGeomDB->GetUserObj( nId) ;
|
|
if ( pUserObj == nullptr)
|
|
return OPER_NULL ;
|
|
// recupero il tipo di UserObj
|
|
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
|
|
return OPER_NULL ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
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" ;
|
|
// verifico che il nome sia unico
|
|
int nCount = 0 ;
|
|
string sOrigName = sName ;
|
|
while ( GetOperationId( sName) != GDB_ID_NULL) {
|
|
++ nCount ;
|
|
sName = sOrigName + "_" + ToString( nCount) ;
|
|
}
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
std::string
|
|
MachMgr::GetOperationName( int nId) const
|
|
{
|
|
// recupero il gruppo delle operazioni nella macchinata corrente
|
|
int nOperGrpId = GetCurrOperId() ;
|
|
if ( nOperGrpId == GDB_ID_NULL)
|
|
return "" ;
|
|
// verifico che il gruppo ricevuto sia corretto
|
|
if ( m_pGeomDB->GetParentId( nId) != nOperGrpId)
|
|
return "" ;
|
|
// recupero il nome del gruppo riferito
|
|
string sName ;
|
|
m_pGeomDB->GetName( nId, sName) ;
|
|
return sName ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::GetOperationId( const string& sName) const
|
|
{
|
|
// verifica dei parametri
|
|
if ( &sName == nullptr || sName.empty())
|
|
return false ;
|
|
// recupero il gruppo delle operazioni nella macchinata corrente
|
|
int nOperGrpId = GetCurrOperId() ;
|
|
if ( nOperGrpId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// recupero l'identificativo del gruppo con il nome indicato
|
|
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
|
|
if ( IsNull( pIter))
|
|
return false ;
|
|
bool bIter = pIter->GoToFirstGroupInGroup( m_nMachBaseId) ;
|
|
while( bIter) {
|
|
// verifico il nome
|
|
string sOperGrpName ;
|
|
if ( pIter->GetName( sOperGrpName) && EqualNoCase( sOperGrpName, sName))
|
|
return pIter->GetId() ;
|
|
// passo al successivo
|
|
bIter = pIter->GoToNextGroup() ;
|
|
}
|
|
return GDB_ID_NULL ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::RemoveOperation( int nId)
|
|
{
|
|
// verifico sia una Operazione
|
|
if ( GetOperationType( nId) == OPER_NULL)
|
|
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::RemoveAllOperations( bool bExceptFirstDisp)
|
|
{
|
|
// indice terminazione ciclo
|
|
int nStopId = ( bExceptFirstDisp ? GetFirstOperation() : GDB_ID_NULL) ;
|
|
// rimuovo tutte le operazioni a partire dalla fine
|
|
int nId = GetLastOperation() ;
|
|
while ( nId != GDB_ID_NULL && nId != nStopId) {
|
|
RemoveOperation( nId) ;
|
|
nId = GetLastOperation() ;
|
|
}
|
|
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 ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
// 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 ;
|
|
// eseguo
|
|
return AddDisposition( sNewName, nOperGrpId, m_nCurrPhase) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::AddDisposition( const string& sName, int nOperGrpId, int nPhase)
|
|
{
|
|
// 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( nPhase) ;
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
// 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 std::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
|
|
m_pGeomDB->SetName( nId, sNewName) ;
|
|
// installo il gestore della lavorazione
|
|
Machining* pMch = nullptr ;
|
|
switch ( nMchType) {
|
|
case MT_DRILLING : pMch = new( nothrow) Drilling ; break ;
|
|
case MT_SAWING : pMch = new( nothrow) Sawing ; break ;
|
|
case MT_MILLING : pMch = new( nothrow) Milling ; break ;
|
|
}
|
|
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 ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
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 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 ;
|
|
// calcolo l'anteprima della lavorazione
|
|
return pMch->Preview( bRecalc) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
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 ;
|
|
// 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::IsEmpty( void) 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 lo stato
|
|
return pMch->IsEmpty() ;
|
|
}
|