diff --git a/Simulator.cpp b/Simulator.cpp index 794f8d2..9a2efd0 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -257,29 +257,13 @@ Simulator::GetAxisInfoPos( int nI, string& sName, string& sToken, bool& bLinear, // recupero i dati dell'asse if ( nI < 0 || nI >= nAxisCount + nAuxAxisCount) return false ; - // se asse ausiliario, verifico non coincida con uno attivo - if ( nI >= nAxisCount) { - while ( nI < nAxisCount + nAuxAxisCount) { - bool bFound = false ; - for ( int j = 0 ; j < nAxisCount ; ++ j) { - if ( m_AuxAxesName[ nI - nAxisCount] == m_AxesName[j]) { - bFound = true ; - break ; - } - } - if ( bFound) - ++ nI ; - else - break ; - } - if ( nI >= nAxisCount + nAuxAxisCount) - return false ; - } + // se asse principale if ( nI < nAxisCount) { sName = m_AxesName[nI] ; sToken = m_AxesToken[nI] ; bLinear = m_AxesLinear[nI] ; } + // altrimenti asse ausiliario else { sName = m_AuxAxesName[ nI - nAxisCount] ; sToken = m_AuxAxesToken[ nI - nAxisCount] ; @@ -1228,12 +1212,15 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co m_pMachine->GetAxisInvert( sName, bInvert) && m_pMachine->GetAxisType( sName, bLinear) && m_pMachine->GetAxisPos( sName, dVal)) { - m_AuxAxesName.emplace_back( sName) ; - m_AuxAxesToken.emplace_back( sToken) ; - m_AuxAxesInvert.push_back( bInvert) ; - m_AuxAxesLinear.push_back( bLinear) ; - m_AuxAxesVal.emplace_back( dVal) ; - m_AuxAxesEnd.emplace_back( dVal) ; + // se non è già negli assi principali, lo aggiungo + if ( find( m_AxesName.begin(), m_AxesName.end(), sName) == m_AxesName.end()) { + m_AuxAxesName.emplace_back( sName) ; + m_AuxAxesToken.emplace_back( sToken) ; + m_AuxAxesInvert.push_back( bInvert) ; + m_AuxAxesLinear.push_back( bLinear) ; + m_AuxAxesVal.emplace_back( dVal) ; + m_AuxAxesEnd.emplace_back( dVal) ; + } } else bOk = false ; @@ -1465,16 +1452,19 @@ Simulator::OnMoveStart( const CamData* pCamData, int& nErr) m_pMachine->GetAxisType( sName, bLinear) && m_pMachine->GetAxisPos( sName, dVal) && m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) { - m_AuxAxesName.emplace_back( sName) ; - m_AuxAxesToken.emplace_back( sToken) ; - m_AuxAxesInvert.push_back( bInvert) ; - m_AuxAxesLinear.push_back( bLinear) ; - m_AuxAxesVal.emplace_back( dVal) ; - m_AuxAxesEnd.emplace_back( dEnd) ; - if ( ! m_pMachine->VerifyOutstroke( sName, dEnd)) { - nErr = 1 ; - bOk = false ; - } + // se non è già negli assi principali, lo aggiungo + if ( find( m_AxesName.begin(), m_AxesName.end(), sName) == m_AxesName.end()) { + m_AuxAxesName.emplace_back( sName) ; + m_AuxAxesToken.emplace_back( sToken) ; + m_AuxAxesInvert.push_back( bInvert) ; + m_AuxAxesLinear.push_back( bLinear) ; + m_AuxAxesVal.emplace_back( dVal) ; + m_AuxAxesEnd.emplace_back( dEnd) ; + if ( ! m_pMachine->VerifyOutstroke( sName, dEnd)) { + nErr = 1 ; + bOk = false ; + } + } } else bOk = false ;