From a06fe0c00b7975bbef68ccc0fa2d9217970202b4 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 17 Feb 2015 22:47:51 +0000 Subject: [PATCH] EgtInterface 1.6b4 : - aggiunta funzione per impostazione sola trasparenza EgtSetAlpha - aggiunto parametro per non settare alfa a EgtSetColor. --- API_GdbObjAttribs.cpp | 62 ++++++++++++++++++++++++++++++++++++++++-- EgtInterface.rc | Bin 11718 -> 11718 bytes LUA_GdbObjAttribs.cpp | 28 +++++++++++++++++-- LUA_GeoSnap.cpp | 30 ++++++++++---------- 4 files changed, 101 insertions(+), 19 deletions(-) diff --git a/API_GdbObjAttribs.cpp b/API_GdbObjAttribs.cpp index 83b89b0..53ec26e 100644 --- a/API_GdbObjAttribs.cpp +++ b/API_GdbObjAttribs.cpp @@ -262,7 +262,7 @@ __stdcall EgtStdColor( const wchar_t* wsName, int StdCol[4]) //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetColor( int nId, const int ObjCol[4]) +__stdcall EgtSetColor( int nId, const int ObjCol[4], BOOL bSetAlpha) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) @@ -271,14 +271,29 @@ __stdcall EgtSetColor( int nId, const int ObjCol[4]) bool bOk = true ; // assegno il colore a un singolo oggetto if ( nId != GDB_ID_SEL) { + // se richiesto, recupero alpha originale + if ( ! bSetAlpha) { + Color cOri ; + if ( pGeomDB->GetCalcMaterial( nId, cOri)) + cCol.SetAlpha( cOri.GetIntAlpha()) ; + } + // eseguo assegnazione bOk = pGeomDB->SetMaterial( nId, cCol) ; } // assegno il colore ai selezionati else { int nI = pGeomDB->GetFirstSelectedObj() ; while ( nI != GDB_ID_NULL && bOk) { + // se richiesto, recupero alpha originale + if ( ! bSetAlpha) { + Color cOri ; + if ( pGeomDB->GetCalcMaterial( nI, cOri)) + cCol.SetAlpha( cOri.GetIntAlpha()) ; + } + // eseguo assegnazione if ( ! pGeomDB->SetMaterial( nI, cCol)) bOk = false ; + // passo al successivo nI = pGeomDB->GetNextSelectedObj() ; } } @@ -286,7 +301,50 @@ __stdcall EgtSetColor( int nId, const int ObjCol[4]) // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSetColor(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + ",{" + - ToString( cCol) + "})" + + ToString( cCol) + "}," + + ( bSetAlpha ? "true" : "false") + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return ( bOk ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetAlpha( int nId, int nAlpha) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, FALSE) + bool bOk = true ; + // assegno il colore a un singolo oggetto + if ( nId != GDB_ID_SEL) { + // recupero il colore originale + Color cCol ; + bOk = bOk && pGeomDB->GetCalcMaterial( nId, cCol) ; + cCol.SetAlpha( nAlpha) ; + // eseguo assegnazione + bOk = bOk && pGeomDB->SetMaterial( nId, cCol) ; + } + // assegno il colore ai selezionati + else { + int nI = pGeomDB->GetFirstSelectedObj() ; + while ( nI != GDB_ID_NULL && bOk) { + // recupero il colore originale + Color cCol ; + bOk = bOk && pGeomDB->GetCalcMaterial( nI, cCol) ; + cCol.SetAlpha( nAlpha) ; + // eseguo assegnazione + bOk = bOk && pGeomDB->SetMaterial( nI, cCol) ; + // passo al successivo + nI = pGeomDB->GetNextSelectedObj() ; + } + } + EgtSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSetAlpha(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + "," + + ToString( nAlpha) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/EgtInterface.rc b/EgtInterface.rc index 323311f41068dbb4b53752cc3c5cfeb3b304ec96..3024d087b7b3881c6b7cac7aac0e2162979ca4f1 100644 GIT binary patch delta 111 zcmX>WeJpyzFE&P#%^&$rGEF|hS;uHH`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o07@$;z5oCK delta 111 zcmX>WeJpyzFE&Qw%^&$rGEF|hS;uHR`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o07yS5wg3PC diff --git a/LUA_GdbObjAttribs.cpp b/LUA_GdbObjAttribs.cpp index ff26df8..18fff88 100644 --- a/LUA_GdbObjAttribs.cpp +++ b/LUA_GdbObjAttribs.cpp @@ -332,18 +332,41 @@ LuaStdColor( lua_State* L) static int LuaSetColor( lua_State* L) { - // 2 parametri : Id/s, Colore + // 2 o 3 parametri : Id/s, Colore [, bSetAlpha] INTVECTOR vId ; LuaCheckParam( L, 1, vId) Color cCol ; LuaCheckParam( L, 2, cCol) + bool bSetAlpha = true ; + LuaGetParam( L, 3, bSetAlpha) ; LuaClearStack( L) ; // assegno il colore int vCol[4] ; cCol.GetInt( vCol) ; bool bOk = true ; for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) { - if ( EgtSetColor( vId[i], vCol) == FALSE) + if ( EgtSetColor( vId[i], vCol, bSetAlpha) == FALSE) + bOk = false ; + } + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSetAlpha( lua_State* L) +{ + // 2 : Id/s, nAlpha + INTVECTOR vId ; + LuaCheckParam( L, 1, vId) + int nAlpha ; + LuaCheckParam( L, 2, nAlpha) + LuaClearStack( L) ; + // assegno la trasparenza + bool bOk = true ; + for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) { + if ( EgtSetAlpha( vId[i], nAlpha) == FALSE) bOk = false ; } // restituisco il risultato @@ -573,6 +596,7 @@ LuaInstallGdbObjAttribs( lua_State* L) lua_register( L, "EgtGetCalcMark", LuaGetCalcMark) ; lua_register( L, "EgtStdColor", LuaStdColor) ; lua_register( L, "EgtSetColor", LuaSetColor) ; + lua_register( L, "EgtSetAlpha", LuaSetAlpha) ; lua_register( L, "EgtResetColor", LuaResetColor) ; lua_register( L, "EgtGetColor", LuaGetColor) ; lua_register( L, "EgtGetCalcColor", LuaGetCalcColor) ; diff --git a/LUA_GeoSnap.cpp b/LUA_GeoSnap.cpp index ec97632..d4b8d6f 100644 --- a/LUA_GeoSnap.cpp +++ b/LUA_GeoSnap.cpp @@ -26,7 +26,7 @@ using namespace std ; static int LuaStartPoint( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; @@ -45,7 +45,7 @@ LuaStartPoint( lua_State* L) static int LuaEndPoint( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; @@ -64,7 +64,7 @@ LuaEndPoint( lua_State* L) static int LuaMidPoint( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; @@ -83,7 +83,7 @@ LuaMidPoint( lua_State* L) static int LuaCenterPoint( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; @@ -102,7 +102,7 @@ LuaCenterPoint( lua_State* L) static int LuaAtParamPoint( lua_State* L) { - // 2 o 3 parametri : Id, U [, nRefIf] + // 2 o 3 parametri : Id, U [, nRefId] int nId ; LuaCheckParam( L, 1, nId) double dU ; @@ -123,7 +123,7 @@ LuaAtParamPoint( lua_State* L) static int LuaNearPoint( lua_State* L) { - // 2 o 3 parametri : Id, ptNear [, nRefIf] + // 2 o 3 parametri : Id, ptNear [, nRefId] int nId ; LuaCheckParam( L, 1, nId) Point3d ptNear ; @@ -144,7 +144,7 @@ LuaNearPoint( lua_State* L) static int LuaIntersectionPoint( lua_State* L) { - // 3 o 4 parametri : Id1, Id2, ptNear [, nRefIf] + // 3 o 4 parametri : Id1, Id2, ptNear [, nRefId] int nId1 ; LuaCheckParam( L, 1, nId1) int nId2 ; @@ -167,7 +167,7 @@ LuaIntersectionPoint( lua_State* L) static int LuaStartVector( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; @@ -186,7 +186,7 @@ LuaStartVector( lua_State* L) static int LuaEndVector( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; @@ -205,7 +205,7 @@ LuaEndVector( lua_State* L) static int LuaMidVector( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; @@ -224,7 +224,7 @@ LuaMidVector( lua_State* L) static int LuaAtParamVector( lua_State* L) { - // 2, 3 o 4 parametri : Id, U, sSide [, nRefIf] + // 2, 3 o 4 parametri : Id, U, sSide [, nRefId] int nId ; LuaCheckParam( L, 1, nId) double dU ; @@ -250,7 +250,7 @@ LuaAtParamVector( lua_State* L) static int LuaFrame( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; @@ -269,7 +269,7 @@ LuaFrame( lua_State* L) static int LuaCurveExtrusion( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; @@ -306,7 +306,7 @@ LuaCurveThickness( lua_State* L) static int LuaCurveArcNormVersor( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ; @@ -325,7 +325,7 @@ LuaCurveArcNormVersor( lua_State* L) static int LuaExtTextNormVersor( lua_State* L) { - // 1 o 2 parametri : Id [, nRefIf] + // 1 o 2 parametri : Id [, nRefId] int nId ; LuaCheckParam( L, 1, nId) int nRefId = nId ;