Files
EgtMachKernel/Exit.cpp
T
Dario Sassi 50e2127a41 EgtMachKernel 2.3d2 :
- aggiunta gestione Dist e StemDiam in utensili
- aggiunta funzione EmtModifyExitPosition
- aggiunta gestione Dist a OnSetHead e aggiornamento posizione uscita.
2021-04-06 06:40:06 +00:00

138 lines
4.0 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : Exit.cpp Data : 25.05.15 Versione : 1.6e7
// Contenuto : Oggetto uscita per gruppo uscita di testa di macchina.
//
//
//
// Modifiche : 25.05.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "Exit.h"
#include "MachConst.h"
#include "/EgtDev/Include/EGkGdbConst.h"
#include "/EgtDev/Include/EGkUserOBJFactory.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUiUnits.h"
using namespace std ;
//----------------------------------------------------------------------------
USEROBJ_REGISTER( "EMkExit", Exit) ;
//----------------------------------------------------------------------------
const string&
Exit::GetClassName( void) const
{
return USEROBJ_GETNAME( Exit) ;
}
//----------------------------------------------------------------------------
Exit*
Exit::Clone( void) const
{
// alloco oggetto
Exit* pExit = new(nothrow) Exit ;
// eseguo copia dei dati
if ( pExit != nullptr) {
try { pExit->m_nOwnerId = GDB_ID_NULL ;
pExit->m_pGeomDB = nullptr ;
pExit->m_sName = m_sName ;
pExit->m_ptPos = m_ptPos ;
pExit->m_vtTDir = m_vtTDir ;
pExit->m_sTool = m_sTool ;
}
catch( ...) {
delete pExit ;
return nullptr ;
}
}
// ritorno l'oggetto
return pExit ;
}
//----------------------------------------------------------------------------
bool
Exit::Dump( string& sOut, bool bMM, const char* szNewLine) const
{
sOut += GetClassName() + szNewLine ;
sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ;
sOut += "Name=" + m_sName + szNewLine ;
sOut += "Pos=" + ToString( GetInUiUnits( m_ptPos, bMM), 4) + szNewLine ;
sOut += "TDir=" + ToString( m_vtTDir) + szNewLine ;
sOut += "Tool=" + m_sTool + szNewLine ;
return true ;
}
//----------------------------------------------------------------------------
bool
Exit::SetOwner( int nId, IGeomDB* pGDB)
{
m_nOwnerId = nId ;
m_pGeomDB = pGDB ;
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
}
//----------------------------------------------------------------------------
int
Exit::GetOwner( void) const
{
return m_nOwnerId ;
}
//----------------------------------------------------------------------------
IGeomDB*
Exit::GetGeomDB( void) const
{
return m_pGeomDB ;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
Exit::Exit( void)
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr)
{
}
//----------------------------------------------------------------------------
bool
Exit::Set( const string& sName, const Point3d& ptPos, const Vector3d& vtTDir)
{
m_sName = sName ;
m_ptPos = ptPos ;
m_vtTDir = vtTDir ;
m_sTool.clear() ;
return true ;
}
//----------------------------------------------------------------------------
bool
Exit::Modify( const Point3d& ptPos, double dExitMaxAdjust)
{
// Verifico che lo spostamento non superi il massimo ammesso
Vector3d vtDelta = ptPos - m_ptPos ;
if ( vtDelta.Len() > dExitMaxAdjust) {
string sOut = " Modify Exit " + m_sName + " Position (" + ToString( ptPos) + ") failed" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
// Assegno la nuova posizione
m_ptPos = ptPos ;
return true ;
}
//----------------------------------------------------------------------------
bool
Exit::SetTool( const string& sTool)
{
m_sTool = sTool ;
return true ;
}