diff --git a/API.h b/API.h index 25d7389..ad14370 100644 --- a/API.h +++ b/API.h @@ -134,6 +134,9 @@ bool EgtMirror( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, int nR bool EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtDir, double dCoeff, int nRefType) ; +//--------------------------- Machining -------------------------------------- +int EgtAddMachGroup( const std::string& sName, const std::string& sMachineName) ; + //--------------------------- Scene ------------------------------------------ bool EgtSetBackground( Color TopCol, Color BottomCol, bool bRedraw) ; bool EgtSetMarkAttribs( Color MarkCol) ; diff --git a/API_GdbObjects.cpp b/API_GdbObjects.cpp index ec9d124..b76275a 100644 --- a/API_GdbObjects.cpp +++ b/API_GdbObjects.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "API.h" #include "API_Macro.h" +#include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGnStringConverter.h" @@ -231,14 +232,14 @@ __stdcall EgtCopy( int nSouId, int nRefId, int nSonBeforeAfter) // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; - if ( nSonBeforeAfter == GDB_SON) + if ( nSonBeforeAfter == GDB_LAST_SON) sLua = "EgtCopy(" + ToString( nSouId) + "," + ToString( nRefId) + ")" + " -- Id=" + ToString( nNewId) ; else sLua = "EgtCopy(" + ToString( nSouId) + "," + ToString( nRefId) + "," + - ( nSonBeforeAfter == GDB_AFTER ? "'AFTER'" : "'BEFORE'") + ")" + + InsToString( nSonBeforeAfter) + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -258,14 +259,14 @@ __stdcall EgtCopyGlob( int nSouId, int nRefId, int nSonBeforeAfter) // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; - if ( nSonBeforeAfter == GDB_SON) + if ( nSonBeforeAfter == GDB_LAST_SON) sLua = "EgtCopyGlob(" + ToString( nSouId) + "," + ToString( nRefId) + ")" + " -- Id=" + ToString( nNewId) ; else sLua = "EgtCopyGlob(" + ToString( nSouId) + "," + ToString( nRefId) + "," + - ( nSonBeforeAfter == GDB_AFTER ? "'AFTER'" : "'BEFORE'") + ")" + + InsToString( nSonBeforeAfter) + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -285,14 +286,14 @@ __stdcall EgtRelocate( int nSouId, int nRefId, int nSonBeforeAfter) // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; - if ( nSonBeforeAfter == GDB_SON) + if ( nSonBeforeAfter == GDB_LAST_SON) sLua = "EgtRelocate(" + ToString( nSouId) + "," + ToString( nRefId) + ")" + " -- Ok=" + ToString( bOk) ; else sLua = "EgtRelocate(" + ToString( nSouId) + "," + ToString( nRefId) + "," + - ( nSonBeforeAfter == GDB_AFTER ? "'AFTER'" : "'BEFORE'") + ")" + + InsToString( nSonBeforeAfter) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -312,14 +313,14 @@ __stdcall EgtRelocateGlob( int nSouId, int nRefId, int nSonBeforeAfter) // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; - if ( nSonBeforeAfter == GDB_SON) + if ( nSonBeforeAfter == GDB_LAST_SON) sLua = "EgtRelocateGlob(" + ToString( nSouId) + "," + ToString( nRefId) + ")" + " -- Ok=" + ToString( bOk) ; else sLua = "EgtRelocateGlob(" + ToString( nSouId) + "," + ToString( nRefId) + "," + - ( nSonBeforeAfter == GDB_AFTER ? "'AFTER'" : "'BEFORE'") + ")" + + InsToString( nSonBeforeAfter) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/API_MachMgr.cpp b/API_MachMgr.cpp new file mode 100644 index 0000000..1289214 --- /dev/null +++ b/API_MachMgr.cpp @@ -0,0 +1,57 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : API_MachMgr.cpp Data : 23.03.15 Versione : 1.6c8 +// Contenuto : Funzioni Machining Manager per API. +// +// +// +// Modifiche : 23.03.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "API.h" +#include "API_Macro.h" +#include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EGnStringConverter.h" +#include "/EgtDev/Include/EgtPointerOwner.h" + +using namespace std ; + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtInitMachMgr( void) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX( pGseCtx, FALSE) + // inizializzazione gestore lavorazioni + PtrOwner pMachMgr( CreateMachMgr()) ; + VERIFY_NULL( Get( pMachMgr), "Error in CreateMachMgr", FALSE) + pMachMgr->Init( pGseCtx->m_pGeomDB) ; + // assegno il gestore al contesto + pGseCtx->m_pMachMgr = Release( pMachMgr) ; + // log avvio Machining Manager + string sLog = "MachMgr started " ; + LOG_INFO( GetLogger(), sLog.c_str()) + return TRUE ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtAddMachGroup( const wchar_t* wsName, const wchar_t* wsMachineName) +{ + return EgtAddMachGroup( wstrztoA( wsName), wstrztoA( wsMachineName)) ; +} + +//----------------------------------------------------------------------------- +int +EgtAddMachGroup( const string& sName, const string& sMachineName) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL) + // aggiungo la macchinata (gruppo di lavorazione) + return pMachMgr->AddMachGroup( sName, sMachineName) ; +} diff --git a/API_Macro.h b/API_Macro.h index 1e73d48..5dd8470 100644 --- a/API_Macro.h +++ b/API_Macro.h @@ -35,6 +35,12 @@ //----------------------------------------------------------------------------- #define VERIFY_CTX_GEOMDB( pC, Ret) VERIFY_2NULL( pC, pC->m_pGeomDB, "Context or GeomDB invalid", Ret) +//----------------------------------------------------------------------------- +#define VERIFY_MACHMGR( pM, Ret) VERIFY_NULL( pM, "MachMgr invalid", Ret) + +//----------------------------------------------------------------------------- +#define VERIFY_CTX_MACHMGR( pC, Ret) VERIFY_2NULL( pC, pC->m_pMachMgr, "Context or MachMgr invalid", Ret) + //----------------------------------------------------------------------------- #define VERIFY_SCENE( pS, Ret) VERIFY_NULL( pS, "Scene invalid", Ret) diff --git a/AuxTools.cpp b/AuxTools.cpp index 3072aee..c2abb2c 100644 --- a/AuxTools.cpp +++ b/AuxTools.cpp @@ -78,6 +78,37 @@ StringToSep( const string& sSep) return SEP_STD ; } +//---------------------------------------------------------------------------- +const char* +InsToString( int nIns) +{ + switch ( nIns) { + default : + case GDB_LAST_SON : return "'LAST_SON'" ; + case GDB_FIRST_SON : return "'FIRST_SON'" ; + case GDB_BEFORE : return "'BEFORE'" ; + case GDB_AFTER : return "'AFTER'" ; + } +} + +//---------------------------------------------------------------------------- +int +StringToIns( const string& sIns) +{ + string sTmp = sIns ; + ToUpper( sTmp) ; + if ( sTmp == "LAST_SON") + return GDB_LAST_SON ; + else if ( sTmp == "FIRST_SON") + return GDB_FIRST_SON ; + else if ( sTmp == "BEFORE") + return GDB_BEFORE ; + else if ( sTmp == "AFTER") + return GDB_AFTER ; + // default + return GDB_LAST_SON ; +} + //---------------------------------------------------------------------------- const char* RefTypeToString( int nRefType) diff --git a/AuxTools.h b/AuxTools.h index 2e596a0..ec803b9 100644 --- a/AuxTools.h +++ b/AuxTools.h @@ -23,6 +23,9 @@ int StringToNgeType( const std::string& sNgeType) ; // Tipo punto per creazione rette e archi const char* SepToString( int nSep) ; int StringToSep( const std::string& sSep) ; +// Flag per posizione di inserimento nel DB geometrico +const char* InsToString( int nIns) ; +int StringToIns( const std::string& sIns) ; // Tipo riferimento in cui sono espressi i dati geometrici const char* RefTypeToString( int nRefType) ; int StringToRefType( const std::string& sRefType) ; diff --git a/EgtInterface.rc b/EgtInterface.rc index 0686295..8e51660 100644 Binary files a/EgtInterface.rc and b/EgtInterface.rc differ diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj index cfdc797..bb28794 100644 --- a/EgtInterface.vcxproj +++ b/EgtInterface.vcxproj @@ -237,6 +237,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -262,6 +263,7 @@ copy $(TargetPath) \EgtProg\Dll64 + Create diff --git a/EgtInterface.vcxproj.filters b/EgtInterface.vcxproj.filters index a7cc255..3f0410a 100644 --- a/EgtInterface.vcxproj.filters +++ b/EgtInterface.vcxproj.filters @@ -206,6 +206,12 @@ File di origine\LUA + + File di origine\API + + + File di origine\LUA + diff --git a/GseContext.cpp b/GseContext.cpp index 5675242..3392f37 100644 --- a/GseContext.cpp +++ b/GseContext.cpp @@ -137,6 +137,15 @@ GetCurrGeomDB( void) return ( s_GseCtx[s_nCurrGseCtx-1].m_pGeomDB) ; } +//---------------------------------------------------------------------------- +IMachMgr* +GetCurrMachMgr( void) +{ + if ( s_nCurrGseCtx < 1 || s_nCurrGseCtx > MAX_CTX || ! s_GseOn[s_nCurrGseCtx-1]) + return nullptr ; + return ( s_GseCtx[s_nCurrGseCtx-1].m_pMachMgr) ; +} + //---------------------------------------------------------------------------- IEGrScene* GetCurrScene( void) diff --git a/GseContext.h b/GseContext.h index 0fc0441..704d466 100644 --- a/GseContext.h +++ b/GseContext.h @@ -16,6 +16,7 @@ #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGrScene.h" #include "/EgtDev/Include/EGnCmdParser.h" +#include "/EgtDev/Include/EMkMachMgr.h" #define NOMINMAX #include @@ -25,6 +26,7 @@ class GseContext public : IGeomDB* m_pGeomDB ; Color m_colDef ; + IMachMgr* m_pMachMgr ; HWND m_hWnd ; IEGrScene* m_pScene ; ICmdParser* m_pTscExec ; @@ -36,8 +38,8 @@ class GseContext public : GseContext( void) - : m_pGeomDB( nullptr), m_colDef( GRAY), m_hWnd( nullptr), m_pScene( nullptr), m_pTscExec( nullptr), - m_sFilePath(), m_bEnableModified( true), m_bModified( false), + : m_pGeomDB( nullptr), m_colDef( GRAY), m_pMachMgr( nullptr), m_hWnd( nullptr), m_pScene( nullptr), + m_pTscExec( nullptr), m_sFilePath(), m_bEnableModified( true), m_bModified( false), m_nCurrPart( GDB_ID_NULL), m_nCurrLayer( GDB_ID_NULL) {} ~GseContext( void) @@ -54,6 +56,10 @@ class GseContext m_pScene = nullptr ; } m_hWnd = nullptr ; + if ( m_pMachMgr != nullptr) { + delete m_pMachMgr ; + m_pMachMgr = nullptr ; + } if ( m_pGeomDB != nullptr) { delete m_pGeomDB ; m_pGeomDB = nullptr ; @@ -79,5 +85,6 @@ bool ResetCurrGseContext( void) ; int GetIndCurrGseContext( void) ; GseContext* GetCurrGseContext( void) ; IGeomDB* GetCurrGeomDB( void) ; +IMachMgr* GetCurrMachMgr( void) ; IEGrScene* GetCurrScene( void) ; ICmdParser* GetCurrTscExecutor( void) ; diff --git a/LUA.h b/LUA.h index a3a8344..34d7ad4 100644 --- a/LUA.h +++ b/LUA.h @@ -58,6 +58,9 @@ bool LuaInstallGeoSnap( void) ; //-------------------------- GeoTransform ------------------------------------ bool LuaInstallGeoTransform( void) ; +//-------------------------- MachMgr ----------------------------------------- +bool LuaInstallMachMgr( void) ; + //-------------------------- Scene ------------------------------------------- bool LuaInstallScene( void) ; diff --git a/LUA_Base.cpp b/LUA_Base.cpp index 53e3063..434af6d 100644 --- a/LUA_Base.cpp +++ b/LUA_Base.cpp @@ -92,6 +92,10 @@ LuaInit( void) LOG_ERROR( GetLogger(), "Error in LuaInstallGeoTransform (" __FUNCTION__ ")") return false ; } + if ( ! LuaInstallMachMgr()) { + LOG_ERROR( GetLogger(), "Error in LuaInstallMachMgr (" __FUNCTION__ ")") + return false ; + } if ( ! LuaInstallScene()) { LOG_ERROR( GetLogger(), "Error in LuaInstallScene (" __FUNCTION__ ")") return false ; diff --git a/LUA_GdbObjects.cpp b/LUA_GdbObjects.cpp index 073d086..545bc09 100644 --- a/LUA_GdbObjects.cpp +++ b/LUA_GdbObjects.cpp @@ -17,6 +17,7 @@ #include "LUA.h" #include "LUA_Base.h" #include "LUA_Aux.h" +#include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EgnStringUtils.h" @@ -174,15 +175,11 @@ LuaCopy( lua_State* L) LuaCheckParam( L, 1, nSouId) int nRefId ; LuaCheckParam( L, 2, nRefId) - int nSonBeforeAfter = GDB_SON ; + int nSonBeforeAfter = GDB_LAST_SON ; if ( lua_gettop( L) >= 3) { string sSonBeforeAfter ; LuaCheckParam( L, 3, sSonBeforeAfter) ; - ToUpper( sSonBeforeAfter) ; - if ( sSonBeforeAfter == "BEFORE") - nSonBeforeAfter = GDB_BEFORE ; - else if ( sSonBeforeAfter == "AFTER") - nSonBeforeAfter = GDB_AFTER ; + nSonBeforeAfter = StringToIns( sSonBeforeAfter) ; } LuaClearStack( L) ; // eseguo la copia @@ -204,15 +201,11 @@ LuaCopyGlob( lua_State* L) LuaCheckParam( L, 1, nSouId) int nRefId ; LuaCheckParam( L, 2, nRefId) - int nSonBeforeAfter = GDB_SON ; + int nSonBeforeAfter = GDB_LAST_SON ; if ( lua_gettop( L) >= 3) { string sSonBeforeAfter ; LuaCheckParam( L, 3, sSonBeforeAfter) ; - ToUpper( sSonBeforeAfter) ; - if ( sSonBeforeAfter == "BEFORE") - nSonBeforeAfter = GDB_BEFORE ; - else if ( sSonBeforeAfter == "AFTER") - nSonBeforeAfter = GDB_AFTER ; + nSonBeforeAfter = StringToIns( sSonBeforeAfter) ; } LuaClearStack( L) ; // eseguo la copia @@ -234,15 +227,11 @@ LuaRelocate( lua_State* L) LuaCheckParam( L, 1, nSouId) int nRefId ; LuaCheckParam( L, 2, nRefId) - int nSonBeforeAfter = GDB_SON ; + int nSonBeforeAfter = GDB_LAST_SON ; if ( lua_gettop( L) >= 3) { string sSonBeforeAfter ; LuaCheckParam( L, 3, sSonBeforeAfter) ; - ToUpper( sSonBeforeAfter) ; - if ( sSonBeforeAfter == "BEFORE") - nSonBeforeAfter = GDB_BEFORE ; - else if ( sSonBeforeAfter == "AFTER") - nSonBeforeAfter = GDB_AFTER ; + nSonBeforeAfter = StringToIns( sSonBeforeAfter) ; } LuaClearStack( L) ; // eseguo la rilocazione @@ -261,15 +250,11 @@ LuaRelocateGlob( lua_State* L) LuaCheckParam( L, 1, nSouId) int nRefId ; LuaCheckParam( L, 2, nRefId) - int nSonBeforeAfter = GDB_SON ; + int nSonBeforeAfter = GDB_LAST_SON ; if ( lua_gettop( L) >= 3) { string sSonBeforeAfter ; LuaCheckParam( L, 3, sSonBeforeAfter) ; - ToUpper( sSonBeforeAfter) ; - if ( sSonBeforeAfter == "BEFORE") - nSonBeforeAfter = GDB_BEFORE ; - else if ( sSonBeforeAfter == "AFTER") - nSonBeforeAfter = GDB_AFTER ; + nSonBeforeAfter = StringToIns( sSonBeforeAfter) ; } LuaClearStack( L) ; // eseguo la rilocazione diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp new file mode 100644 index 0000000..5f255a7 --- /dev/null +++ b/LUA_MachMgr.cpp @@ -0,0 +1,50 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : LUA_MachMgr.cpp Data : 24.03.15 Versione : 1.6c8 +// Contenuto : Funzioni Machining Manager per LUA. +// +// +// +// Modifiche : 24.03.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "API.h" +#include "LUA.h" +#include "LUA_Base.h" +#include "LUA_Aux.h" +#include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EgnStringUtils.h" + +using namespace std ; + + +//------------------------------------------------------------------------------- +static int +LuaAddMachGroup( lua_State* L) +{ + // 2 parametri : nome del gruppo, nome della macchina da utilizzare + string sName ; + LuaCheckParam( L, 1, sName) + string sMachineName ; + LuaCheckParam( L, 2, sMachineName) + LuaClearStack( L) ; + // aggiungo la macchinata + int nId = EgtAddMachGroup( sName, sMachineName) ; + // restituisco il risultato + LuaSetReturn( L, nId) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +bool +LuaInstallMachMgr( void) +{ + bool bOk = true ; + bOk = bOk && LuaRegisterFunction( "EgtAddMachGroup", LuaAddMachGroup) ; + return bOk ; +}