From 7a451b3e3f6a27634ee38be97aea990f586428e3 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 17 May 2019 18:21:32 +0000 Subject: [PATCH] EgtMachKernel : - aggiunto aggiornamento disegni utensili al salvataggio DB utensili - aggiunta funzione MachMgr::TdbCurrToolDraw - modifiche varie per supportare i punti precedenti. --- MachConst.h | 24 +++ MachMgr.h | 17 ++- MachMgrBasic.cpp | 3 +- MachMgrDBTools.cpp | 357 ++++++++++++++++++++++++++++++++++++++++++++- ToolsMgr.cpp | 15 +- ToolsMgr.h | 10 +- 6 files changed, 415 insertions(+), 11 deletions(-) diff --git a/MachConst.h b/MachConst.h index a701c77..b0330cf 100644 --- a/MachConst.h +++ b/MachConst.h @@ -84,6 +84,30 @@ const std::string SETUP_SEC = "Setup" ; // Chiave per attrezzaggio di default const std::string SETUP_DEF_KEY = "Default" ; +//---------------------------------------------------------------------------- +// Sezione utensili nel file INI di macchina +const std::string TOOLS_SEC = "Tools" ; +// Chiave per generatore disegno punte a forare +const std::string DRILLMAKER_KEY = "DrillMaker" ; +// Chiave per generatore disegno lame +const std::string SAWBLADEMAKER_KEY = "SawbladeMaker" ; +// Chiave per generatore disegno frese +const std::string MILLMAKER_KEY = "MillMaker" ; +// Chiave per generatore disegno mortasatrici/seghe a catena +const std::string MORTISEMAKER_KEY = "MortiseMaker" ; +// Chiave per generatore disegno scalpelli +const std::string CHISELMAKER_KEY = "ChiselMaker" ; +// Chiave per porta utensili punte a forare (marmo) +const std::string DRILLHOLDER_KEY = "DrillHolder" ; +// Chiave per porta utensili lame (marmo) +const std::string SAWBLADEHOLDER_KEY = "SawBladeHolder" ; +// Chiave per portautensili frese (marmo) +const std::string MILLHOLDER_KEY = "MillHolder" ; + +//---------------------------------------------------------------------------- +// Sezione portautensili nel file INI di macchina +const std::string TOOLHOLDER_SEC = "ToolHolder" ; + //---------------------------------------------------------------------------- // Minimo spessore del grezzo const double RAW_MIN_H = 1 ; diff --git a/MachMgr.h b/MachMgr.h index 3f54a81..23ba771 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -1,13 +1,13 @@ //---------------------------------------------------------------------------- -// EgalTech 2015-2018 +// EgalTech 2015-2019 //---------------------------------------------------------------------------- -// File : MachMgr.h Data : 27.11.18 Versione : 1.9k2 +// File : MachMgr.h Data : 16.05.19 Versione : 2.1e3 // Contenuto : Dichiarazione della classe MachMgr. // // // // Modifiche : 23.03.15 DS Creazione modulo. -// +// 16.05.19 DS Aggiunto parametro sToolMakersDir a Init. // //---------------------------------------------------------------------------- @@ -65,7 +65,7 @@ class MachMgr : public IMachMgr public : // Basic ~MachMgr( void) override ; - bool Init( const std::string& sMachinesDir, IGeomDB* pGeomDB, + bool Init( const std::string& sMachinesDir, const std::string& sToolMakersDir, IGeomDB* pGeomDB, int nContextId, const std::string& sLuaLibsDir, const std::string& sLuaLastRequire) override ; bool Update( void) override ; bool Insert( int nInsGrp) override ; @@ -167,6 +167,7 @@ class MachMgr : public IMachMgr bool TdbGetCurrToolParam( int nType, double& dVal) const override ; bool TdbGetCurrToolParam( int nType, std::string& sVal) const override ; bool TdbGetCurrToolMaxDepth( double& dMaxDepth) const override ; + int TdbCurrToolDraw( int nGenCtx, int nToolCtx) const override ; bool TdbReload( void) override ; bool TdbSave( void) const override ; bool TdbGetToolDir( std::string& sToolDir) const override ; @@ -433,6 +434,13 @@ class MachMgr : public IMachMgr int SwapRawPartPart( int nId, bool bToRawPart) ; bool UpdateStatusMgoLayers( int nPartId, bool bToRawPart) ; bool ShowRootParts( bool bShow) ; + // Tools DataBase + bool UpdateAllToolDraws( void) const ; + bool UpdateToolDraw( const EgtUUID& UuidTool) const ; + int UpdateStandardToolDraw( const ToolData* pTdata, int nGenCtx, int nToolCtx, bool bToSave) const ; + int UpdateCustomToolDraw( const ToolData* pTdata, int nGenCtx, int nToolCtx, bool bToSave) const ; + std::string GetToolMakerKeyFromType( int nType) const ; + std::string GetToolHolderPath( const std::string& sHeadName, int nExit, int nType) const ; // Operations : dispositions int AddDisposition( const std::string& sName) ; @@ -444,6 +452,7 @@ class MachMgr : public IMachMgr int m_nContextId ; // indice contesto corrente (1-based) IGeomDB* m_pGeomDB ; // puntatore al DB geometrico del contesto corrente std::string m_sMachinesDir ; // direttorio delle macchine + std::string m_sToolMakersDir ; // direttorio dei generatori di disegni utensili standard std::string m_sLuaLibsDir ; // direttorio delle librerie lua std::string m_sLuaLastRequire ; // nome ultima libreria caricata int m_nLastError ; // identificativo ultimo errore diff --git a/MachMgrBasic.cpp b/MachMgrBasic.cpp index e6ff569..a58a5f4 100644 --- a/MachMgrBasic.cpp +++ b/MachMgrBasic.cpp @@ -89,12 +89,13 @@ MachMgr::Clear( void) //---------------------------------------------------------------------------- bool -MachMgr::Init( const string& sMachinesDir, IGeomDB* pGeomDB, +MachMgr::Init( const string& sMachinesDir, const string& sToolMakersDir, IGeomDB* pGeomDB, int nContextId, const string& sLuaLibsDir, const string& sLuaLastRequire) { m_nContextId = nContextId ; m_pGeomDB = pGeomDB ; m_sMachinesDir = sMachinesDir ; + m_sToolMakersDir = sToolMakersDir ; m_sLuaLibsDir = sLuaLibsDir ; m_sLuaLastRequire = sLuaLastRequire ; m_nMachBaseId = GDB_ID_NULL ; diff --git a/MachMgrDBTools.cpp b/MachMgrDBTools.cpp index 9b8dbd0..38eeb05 100644 --- a/MachMgrDBTools.cpp +++ b/MachMgrDBTools.cpp @@ -15,6 +15,9 @@ #include "stdafx.h" #include "DllMain.h" #include "MachMgr.h" +#include "/EgtDev/Include/EXeConst.h" +#include "/EgtDev/Include/EGnFileUtils.h" +#include "/EgtDev/Include/EgtIniFile.h" using namespace std ; @@ -255,6 +258,46 @@ MachMgr::TdbGetCurrToolMaxDepth( double& dMaxDepth) const return pTsMgr->GetCurrToolMaxDepth( dMaxDepth) ; } +//---------------------------------------------------------------------------- +int +MachMgr::TdbCurrToolDraw( int nGenCtx, int nToolCtx) const +{ + // recupero il gestore di utensili della macchina corrente + ToolsMgr* pTsMgr = GetCurrToolsMgr() ; + if ( pTsMgr == nullptr) + return TD_INT_ERR ; + // recupero il direttorio degli utensili + string sToolDir ; + TdbGetToolDir( sToolDir) ; + // recupero i dati dell'utensile corrente + const ToolData* pTdata = pTsMgr->GetCurrTool() ; + if ( pTdata == nullptr) + return TD_INT_ERR ; + string sDraw ; + pTdata->GetParam( TPA_DRAW, sDraw) ; + if ( sDraw.empty()) { + string sUuid ; + pTdata->GetParam( TPA_UUID, sUuid) ; + sDraw = sUuid + ".nge" ; + } + string sDrawPath = sToolDir + "\\" + sDraw ; + int nErr = 0 ; + // Se è disegno standard, lo ricreo + if ( IsUUID( GetFileTitleEgt( sDraw))) { + // Eseguo disegno + nErr = UpdateStandardToolDraw( pTdata, nGenCtx, nToolCtx, false) ; + } + // altrimenti è disegno custom, lo modifico + else { + // Carico e aggiorno il disegno dell'utensile + if ( ExeOpenFile( sDrawPath)) + nErr = UpdateCustomToolDraw( pTdata, nGenCtx, nToolCtx, false) ; + else + nErr = TD_INT_ERR ; + } + return nErr ; +} + //---------------------------------------------------------------------------- bool MachMgr::TdbReload( void) @@ -274,7 +317,9 @@ MachMgr::TdbSave( void) const // recupero il gestore di utensili della macchina corrente ToolsMgr* pTsMgr = GetCurrToolsMgr() ; if ( pTsMgr == nullptr) - return nullptr ; + return false ; + // verifico e aggiorno i disegni degli utensili + UpdateAllToolDraws() ; // se non ci sono state modifiche, esco subito if ( ! pTsMgr->GetModified()) return true ; @@ -305,11 +350,317 @@ MachMgr::TdbGetToolDir( string& sToolDir) const //---------------------------------------------------------------------------- bool -MachMgr::TdbGetToolHolderDir( string& sToolDir) const +MachMgr::TdbGetToolHolderDir( string& sToolHolderDir) const { string sMachineName ; if ( ! GetCurrMachineName( sMachineName)) return false ; - sToolDir = m_sMachinesDir + "\\" + sMachineName + "\\" + TOOLHOLDERS_DIR ; + sToolHolderDir = m_sMachinesDir + "\\" + sMachineName + "\\" + TOOLHOLDERS_DIR ; return true ; } + +//---------------------------------------------------------------------------- +bool +MachMgr::UpdateAllToolDraws( void) const +{ + // recupero il gestore di utensili della macchina corrente + ToolsMgr* pTsMgr = GetCurrToolsMgr() ; + if ( pTsMgr == nullptr) + return false ; + // recupero il direttorio degli utensili + string sToolDir ; + TdbGetToolDir( sToolDir) ; + // aggiorno il disegno degli utensili ( mancanti o modificati) + UUIDVECTOR vUuidMod = pTsMgr->GetUtModified() ; + string sName ; int nType ; + bool bNext = pTsMgr->GetFirstTool( TF_ALL, sName, nType) ; + while ( bNext) { + // dati dell'utensile + const ToolData* pTdata = pTsMgr->GetTool( sName) ; + // verifico se modificato + EgtUUID UuidTool = pTdata->m_Uuid ; + auto iIter = find( vUuidMod.begin(), vUuidMod.end(), UuidTool) ; + bool bModif = ( iIter != vUuidMod.end()) ; + if ( bModif) + vUuidMod.erase( iIter) ; + // verifico se non esiste il disegno associato + string sDraw ; pTdata->GetParam( TPA_DRAW, sDraw) ; + bool bNoDraw = ( ! sDraw.empty() && ! ExistsFile( sToolDir + "\\" + sDraw)) ; + // se modificato o senza disegno, ne lancio la creazione + if ( bModif || bNoDraw) + UpdateToolDraw( UuidTool) ; + // passo al successivo + bNext = pTsMgr->GetNextTool( TF_ALL, sName, nType) ; + } + // nel vettore sono rimasti solo gli utensili cancellati, ne elimino i disegni + for ( const auto& UuidTool : vUuidMod) { + string sDrawPath = sToolDir + "\\" + ToString( UuidTool) + ".nge" ; + EraseFile( sDrawPath) ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::UpdateToolDraw( const EgtUUID& UuidTool) const +{ + // recupero il gestore di utensili della macchina corrente + ToolsMgr* pTsMgr = GetCurrToolsMgr() ; + if ( pTsMgr == nullptr) + return false ; + // recupero il direttorio degli utensili + string sToolDir ; + TdbGetToolDir( sToolDir) ; + // recupero l'utensile + const ToolData* pTdata = pTsMgr->GetTool( UuidTool) ; + // se non esiste, esco + if ( pTdata == nullptr) + return false ; + // Recupero il nome del disegno dell'utensile + string sDraw ; + pTdata->GetParam( TPA_DRAW, sDraw) ; + if ( sDraw.empty()) + return true ; + // Determino la path del disegno + string sDrawPath = sToolDir + "\\" + sDraw ; + // Recupero contesto generale e creo contesto per il disegno utensile + int nGenCtx = ExeGetCurrentContext() ; + int nToolCtx = ExeInitContext() ; + bool bOk = ( nToolCtx != 0) ; + // Se è disegno standard, lo ricreo + if ( IsUUID( GetFileTitleEgt( sDraw))) { + // Eseguo disegno + bOk = bOk && ( UpdateStandardToolDraw( pTdata, nGenCtx, nToolCtx, true) == 0) ; + } + // altrimenti è disegno custom, lo modifico + else { + // Carico e aggiorno il disegno dell'utensile + bOk = bOk && ExeOpenFile( sDrawPath) ; + bOk = bOk && ( UpdateCustomToolDraw( pTdata, nGenCtx, nToolCtx, true) == 0) ; + } + // Salvo il disegno + ExeSetCurrentContext( nToolCtx) ; + bOk = bOk && ExeSaveFile( sDrawPath, GDB_SV_CMPTXT) ; + // Ripristino il contesto originale + ExeSetCurrentContext( nGenCtx) ; + ExeDeleteContext( nToolCtx) ; + return bOk ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::UpdateStandardToolDraw( const ToolData* pTdata, int nGenCtx, int nToolCtx, bool bToSave) const +{ + // Imposto contesto generale + if ( ! ExeSetCurrentContext( nGenCtx)) + return TD_INT_ERR ; + // Verifico esista macchina corrente + Machine* pMch = GetCurrMachine() ; + if ( pMch == nullptr) + return TD_INT_ERR ; + // Recupero file Ini della macchina + string sMachIni = pMch->GetMachineDir() + "\\" + pMch->GetMachineName() + ".ini" ; + // Recupero i dati dell'utensile + int nType = TT_NONE ; + pTdata->GetParam( TPA_TYPE, nType) ; + string sHeadName ; + pTdata->GetParam( TPA_HEAD, sHeadName) ; + int nExit = 0 ; + pTdata->GetParam( TPA_EXIT, nExit) ; + double dLen = 0 ; + pTdata->GetParam( TPA_LEN, dLen) ; + double dTotLen = 0 ; + pTdata->GetParam( TPA_TOTLEN, dTotLen) ; + double dDiam = 0 ; + pTdata->GetParam( TPA_DIAM, dDiam) ; + double dTotDiam = 0 ; + pTdata->GetParam( TPA_TOTDIAM, dTotDiam) ; + double dMaxMat = 0 ; + pTdata->GetParam( TPA_MAXMAT, dMaxMat) ; + double dCornRad = 0 ; + pTdata->GetParam( TPA_CORNRAD, dCornRad) ; + double dSideAng = 0 ; + pTdata->GetParam( TPA_SIDEANG, dSideAng) ; + double dThick = 0 ; + pTdata->GetParam( TPA_THICK, dThick) ; + // Recupero la path dell'eventuale portautensile + string sThPath = GetToolHolderPath( sHeadName, nExit, nType) ; + // Carico generatore disegno utensile + string sMaker = GetPrivateProfileStringUtf8( TOOLS_SEC.c_str(), GetToolMakerKeyFromType( nType).c_str(), "", sMachIni.c_str()) ; + if ( sMaker.empty()) + return TD_INT_ERR ; + // Imposto contesto per il disegno utensile + if ( ! ExeSetCurrentContext( nToolCtx)) + return TD_INT_ERR ; + // Acquisisco il programma lua di creazione disegno utensile + if ( ! ExeLuaExecFile( m_sToolMakersDir + "\\" + sMaker)) + return TD_INT_ERR ; + // Assegno i dati utensile a seconda del tipo + bool bOk = true ; + switch ( nType) { + case TT_DRILL_STD : + case TT_DRILL_LONG : + case TT_CHISEL_STD : + bOk = bOk && ExeLuaSetGlobStringVar( "TOOL.TOOLHOLDER", sThPath) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.TOTLEN", dTotLen) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.LEN", dLen) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.DIAM", dDiam) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.MAXMAT", dMaxMat) ; + break ; + case TT_SAW_STD : + case TT_SAW_FLAT : + bOk = bOk && ExeLuaSetGlobStringVar( "TOOL.TOOLHOLDER", sThPath) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.LEN", dLen) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.DIAM", dDiam) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.CORE", ( dLen >= dThick ? dThick - 1 : 2 * dLen - dThick)) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.THICK", dThick) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.MAXMAT", dMaxMat) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.CORNRAD", dCornRad) ; + break ; + case TT_MILL_STD : + case TT_MILL_NOTIP : + bOk = bOk && ExeLuaSetGlobStringVar( "TOOL.TOOLHOLDER", sThPath) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.TOTLEN", dTotLen) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.LEN", dLen) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.TOTDIAM", dTotDiam) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.DIAM", dDiam) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.MAXMAT", dMaxMat) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.HEIGHT", dThick) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.SIDEANG", dSideAng) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.CORNRAD", dCornRad) ; + break ; + case TT_MORTISE_STD : + bOk = bOk && ExeLuaSetGlobStringVar( "TOOL.TOOLHOLDER", sThPath) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.LEN", dLen) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.DIAM", dDiam) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.MAXMAT", dMaxMat) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.THICK", dThick) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.CORNRAD", dCornRad) ; + break ; + default : + return TD_INT_ERR ; + } + // Eseguo creazione utensile + bOk = bOk && ExeLuaCallFunction( "CreateTool") ; + // Recupero errore + int nErr = TD_INT_ERR ; + if ( ! ExeLuaGetGlobIntVar( "TOOL.ERR", &nErr) || nErr != 0) + return nErr ; + // Se per salvataggio + if ( bOk && bToSave) { + // Nascondo layer ausiliario + int nAuxId = ExeGetFirstNameInGroup( ExeGetFirstGroupInGroup( GDB_ID_ROOT), "AUX") ; + ExeSetStatus( { nAuxId}, GDB_ST_OFF) ; + // Se lama devo ruotare -90 deg attorno a Z+ + if ( nType == TT_SAW_STD || nType == TT_SAW_FLAT) { + int nPartId = ExeGetFirstGroupInGroup( GDB_ID_ROOT) ; + ExeRotate( { nPartId}, ORIG, Z_AX, -90, RTY_GLOB) ; + } + } + return ( bOk ? 0 : TD_INT_ERR) ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::UpdateCustomToolDraw( const ToolData* pTdata, int nGenCtx, int nToolCtx, bool bToSave) const +{ + // Imposto contesto generale + if ( ! ExeSetCurrentContext( nGenCtx)) + return TD_INT_ERR ; + // Recupero i dati dell'utensile + int nType = TT_NONE ; + pTdata->GetParam( TPA_TYPE, nType) ; + double dLen = 0 ; + pTdata->GetParam( TPA_LEN, dLen) ; + double dDiam = 0 ; + pTdata->GetParam( TPA_DIAM, dDiam) ; + // Solo per frese + if ( nType != TT_MILL_STD && nType != TT_MILL_NOTIP) + return TD_INT_ERR ; + // Imposto contesto per il disegno utensile + if ( ! ExeSetCurrentContext( nToolCtx)) + return TD_INT_ERR ; + // Acquisisco il programma lua di aggiornamento disegno utensile + bool bOk = ExeLuaExecFile( m_sToolMakersDir + "\\" + "ToolAdjust.lua") ; + // Assegno i dati utensile + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.LEN", dLen) ; + bOk = bOk && ExeLuaSetGlobNumVar( "TOOL.DIAM", dDiam) ; + // Eseguo aggiornamento utensile + bOk = bOk && ExeLuaCallFunction( "AdjustCustomTool") ; + // Recupero errore + int nErr = TD_INT_ERR ; + if ( ! ExeLuaGetGlobIntVar( "TOOL.ERR", &nErr) || nErr != 0) + return nErr ; + return ( bOk ? 0 : TD_INT_ERR) ; +} + +//---------------------------------------------------------------------------- +string +MachMgr::GetToolMakerKeyFromType( int nType) const +{ + switch ( nType) { + case TT_DRILL_STD : + case TT_DRILL_LONG : + return DRILLMAKER_KEY ; + case TT_SAW_STD : + case TT_SAW_FLAT : + return SAWBLADEMAKER_KEY ; + case TT_MILL_STD : + case TT_MILL_NOTIP : + return MILLMAKER_KEY ; + case TT_MORTISE_STD : + return MORTISEMAKER_KEY ; + case TT_CHISEL_STD : + return CHISELMAKER_KEY ; + case TT_COMPO : + return "" ; + } + return "" ; +} + +//---------------------------------------------------------------------------- +string +MachMgr::GetToolHolderPath( const string& sHeadName, int nExit, int nType) const +{ + // Verifiche su testa e uscita + if ( sHeadName.empty() || nExit == 0) + return "" ; + // Verifico esista macchina corrente + Machine* pMch = GetCurrMachine() ; + if ( pMch == nullptr) + return false ; + // Recupero file Ini della macchina + string sMachIni = pMch->GetMachineDir() + "\\" + pMch->GetMachineName() + ".ini" ; + // Recupero nome portautensile + string sToolHolder ; + // Da sezione ToolHolder di Ini di macchina + string sKey = sHeadName + "." + ToString( nExit) ; + if ( nType == TT_SAW_STD) { + string sKey2 = sKey + ":SAW_STD" ; + sToolHolder = GetPrivateProfileStringUtf8( TOOLHOLDER_SEC.c_str(), sKey2.c_str(), "", sMachIni.c_str()) ; + } + else if(nType == TT_SAW_FLAT) { + string sKey2 = sKey + ":SAW_FLAT" ; + sToolHolder = GetPrivateProfileStringUtf8( TOOLHOLDER_SEC.c_str(), sKey2.c_str(), "", sMachIni.c_str()) ; + } + if ( sToolHolder.empty()) + sToolHolder = GetPrivateProfileStringUtf8( TOOLHOLDER_SEC.c_str(), sKey.c_str(), "", sMachIni.c_str()) ; + // Se non trovato, provo da sezione Tools di Ini di macchina + if ( sToolHolder.empty()) { + if ( nType == TT_DRILL_STD || nType == TT_DRILL_LONG) + sToolHolder = GetPrivateProfileStringUtf8( TOOLS_SEC.c_str(), DRILLHOLDER_KEY.c_str(), "", sMachIni.c_str()) ; + else if ( nType == TT_SAW_STD || nType == TT_SAW_FLAT) + sToolHolder = GetPrivateProfileStringUtf8( TOOLS_SEC.c_str(), SAWBLADEHOLDER_KEY.c_str(), "", sMachIni.c_str()) ; + else if ( nType == TT_MILL_STD || nType == TT_MILL_NOTIP) + sToolHolder = GetPrivateProfileStringUtf8( TOOLS_SEC.c_str(), MILLHOLDER_KEY.c_str(), "", sMachIni.c_str()) ; + } + // Se non trovato ancora, esco + if ( sToolHolder.empty()) + return "" ; + // Recupero il direttorio dei portautensili + string sToolHolderDir ; + if ( ! TdbGetToolHolderDir( sToolHolderDir)) + return "" ; + // Restituisco la path + return ( sToolHolderDir + "\\" + sToolHolder) ; +} diff --git a/ToolsMgr.cpp b/ToolsMgr.cpp index df01ee7..66cd5f1 100644 --- a/ToolsMgr.cpp +++ b/ToolsMgr.cpp @@ -56,6 +56,7 @@ ToolsMgr::Clear( void) m_suCIter = m_suData.cend() ; m_bCurrTool = false ; m_bModified = false ; + m_utModified.clear() ; return true ; } @@ -271,6 +272,7 @@ ToolsMgr::Save( bool bCompressed) const // dichiaro non più modificato rispetto al file m_bModified = false ; + m_utModified.clear() ; return true ; } @@ -359,6 +361,8 @@ ToolsMgr::AddTool( const string& sName, int nType) ! m_suData.emplace( tData.m_sName, tData.m_Uuid).second) return false ; m_bModified = true ; + if ( find( m_utModified.begin(), m_utModified.end(), tData.m_Uuid) == m_utModified.end()) + m_utModified.emplace_back( tData.m_Uuid) ; // lo rendo il nuovo utensile corrente m_bCurrTool = true ; m_tdCurrTool = tData ; @@ -391,6 +395,8 @@ ToolsMgr::CopyTool( const string& sSource, const string& sName) ! m_suData.emplace( tData.m_sName, tData.m_Uuid).second) return false ; m_bModified = true ; + if ( find( m_utModified.begin(), m_utModified.end(), tData.m_Uuid) == m_utModified.end()) + m_utModified.emplace_back( tData.m_Uuid) ; // lo rendo il nuovo utensile corrente m_bCurrTool = true ; m_tdCurrTool = tData ; @@ -405,15 +411,18 @@ ToolsMgr::RemoveTool( const string& sName) auto iNameIter = m_suData.find( sName) ; if ( iNameIter == m_suData.end()) return true ; + EgtUUID ToolUuid = iNameIter->second ; // se era anche l'utensile corrente, lo resetto - if ( m_bCurrTool && m_tdCurrTool.m_Uuid == iNameIter->second) + if ( m_bCurrTool && m_tdCurrTool.m_Uuid == ToolUuid) m_bCurrTool = false ; // rimuovo l'utensile dal dizionario degli UUID - m_utData.erase( iNameIter->second) ; + m_utData.erase( ToolUuid) ; // rimuovo l'utensile dall'elenco dei nomi m_suData.erase( iNameIter) ; // dichiaro la modifica m_bModified = true ; + if ( find( m_utModified.begin(), m_utModified.end(), ToolUuid) == m_utModified.end()) + m_utModified.emplace_back( ToolUuid) ; return true ; } @@ -535,6 +544,8 @@ ToolsMgr::SaveCurrTool( void) UpdateCurrToolHolderData() ; // eseguo salvataggio m_bModified = true ; + if ( find( m_utModified.begin(), m_utModified.end(), m_tdCurrTool.m_Uuid) == m_utModified.end()) + m_utModified.emplace_back( m_tdCurrTool.m_Uuid) ; iIter->second = m_tdCurrTool ; return true ; } diff --git a/ToolsMgr.h b/ToolsMgr.h index 7c07469..f258ed4 100644 --- a/ToolsMgr.h +++ b/ToolsMgr.h @@ -27,8 +27,10 @@ class ToolsMgr ToolsMgr( void) ; bool Load( const std::string& sToolsDir, const std::string& sToolsFile) ; bool Reload( void) ; - bool GetModified( void) + bool GetModified( void) const { return m_bModified ; } + const UUIDVECTOR& GetUtModified( void) const + { return m_utModified ; } bool Save( bool bCompressed = true) const ; bool GetToolNewName( std::string& sName) const ; bool AddTool( const std::string& sName, int nType) ; @@ -50,6 +52,11 @@ class ToolsMgr bool GetCurrToolParam( int nType, double& dVal) const ; bool GetCurrToolParam( int nType, std::string& sVal) const ; bool GetCurrToolMaxDepth( double& dMaxDepth) const ; + const ToolData* GetCurrTool( void) const + { if ( m_bCurrTool) + return &m_tdCurrTool ; + else + return nullptr ; } private : bool Clear( void) ; @@ -74,4 +81,5 @@ class ToolsMgr bool m_bCurrTool ; ToolData m_tdCurrTool ; mutable bool m_bModified ; + mutable UUIDVECTOR m_utModified ; } ; \ No newline at end of file