EgtMachKernel 1.6e7 :
- introdotto uso ObjUser per gruppi di macchina - prima versione prototipo delle forature - migliorie al calolo angoli e posizioni macchina.
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : MachMgrMachinings.cpp Data : 21.05.15 Versione : 1.6e7
|
||||
// Contenuto : Implementazione gestione lavorazioni della classe MachMgr.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 16.04.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DllMain.h"
|
||||
#include "MachMgr.h"
|
||||
#include "MachConst.h"
|
||||
#include "Drilling.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
MachMgr::GetOperationNbr( void) const
|
||||
{
|
||||
// recupero il gruppo delle operazioni nella macchinata corrente
|
||||
int nOperGrpId = GetCurrOperId() ;
|
||||
if ( nOperGrpId == GDB_ID_NULL)
|
||||
return 0 ;
|
||||
// ritorno numero di operazioni
|
||||
return m_pGeomDB->GetGroupObjs( nOperGrpId) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
MachMgr::GetFirstOperation( void) const
|
||||
{
|
||||
// recupero il gruppo delle operazioni nella macchinata corrente
|
||||
int nOperGrpId = GetCurrOperId() ;
|
||||
if ( nOperGrpId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il primo sottogruppo
|
||||
int nId = m_pGeomDB->GetFirstGroupInGroup( nOperGrpId) ;
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
MachMgr::GetNextOperation( int nId) const
|
||||
{
|
||||
// recupero il gruppo delle operazioni nella macchinata corrente
|
||||
int nOperGrpId = GetCurrOperId() ;
|
||||
if ( nOperGrpId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// verifico che il gruppo ricevuto sia corretto
|
||||
if ( m_pGeomDB->GetParentId( nId) != nOperGrpId)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il successivo sottogruppo
|
||||
int nNextId = m_pGeomDB->GetNextGroup( nId) ;
|
||||
return nNextId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::GetOperationNewName( string& sName) const
|
||||
{
|
||||
// il parametro nome deve essere valido
|
||||
if ( &sName == nullptr)
|
||||
return false ;
|
||||
// il gruppo per le operazioni deve essere presente nella macchinata corrente
|
||||
if ( GetCurrOperId() == GDB_ID_NULL)
|
||||
return false ;
|
||||
// se nome vuoto, assegno radice standard
|
||||
if ( sName.empty())
|
||||
sName = "Oper" ;
|
||||
// verifico che il nome sia unico
|
||||
int nCount = 1 ;
|
||||
string sOrigName = sName ;
|
||||
while ( GetOperationId( sName) != GDB_ID_NULL) {
|
||||
++ nCount ;
|
||||
sName = sOrigName + "_" + ToString( nCount) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string
|
||||
MachMgr::GetOperationName( int nId) const
|
||||
{
|
||||
// recupero il gruppo delle operazioni nella macchinata corrente
|
||||
int nOperGrpId = GetCurrOperId() ;
|
||||
if ( nOperGrpId == GDB_ID_NULL)
|
||||
return "" ;
|
||||
// verifico che il gruppo ricevuto sia corretto
|
||||
if ( m_pGeomDB->GetParentId( nId) != nOperGrpId)
|
||||
return "" ;
|
||||
// recupero il nome del gruppo riferito
|
||||
string sName ;
|
||||
m_pGeomDB->GetName( nId, sName) ;
|
||||
return sName ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
MachMgr::GetOperationId( const string& sName) const
|
||||
{
|
||||
// verifica dei parametri
|
||||
if ( &sName == nullptr || sName.empty())
|
||||
return false ;
|
||||
// recupero il gruppo delle operazioni nella macchinata corrente
|
||||
int nOperGrpId = GetCurrOperId() ;
|
||||
if ( nOperGrpId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero l'identificativo del gruppo con il nome indicato
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
bool bIter = pIter->GoToFirstGroupInGroup( m_nMachBaseId) ;
|
||||
while( bIter) {
|
||||
// verifico il nome
|
||||
string sOperGrpName ;
|
||||
if ( pIter->GetName( sOperGrpName) && EqualNoCase( sOperGrpName, sName))
|
||||
return pIter->GetId() ;
|
||||
// passo al successivo
|
||||
bIter = pIter->GoToNextGroup() ;
|
||||
}
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
MachMgr::AddDrilling( const string& sName)
|
||||
{
|
||||
// recupero il gruppo delle operazioni nella macchinata corrente
|
||||
int nOperGrpId = GetCurrOperId() ;
|
||||
if ( nOperGrpId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero nome originale, partendo da quello proposto
|
||||
string sNewName = sName ;
|
||||
if ( ! GetOperationNewName( sNewName))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco il gruppo
|
||||
int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// assegno il nome
|
||||
m_pGeomDB->SetName( nId, sNewName) ;
|
||||
// installo il gestore della lavorazione
|
||||
Drilling* pDrilling = new(nothrow) Drilling ;
|
||||
if ( pDrilling == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
m_pGeomDB->SetObjUser( nId, pDrilling) ;
|
||||
return nId ;
|
||||
}
|
||||
Reference in New Issue
Block a user