diff --git a/Disposition.cpp b/Disposition.cpp index 45f6ed1..fd15f89 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -256,10 +256,28 @@ Disposition::SetTable( const string& sTable) return true ; } +//---------------------------------------------------------------------------- +bool +Disposition::GetTableRef1( Point3d& ptRef1) +{ + // verifico MachMgr e GeomDB + if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) + return false ; + // verifico tavola + if ( ! m_bTabOk && ! SetTable( m_sTabName)) + return false ; + // recupero il primo riferimento della tavola + ptRef1 = m_ptRef1 ; + return true ; +} + //---------------------------------------------------------------------------- bool Disposition::Apply(void) { + // verifico tavola + if ( ! m_bTabOk && ! SetTable( m_sTabName)) + return false ; // aggiornamento sottopezzi for ( auto& FixData : m_vFixData) { // se sottopezzo da caricare diff --git a/Disposition.h b/Disposition.h index bf81bf8..9ecdbfa 100644 --- a/Disposition.h +++ b/Disposition.h @@ -66,6 +66,7 @@ class Disposition : public IUserObj bool Init( MachMgr* pMchMgr) ; bool SetTable( const std::string& sTable) ; bool Apply( void) ; + bool GetTableRef1( Point3d& ptRef1) ; int AddSubPiece( const std::string& sName, const Point3d& ptPos, double dAngDeg = 0, bool bAddToList = true) ; bool MoveSubPiece( int nId, const Vector3d& vtMove) ; bool RotateSubPiece( int nId, double dAngDeg) ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 5dfb3b7..a22cde5 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/EgtMachKernel.vcxproj b/EgtMachKernel.vcxproj index a5e1782..b922f0e 100644 --- a/EgtMachKernel.vcxproj +++ b/EgtMachKernel.vcxproj @@ -235,6 +235,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtMachKernel.vcxproj.filters b/EgtMachKernel.vcxproj.filters index 4758a20..8278d0a 100644 --- a/EgtMachKernel.vcxproj.filters +++ b/EgtMachKernel.vcxproj.filters @@ -129,6 +129,9 @@ Source Files\Operations + + Source Files\MachMgr + diff --git a/MachMgr.h b/MachMgr.h index 4d85459..b772a3e 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -73,8 +73,9 @@ class MachMgr : public IMachMgr virtual int GetRawPartCount( void) const ; virtual int GetFirstRawPart( void) const ; virtual int GetNextRawPart( int nId) const ; - virtual int AddRawPart( const Point3d& ptOrig, double dWidth, double dLen, double dHeight, Color cCol) ; + virtual int AddRawPart( const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol) ; virtual int AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color cCol) ; + virtual bool ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight) ; virtual bool ModifyRawPartHeight( int nRawId, double dHeight) ; virtual bool RemoveRawPart( int nRawId) ; virtual bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ; @@ -91,7 +92,9 @@ class MachMgr : public IMachMgr virtual bool RotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) ; // Tables and Fixtures virtual bool SetTable( const std::string& sTable) ; + virtual bool GetTableRef1( Point3d& ptPos) ; virtual int AddSubPiece( const std::string& sName, const Point3d& ptPos, double dAngRotDeg) ; + virtual bool ShowOnlyTable( bool bVal) ; // Machine virtual bool SetAxisPos( const std::string& sAxis, double dVal) ; virtual bool GetAxisPos( const std::string& sAxis, double& dVal) ; @@ -101,11 +104,16 @@ class MachMgr : public IMachMgr virtual bool ResetHeadSet( const std::string& sHead) ; virtual bool SetCalcTable( const std::string& sTable) ; virtual bool SetCalcTool( const std::string& sTool, const std::string& sHead, int nExit) ; + virtual bool GetCalcTool( std::string& sTool) ; virtual bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) ; virtual bool GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB, int& nStat, double& dX, double& dY, double& dZ) ; virtual bool VerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) ; + // Tools + virtual bool GetToolParam( const std::string& sName, int nType, int& nVal) const ; + virtual bool GetToolParam( const std::string& sName, int nType, double& dVal) const ; + virtual bool GetToolParam( const std::string& sName, int nType, std::string& sVal) const ; // Operations virtual int AddMachining( const std::string& sName, const std::string& sMachining) ; virtual bool SetMachiningParam( int nType, bool bVal) ; @@ -160,6 +168,8 @@ class MachMgr : public IMachMgr Machine* GetCurrMachine( void) const ; ToolsMgr* GetCurrToolsMgr( void) const ; MachiningsMgr* GetCurrMachiningsMgr( void) const ; + // Tools + const ToolData* GetToolData( const std::string& sName) const ; private : // Basic diff --git a/MachMgrFixtures.cpp b/MachMgrFixtures.cpp index 9d3be4a..3d30818 100644 --- a/MachMgrFixtures.cpp +++ b/MachMgrFixtures.cpp @@ -33,6 +33,20 @@ MachMgr::SetTable( const string& sTable) return ( pDisp != nullptr && pDisp->SetTable( sTable)) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::GetTableRef1( Point3d& ptPos) +{ + // recupero la prima operazione, deve essere la disposizione + int nDispId = GetFirstOperation() ; + // recupero l'oggetto disposizione + Disposition* pDisp = dynamic_cast( m_pGeomDB->GetUserObj( nDispId)) ; + if ( pDisp == nullptr) + return false ; + // recupero il punto + return pDisp->GetTableRef1( ptPos) ; +} + //---------------------------------------------------------------------------- int MachMgr::AddSubPiece( const string& sName, const Point3d& ptPos, double dAngRotDeg) @@ -46,3 +60,34 @@ MachMgr::AddSubPiece( const string& sName, const Point3d& ptPos, double dAngRotD // eseguo l'operazione return pDisp->AddSubPiece( sName, ptPos, dAngRotDeg) ; } + +//---------------------------------------------------------------------------- +bool +MachMgr::ShowOnlyTable( bool bVal) +{ + // verifico DB geometrico + if ( m_pGeomDB == nullptr) + return false ; + // recupero la macchina corrente + Machine* pMch = GetCurrMachine() ; + if ( pMch == nullptr) + return false ; + // recupero la tavola corrente + int nTabId = pMch->GetCurrTable() ; + if ( nTabId == GDB_ID_NULL) + return false ; + // nascondo o visualizzo i fratelli e tutti i fratelli degli ascendenti + int nCurrId = nTabId ; + int nParentId = m_pGeomDB->GetParentId( nCurrId) ; + while ( nParentId != GDB_ID_NULL && nParentId != GetMachAuxId()) { + int nId = m_pGeomDB->GetFirstInGroup( nParentId) ; + while ( nId != GDB_ID_NULL) { + if ( nId != nCurrId) + m_pGeomDB->SetStatus( nId, ( bVal ? GDB_ST_OFF : GDB_ST_ON)) ; + nId = m_pGeomDB->GetNext( nId) ; + } + nCurrId = nParentId ; + nParentId = m_pGeomDB->GetParentId( nParentId) ; + } + return true ; +} diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 13c37be..68f975d 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -187,6 +187,16 @@ MachMgr::SetCalcTool( const string& sTool, const string& sHead, int nExit) return m_vMachines[m_nCurrMch].pMachine->SetCurrTool( sTool, sHead, nExit) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::GetCalcTool( string& sTool) +{ + if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || + m_vMachines[m_nCurrMch].pMachine == nullptr) + return false ; + return m_vMachines[m_nCurrMch].pMachine->GetCurrTool( sTool) ; +} + //---------------------------------------------------------------------------- bool MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index 835f367..0dc66be 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -1,8 +1,8 @@ //---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- -// File : MachMgrMachinings.cpp Data : 21.05.15 Versione : 1.6e7 -// Contenuto : Implementazione gestione lavorazioni della classe MachMgr. +// File : MachMgrOperations.cpp Data : 21.05.15 Versione : 1.6e7 +// Contenuto : Implementazione gestione operazioni della classe MachMgr. // // // diff --git a/MachMgrRawParts.cpp b/MachMgrRawParts.cpp index 1f02200..77e9a05 100644 --- a/MachMgrRawParts.cpp +++ b/MachMgrRawParts.cpp @@ -69,14 +69,14 @@ MachMgr::GetNextRawPart( int nId) const //---------------------------------------------------------------------------- int -MachMgr::AddRawPart( const Point3d& ptOrig, double dWidth, double dLen, double dHeight, Color cCol) +MachMgr::AddRawPart( const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol) { // recupero il gruppo dei grezzi nella macchinata corrente int nRawGroupId = GetCurrRawGroupId() ; if ( nRawGroupId == GDB_ID_NULL) return GDB_ID_NULL ; // creo il solido - PtrOwner pStm( GetSurfTriMeshBox( dWidth, dLen, dHeight)) ; + PtrOwner pStm( GetSurfTriMeshBox( dLen, dWidth, dHeight)) ; if ( IsNull( pStm)) return GDB_ID_NULL ; // inserisco il gruppo del grezzo nei grezzi della macchinata @@ -275,6 +275,46 @@ MachMgr::AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color return nRawId ; } +//---------------------------------------------------------------------------- +bool +MachMgr::ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight) +{ + // le nuove dimensioni non possono essere nulle + if ( dLength < EPS_SMALL || dWidth < EPS_SMALL || dHeight < EPS_SMALL) + return false ; + // verifica validità grezzo + if ( ! VerifyRawPart( nRawId)) + return false ; + // recupero il solido del grezzo + int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + if ( nRawSolId == GDB_ID_NULL) + return false ; + // recupero il box del grezzo + BBox3d b3Raw ; + if ( ! m_pGeomDB->GetLocalBBox( nRawSolId, b3Raw)) + return false ; + // determino il coefficente di scalatura in X + double dOldL = b3Raw.GetMax().x - b3Raw.GetMin().x ; + if ( dOldL < EPS_SMALL) + return false ; + double dCoeffX = dLength / dOldL ; + // determino il coefficente di scalatura in Y + double dOldW = b3Raw.GetMax().y - b3Raw.GetMin().y ; + if ( dOldW < EPS_SMALL) + return false ; + double dCoeffY = dWidth / dOldW ; + // determino il coefficente di scalatura in Z + double dOldH = b3Raw.GetMax().z - b3Raw.GetMin().z ; + if ( dOldH < EPS_SMALL) + return false ; + double dCoeffZ = dHeight / dOldH ; + // eseguo scalatura + bool bOk = m_pGeomDB->Scale( nRawSolId, Frame3d( b3Raw.GetMin()), dCoeffX, dCoeffY, dCoeffZ) ; + // dichiaro centro da ricalcolare + ResetRawPartCenter( nRawId) ; + return bOk ; +} + //---------------------------------------------------------------------------- bool MachMgr::ModifyRawPartHeight( int nRawId, double dHeight) diff --git a/MachMgrTools.cpp b/MachMgrTools.cpp new file mode 100644 index 0000000..4a2aade --- /dev/null +++ b/MachMgrTools.cpp @@ -0,0 +1,67 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : MachMgrTools.cpp Data : 17.09.15 Versione : 1.6i7 +// Contenuto : Implementazione gestione utensili della classe MachMgr. +// +// +// +// Modifiche : 17.09.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "DllMain.h" +#include "MachMgr.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +const ToolData* +MachMgr::GetToolData( const string& sName) const +{ + // recupero il gestore di utensili della macchina corrente + ToolsMgr* pTsMgr = GetCurrToolsMgr() ; + if ( pTsMgr == nullptr) + return nullptr ; + // recupero l'utensile + return pTsMgr->GetTool( sName) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::GetToolParam( const string& sName, int nType, int& nVal) const +{ + // recupero l'utensile + const ToolData* pTdata = GetToolData( sName) ; + if ( pTdata == nullptr) + return false ; + // recupero il parametro + return pTdata->GetParam( nType, nVal) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::GetToolParam( const string& sName, int nType, double& dVal) const +{ + // recupero l'utensile + const ToolData* pTdata = GetToolData( sName) ; + if ( pTdata == nullptr) + return false ; + // recupero il parametro + return pTdata->GetParam( nType, dVal) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::GetToolParam( const string& sName, int nType, string& sVal) const +{ + // recupero l'utensile + const ToolData* pTdata = GetToolData( sName) ; + if ( pTdata == nullptr) + return false ; + // recupero il parametro + return pTdata->GetParam( nType, sVal) ; +} diff --git a/Machine.h b/Machine.h index 18c62b3..c0dcb60 100644 --- a/Machine.h +++ b/Machine.h @@ -44,7 +44,11 @@ class Machine bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) ; bool ResetAxisPos( const std::string& sAxis) ; bool SetCurrTable( const std::string& sTable) ; + int GetCurrTable( void) ; + bool GetCurrTable( std::string& sTable) ; bool SetCurrTool( const std::string& sTool, const std::string& sHead, int nExit) ; + int GetCurrTool( void) ; + bool GetCurrTool( std::string& sTool) ; bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) ; bool GetPositions( const Point3d& ptP, double dA, double dB, diff --git a/MachineCalc.cpp b/MachineCalc.cpp index be69c81..01948c9 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -20,6 +20,7 @@ #include "Head.h" #include "Exit.h" #include "/EgtDev/Include/EGkGeoVector3d.h" +#include "/EgtDev/Include/EMkToolConst.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" @@ -41,6 +42,28 @@ Machine::SetCurrTable( const string& sTable) return true ; } +//---------------------------------------------------------------------------- +int +Machine::GetCurrTable( void) +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return GDB_ID_NULL ; + // recupero identificativo della tavola corrente + return m_nCalcTabId ; +} + +//---------------------------------------------------------------------------- +bool +Machine::GetCurrTable( string& sTable) +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return false ; + // recupero nome della tavola corrente + return m_pGeomDB->GetName( m_nCalcTabId, sTable) ; +} + //---------------------------------------------------------------------------- bool Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) @@ -72,8 +95,8 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) int nToolId = m_pGeomDB->GetFirstNameInGroup( nExitId, sTool) ; if ( nToolId == GDB_ID_NULL || m_pGeomDB->GetGdbType( nToolId) != GDB_TY_GROUP) return false ; - double dTLen ; - if ( ! m_pGeomDB->GetInfo( nToolId, "L", dTLen)) + double dTLen = 0 ; + if ( ! m_pMchMgr->GetToolParam( sTool, TPA_LEN, dTLen)) return false ; // assegno tutti i dati m_nCalcHeadId = nHeadId ; @@ -87,6 +110,28 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) return CalculateKinematicChain() ; } +//---------------------------------------------------------------------------- +int +Machine::GetCurrTool( void) +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return GDB_ID_NULL ; + // recupero identificativo dell'utensile + return m_nCalcToolId ; +} + +//---------------------------------------------------------------------------- +bool +Machine::GetCurrTool( string& sTool) +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return false ; + // recupero nome gruppo dell'utensile + return m_pGeomDB->GetName( m_nCalcToolId, sTool) ; +} + //---------------------------------------------------------------------------- bool Machine::CalculateKinematicChain( void) diff --git a/MachineHeads.cpp b/MachineHeads.cpp index f97220f..b66458e 100644 --- a/MachineHeads.cpp +++ b/MachineHeads.cpp @@ -16,6 +16,7 @@ #include "MachMgr.h" #include "DllMain.h" #include "Exit.h" +#include "/EgtDev/Include/EMkToolConst.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" @@ -42,7 +43,10 @@ Machine::LoadTool( const string& sHead, int nExit, const string& sTool) if ( sTool == pExit->GetTool()) return EnableHeadInSet( sHead) ; // verifico esistenza file utensile - string sToolFile = m_sMachineDir + "\\" + TOOLS_DIR + "\\" + sTool + ".Nge" ; + string sDraw ; + if ( ! m_pMchMgr->GetToolParam( sTool, TPA_DRAW, sDraw)) + return false ; + string sToolFile = m_sMachineDir + "\\" + TOOLS_DIR + "\\" + sDraw ; if ( ! ExistsFile( sToolFile)) return false ; // pulisco il gruppo dell'uscita diff --git a/ToolData.cpp b/ToolData.cpp index 6381c87..4d466b5 100644 --- a/ToolData.cpp +++ b/ToolData.cpp @@ -14,8 +14,10 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "ToolData.h" +#include "/EgtDev/Include/EMkToolConst.h" #include "/EgtDev/Include/EGkGeoConst.h" #include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGnEgtUUID.h" #include #include @@ -237,3 +239,108 @@ ToolData::VerifySpeed( double dVal) const { return ( dVal < m_dMaxSpeed + EPS_SMALL) ; } + +//---------------------------------------------------------------------------- +bool +ToolData::GetParam( int nType, int& nVal) const +{ + switch ( nType) { + case TPA_CORR : + nVal = m_nCorr ; + return true ; + case TPA_EXIT : + nVal = m_nExit ; + return true ; + case TPA_TYPE : + nVal = m_nType ; + return true ; + } + return false ; +} + +//---------------------------------------------------------------------------- +bool +ToolData::GetParam( int nType, double& dVal) const +{ + switch ( nType) { + case TPA_CORNRAD : + dVal = m_dCornRad ; + return true ; + case TPA_DIAM : + dVal = m_dDiam ; + return true ; + case TPA_TOTDIAM : + dVal = m_dTDiam ; + return true ; + case TPA_FEED : + dVal = m_dFeed ; + return true ; + case TPA_ENDFEED : + dVal = m_dEndFeed ; + return true ; + case TPA_STARTFEED : + dVal = m_dStartFeed ; + return true ; + case TPA_TIPFEED : + dVal = m_dTipFeed ; + return true ; + case TPA_LEN : + dVal = m_dLen ; + return true ; + case TPA_TOTLEN : + dVal = m_dTLen ; + return true ; + case TPA_MAXMAT : + dVal = m_dMaxMat ; + return true ; + case TPA_LONOFFSET : + dVal = m_dOffsL ; + return true ; + case TPA_RADOFFSET : + dVal = m_dOffsR ; + return true ; + case TPA_SPEED : + dVal = m_dSpeed ; + return true ; + case TPA_SIDEANG : + dVal = m_dSideAng ; + return true ; + case TPA_MAXSPEED : + dVal = m_dMaxSpeed ; + return true ; + case TPA_THICK : + dVal = m_dThick ; + return true ; + } + return false ; +} + +//---------------------------------------------------------------------------- +bool +ToolData::GetParam( int nType, string& sVal) const +{ + switch ( nType) { + case TPA_DRAW : + sVal = m_sDraw ; + return true ; + case TPA_HEAD : + sVal = m_sHead ; + return true ; + case TPA_NAME : + sVal = m_sName ; + return true ; + case TPA_SYSNOTES : + sVal = m_sSysNotes ; + return true ; + case TPA_USERNOTES : + sVal = m_sUserNotes ; + return true ; + case TPA_TCPOS : + sVal = m_sTcPos ; + return true ; + case TPA_UUID : + sVal = ::ToString( m_Uuid) ; + return true ; + } + return false ; +} \ No newline at end of file diff --git a/ToolData.h b/ToolData.h index 5d1ffad..5c27bf2 100644 --- a/ToolData.h +++ b/ToolData.h @@ -57,6 +57,9 @@ struct ToolData std::string ToString( int nInd) const ; bool VerifySpeed( double dVal) const ; + bool GetParam( int nType, int& nVal) const ; + bool GetParam( int nType, double& dVal) const ; + bool GetParam( int nType, std::string& sVal) const ; } ; //----------------------------------------------------------------------------