2324a8b3f4
- modifiche a DB utensili per gestione utensile corrente - prima versione generatore codice.
107 lines
3.8 KiB
C++
107 lines
3.8 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : MachineHeads.cpp Data : 10.05.15 Versione : 1.6e3
|
|
// Contenuto : Implementazione gestione macchina : funzioni per teste.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 10.05.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "MachMgr.h"
|
|
#include "DllMain.h"
|
|
#include "Exit.h"
|
|
#include "/EgtDev/Include/EMkToolConst.h"
|
|
#include "/EgtDev/Include/EGnStringUtils.h"
|
|
#include "/EgtDev/Include/EGnFileUtils.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::LoadTool( const string& sHead, int nExit, const string& sTool)
|
|
{
|
|
// controllo GeomDB
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// recupero il gruppo della testa
|
|
int nHdGrp = GetGroup( sHead) ;
|
|
if ( ! IsHeadGroup( nHdGrp))
|
|
return false ;
|
|
// cerco il gruppo dell'uscita in quello della testa
|
|
string sExit = MCH_EXIT + ToString( nExit) ;
|
|
int nExGrp = m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ;
|
|
Exit* pExit = GetExit( nExGrp) ;
|
|
if ( pExit == nullptr)
|
|
return false ;
|
|
// se utensile già montato, abilito ed esco
|
|
if ( sTool == pExit->GetTool())
|
|
return EnableHeadInSet( sHead) ;
|
|
// verifico esistenza file utensile
|
|
string sDraw ;
|
|
if ( ! m_pMchMgr->TdbSetCurrTool( sTool) || ! m_pMchMgr->TdbGetCurrToolParam( TPA_DRAW, sDraw))
|
|
return false ;
|
|
string sToolFile = m_sMachineDir + "\\" + TOOLS_DIR + "\\" + sDraw ;
|
|
if ( ! ExistsFile( sToolFile))
|
|
return false ;
|
|
// pulisco il gruppo dell'uscita
|
|
m_pGeomDB->EmptyGroup( nExGrp) ;
|
|
// inserisco l'utensile nel gruppo
|
|
if ( ! m_pGeomDB->Load( sToolFile, nExGrp))
|
|
return false ;
|
|
int nTGrpId = m_pGeomDB->GetFirstGroupInGroup( nExGrp) ;
|
|
int nSolidId = m_pGeomDB->GetFirstNameInGroup( nTGrpId, "SOLID") ;
|
|
if ( nSolidId == GDB_ID_NULL)
|
|
return false ;
|
|
m_pGeomDB->RelocateGlob( nSolidId, nExGrp, GDB_FIRST_SON) ;
|
|
m_pGeomDB->Erase( nTGrpId) ;
|
|
m_pGeomDB->SetName( nSolidId, sTool) ;
|
|
// lo ruoto 90 deg attorno alla X locale
|
|
int nT = m_pGeomDB->GetFirstGroupInGroup( nExGrp) ;
|
|
if ( nT == GDB_ID_NULL)
|
|
return false ;
|
|
m_pGeomDB->Rotate( nT, ORIG, X_AX, 90) ;
|
|
pExit->SetTool( sTool) ;
|
|
return EnableHeadInSet( sHead) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::ResetHeadSet( const string& sHead)
|
|
{
|
|
// controllo GeomDB
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// recupero il set della testa
|
|
const STRVECTOR& vsHSet = GetHSet( sHead) ;
|
|
if ( vsHSet.empty())
|
|
return false ;
|
|
// ciclo su tutte le teste dell'insieme per svuotarle
|
|
for ( size_t i = 0 ; i < vsHSet.size() ; ++ i) {
|
|
// recupero il gruppo della testa
|
|
int nHdGrp = GetGroup( vsHSet[i]) ;
|
|
if ( ! IsHeadGroup( nHdGrp))
|
|
return false ;
|
|
// ciclo sulle sue uscite
|
|
for ( int j = 1 ; true ; ++ j) {
|
|
// recupero il gruppo dell'uscita
|
|
string sExit = MCH_EXIT + ToString( j) ;
|
|
int nExGrp = m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ;
|
|
// recupero l'oggetto uscita
|
|
Exit* pExit = GetExit( nExGrp) ;
|
|
if ( pExit == nullptr)
|
|
break ;
|
|
// pulisco il gruppo dell'uscita
|
|
m_pGeomDB->EmptyGroup( nExGrp) ;
|
|
pExit->SetTool( "") ;
|
|
}
|
|
// visualizzo solo la prima testa
|
|
m_pGeomDB->SetStatus( nHdGrp, ( i == 0 ? GDB_ST_ON : GDB_ST_OFF)) ;
|
|
}
|
|
return true ;
|
|
} |