cdbc4bfb63
- aggiunta gestione quota di base del tool holder ( se negativa indica spazio libero su testa).
158 lines
6.6 KiB
C++
158 lines
6.6 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : ToolsMgr.h Data : 01.06.15 Versione : 1.6f1
|
|
// Contenuto : Dichiarazione della classe ToolsMgr.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 01.06.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "ToolData.h"
|
|
#include "/EgtDEv/Include/EmkToolConst.h"
|
|
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
|
#include <unordered_map>
|
|
#include <map>
|
|
|
|
class Scanner ;
|
|
class Writer ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
class ToolsMgr
|
|
{
|
|
public :
|
|
ToolsMgr( void) ;
|
|
bool Load( const std::string& sToolsDir, const std::string& sToolsFile) ;
|
|
bool Reload( 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) ;
|
|
bool CopyTool( const std::string& sSource, const std::string& sName) ;
|
|
bool RemoveTool( const std::string& sName) ;
|
|
const ToolData* GetTool( const EgtUUID& Uuid) const ;
|
|
const ToolData* GetTool( const std::string& sName) const ;
|
|
bool GetFirstTool( int nFamily, std::string& sName, int& nType) const ;
|
|
bool GetNextTool( int nFamily, std::string& sName, int& nType) const ;
|
|
bool SetCurrTool( const std::string& sName) ;
|
|
bool SaveCurrTool( void) ;
|
|
bool IsCurrToolModified( void) const ;
|
|
bool SetCurrToolParam( int nType, bool bVal) ;
|
|
bool SetCurrToolParam( int nType, int nVal) ;
|
|
bool SetCurrToolParam( int nType, double dVal) ;
|
|
bool SetCurrToolParam( int nType, const std::string& sVal) ;
|
|
template <class T> bool SetCurrToolValInNotes( int nType, const std::string& sKey, T& Val) ;
|
|
bool RemoveCurrToolValInNotes( int nType, const std::string& sKey) ;
|
|
bool GetCurrToolParam( int nType, bool& bVal) const ;
|
|
bool GetCurrToolParam( int nType, int& nVal) const ;
|
|
bool GetCurrToolParam( int nType, double& dVal) const ;
|
|
bool GetCurrToolParam( int nType, std::string& sVal) const ;
|
|
template <class T> bool GetCurrToolValInNotes( int nType, const std::string& sKey, T& Val) const ;
|
|
bool UpdateCurrToolHolderData( double dTHoldBase, double dTHoldLen, double dTHoldDiam) ;
|
|
bool GetCurrToolMaxDepth( double dSafe, double& dMaxDepth) const ;
|
|
bool GetCurrToolThDiam( double& dThDiam) const ;
|
|
bool GetCurrToolThLength( double& dThLen) const ;
|
|
const ToolData* GetCurrTool(void) const
|
|
{ return (m_bCurrTool ? &m_tdCurrTool : nullptr) ; }
|
|
bool Export( const STRVECTOR& vsToolsNames, const std::string& sOutFile, bool bCompressed = true) const ;
|
|
bool ToBeImported( const std::string& sFile, STRVECTOR& vsToolsNames, INTVECTOR& vToolsTypes) const ;
|
|
bool Import( const std::string& sFile, const STRVECTOR& vsToolsToImport, const STRVECTOR& vsToolsNames, STRVECTOR& vsImported) ;
|
|
|
|
private :
|
|
bool Clear( void) ;
|
|
bool LoadHeader( Scanner& TheScanner, int& nVersion, int& nToolSize, int& nTotal, bool& bEnd) const ;
|
|
bool LoadOneTool( Scanner& TheScanner, int nToolSize, ToolData& tData, bool& bEnd) const ;
|
|
bool SaveHeader( Writer& TheWriter) const ;
|
|
bool SaveOneTool( const EgtUUID& Uuid, int& nCounter, Writer& TheWriter) const ;
|
|
bool VerifyTool( int nFamily, std::string& sName, int& nType) const ;
|
|
bool ExportOneTool( const std::string& sToolName, Writer& TheWriter, int nCounter, const std::string& sOutDir) const ;
|
|
bool ReadTool( Scanner& TheScanner, ToolData& tData, int nToolSize) const ;
|
|
bool CopyToolDraw( const std::string& sDraw, const std::string& sOutDraw, const std::string& sToolName) const ;
|
|
|
|
private :
|
|
typedef std::unordered_map< EgtUUID, ToolData> UUIDTDATA_UMAP ;
|
|
typedef std::map< std::string, EgtUUID> STRUUID_MAP ;
|
|
typedef STRUUID_MAP::const_iterator STRUUID_CITER ;
|
|
|
|
private :
|
|
std::string m_sToolsDir ;
|
|
std::string m_sToolsPath ;
|
|
UUIDTDATA_UMAP m_utData ;
|
|
STRUUID_MAP m_suData ;
|
|
mutable STRUUID_CITER m_suCIter ;
|
|
bool m_bCurrTool ;
|
|
ToolData m_tdCurrTool ;
|
|
mutable bool m_bModified ;
|
|
mutable UUIDVECTOR m_utModified ;
|
|
} ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
template <class T>
|
|
bool
|
|
ToolsMgr::SetCurrToolValInNotes( int nType, const std::string& sKey, T& Val)
|
|
{
|
|
// deve esistere utensile corrente
|
|
if ( ! m_bCurrTool)
|
|
return false ;
|
|
// le note ammesse sono utente o sistema
|
|
if ( nType != TPA_USERNOTES && nType != TPA_SYSNOTES)
|
|
return false ;
|
|
// recupero le note da aggiornare
|
|
std::string sNotes ;
|
|
if ( ! m_tdCurrTool.GetParam( nType, sNotes))
|
|
return false ;
|
|
// aggiorno le note
|
|
if ( ! SetValInNotes( sKey, Val, sNotes))
|
|
return false ;
|
|
// salvo le note
|
|
return m_tdCurrTool.SetParam( nType, sNotes) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
template <class T>
|
|
bool
|
|
ToolsMgr::GetCurrToolValInNotes( int nType, const std::string& sKey, T& Val) const
|
|
{
|
|
// deve esistere utensile corrente
|
|
if ( ! m_bCurrTool)
|
|
return false ;
|
|
// le note ammesse sono utente o sistema
|
|
if ( nType != TPA_USERNOTES && nType != TPA_SYSNOTES)
|
|
return false ;
|
|
// recupero le note da cui leggere il valore
|
|
std::string sNotes ;
|
|
if ( ! m_tdCurrTool.GetParam( nType, sNotes))
|
|
return false ;
|
|
// recupero il valore
|
|
return GetValInNotes( sNotes, sKey, Val) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
inline bool
|
|
ToolsMgr::RemoveCurrToolValInNotes( int nType, const std::string& sKey)
|
|
{
|
|
// deve esistere utensile corrente
|
|
if ( ! m_bCurrTool)
|
|
return false ;
|
|
// le note ammesse sono utente o sistema
|
|
if ( nType != TPA_USERNOTES && nType != TPA_SYSNOTES)
|
|
return false ;
|
|
// recupero le note da aggiornare
|
|
std::string sNotes ;
|
|
if ( ! m_tdCurrTool.GetParam( nType, sNotes))
|
|
return false ;
|
|
// aggiorno le note
|
|
if ( ! RemoveValInNotes( sKey, sNotes))
|
|
return false ;
|
|
// salvo le note
|
|
return m_tdCurrTool.SetParam( nType, sNotes) ;
|
|
}
|