From 403d3a658dad5daa2e97460ef1704d2e80dd0f2c Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 18 Feb 2016 18:45:52 +0000 Subject: [PATCH] EgtExecutor 1.6n7 : - aggiunte ExeGetPhotoOrigin, ExeGetPhotoCenter, ExeGetPhotoMMxPixel. --- EXE_Photo.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++-- EgtExecutor.rc | Bin 11694 -> 11694 bytes PhotoObj.cpp | 33 +++++++++++++++++++++++++++ PhotoObj.h | 4 ++++ 4 files changed, 95 insertions(+), 2 deletions(-) diff --git a/EXE_Photo.cpp b/EXE_Photo.cpp index 4e39125..0b209e5 100644 --- a/EXE_Photo.cpp +++ b/EXE_Photo.cpp @@ -73,7 +73,7 @@ bool ExeGetPhotoPath( int nId, string& sPath) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // recupero il gestore dei dati della fotografia dell'oggetto PhotoObj* pPhoto = dynamic_cast( pGeomDB->GetUserObj( nId)) ; if ( pPhoto == nullptr) @@ -87,7 +87,7 @@ bool ExeChangePhotoPath( int nId, const string& sPath) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) // recupero il gestore dei dati della fotografia dell'oggetto PhotoObj* pPhoto = dynamic_cast( pGeomDB->GetUserObj( nId)) ; if ( pPhoto == nullptr) @@ -95,3 +95,59 @@ ExeChangePhotoPath( int nId, const string& sPath) // imposto la nuova path della fotografia return pPhoto->ChangePath( sPath) ; } + +//---------------------------------------------------------------------------- +bool +ExeGetPhotoOrigin( int nId, Point3d& ptOri) +{ + 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 l'origine della fotografia + return pPhoto->GetOrigin( ptOri) ; +} + +//---------------------------------------------------------------------------- +bool +ExeGetPhotoCenter( int nId, Point3d& ptCen) +{ + 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 il centro di ripresa della fotografia + return pPhoto->GetCenter( ptCen) ; +} + +//---------------------------------------------------------------------------- +bool +ExeGetPhotoMMxPixel( int nId, double& dMMxPixel) +{ + 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 fisiche della fotografia + double dDimX, dDimY ; + if ( ! pPhoto->GetDimensions( dDimX, dDimY)) + return false ; + // recupero le dimensioni in pixels della fotografia + string sName ; + if ( ! pPhoto->GetName( sName)) + return false ; + int nWidth, nHeight ; + if ( ! pScene->GetTexturePixels( sName, nWidth, nHeight) || nWidth == 0 || nHeight == 0) + return false ; + // calcolo il fattore di scala + dMMxPixel = ( dDimX / nWidth + dDimY / nHeight) / 2 ; + return true ; +} diff --git a/EgtExecutor.rc b/EgtExecutor.rc index f7d02fdae1e2f5a413db1bb5e29ed0420f6eba73..c7d029ba082b886aa4c321ef920ab2496714038a 100644 GIT binary patch delta 97 zcmZ1%y)JsgA2vqw%@@V4Gflq2na5~8Ignd-a{*Tk3sCf++-0W82LxfF21;&>n->Y| cF@rU@0x76sKgP|Iq`|@mWB>pF delta 105 zcmZ1%y)JsgA2vp_%@@V4Gflq2nKwB}L}GFQr`YBKt{N7g_(8eLOp^}?BE$`p+!!}6 e64qk|YjR~q(%{Fqd6G0(;-H)(Lc&0)jvD~(JR=+c diff --git a/PhotoObj.cpp b/PhotoObj.cpp index fce0ded..e46d3a2 100644 --- a/PhotoObj.cpp +++ b/PhotoObj.cpp @@ -199,6 +199,14 @@ PhotoObj::Set( const string& sName, const string& sPath, return true ; } +//---------------------------------------------------------------------------- +bool +PhotoObj::GetName( string& sName) +{ + sName = m_sName ; + return true ; +} + //---------------------------------------------------------------------------- bool PhotoObj::GetPath( string& sPath) @@ -214,3 +222,28 @@ PhotoObj::ChangePath( const string& sPath) m_sPath = sPath ; return ( ! m_sPath.empty()) ; } + +//---------------------------------------------------------------------------- +bool +PhotoObj::GetOrigin( Point3d& ptOri) +{ + ptOri = m_ptOri ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +PhotoObj::GetCenter( Point3d& ptCen) +{ + ptCen = m_ptCen ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +PhotoObj::GetDimensions( double& dDimX, double& dDimY) +{ + dDimX = m_dDimX ; + dDimY = m_dDimY ; + return true ; +} diff --git a/PhotoObj.h b/PhotoObj.h index 0064a76..ce95614 100644 --- a/PhotoObj.h +++ b/PhotoObj.h @@ -34,8 +34,12 @@ class PhotoObj : public IUserObj PhotoObj( void) ; bool Set( const std::string& sName, const std::string& sPath, const Point3d& ptOri, const Point3d& ptCen, double dDimX, double dDimY) ; + bool GetName( std::string& sName) ; bool GetPath( std::string& sPath) ; bool ChangePath( const std::string& sPath) ; + bool GetOrigin( Point3d& ptOri) ; + bool GetCenter( Point3d& ptCen) ; + bool GetDimensions( double& dDimX, double& dDimY) ; private : int m_nOwnerId ;