EgtExchange 1.8c4 :

- migliorie import CNC per gestire movimenti soli assi rotanti.
This commit is contained in:
Dario Sassi
2017-03-27 06:50:17 +00:00
parent 62d7bd4fb9
commit 673e461737
3 changed files with 50 additions and 16 deletions
+34 -15
View File
@@ -1,13 +1,13 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
// EgalTech 2014-2017
//----------------------------------------------------------------------------
// File : ImportCnc.cpp Data : 15.09.14 Versione : 1.5i3
// File : ImportCnc.cpp Data : 26.03.17 Versione : 1.8c4
// Contenuto : Implementazione della classe per l'importazione di CNC.
//
//
//
// Modifiche : 15.09.14 DS Creazione modulo.
//
// 26/03/17 DS Gestione punto come solo cambio assi rotanti.
//
//----------------------------------------------------------------------------
@@ -32,9 +32,9 @@
using namespace std ;
//----------------------------------------------------------------------------
static const string NAME_ERROR = "Error" ;
static const Color COL_RAPID( 0, 192, 192, 50) ;
static const Color COL_ERROR( 255, 0, 0, 100) ;
static const string KEY_ERROR = "ERR" ;
static const string KEY_TCS = "TCS" ;
static const string KEY_TCOMP = "TCOMP" ;
static const string KEY_TNAME = "TNAME" ;
@@ -112,6 +112,7 @@ ImportCnc::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup, int nFlag)
m_dRotAxA = NAN ;
m_dRotAxB = NAN ;
m_dRotAxC = NAN ;
SaveRotAxes() ;
m_colCurr = BLACK ;
m_sToolName.clear() ;
m_nExit = 1 ;
@@ -547,6 +548,7 @@ ImportCnc::ParseA( const string& sToken)
if ( ! FromString( sToken.substr( nStart), dVal))
dVal = 0 ;
m_dRotAxA = ( m_bAbsCoord ? dVal : m_dRotAxA + dVal) ;
m_bToMove = true ;
return true ;
}
@@ -559,6 +561,7 @@ ImportCnc::ParseB( const string& sToken)
if ( ! FromString( sToken.substr( nStart), dVal))
dVal = 0 ;
m_dRotAxB = ( m_bAbsCoord ? dVal : m_dRotAxB + dVal) ;
m_bToMove = true ;
return true ;
}
@@ -582,6 +585,7 @@ ImportCnc::ParseC( const string& sToken)
if ( ! FromString( sToken.substr( nStart), dVal))
dVal = 0 ;
m_dRotAxC = ( m_bAbsCoord ? dVal : m_dRotAxC + dVal) ;
m_bToMove = true ;
return true ;
}
@@ -653,15 +657,21 @@ ImportCnc::ExecMovement( void)
// eseguo movimento
switch ( m_nMoveType) {
case RAPID :
return AddLine( L_RAPID) ;
if ( AreSamePointApprox( m_ptLast, m_ptNext))
return ( RotAxesChanged() ? AddPoint( P_RAPID) : true) ;
else
return AddLine( L_RAPID) ;
case LINE :
return AddLine( L_LINE) ;
if ( AreSamePointApprox( m_ptLast, m_ptNext))
return ( RotAxesChanged() ? AddPoint( P_PNT) : true) ;
else
return AddLine( L_LINE) ;
case ARC_CW :
case ARC_CCW :
if ( AddArc( m_nMoveType == ARC_CCW))
return true ;
if ( AreSamePointApprox( m_ptLast, m_ptNext))
AddPoint() ;
AddPoint( P_ERROR) ;
else
AddLine( L_ERROR) ;
return false ;
@@ -672,7 +682,7 @@ ImportCnc::ExecMovement( void)
//----------------------------------------------------------------------------
bool
ImportCnc::AddPoint( void)
ImportCnc::AddPoint( int nPntType)
{
// creo il punto
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
@@ -688,8 +698,18 @@ ImportCnc::AddPoint( void)
if ( nId == GDB_ID_NULL)
return false ;
// attributi
m_pGDB->SetMaterial( nId, COL_ERROR) ;
m_pGDB->SetInfo( nId, KEY_ERROR, "1") ;
switch ( nPntType) {
case P_RAPID :
m_pGDB->SetMaterial( nId, COL_RAPID) ;
break ;
case P_PNT :
m_pGDB->SetMaterial( nId, m_colCurr) ;
break ;
case P_ERROR :
m_pGDB->SetMaterial( nId, COL_ERROR) ;
m_pGDB->SetName( nId, NAME_ERROR) ;
break ;
}
// assegnazione numero di linea
m_pGDB->SetName( nId, ToString( m_nLine)) ;
// assegnazione eventuale uscita
@@ -706,6 +726,7 @@ ImportCnc::AddPoint( void)
m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ;
// movimento effettuato
m_ptLast = m_ptNext ;
SaveRotAxes() ;
return true ;
}
@@ -713,10 +734,6 @@ ImportCnc::AddPoint( void)
bool
ImportCnc::AddLine( int nLineType)
{
// se la linea è nulla, non la inserisco ma proseguo senza errore
if ( AreSamePointApprox( m_ptLast, m_ptNext))
return true ;
// creo la linea
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
if ( IsNull( pCrvLine))
@@ -740,7 +757,7 @@ ImportCnc::AddLine( int nLineType)
break ;
case L_ERROR :
m_pGDB->SetMaterial( nId, COL_ERROR) ;
m_pGDB->SetName( nId, "Error") ;
m_pGDB->SetName( nId, NAME_ERROR) ;
break ;
}
// eventuale info sul correttore (se non è riferito a zero macchina)
@@ -765,6 +782,7 @@ ImportCnc::AddLine( int nLineType)
m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ;
// movimento effettuato
m_ptLast = m_ptNext ;
SaveRotAxes() ;
return true ;
}
@@ -851,6 +869,7 @@ ImportCnc::AddArc( bool bCCW)
m_pGDB->SetInfo( nId, KEY_ROTAX_C, m_dRotAxC) ;
// movimento effettuato
m_ptLast = m_ptNext ;
SaveRotAxes() ;
return true ;
}