EgtInterface 1.6b6 :

- aggiornamenti vari
- introdotto comando per merge (cucitura) di superfici
- migliorata gestione oggetti selezionati in comandi.
This commit is contained in:
Dario Sassi
2015-03-11 09:06:35 +00:00
parent 5e3c729190
commit b0389f3fda
28 changed files with 1168 additions and 614 deletions
+127 -71
View File
@@ -126,35 +126,68 @@ __stdcall EgtGetCalcMode( int nId, int* pnMode)
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetStatus( int nId, int nStat)
{
INTVECTOR vIds ;
vIds.push_back( nId) ;
return ( EgtSetStatus( vIds, nStat) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
bool
EgtSetStatus( const INTVECTOR& vIds, int nStat)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// imposto il modo
bool bOk = pGeomDB->SetStatus( nId, nStat) ;
// se nascosto pezzo corrente o layer corrente
if ( nStat == GDB_ST_OFF) {
int nCurrPartId = EgtGetCurrPart() ;
if ( nId == nCurrPartId)
EgtResetCurrPartLayer() ;
else if ( nId == EgtGetCurrLayer())
EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero pezzo e layer correnti
bool bCurrPartOff = false ;
bool bCurrLayerOff = false ;
int nCurrPartId = EgtGetCurrPart() ;
int nCurrLayerId = EgtGetCurrLayer() ;
// ciclo sul vettore degli identificativi
bool bOk = true ;
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
// impostazione stato
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// imposto il modo
if ( ! pGeomDB->SetStatus( nId, nStat))
bOk = false ;
// se nascosto pezzo corrente o layer corrente
if ( nStat == GDB_ST_OFF) {
if ( nId == nCurrPartId)
bCurrPartOff = true ;
else if ( nId == nCurrLayerId)
bCurrLayerOff = true ;
}
// passo al successivo
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
// se pezzo o layer correnti da rideterminare
if ( bCurrPartOff)
EgtResetCurrPartLayer() ;
else if ( bCurrLayerOff)
EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ;
// dichiaro progetto modificato
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sIds ;
for ( size_t i = 0 ; i < vIds.size() ; ++ i)
sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ;
sIds.pop_back() ;
string sStat = "'ON'" ;
if ( nStat == GDB_ST_SEL)
sStat = "'SEL'" ;
else if ( nStat == GDB_ST_OFF)
sStat = "'OFF'" ;
string sLua = "EgtSetStatus(" + ToString( nId) + "," +
sStat + ")" +
string sLua = "EgtSetStatus({" + sIds + "}," +
sStat + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return bOk ;
}
//-----------------------------------------------------------------------------
@@ -264,123 +297,146 @@ __stdcall EgtStdColor( const wchar_t* wsName, int StdCol[4])
BOOL
__stdcall EgtSetColor( int nId, const int ObjCol[4], BOOL bSetAlpha)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// assegno indice entità
INTVECTOR vIds ;
vIds.push_back( nId) ;
// sistemo il colore
Color cCol( ObjCol) ;
// eseguo
return ( EgtSetColor( vIds, cCol, (bSetAlpha != FALSE)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
bool
EgtSetColor( const INTVECTOR& vIds, const Color& cCol, bool bSetAlpha)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// assegno il colore
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) {
for ( size_t i = 0 ; i < vIds.size() ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
Color cNew = cCol ;
// se richiesto, recupero alpha originale
if ( ! bSetAlpha) {
Color cOri ;
if ( pGeomDB->GetCalcMaterial( nI, cOri))
cCol.SetAlpha( cOri.GetIntAlpha()) ;
if ( pGeomDB->GetCalcMaterial( nId, cOri))
cNew.SetAlpha( cOri.GetIntAlpha()) ;
}
// eseguo assegnazione
if ( ! pGeomDB->SetMaterial( nI, cCol))
if ( ! pGeomDB->SetMaterial( nId, cNew))
bOk = false ;
// passo al successivo
nI = pGeomDB->GetNextSelectedObj() ;
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSetColor(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + ",{" +
ToString( cCol) + "}," +
( bSetAlpha ? "true" : "false") + ")" +
string sIds ;
for ( size_t i = 0 ; i < vIds.size() ; ++ i)
sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ;
sIds.pop_back() ;
string sLua = "EgtSetColor({" + sIds + "},{" +
ToString( cCol) + "}," +
( bSetAlpha ? "true" : "false") + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return bOk ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetAlpha( int nId, int nAlpha)
{
// assegno indice entità
INTVECTOR vIds ;
vIds.push_back( nId) ;
// eseguo
return ( EgtSetAlpha( vIds, nAlpha) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
bool
EgtSetAlpha( const INTVECTOR& vIds, int nAlpha)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
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) {
// assegno la trasparenza
for ( size_t i = 0 ; i < vIds.size() ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
// recupero il colore originale
Color cCol ;
bOk = bOk && pGeomDB->GetCalcMaterial( nI, cCol) ;
bOk = bOk && pGeomDB->GetCalcMaterial( nId, cCol) ;
cCol.SetAlpha( nAlpha) ;
// eseguo assegnazione
bOk = bOk && pGeomDB->SetMaterial( nI, cCol) ;
bOk = bOk && pGeomDB->SetMaterial( nId, cCol) ;
// passo al successivo
nI = pGeomDB->GetNextSelectedObj() ;
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : 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) + ")" +
string sIds ;
for ( size_t i = 0 ; i < vIds.size() ; ++ i)
sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ;
sIds.pop_back() ;
string sLua = "EgtSetAlpha({" + sIds + "}," +
ToString( nAlpha) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return bOk ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtResetColor( int nId)
{
// assegno indice entità
INTVECTOR vIds ;
vIds.push_back( nId) ;
// eseguo
return ( EgtResetColor( vIds) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
bool
EgtResetColor( const INTVECTOR& vIds)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
VERIFY_GEOMDB( pGeomDB, false)
// tolgo il colore
bool bOk = true ;
// tolgo il colore a un singolo oggetto
if ( nId != GDB_ID_SEL) {
bOk = pGeomDB->SetMaterial( nId, GDB_MT_PARENT) ;
}
// tolgo il colore ai selezionati
else {
int nI = pGeomDB->GetFirstSelectedObj() ;
while ( nI != GDB_ID_NULL && bOk) {
if ( ! pGeomDB->SetMaterial( nI, GDB_MT_PARENT))
for ( size_t i = 0 ; i < vIds.size() ; ++ i) {
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
while ( nId != GDB_ID_NULL) {
if ( ! pGeomDB->SetMaterial( nId, GDB_MT_PARENT))
bOk = false ;
nI = pGeomDB->GetNextSelectedObj() ;
// passo al successivo
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
}
}
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtResetColor(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + ")" +
string sIds ;
for ( size_t i = 0 ; i < vIds.size() ; ++ i)
sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ;
sIds.pop_back() ;
string sLua = "EgtResetColor({" + sIds + "})" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
return bOk ;
}
//-----------------------------------------------------------------------------