EgtMachKernel 1.6e3 :
- aggiunta prima gestione semplice della macchina.
This commit is contained in:
+84
@@ -0,0 +1,84 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Machine.cpp Data : 06.05.15 Versione : 1.6e3
|
||||
// Contenuto : Implementazione gestione macchina.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 06.05.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "Machine.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Machine::Machine( void)
|
||||
{
|
||||
m_nContextId = 0 ;
|
||||
m_pGeomDB = nullptr ;
|
||||
m_nGroupId = GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Machine::~Machine( void)
|
||||
{
|
||||
Clear() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Machine::Clear( void)
|
||||
{
|
||||
// cancellazione eventuale gruppo geometrico associato
|
||||
if ( m_pGeomDB != nullptr && m_nGroupId != GDB_ID_NULL)
|
||||
m_pGeomDB->Erase( m_nGroupId) ;
|
||||
// reset membri
|
||||
m_nContextId = 0 ;
|
||||
m_pGeomDB = nullptr ;
|
||||
m_nGroupId = GDB_ID_NULL ;
|
||||
m_sName.clear() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::Init( int nContextId, IGeomDB* pGeomDB, int nMachAuxId,
|
||||
const string& sMachineDir, const string& sMachineName)
|
||||
{
|
||||
// pulisco
|
||||
Clear() ;
|
||||
// verifico ambiente geometrico
|
||||
if ( nContextId == 0 || pGeomDB == nullptr)
|
||||
return false ;
|
||||
// verifico esistenza macchina
|
||||
string sMachineMde = sMachineDir + "\\" + sMachineName + ".Mde" ;
|
||||
if ( ! ExistsFile( sMachineMde))
|
||||
return false ;
|
||||
// creo il gruppo per la macchina
|
||||
int nId = pGeomDB->InsertGroup( GDB_ID_NULL, nMachAuxId, GDB_LAST_SON, GLOB_FRM) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// imposto nome del gruppo
|
||||
pGeomDB->SetName( nId, sMachineName) ;
|
||||
// inserisco la geometria della macchina !!! PROVVISORIO !!!
|
||||
string sMachineNge = sMachineDir + "\\" + sMachineName + ".Nge" ;
|
||||
if ( ! pGeomDB->Load( sMachineNge, nId)) {
|
||||
pGeomDB->Erase( nId) ;
|
||||
return false ;
|
||||
}
|
||||
// salvo i dati
|
||||
m_nContextId = nContextId ;
|
||||
m_pGeomDB = pGeomDB ;
|
||||
m_nGroupId = nId ;
|
||||
m_sMachineDir = sMachineDir ;
|
||||
m_sName = sMachineName ;
|
||||
return true ;
|
||||
}
|
||||
Reference in New Issue
Block a user