EgtInterface 1.6b4 :

- aggiunta funzione per impostazione sola trasparenza EgtSetAlpha
- aggiunto parametro per non settare alfa a EgtSetColor.
This commit is contained in:
Dario Sassi
2015-02-17 22:47:51 +00:00
parent 4c419a2f08
commit a06fe0c00b
4 changed files with 101 additions and 19 deletions
+60 -2
View File
@@ -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()) ;
}
BIN
View File
Binary file not shown.
+26 -2
View File
@@ -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) ;
+15 -15
View File
@@ -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 ;