EgtMachKernel 1.6v7 :

- modifiche per bloccaggi su più fasi
This commit is contained in:
Dario Sassi
2016-10-15 10:06:51 +00:00
parent 64c0e3826c
commit d682572702
12 changed files with 198 additions and 80 deletions
+63 -68
View File
@@ -421,22 +421,46 @@ Disposition::AddFixture( const string& sName, const Point3d& ptPos, double dAngD
// verifico che la posizione sia nell'area della tavola
if ( ! m_b3Area1.EnclosesXY( m_ptRef1 + ptPos))
return GDB_ID_NULL ;
// recupero il gruppo delle fixtures nella macchinata corrente
int nFixtGrpId = m_pMchMgr->GetCurrFixtGroupId() ;
if ( nFixtGrpId == GDB_ID_NULL)
return GDB_ID_NULL ;
// verifico esistenza file sottopezzo
string sFixtFile = m_pMchMgr->GetCurrFixtDir() + "\\" + sName + ".Nge" ;
if ( ! ExistsFile( sFixtFile))
return GDB_ID_NULL ;
// inserisco il sottopezzo nel gruppo
if ( ! m_pGeomDB->Load( sFixtFile, nFixtGrpId))
return GDB_ID_NULL ;
int nFixtId = m_pGeomDB->GetLastGroupInGroup( nFixtGrpId) ;
if ( nFixtId == GDB_ID_NULL)
return GDB_ID_NULL ;
// imposto il livello a temporaneo
m_pGeomDB->SetLevel( nFixtId, GDB_LV_TEMP) ;
// Nome tutto maiuscolo
string sMyName = sName ;
ToUpper( sMyName) ;
// Se recuperabile dal gruppo dei bloccaggi
int nFixtId = m_pMchMgr->GetUnusedFixture( sMyName, m_nPhase) ;
if ( nFixtId != GDB_ID_NULL) {
// aggiungo la fase al bloccaggio
INTVECTOR vPhase ;
m_pMchMgr->GetFixturePhases( nFixtId, vPhase) ;
vPhase.push_back( m_nPhase) ;
m_pGeomDB->SetInfo( nFixtId, MACH_FXT_PHASE, vPhase) ;
// aggiorno visualizzazione
m_pGeomDB->SetStatus( nFixtId, GDB_ST_ON) ;
}
// altrimenti lo carico da file
else {
// recupero il gruppo delle fixtures nella macchinata corrente
int nFixtGrpId = m_pMchMgr->GetCurrFixtGroupId() ;
if ( nFixtGrpId == GDB_ID_NULL)
return GDB_ID_NULL ;
// verifico esistenza file sottopezzo
string sFixtFile = m_pMchMgr->GetCurrFixtDir() + "\\" + sName + ".Nge" ;
if ( ! ExistsFile( sFixtFile))
return GDB_ID_NULL ;
// inserisco il sottopezzo nel gruppo
if ( ! m_pGeomDB->Load( sFixtFile, nFixtGrpId))
return GDB_ID_NULL ;
nFixtId = m_pGeomDB->GetLastGroupInGroup( nFixtGrpId) ;
if ( nFixtId == GDB_ID_NULL)
return GDB_ID_NULL ;
// assegno il nome
m_pGeomDB->SetName( nFixtId, sMyName) ;
// imposto il livello a temporaneo
m_pGeomDB->SetLevel( nFixtId, GDB_LV_TEMP) ;
// aggiungo la fase al bloccaggio
m_pGeomDB->SetInfo( nFixtId, MACH_FXT_PHASE, m_nPhase) ;
}
// resetto il riferimento del gruppo
Frame3d* pfrFixt = m_pGeomDB->GetGroupFrame( nFixtId) ;
pfrFixt->Reset() ;
// la muovo nella posizione voluta
Vector3d vtMove = ( m_ptRef1 + ptPos) - ORIG ;
m_pGeomDB->TranslateGlob( nFixtId, vtMove) ;
@@ -469,7 +493,7 @@ Disposition::GetFirstFixture( void)
// recupero il primo
int nId = m_vFixData.front().nId ;
// ne verifico la validità
if ( ! VerifyFixture( nId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false))
return GDB_ID_NULL ;
return nId ;
}
@@ -478,9 +502,6 @@ Disposition::GetFirstFixture( void)
int
Disposition::GetNextFixture( int nId)
{
// verifica validità bloccaggio
if ( ! VerifyFixture( nId))
return GDB_ID_NULL ;
// ciclo sui bloccaggi
int nFxtTot = int( m_vFixData.size()) ;
for ( int i = 0 ; i < nFxtTot ; ++ i) {
@@ -488,7 +509,8 @@ Disposition::GetNextFixture( int nId)
if ( m_vFixData[i].nId == nId) {
// se esiste successivo e valido
int j = i + 1 ;
if ( j < nFxtTot && VerifyFixture( m_vFixData[j].nId))
if ( j < nFxtTot &&
m_pMchMgr != nullptr && m_pMchMgr->VerifyFixture( m_vFixData[j].nId, false))
return m_vFixData[j].nId ;
else
return GDB_ID_NULL ;
@@ -502,7 +524,7 @@ bool
Disposition::MoveFixture( int nId, const Vector3d& vtMove)
{
// verifica validità sottopezzo
if ( ! VerifyFixture( nId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false))
return false ;
// verifico aggiornamento tavola
if ( ! m_bTabOk && ! SetTable( m_sTabName))
@@ -529,7 +551,7 @@ bool
Disposition::RotateFixture( int nId, double dDeltaAngDeg)
{
// verifica validità sottopezzo
if ( ! VerifyFixture( nId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false))
return false ;
// verifico aggiornamento tavola
if ( ! m_bTabOk && ! SetTable( m_sTabName))
@@ -551,7 +573,7 @@ bool
Disposition::MoveFixtureMobile( int nId, double dDeltaMov)
{
// verifica validità sottopezzo
if ( ! VerifyFixture( nId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false))
return false ;
// verifico aggiornamento tavola
if ( ! m_bTabOk && ! SetTable( m_sTabName))
@@ -581,7 +603,7 @@ bool
Disposition::PlaceFixture( int nId, const Point3d& ptPos, double dAngDeg, double dMov)
{
// verifica validità sottopezzo
if ( ! VerifyFixture( nId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false))
return false ;
// verifico aggiornamento tavola
if ( ! m_bTabOk && ! SetTable( m_sTabName))
@@ -627,13 +649,20 @@ bool
Disposition::RemoveFixture( int nId)
{
// verifica validità sottopezzo
if ( ! VerifyFixture( nId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false))
return false ;
// verifico aggiornamento tavola
if ( ! m_bTabOk && ! SetTable( m_sTabName))
return false ;
// rimuovo l'oggetto dal DB
m_pGeomDB->Erase( nId) ;
// dichiaro l'oggetto non più usato dalla fase
INTVECTOR vPhase ;
if ( ! m_pMchMgr->GetFixturePhases( nId, vPhase))
return false ;
auto iIter = find( vPhase.begin(), vPhase.end(), m_nPhase) ;
if ( iIter != vPhase.end()) {
vPhase.erase( iIter) ;
m_pGeomDB->SetInfo( nId, MACH_FXT_PHASE, vPhase) ;
}
// rimuovo l'oggetto dal vettore dei comandi
while ( true) {
auto iIter = find_if( m_vFixData.begin(), m_vFixData.end(),
@@ -652,7 +681,7 @@ bool
Disposition::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList)
{
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyRawPart( nRawId, false))
return false ;
// recupero il solido
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
@@ -708,7 +737,7 @@ bool
Disposition::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList)
{
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyRawPart( nRawId, false))
return false ;
// recupero il solido
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
@@ -764,7 +793,7 @@ bool
Disposition::MoveRawPart( int nRawId, const Vector3d& vtMove)
{
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyRawPart( nRawId, false))
return false ;
// se movimento nullo, non devo fare alcunché
if ( vtMove.IsSmall())
@@ -803,7 +832,7 @@ bool
Disposition::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg)
{
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyRawPart( nRawId, false))
return false ;
// recupero centro del grezzo
Point3d ptAx ;
@@ -834,7 +863,7 @@ bool
Disposition::ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADeg, double dAngC1Deg)
{
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyRawPart( nRawId, false))
return false ;
// recupero centro del grezzo
Point3d ptCen ;
@@ -859,7 +888,7 @@ bool
Disposition::RemoveRawPart( int nRawId)
{
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyRawPart( nRawId, false))
return false ;
// elimino i movimenti registrati per questo grezzo
while ( true) {
@@ -874,40 +903,6 @@ Disposition::RemoveRawPart( int nRawId)
return true ;
}
//----------------------------------------------------------------------------
bool
Disposition::VerifyFixture( int nFixtId) const
{
// verifico MachMgr e GeomDB
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// recupero il gruppo delle fixtures nella macchinata corrente
int nFixtGrpId = m_pMchMgr->GetCurrFixtGroupId() ;
if ( nFixtGrpId == GDB_ID_NULL)
return false ;
// verifico che l'oggetto appartenga al gruppo delle fixtures
if ( m_pGeomDB->GetParentId( nFixtId) != nFixtGrpId)
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
Disposition::VerifyRawPart( int nRawId) const
{
// verifico MachMgr e GeomDB
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// recupero il gruppo dei grezzi nella macchinata corrente
int nRawGroupId = m_pMchMgr->GetCurrRawGroupId() ;
if ( nRawGroupId == GDB_ID_NULL)
return false ;
// verifico che questo grezzo ne faccia parte
if ( m_pGeomDB->GetParentId( nRawId) != nRawGroupId)
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
Disposition::GetFixtureData( int nInd, string& sName, int& nId, Point3d& ptPos, double& dAngDeg) const