EgtMachKernel :
- aggiunte funzioni per gestione preview utensile in lavorazione.
This commit is contained in:
@@ -249,6 +249,9 @@ class MachMgr : public IMachMgr
|
||||
bool RemoveMachiningPreview( void) override ;
|
||||
bool MachiningApply( bool bRecalc, bool bPostApply = true) override ;
|
||||
bool MachiningUpdate( bool bPostApply = true) override ;
|
||||
bool PreparePreviewMachiningTool( void) const override ;
|
||||
bool RemovePreviewMachiningTool( void) const override ;
|
||||
int PreviewMachiningTool( int nEntId, int nFlag) const override ;
|
||||
bool GetMachiningParam( int nType, bool& bVal) const override ;
|
||||
bool GetMachiningParam( int nType, int& dVal) const override ;
|
||||
bool GetMachiningParam( int nType, double& dVal) const override ;
|
||||
|
||||
+55
-2
@@ -573,6 +573,9 @@ MachMgr::DispositionSpecialUpdate( int nId)
|
||||
bool
|
||||
MachMgr::SetCurrMachining( int nId)
|
||||
{
|
||||
// se corrente esiste ed è diversa, ne eseguo il reset
|
||||
if ( m_nCurrMachiningId != GDB_ID_NULL && nId != m_nCurrMachiningId)
|
||||
ResetCurrMachining() ;
|
||||
// recupero il gruppo delle operazioni nella macchinata corrente
|
||||
int nOperGrpId = GetCurrOperId() ;
|
||||
if ( nOperGrpId == GDB_ID_NULL)
|
||||
@@ -595,6 +598,9 @@ MachMgr::SetCurrMachining( int nId)
|
||||
bool
|
||||
MachMgr::ResetCurrMachining( void)
|
||||
{
|
||||
// disabilito preview utensile
|
||||
RemovePreviewMachiningTool() ;
|
||||
// reset
|
||||
m_nCurrMachiningId = GDB_ID_NULL ;
|
||||
return true ;
|
||||
}
|
||||
@@ -619,7 +625,7 @@ int
|
||||
MachMgr::AddMachining( const string& sName, const string& sMachining)
|
||||
{
|
||||
// nessuna lavorazione corrente
|
||||
m_nCurrMachiningId = GDB_ID_NULL ;
|
||||
ResetCurrMachining() ;
|
||||
// recupero il gestore delle lavorazioni della macchina corrente
|
||||
MachiningsMgr* pMMgr = GetCurrMachiningsMgr() ;
|
||||
if ( pMMgr == nullptr)
|
||||
@@ -674,7 +680,7 @@ int
|
||||
MachMgr::AddMachining( const string& sName, int nMchType, const string& sTool)
|
||||
{
|
||||
// nessuna lavorazione corrente
|
||||
m_nCurrMachiningId = GDB_ID_NULL ;
|
||||
ResetCurrMachining() ;
|
||||
// recupero il gestore delle lavorazioni della macchina corrente
|
||||
MachiningsMgr* pMMgr = GetCurrMachiningsMgr() ;
|
||||
if ( pMMgr == nullptr)
|
||||
@@ -924,6 +930,53 @@ MachMgr::MachiningUpdate( bool bPostApply)
|
||||
return pMch->Update( bPostApply) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::PreparePreviewMachiningTool( 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 ;
|
||||
// eseguo
|
||||
return pMch->PrepareToolPreview() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::RemovePreviewMachiningTool( void) const
|
||||
{
|
||||
// verifico la lavorazione corrente (salto volutamente altri controlli)
|
||||
if ( m_nCurrMachiningId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// ne recupero il gestore
|
||||
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( m_nCurrMachiningId)) ;
|
||||
if ( pMch == nullptr)
|
||||
return false ;
|
||||
// eseguo
|
||||
return pMch->RemoveToolPreview() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
MachMgr::PreviewMachiningTool( int nEntId, int nFlag) const
|
||||
{
|
||||
// recupero la lavorazione corrente
|
||||
int nCurrMchId = GetCurrMachining() ;
|
||||
if ( nCurrMchId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// ne recupero il gestore
|
||||
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ;
|
||||
if ( pMch == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// eseguo
|
||||
return pMch->ToolPreview( nEntId, nFlag) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::GetMachiningParam( int nType, bool& bVal) const
|
||||
|
||||
+130
-24
@@ -118,32 +118,11 @@ Machining::GetEndPoint( Point3d& ptEnd) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::ShowTool( int nPath, double dFraz) const
|
||||
Machining::PrepareToolPreview( void) const
|
||||
{
|
||||
// verifico validità gestore DB geometrico
|
||||
// verifico validità gestori DB geometrico e CAM
|
||||
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr)
|
||||
return false ;
|
||||
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
|
||||
if ( pMch == nullptr)
|
||||
return false ;
|
||||
// recupero gruppo per geometria di lavorazione (Cutter Location)
|
||||
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
|
||||
if ( nClId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// recupero la prima entità del primo sottogruppo
|
||||
int nEntId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstGroupInGroup( nClId)) ;
|
||||
if ( nEntId == GDB_ID_NULL)
|
||||
return false ;
|
||||
string sName ; m_pGeomDB->GetName( nEntId, sName) ;
|
||||
if ( sName == MCH_CL_CLIMB)
|
||||
nEntId = m_pGeomDB->GetNext( nEntId) ;
|
||||
// recupero i dati di questa entità
|
||||
const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ;
|
||||
if ( pCamData == nullptr)
|
||||
return false ;
|
||||
Point3d ptEnd = pCamData->GetEndPoint() ;
|
||||
Vector3d vtTool = pCamData->GetToolDir() ;
|
||||
Vector3d vtBAux = pCamData->GetBackAuxDir() ;
|
||||
// creo o svuoto gruppo per anteprima utensile
|
||||
int nStId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST) ;
|
||||
// se non c'è, lo aggiungo
|
||||
@@ -157,9 +136,136 @@ Machining::ShowTool( int nPath, double dFraz) const
|
||||
// altrimenti lo svuoto
|
||||
else
|
||||
m_pGeomDB->EmptyGroup( nStId) ;
|
||||
// se necessario, imposto l'utensile corrente
|
||||
string sCurrTool ; m_pMchMgr->GetCalcTool( sCurrTool) ;
|
||||
if ( ! EqualNoCase( sCurrTool, GetToolName())) {
|
||||
if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr()))
|
||||
return false ;
|
||||
}
|
||||
// copio la testa della lavorazione nel gruppo
|
||||
int nHeadId = m_pMchMgr->GetHeadId( GetHeadName()) ;
|
||||
int nId = m_pGeomDB->CopyGlob( nHeadId, GDB_ID_NULL, nStId) ;
|
||||
m_pGeomDB->SetStatus( nId, GDB_ST_OFF) ;
|
||||
return ( nId != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::RemoveToolPreview( void) const
|
||||
{
|
||||
// verifico validità gestore DB geometrico
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero gruppo per anteprima utensile
|
||||
int nStId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST) ;
|
||||
// lo svuoto
|
||||
m_pGeomDB->EmptyGroup( nStId) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GetToolPreviewNext( IGeomDB* pGeomDB, int nEntId, int nParentId)
|
||||
{
|
||||
// recupero la successiva
|
||||
int nNewId = (( nEntId != GDB_ID_NULL) ? pGeomDB->GetNext( nEntId) : pGeomDB->GetFirstInGroup( nParentId)) ;
|
||||
int nNewParentId = nParentId ;
|
||||
// ciclo nei gruppi successivi
|
||||
do {
|
||||
// ciclo nel gruppo
|
||||
while ( nNewId != GDB_ID_NULL) {
|
||||
string sName ; pGeomDB->GetName( nNewId, sName) ;
|
||||
if ( sName != MCH_CL_CLIMB && sName != MCH_CL_RISE)
|
||||
break ;
|
||||
nNewId = pGeomDB->GetNext( nNewId) ;
|
||||
}
|
||||
// se trovata, esco
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
return nNewId ;
|
||||
// recupero la prima entità del successivo gruppo
|
||||
nNewParentId = pGeomDB->GetNextGroup( nNewParentId) ;
|
||||
nNewId = pGeomDB->GetFirstInGroup( nNewParentId) ;
|
||||
} while ( nNewId != GDB_ID_NULL) ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GetToolPreviewPrev( IGeomDB* pGeomDB, int nEntId, int nParentId)
|
||||
{
|
||||
// recupero la precedente
|
||||
int nNewId = (( nEntId != GDB_ID_NULL) ? pGeomDB->GetPrev( nEntId) : pGeomDB->GetLastInGroup( nParentId)) ;
|
||||
int nNewParentId = nParentId ;
|
||||
// ciclo nei gruppi precedenti
|
||||
do {
|
||||
// ciclo nel gruppo
|
||||
while ( nNewId != GDB_ID_NULL) {
|
||||
string sName ; pGeomDB->GetName( nNewId, sName) ;
|
||||
if ( sName != MCH_CL_CLIMB && sName != MCH_CL_RISE)
|
||||
break ;
|
||||
nNewId = pGeomDB->GetPrev( nNewId) ;
|
||||
}
|
||||
// se trovata, esco
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
return nNewId ;
|
||||
// recupero l'ultima entità del precedente gruppo
|
||||
nNewParentId = pGeomDB->GetPrevGroup( nNewParentId) ;
|
||||
nNewId = pGeomDB->GetLastInGroup( nNewParentId) ;
|
||||
} while ( nNewId != GDB_ID_NULL) ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Machining::ToolPreview( int nEntId, int nFlag) const
|
||||
{
|
||||
// verifico validità gestori DB geometrico e CAM
|
||||
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero gruppo per geometria di lavorazione (Cutter Location)
|
||||
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
|
||||
if ( nClId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// se entità nulla
|
||||
if ( nEntId == GDB_ID_NULL || ! m_pGeomDB->ExistsObj( nEntId)) {
|
||||
// recupero il gruppo di appartenenza
|
||||
int nParentId = m_pGeomDB->GetFirstGroupInGroup( nClId) ;
|
||||
// se richiesta successiva
|
||||
if ( nFlag == MCH_TPM_AFTER)
|
||||
nEntId = GetToolPreviewNext( m_pGeomDB, nEntId, nParentId) ;
|
||||
// se richiesta precedente
|
||||
else if ( nFlag == MCH_TPM_BEFORE)
|
||||
nEntId = GetToolPreviewPrev( m_pGeomDB, nEntId, nParentId) ;
|
||||
// altrimenti richiesta corrente
|
||||
else
|
||||
nEntId = GDB_ID_NULL ;
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
// verifico che l'entità stia in un sottogruppo di CL
|
||||
int nParentId = m_pGeomDB->GetParentId( nEntId) ;
|
||||
if ( m_pGeomDB->GetParentId( nParentId) == nClId) {
|
||||
// se richiesta successiva
|
||||
if ( nFlag == MCH_TPM_AFTER)
|
||||
nEntId = GetToolPreviewNext( m_pGeomDB, nEntId, nParentId) ;
|
||||
// se richiesta precedente
|
||||
else if ( nFlag == MCH_TPM_BEFORE)
|
||||
nEntId = GetToolPreviewPrev( m_pGeomDB, nEntId, nParentId) ;
|
||||
}
|
||||
else
|
||||
nEntId = GDB_ID_NULL ;
|
||||
}
|
||||
// recupero i dati di questa entità
|
||||
const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ;
|
||||
if ( pCamData == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
Point3d ptEnd = pCamData->GetEndPoint() ;
|
||||
Vector3d vtTool = pCamData->GetToolDir() ;
|
||||
Vector3d vtBAux = pCamData->GetBackAuxDir() ;
|
||||
// recupero la testa nel gruppo per anteprima utensile
|
||||
int nId = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST)) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
m_pGeomDB->SetStatus( nId, GDB_ST_ON) ;
|
||||
// dati correnti testa/uscita
|
||||
int nExitId = m_pGeomDB->GetFirstNameInGroup( nId, MCH_EXIT + ToString( GetExitNbr())) ;
|
||||
@@ -187,7 +293,7 @@ Machining::ShowTool( int nPath, double dFraz) const
|
||||
frHead.ToGlob( frShow) ;
|
||||
*(m_pGeomDB->GetGroupFrame( nId)) = frHead ;
|
||||
|
||||
return true ;
|
||||
return nEntId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+3
-1
@@ -46,7 +46,9 @@ class Machining : public Operation
|
||||
public :
|
||||
bool GetStartPoint( Point3d& ptStart) const ;
|
||||
bool GetEndPoint( Point3d& ptEnd) const ;
|
||||
bool ShowTool( int nPath, double dFraz) const ;
|
||||
bool PrepareToolPreview( void) const ;
|
||||
int ToolPreview( int nEntId, int nFlag) const ;
|
||||
bool RemoveToolPreview( void) const ;
|
||||
|
||||
protected :
|
||||
Machining( void) ;
|
||||
|
||||
@@ -554,11 +554,6 @@ Milling::Apply( bool bRecalc, bool bPostApply)
|
||||
if ( ! Update( bPostApply))
|
||||
return false ;
|
||||
|
||||
//// imposto l'utensile per l'anteprima !!! provvisorio per test !!!
|
||||
// if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr()))
|
||||
// return false ;
|
||||
// ShowTool( 0, 0) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
@@ -531,11 +531,6 @@ Pocketing::Apply( bool bRecalc, bool bPostApply)
|
||||
if ( ! Update( bPostApply))
|
||||
return false ;
|
||||
|
||||
//// imposto l'utensile per l'anteprima !!! provvisorio per test !!!
|
||||
// if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr()))
|
||||
// return false ;
|
||||
// ShowTool( 0, 0) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user