636fa8846f
- ricompilato e adattato per UiUnits.
128 lines
4.0 KiB
C++
128 lines
4.0 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : Axis.cpp Data : 24.05.15 Versione : 1.6e7
|
|
// Contenuto : Oggetto asse per gruppo asse di macchina.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 24.05.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "Axis.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( "EMkAxis", Axis) ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
const string&
|
|
Axis::GetClassName( void) const
|
|
{
|
|
return USEROBJ_GETNAME( Axis) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
Axis*
|
|
Axis::Clone( void) const
|
|
{
|
|
// alloco oggetto
|
|
Axis* pAx = new(nothrow) Axis ;
|
|
// eseguo copia dei dati
|
|
if ( pAx != nullptr) {
|
|
try { pAx->m_nOwnerId = GDB_ID_NULL ;
|
|
pAx->m_pGeomDB = nullptr ;
|
|
pAx->m_sName = m_sName ;
|
|
pAx->m_nType = m_nType ;
|
|
pAx->m_ptPos = m_ptPos ;
|
|
pAx->m_vtDir = m_vtDir ;
|
|
pAx->m_Stroke = m_Stroke ;
|
|
pAx->m_dHomeVal = m_dHomeVal ;
|
|
pAx->m_dCurrVal = m_dCurrVal ;
|
|
}
|
|
catch( ...) {
|
|
delete pAx ;
|
|
return nullptr ;
|
|
}
|
|
}
|
|
// ritorno l'oggetto
|
|
return pAx ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Axis::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
|
{
|
|
sOut += GetClassName() + szNewLine ;
|
|
sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ;
|
|
sOut += "Name=" + m_sName + szNewLine ;
|
|
sOut += "Type=" + ToString( m_nType) + szNewLine ;
|
|
sOut += "Pos=" + ToString( GetInUiUnits( m_ptPos, bMM), 4) + szNewLine ;
|
|
sOut += "Dir=" + ToString( m_vtDir) + szNewLine ;
|
|
if ( m_nType == MCH_AT_LINEAR)
|
|
sOut += "Stroke=" + ToString( GetInUiUnits( m_Stroke.Min, bMM), 4) + "," +
|
|
ToString( GetInUiUnits( m_Stroke.Max, bMM), 4) + szNewLine ;
|
|
else
|
|
sOut += "Stroke=" + ToString( m_Stroke.v, 4) + szNewLine ;
|
|
sOut += "HVal=" + ToString( GetInUiUnits( m_dHomeVal, bMM), 4) + szNewLine ;
|
|
sOut += "Val=" + ToString( GetInUiUnits( m_dCurrVal, bMM), 4) + szNewLine ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Axis::SetOwner( int nId, IGeomDB* pGDB)
|
|
{
|
|
m_nOwnerId = nId ;
|
|
m_pGeomDB = pGDB ;
|
|
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
Axis::GetOwner( void) const
|
|
{
|
|
return m_nOwnerId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
IGeomDB*
|
|
Axis::GetGeomDB( void) const
|
|
{
|
|
return m_pGeomDB ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
//----------------------------------------------------------------------------
|
|
Axis::Axis( void)
|
|
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr),
|
|
m_nType( MCH_AT_NONE), m_Stroke( {{0,0}}), m_dHomeVal( 0), m_dCurrVal( 0)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Axis::Set( const string& sName, int nType,
|
|
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome)
|
|
{
|
|
m_sName = sName ;
|
|
m_nType = nType ;
|
|
m_ptPos = ptPos ;
|
|
m_vtDir = vtDir ;
|
|
m_Stroke = Stroke ;
|
|
m_dHomeVal = dHome ;
|
|
m_dCurrVal = 0.0 ;
|
|
return m_vtDir.Normalize() ;
|
|
}
|
|
|