From 4dfd0396378b5e7a55cd9779276e2b3b91eeece2 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 14 Jan 2017 11:17:37 +0000 Subject: [PATCH] EgtExecutor : - aggiunte ExeGetPhotoDimensions e ExeGetPhotoPixels - in import piccole modifiche in aggiornamento FilePath progetto corrente. --- EXE_Exchange.cpp | 15 ++++++++++----- EXE_Photo.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index 318f00f..637efb8 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -87,7 +87,8 @@ ExeImportDxf( const string& sFilePath, double dScaleFactor) // eseguo l'importazione bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, dScaleFactor) ; // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; + if ( pGseCtx->m_sFilePath.empty()) + pGseCtx->m_sFilePath = sFilePath ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { @@ -117,7 +118,8 @@ ExeImportStl( const string& sFilePath, double dScaleFactor) // eseguo l'importazione bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, dScaleFactor) ; // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; + if ( pGseCtx->m_sFilePath.empty()) + pGseCtx->m_sFilePath = sFilePath ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { @@ -146,7 +148,8 @@ ExeImportCnc( const string& sFilePath, int nFlag) // eseguo l'importazione bOk = bOk && pImpCnc->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, nFlag) ; // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; + if ( pGseCtx->m_sFilePath.empty()) + pGseCtx->m_sFilePath = sFilePath ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { @@ -172,7 +175,8 @@ ExeImportCsf( const string& sFilePath) // eseguo l'importazione (direttamente nella radice) bOk = bOk && pImpCsf->Import( sFilePath, pGseCtx->m_pGeomDB) ; // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; + if ( pGseCtx->m_sFilePath.empty()) + pGseCtx->m_sFilePath = sFilePath ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { @@ -198,7 +202,8 @@ ExeImportBtl( const string& sFilePath, bool bFlatPos, bool bSpecialTrim) // eseguo l'importazione (direttamente nella radice) bOk = bOk && pImpBtl->Import( sFilePath, pGseCtx->m_pGeomDB, bFlatPos, bSpecialTrim) ; // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; + if ( pGseCtx->m_sFilePath.empty()) + pGseCtx->m_sFilePath = sFilePath ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { diff --git a/EXE_Photo.cpp b/EXE_Photo.cpp index 0b209e5..c5c8506 100644 --- a/EXE_Photo.cpp +++ b/EXE_Photo.cpp @@ -151,3 +151,36 @@ ExeGetPhotoMMxPixel( int nId, double& dMMxPixel) dMMxPixel = ( dDimX / nWidth + dDimY / nHeight) / 2 ; return true ; } + +//---------------------------------------------------------------------------- +bool +ExeGetPhotoDimensions( int nId, double& dDimX, double& dDimY) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il gestore dei dati della fotografia dell'oggetto + PhotoObj* pPhoto = dynamic_cast( pGeomDB->GetUserObj( nId)) ; + if ( pPhoto == nullptr) + return false ; + // recupero le dimensioni fisiche della fotografia + return pPhoto->GetDimensions( dDimX, dDimY) ; +} + +//---------------------------------------------------------------------------- +bool +ExeGetPhotoPixels( int nId, int& nPixelX, int& nPixelY) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + IEGrScene* pScene = GetCurrScene() ; + VERIFY_SCENE( pScene, false) + // recupero il gestore dei dati della fotografia dell'oggetto + PhotoObj* pPhoto = dynamic_cast( pGeomDB->GetUserObj( nId)) ; + if ( pPhoto == nullptr) + return false ; + // recupero le dimensioni in pixels della fotografia + string sName ; + if ( ! pPhoto->GetName( sName)) + return false ; + return ( pScene->GetTexturePixels( sName, nPixelX, nPixelY) && nPixelX > 0 && nPixelY > 0) ; +} \ No newline at end of file