ec420de8ef
- aggiunta prima versione di caricamento delle macchine.
79 lines
2.8 KiB
C++
79 lines
2.8 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : MachMgrMachines.cpp Data : 02.05.15 Versione : 1.6e1
|
|
// Contenuto : Implementazione gestione macchine della classe MachMgr.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 02.05.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "MachMgr.h"
|
|
#include "MachConst.h"
|
|
#include "/EgtDev/Include/EGkGdbIterator.h"
|
|
#include "/EgtDev/Include/EgnStringUtils.h"
|
|
#include "/EgtDev/Include/EgnFileUtils.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::LoadMachine( const string& sMachineName)
|
|
{
|
|
// verifico validità del nome
|
|
if ( ! IsValidName( sMachineName))
|
|
return false ;
|
|
// se macchina già caricata, non devo fare alcunchè
|
|
if ( GetMachineId( sMachineName) != GDB_ID_NULL)
|
|
return true ;
|
|
// verifico esistenza macchina
|
|
string sMachineDir = m_sMachinesDir + "\\" + sMachineName ;
|
|
string sMachineMde = sMachineDir + "\\" + sMachineName + ".Mde" ;
|
|
if ( ! ExistsFile( sMachineMde))
|
|
return false ;
|
|
// carico la macchina
|
|
if ( ! CreateMachAux())
|
|
return false ;
|
|
// creo il gruppo per la macchina
|
|
int nId = m_pGeomDB->InsertGroup( GDB_ID_NULL, m_nMachAuxId, GDB_LAST_SON, GLOB_FRM) ;
|
|
if ( nId == GDB_ID_NULL)
|
|
return false ;
|
|
// imposto nome del gruppo
|
|
m_pGeomDB->SetName( nId, sMachineName) ;
|
|
// inserisco la geometria della macchina !!! PROVVISORIO !!!
|
|
string sMachineNge = sMachineDir + "\\" + sMachineName + ".Nge" ;
|
|
return m_pGeomDB->Load( sMachineNge, nId) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::GetMachineId( const string& sMachineName) const
|
|
{
|
|
// verifico validità del nome
|
|
if ( ! IsValidName( sMachineName))
|
|
return GDB_ID_NULL ;
|
|
// se non c'è il gruppo ausiliario per le macchine, non ci può essere la macchina
|
|
if ( ! VerifyMachAux())
|
|
return GDB_ID_NULL ;
|
|
// recupero l'identificativo del gruppo con il nome indicato
|
|
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
|
|
if ( IsNull( pIter))
|
|
return GDB_ID_NULL ;
|
|
bool bIter = pIter->GoToFirstGroupInGroup( m_nMachAuxId) ;
|
|
while( bIter) {
|
|
// verifico il nome
|
|
string sMGroupName ;
|
|
if ( pIter->GetName( sMGroupName) && sMGroupName == sMachineName)
|
|
return pIter->GetId() ;
|
|
// passo al successivo
|
|
bIter = pIter->GoToNextGroup() ;
|
|
}
|
|
return GDB_ID_NULL ;
|
|
}
|