diff --git a/EXE_GdbObjAttribs.cpp b/EXE_GdbObjAttribs.cpp index fa356ab..f4456f5 100644 --- a/EXE_GdbObjAttribs.cpp +++ b/EXE_GdbObjAttribs.cpp @@ -16,6 +16,7 @@ #include "EXE.h" #include "EXE_Macro.h" #include "AuxTools.h" +#include "GeoTools.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EgtStringConverter.h" @@ -497,7 +498,7 @@ ExeSetInfo( int nId, const string& sKey, const string& sInfo) //----------------------------------------------------------------------------- bool -ExeSetInfo( int nId, const std::string& sKey, const Frame3d& frFrame) +ExeSetInfo( int nId, const string& sKey, const Frame3d& frFrame) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) @@ -539,7 +540,7 @@ ExeGetInfo( int nId, const string& sKey, string& sInfo) //----------------------------------------------------------------------------- bool -ExeGetInfo( int nId, const std::string& sKey, Frame3d& frFrame) +ExeGetInfo( int nId, const string& sKey, Frame3d& frFrame) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) @@ -576,3 +577,74 @@ ExeRemoveInfo( int nId, const string& sKey) // restituisco risultato return bOk ; } + +//----------------------------------------------------------------------------- +bool +ExeSetTextureName( int nId, const string& sTxrName) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // assegno il nome della texture + bool bOk = pGeomDB->SetTextureName( nId, sTxrName) ; + ExeSetModified() ; + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +ExeSetTextureFrame( int nId, const Frame3d& frTxrRef, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + bool bOk = true ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; + // porto in locale l'origine e i versori + Point3d ptOrigL = GetPointLocal( pGeomDB, frTxrRef.Orig(), nRefType, frLoc) ; + Vector3d vtXL = GetVectorLocal( pGeomDB, frTxrRef.VersX(), nRefType, frLoc) ; + Vector3d vtYL = GetVectorLocal( pGeomDB, frTxrRef.VersY(), nRefType, frLoc) ; + Vector3d vtZL = GetVectorLocal( pGeomDB, frTxrRef.VersZ(), nRefType, frLoc) ; + // ricreo il riferimento in locale + Frame3d frTxrLoc ; + bOk = bOk && frTxrLoc.Set( ptOrigL, vtXL, vtYL, vtZL) ; + // assegno il riferimento della texture + bOk = bOk && pGeomDB->SetTextureFrame( nId, frTxrLoc) ; + ExeSetModified() ; + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +ExeRemoveTextureData( int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // rimuovo i dati della texture + bool bOk = pGeomDB->RemoveTextureData( nId) ; + ExeSetModified() ; + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +ExeGetTextureName( int nId, string& sTxrName) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il nome della texture + bool bOk = pGeomDB->GetTextureName( nId, sTxrName) ; + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +ExeGetTextureFrame( int nId, int nRefId, Frame3d& frTxrRef) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il riferimento della texture + bool bOk = pGeomDB->GetTextureFrame( nId, frTxrRef) ; + // gestione trasformazione ( eventuale) + return TrasformFrame( pGeomDB, nId, nRefId, frTxrRef) ; +} diff --git a/EXE_GdbObjects.cpp b/EXE_GdbObjects.cpp index 850f355..881bf6c 100644 --- a/EXE_GdbObjects.cpp +++ b/EXE_GdbObjects.cpp @@ -476,6 +476,8 @@ ExeGroupDump( int nId, string& sDump) sDump = "Group " + ToString( nId) + "\r\n" ; // preparo gli attributi pGeomDB->DumpAttributes( nId, sDump, bMM, "\r\n") ; + // preparo TextureData + pGeomDB->DumpTextureData( nId, sDump, bMM, "\r\n") ; // preparo UserObj pGeomDB->DumpUserObj( nId, sDump, bMM, "\r\n") ; // numero di nodi (figli) @@ -522,6 +524,8 @@ ExeGeoObjDump( int nId, string& sDump) sDump = pGeoObj->GetTitle() + " " + ToString( nId) + "\r\n" ; // preparo gli attributi pGeomDB->DumpAttributes( nId, sDump, bMM, "\r\n") ; + // preparo TextureData + pGeomDB->DumpTextureData( nId, sDump, bMM, "\r\n") ; // preparo UserObj pGeomDB->DumpUserObj( nId, sDump, bMM, "\r\n") ; // recupero i dati geometrici diff --git a/EXE_GeoSnap.cpp b/EXE_GeoSnap.cpp index 9900a9c..371c795 100644 --- a/EXE_GeoSnap.cpp +++ b/EXE_GeoSnap.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "EXE.h" #include "EXE_Macro.h" +#include "GeoTools.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EgkGeoPoint3d.h" #include "/EgtDev/Include/EgkGeoVector3d.h" @@ -29,118 +30,6 @@ #include "/EgtDev/Include/EgkIntersCurves.h" #include "/EgtDev/Include/EgtPointerOwner.h" -//---------------------------------------------------------------------------- -static bool -TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) -{ - // se non va trasformato, esco - if ( nRefId == nId) - return true ; - // recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva) - Frame3d frSou ; - if ( ! pGeomDB->GetGlobFrame( nId, frSou)) - return false ; - // se va portato in globale, trasformo ed esco - if ( nRefId == GDB_ID_ROOT) - return ptP.ToGlob( frSou) ; - // recupero il riferimento destinazione - Frame3d frDest ; - if ( nRefId == GDB_ID_GRID) - frDest = pGeomDB->GetGridFrame() ; - else { - // nRefId può essere un gruppo o una entità - if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && - ! pGeomDB->GetGlobFrame( nRefId, frDest)) - return false ; - } - // eseguo la trasformazione - return ptP.LocToLoc( frSou, frDest) ; -} - -//---------------------------------------------------------------------------- -static bool -InvTrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) -{ - // se non va trasformato, esco - if ( nRefId == nId) - return true ; - // recupero il riferimento in cui va espresso il punto (quello dell'entità a cui va riferito) - Frame3d frSou ; - if ( ! pGeomDB->GetGlobFrame( nId, frSou)) - return false ; - // se viene da globale, trasformo ed esco - if ( nRefId == GDB_ID_ROOT) - return ptP.ToLoc( frSou) ; - // recupero il riferimento da cui proviene - Frame3d frDest ; - if ( nRefId == GDB_ID_GRID) - frDest = pGeomDB->GetGridFrame() ; - else { - // nRefId può essere un gruppo o una entità - if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && - ! pGeomDB->GetGlobFrame( nRefId, frDest)) - return false ; - } - // eseguo la trasformazione inversa - return ptP.LocToLoc( frDest, frSou) ; -} - -//---------------------------------------------------------------------------- -static bool -TrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) -{ - // se non va trasformato, esco - if ( nRefId == nId) - return true ; - // recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva) - Frame3d frSou ; - if ( ! pGeomDB->GetGlobFrame( nId, frSou)) - return false ; - // se va portato in globale, trasformo ed esco - if ( nRefId == GDB_ID_ROOT) - return vtV.ToGlob( frSou) ; - // recupero il riferimento destinazione - Frame3d frDest ; - if ( nRefId == GDB_ID_GRID) - frDest = pGeomDB->GetGridFrame() ; - else { - // nRefId può essere un gruppo o una entità - if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && - ! pGeomDB->GetGlobFrame( nRefId, frDest)) - return false ; - } - // eseguo la trasformazione - return vtV.LocToLoc( frSou, frDest) ; -} - -//---------------------------------------------------------------------------- -static bool -TrasformFrame( IGeomDB* pGeomDB, int nId, int nRefId, Frame3d& frF) -{ - // se non va trasformato, esco - if ( nRefId == nId) - return true ; - // recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva) - Frame3d frSou ; - if ( ! pGeomDB->GetGlobFrame( nId, frSou)) - return false ; - // se va portato in globale, trasformo ed esco - if ( nRefId == GDB_ID_ROOT) - return frF.ToGlob( frSou) ; - // recupero il riferimento destinazione - Frame3d frDest ; - if ( nRefId == GDB_ID_GRID) - frDest = pGeomDB->GetGridFrame() ; - else { - // nRefId può essere un gruppo o una entità - if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && - ! pGeomDB->GetGlobFrame( nRefId, frDest)) - return false ; - } - // eseguo la trasformazione - return frF.LocToLoc( frSou, frDest) ; -} - //---------------------------------------------------------------------------- bool ExeStartPoint( int nId, int nRefId, Point3d& ptP) diff --git a/EXE_GeomDB.cpp b/EXE_GeomDB.cpp index 711b8de..5428cd8 100644 --- a/EXE_GeomDB.cpp +++ b/EXE_GeomDB.cpp @@ -247,6 +247,9 @@ ExeNewFile( void) // reinizializzazione (con pulizia) del DB geometrico bOk = bOk && pGseCtx->m_pGeomDB->Init() ; bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; + // pulizia delle textures + if ( pGseCtx->m_pScene != nullptr) + bOk = bOk && pGseCtx->m_pScene->UnloadAllTextures() ; // aggiorno stato file corrente pGseCtx->m_sFilePath.clear() ; ExeResetModified() ; @@ -272,10 +275,14 @@ ExeOpenFile( const string& sFilePath) // reinizializzazione (con pulizia) del DB geometrico bOk = bOk && pGseCtx->m_pGeomDB->Init() ; bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; + // pulizia delle textures + if ( pGseCtx->m_pScene != nullptr) + bOk = bOk && pGseCtx->m_pScene->UnloadAllTextures() ; + // imposto path corrente del file + pGseCtx->m_sFilePath = sFilePath ; // carico il file bOk = bOk && pGseCtx->m_pGeomDB->Load( sFilePath) ; // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; ExeResetModified() ; // aggiornamento gestore lavorazioni ExeUpdateMachMgr() ; @@ -340,13 +347,14 @@ ExeSaveFile( const string& sFilePath, int nFlag) // se ero in CAM, esco int nCurrMachGroup = ExeGetCurrMachGroup() ; ExeResetCurrMachGroup() ; + // imposto path corrente del file + pGseCtx->m_sFilePath = sFilePath ; // salvo il file bool bOk = pGseCtx->m_pGeomDB->Save( GDB_ID_ROOT, sFilePath, nFlag) ; // eventuale ripristino precedente CAM if ( nCurrMachGroup != GDB_ID_NULL) ExeSetCurrMachGroup( nCurrMachGroup) ; // aggiorno stato file corrente - pGseCtx->m_sFilePath = sFilePath ; if ( bOk) ExeResetModified() ; // se richiesto, salvo il comando Lua equivalente diff --git a/EXE_Nesting.cpp b/EXE_Nesting.cpp index 2d8d035..2d17bd6 100644 --- a/EXE_Nesting.cpp +++ b/EXE_Nesting.cpp @@ -513,9 +513,13 @@ static bool VerifyBoxAndMoveOnX( const BBox3d& b3Test, const Vector3d& vtMove, const BOXVECTOR& vb3OnPlace, double dXmax, double& dExtraMove) { + // verifica iniziale BBox3d b3Moved = b3Test ; b3Moved.Translate( vtMove) ; dExtraMove = 0 ; + if ( b3Moved.GetMax().x > dXmax + EPS_SMALL) + return false ; + // verifico con altri pezzi for ( const auto& Box : vb3OnPlace) { if ( b3Moved.OverlapsXY( Box)) { double dNewMove = Box.GetMax().x - b3Moved.GetMin().x + 2 * EPS_SMALL ; diff --git a/EXE_Photo.cpp b/EXE_Photo.cpp new file mode 100644 index 0000000..4e39125 --- /dev/null +++ b/EXE_Photo.cpp @@ -0,0 +1,97 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : EXE_Photo.cpp Data : 05.10.15 Versione : 1.6j1 +// Contenuto : Funzioni per gestione fotografia. +// +// +// +// Modifiche : 05.10.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "PhotoObj.h" +#include "EXE.h" +#include "EXE_Macro.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EXeConst.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +int +ExeAddPhoto( const string& sName, const string& sPath, + const Point3d& ptOri, const Point3d& ptCen, double dMMxPixel, + int nParentId, const Point3d& ptMin, const Point3d& ptMax) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + IEGrScene* pScene = GetCurrScene() ; + VERIFY_SCENE( pScene, GDB_ID_NULL) + // Carico la texture + if ( ! pScene->UnloadTexture( sName) || + ! pScene->LoadTexture( sName, sPath, dMMxPixel, 0, 0, TXR_CLAMP)) + return GDB_ID_NULL ; + // Recupero le dimensioni fisiche + double dDimX, dDimY ; + pScene->GetTextureDimensions( sName, dDimX, dDimY) ; + // Inserisco la regione rettangolare della foto (tutti i dati sono in Globale) + Point3d ptIni = ptOri ; + Point3d ptCross = ptIni + Vector3d( dDimX, dDimY, 0) ; + ptIni.x = max( ptIni.x, ptMin.x) ; + ptIni.y = max( ptIni.y, ptMin.y) ; + ptCross.x = min( ptCross.x, ptMax.x) ; + ptCross.y = min( ptCross.y, ptMax.y) ; + int nId = ExeCreateSurfFrRectangle( nParentId, ptIni, ptCross, RTY_GLOB) ; + if ( nId == GDB_ID_NULL) { + ExeUnloadTexture( sName) ; + return GDB_ID_NULL ; + } + // Assegno gli attributi + pGeomDB->SetMaterial( nId, WHITE) ; + pGeomDB->SetName( nId, sName) ; + // Assegno i dati della texture + pGeomDB->SetTextureName( nId, sName) ; + pGeomDB->SetTextureFrame( nId, Frame3d(ptOri)) ; + // Installo e inizializzo il gestore della foto + PhotoObj* pPhoto = new(nothrow) PhotoObj ; + if ( pPhoto == nullptr) { + pScene->UnloadTexture( sName) ; + return GDB_ID_NULL ; + } + pPhoto->Set( sName, sPath, ptOri, ptCen, dDimX, dDimY) ; + pGeomDB->SetUserObj( nId, pPhoto) ; + ExeSetModified() ; + return nId ; +} + +//---------------------------------------------------------------------------- +bool +ExeGetPhotoPath( int nId, string& sPath) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il gestore dei dati della fotografia dell'oggetto + PhotoObj* pPhoto = dynamic_cast( pGeomDB->GetUserObj( nId)) ; + if ( pPhoto == nullptr) + return false ; + // recupero la path della fotografia + return pPhoto->GetPath( sPath) ; +} + +//---------------------------------------------------------------------------- +bool +ExeChangePhotoPath( int nId, const string& sPath) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il gestore dei dati della fotografia dell'oggetto + PhotoObj* pPhoto = dynamic_cast( pGeomDB->GetUserObj( nId)) ; + if ( pPhoto == nullptr) + return false ; + // imposto la nuova path della fotografia + return pPhoto->ChangePath( sPath) ; +} diff --git a/EXE_Scene.cpp b/EXE_Scene.cpp index e836773..83435ce 100644 --- a/EXE_Scene.cpp +++ b/EXE_Scene.cpp @@ -677,18 +677,18 @@ ExeUnProjectPoint( int nWinX, int nWinY, Point3d& ptP) //----------------------------------------------------------------------------- bool -ExeLoadTexture( const std::string& sName, const std::string& sFile, - double dMMxPix, double dDimX, double dDimY, bool bRepeat) +ExeLoadTexture( const string& sName, const string& sFile, + double dMMxPix, double dDimX, double dDimY, int nRepeat) { IEGrScene* pScene = GetCurrScene() ; VERIFY_SCENE( pScene, false) // lancio il caricamento della texture - return pScene->LoadTexture( sName, sFile, dMMxPix, dDimX, dDimY, bRepeat) ; + return pScene->LoadTexture( sName, sFile, dMMxPix, dDimX, dDimY, nRepeat) ; } //----------------------------------------------------------------------------- bool -ExeUnloadTexture( const std::string& sName) +ExeUnloadTexture( const string& sName) { IEGrScene* pScene = GetCurrScene() ; VERIFY_SCENE( pScene, false) @@ -696,13 +696,23 @@ ExeUnloadTexture( const std::string& sName) return pScene->UnloadTexture( sName) ; } +//----------------------------------------------------------------------------- +bool +ExeExistsTexture( const string& sName) +{ + IEGrScene* pScene = GetCurrScene() ; + VERIFY_SCENE( pScene, false) + // verifico esistenza della texture + return pScene->ExistsTexture( sName) ; +} + //----------------------------------------------------------------------------- bool ExeGetTexturePixels( const std::string& sName, int& nWidth, int& nHeight) { IEGrScene* pScene = GetCurrScene() ; VERIFY_SCENE( pScene, false) - // lancio lo scaricamento della texture + // recupero la dimensione in pixels della texture return pScene->GetTexturePixels( sName, nWidth, nHeight) ; } @@ -712,7 +722,7 @@ ExeGetTextureDimensions( const std::string& sName, double& dDimX, double& dDimY) { IEGrScene* pScene = GetCurrScene() ; VERIFY_SCENE( pScene, false) - // lancio lo scaricamento della texture + // recupero la dimensione fisica della texture return pScene->GetTextureDimensions( sName, dDimX, dDimY) ; } @@ -722,6 +732,6 @@ ExeChangeTextureDimensions( const std::string& sName, double dDimX, double dDimY { IEGrScene* pScene = GetCurrScene() ; VERIFY_SCENE( pScene, false) - // lancio lo scaricamento della texture + // modifico le dimensioni della texture return pScene->ChangeTextureDimensions( sName, dDimX, dDimY) ; } diff --git a/EgtExecutor.rc b/EgtExecutor.rc index d3ce5c9..8ef7064 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/EgtExecutor.vcxproj b/EgtExecutor.vcxproj index 1ec69dc..dab0db7 100644 --- a/EgtExecutor.vcxproj +++ b/EgtExecutor.vcxproj @@ -222,6 +222,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -245,6 +246,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -274,8 +276,10 @@ copy $(TargetPath) \EgtProg\Dll64 + + Create Create diff --git a/EgtExecutor.vcxproj.filters b/EgtExecutor.vcxproj.filters index e41f342..8784f19 100644 --- a/EgtExecutor.vcxproj.filters +++ b/EgtExecutor.vcxproj.filters @@ -31,6 +31,9 @@ {77e59e94-e3d5-4510-8bcb-d1360cf74848} + + {f7a8e338-3240-4d1b-a19f-792efb144a8a} + @@ -84,6 +87,9 @@ File di intestazione\Include + + File di intestazione + @@ -239,6 +245,15 @@ File di origine\LUA + + File di origine\UserCustom + + + File di origine\EXE + + + File di origine\LUA + diff --git a/GeoTools.cpp b/GeoTools.cpp index d6e9391..68b5267 100644 --- a/GeoTools.cpp +++ b/GeoTools.cpp @@ -58,6 +58,118 @@ GetPointLocal( IGeomDB* pGeomDB, const Point3d& ptP, int nRefType, const Frame3d return ptPL ; } +//---------------------------------------------------------------------------- +bool +TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) +{ + // se non va trasformato, esco + if ( nRefId == nId) + return true ; + // recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva) + Frame3d frSou ; + if ( ! pGeomDB->GetGlobFrame( nId, frSou)) + return false ; + // se va portato in globale, trasformo ed esco + if ( nRefId == GDB_ID_ROOT) + return ptP.ToGlob( frSou) ; + // recupero il riferimento destinazione + Frame3d frDest ; + if ( nRefId == GDB_ID_GRID) + frDest = pGeomDB->GetGridFrame() ; + else { + // nRefId può essere un gruppo o una entità + if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && + ! pGeomDB->GetGlobFrame( nRefId, frDest)) + return false ; + } + // eseguo la trasformazione + return ptP.LocToLoc( frSou, frDest) ; +} + +//---------------------------------------------------------------------------- +bool +InvTrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) +{ + // se non va trasformato, esco + if ( nRefId == nId) + return true ; + // recupero il riferimento in cui va espresso il punto (quello dell'entità a cui va riferito) + Frame3d frSou ; + if ( ! pGeomDB->GetGlobFrame( nId, frSou)) + return false ; + // se viene da globale, trasformo ed esco + if ( nRefId == GDB_ID_ROOT) + return ptP.ToLoc( frSou) ; + // recupero il riferimento da cui proviene + Frame3d frDest ; + if ( nRefId == GDB_ID_GRID) + frDest = pGeomDB->GetGridFrame() ; + else { + // nRefId può essere un gruppo o una entità + if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && + ! pGeomDB->GetGlobFrame( nRefId, frDest)) + return false ; + } + // eseguo la trasformazione inversa + return ptP.LocToLoc( frDest, frSou) ; +} + +//---------------------------------------------------------------------------- +bool +TrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) +{ + // se non va trasformato, esco + if ( nRefId == nId) + return true ; + // recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva) + Frame3d frSou ; + if ( ! pGeomDB->GetGlobFrame( nId, frSou)) + return false ; + // se va portato in globale, trasformo ed esco + if ( nRefId == GDB_ID_ROOT) + return vtV.ToGlob( frSou) ; + // recupero il riferimento destinazione + Frame3d frDest ; + if ( nRefId == GDB_ID_GRID) + frDest = pGeomDB->GetGridFrame() ; + else { + // nRefId può essere un gruppo o una entità + if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && + ! pGeomDB->GetGlobFrame( nRefId, frDest)) + return false ; + } + // eseguo la trasformazione + return vtV.LocToLoc( frSou, frDest) ; +} + +//---------------------------------------------------------------------------- +bool +TrasformFrame( IGeomDB* pGeomDB, int nId, int nRefId, Frame3d& frF) +{ + // se non va trasformato, esco + if ( nRefId == nId) + return true ; + // recupero il riferimento in cui è espresso il punto (quello dell'entità da cui deriva) + Frame3d frSou ; + if ( ! pGeomDB->GetGlobFrame( nId, frSou)) + return false ; + // se va portato in globale, trasformo ed esco + if ( nRefId == GDB_ID_ROOT) + return frF.ToGlob( frSou) ; + // recupero il riferimento destinazione + Frame3d frDest ; + if ( nRefId == GDB_ID_GRID) + frDest = pGeomDB->GetGridFrame() ; + else { + // nRefId può essere un gruppo o una entità + if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && + ! pGeomDB->GetGlobFrame( nRefId, frDest)) + return false ; + } + // eseguo la trasformazione + return frF.LocToLoc( frSou, frDest) ; +} + //---------------------------------------------------------------------------- bool VerifySameFrame( IGeomDB* pGeomDB, const INTVECTOR& vIds) diff --git a/GeoTools.h b/GeoTools.h index 2913447..fc6a18e 100644 --- a/GeoTools.h +++ b/GeoTools.h @@ -23,6 +23,14 @@ int AdjustId( int nId) ; Vector3d GetVectorLocal( IGeomDB* pGeomDB, const Vector3d& vtV, int nRefType, const Frame3d& frLoc) ; // Punto espresso nel riferimento desiderato partendo da punto nel riferimento RefType Point3d GetPointLocal( IGeomDB* pGeomDB, const Point3d& ptP, int nRefType, const Frame3d& frLoc) ; +// Punto portato dal riferimento di nId a quello di nRefId +bool TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) ; +// Trasformazione inversa della precedente, dal riferimento di nRefId a quello di nId +bool InvTrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) ; +// Vettore portato dal riferimento di nId a quello di nRefId +bool TrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) ; +// Riferimento portato dal riferimento di nId a quello di nRefId +bool TrasformFrame( IGeomDB* pGeomDB, int nId, int nRefId, Frame3d& frF) ; // Verifica che tutti gli oggetti dell'insieme abbiano lo stesso riferimento bool VerifySameFrame( IGeomDB* pGeomDB, const INTVECTOR& vIds) ; diff --git a/LUA.h b/LUA.h index 3cfccff..70e9bea 100644 --- a/LUA.h +++ b/LUA.h @@ -72,5 +72,8 @@ bool LuaInstallNesting( LuaMgr& luaMgr) ; //-------------------------- Scene ------------------------------------------- bool LuaInstallScene( LuaMgr& luaMgr) ; +//-------------------------- Photo ------------------------------------------- +bool LuaInstallPhoto( LuaMgr& luaMgr) ; + //-------------------------- Exchange ---------------------------------------- bool LuaInstallExchange( LuaMgr& luaMgr) ; diff --git a/LUA_Base.cpp b/LUA_Base.cpp index 088b13e..fd83960 100644 --- a/LUA_Base.cpp +++ b/LUA_Base.cpp @@ -102,6 +102,10 @@ LuaInstallEgtFunctions( LuaMgr& LuaMgr) LOG_ERROR( GetLogger(), "Error in LuaInstallScene (" __FUNCTION__ ")") return false ; } + if ( ! LuaInstallPhoto( LuaMgr)) { + LOG_ERROR( GetLogger(), "Error in LuaInstallPhoto (" __FUNCTION__ ")") + return false ; + } if ( ! LuaInstallExchange( LuaMgr)) { LOG_ERROR( GetLogger(), "Error in LuaInstallExchange (" __FUNCTION__ ")") return false ; diff --git a/LUA_Exchange.cpp b/LUA_Exchange.cpp index eb5fb9b..79ccc2e 100644 --- a/LUA_Exchange.cpp +++ b/LUA_Exchange.cpp @@ -2,7 +2,7 @@ // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : LUA_Exchange.cpp Data : 29.09.14 Versione : 1.5i5 -// Contenuto : Funzioni generali per LUA. +// Contenuto : Funzioni di import/export per LUA. // // // diff --git a/LUA_GdbObjAttribs.cpp b/LUA_GdbObjAttribs.cpp index 1a356cd..5c54d92 100644 --- a/LUA_GdbObjAttribs.cpp +++ b/LUA_GdbObjAttribs.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "LUA.h" #include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EGkGdbConst.h" #include "/EgtDev/Include/EGkLuaAux.h" #include "/EgtDev/Include/EGnStringUtils.h" @@ -540,6 +541,97 @@ LuaRemoveInfo( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaSetTextureName( lua_State* L) +{ + // 2 parametri : Id, Nome + int nId ; + LuaCheckParam( L, 1, nId) + string sTxrName ; + LuaCheckParam( L, 2, sTxrName) + LuaClearStack( L) ; + // assegno il nome della texture + bool bOk = ExeSetTextureName( nId, sTxrName) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSetTextureFrame( lua_State* L) +{ + // 2 o 3 parametri : Id, TxrRef [, nRefType] + int nId ; + LuaCheckParam( L, 1, nId) + Frame3d frTxrRef ; + LuaCheckParam( L, 2, frTxrRef) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 3, nRefType) ; + LuaClearStack( L) ; + // assegno il riferimento della texture + bool bOk = ExeSetTextureFrame( nId, frTxrRef, nRefType) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaRemoveTextureData( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // rimuovo i dati della texture + bool bOk = ExeRemoveTextureData( nId) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetTextureName( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero il nome della texture + string sTxrName ; + bool bOk = ExeGetTextureName( nId, sTxrName) ; + // restituisco il risultato + if ( bOk) + LuaSetParam( L, sTxrName) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetTextureFrame( lua_State* L) +{ + // 1 o 2 parametri : Id [, nRefId] + int nId ; + LuaCheckParam( L, 1, nId) + int nRefId = nId ; + LuaGetParam( L, 2, nRefId) ; + LuaClearStack( L) ; + // recupero il riferimento della texture + Frame3d frTxrRef ; + bool bOk = ExeGetTextureFrame( nId, nRefId, frTxrRef) ; + // restituisco il risultato + if ( bOk) + LuaSetParam( L, frTxrRef) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGdbObjAttribs( LuaMgr& luaMgr) @@ -575,5 +667,10 @@ LuaInstallGdbObjAttribs( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtGetInfo", LuaGetInfo) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExistsInfo", LuaExistsInfo) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveInfo", LuaRemoveInfo) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSetTextureName", LuaSetTextureName) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSetTextureFrame", LuaSetTextureFrame) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveTextureData", LuaRemoveTextureData) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetTextureName", LuaGetTextureName) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetTextureFrame", LuaGetTextureFrame) ; return bOk ; } diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index df2fead..c6ff600 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -145,9 +145,10 @@ LuaGetMachGroupId( lua_State* L) static int LuaSetCurrMachGroup( lua_State* L) { - // 1 parametro : identificativo del gruppo + // nessuno o 1 parametro : [identificativo del gruppo] int nMGroupInd ; - LuaCheckParam( L, 1, nMGroupInd) + if ( ! LuaGetParam( L, 1, nMGroupInd)) + nMGroupInd = ExeGetFirstMachGroup() ; LuaClearStack( L) ; // imposto il gruppo corrente bool bOk = ExeSetCurrMachGroup( nMGroupInd) ; diff --git a/LUA_Photo.cpp b/LUA_Photo.cpp new file mode 100644 index 0000000..561fa8a --- /dev/null +++ b/LUA_Photo.cpp @@ -0,0 +1,100 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : LUA_Photo.cpp Data : 11.10.15 Versione : 1.6j1 +// Contenuto : Funzioni sulla fotografia per LUA. +// +// +// +// Modifiche : 11.10.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "LUA.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EgnStringUtils.h" + +using namespace std ; + +//------------------------------------------------------------------------------- +static int +LuaAddPhoto( lua_State* L) +{ + // 8 parametri : nome per la texture, path della immagine, ptOri, ptCen, dMMxPixel, nParentId, ptMin, ptMax + string sName ; + LuaCheckParam( L, 1, sName) + string sPath ; + LuaCheckParam( L, 2, sPath) + Point3d ptOri ; + LuaCheckParam( L, 3, ptOri) + Point3d ptCen ; + LuaCheckParam( L, 4, ptCen) + double dMMxPixel ; + LuaCheckParam( L, 5, dMMxPixel) + int nParentId ; + LuaCheckParam( L, 6, nParentId) + Point3d ptMin ; + LuaCheckParam( L, 7, ptMin) + Point3d ptMax ; + LuaCheckParam( L, 8, ptMax) + LuaClearStack( L) ; + // inserisco la foto + int nId = ExeAddPhoto( sName, sPath, ptOri, ptCen, dMMxPixel, nParentId, ptMin, ptMax) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetPhotoPath( lua_State* L) +{ + // 1 parametro : nId + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero la path della immagine della foto + string sPath ; + bool bOk = ExeGetPhotoPath( nId, sPath) ; + // restituisco il risultato + if ( bOk) + LuaSetParam( L, sPath) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaChangePhotoPath( lua_State* L) +{ + // 2 parametri : nId, + int nId ; + LuaCheckParam( L, 1, nId) + string sPath ; + LuaCheckParam( L, 2, sPath) + LuaClearStack( L) ; + // assegno la path della immagine della foto + bool bOk = ExeChangePhotoPath( nId, sPath) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +bool +LuaInstallPhoto( LuaMgr& luaMgr) +{ + bool bOk = ( &luaMgr != nullptr) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAddPhoto", LuaAddPhoto) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetPhotoPath", LuaGetPhotoPath) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtChangePhotoPath", LuaChangePhotoPath) ; + return bOk ; +} diff --git a/PhotoObj.cpp b/PhotoObj.cpp new file mode 100644 index 0000000..d1f1728 --- /dev/null +++ b/PhotoObj.cpp @@ -0,0 +1,198 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : PhotoObj.cpp Data : 05.10.15 Versione : 1.6j1 +// Contenuto : Oggetto custom Photo. +// Viene attaccato ad una Region rettangolare. +// +// +// Modifiche : 05.10.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "PhotoObj.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EGrScene.h" +#include "/EgtDev/Include/EGkGdbConst.h" +#include "/EgtDev/Include/EGkUserObjFactory.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EGnStringKeyVal.h" +#include "/EgtDev/Include/EGnFileUtils.h" + +#undef GetClassName + +using namespace std ; + +//---------------------------------------------------------------------------- +static const int NKEY = 6 ; +static const string KEY_NAME = "N" ; +static const string KEY_PATH = "P" ; +static const string KEY_ORIG = "O" ; +static const string KEY_CEN = "C" ; +static const string KEY_DIMX = "DX" ; +static const string KEY_DIMY = "DY" ; + +//---------------------------------------------------------------------------- +USEROBJ_REGISTER( "EXePhoto", PhotoObj) ; + +//---------------------------------------------------------------------------- +const string& +PhotoObj::GetClassName( void) const +{ + return USEROBJ_GETNAME( PhotoObj) ; +} + +//---------------------------------------------------------------------------- +PhotoObj* +PhotoObj::Clone( void) const +{ + // alloco oggetto + PhotoObj* pPhoto = new(nothrow) PhotoObj ; + // eseguo copia dei dati + if ( pPhoto != nullptr) { + try { + + } + catch( ...) { + delete pPhoto ; + return nullptr ; + } + } + // ritorno l'oggetto + return pPhoto ; +} + +//---------------------------------------------------------------------------- +bool +PhotoObj::Dump( string& sOut, bool bMM, const char* szNewLine) const +{ + sOut += GetClassName() + szNewLine ; + sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ; + sOut += "Name=" + m_sName + szNewLine ; + sOut += "Path=" + m_sPath + szNewLine ; + sOut += "Orig=" + ToString( m_ptOri) + szNewLine ; + sOut += "Cen=" + ToString( m_ptCen) + szNewLine ; + sOut += "Dim=" + ToString( m_dDimX) + "," + ToString( m_dDimY) + szNewLine ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +PhotoObj::Save( STRVECTOR& vString) const +{ + try { + vString.insert( vString.begin(), NKEY, "") ; + if ( ! SetVal( KEY_NAME, m_sName, vString[0])) + return false ; + if ( ! SetVal( KEY_PATH, m_sPath, vString[1])) + return false ; + if ( ! SetVal( KEY_ORIG, m_ptOri, vString[2])) + return false ; + if ( ! SetVal( KEY_CEN, m_ptCen, vString[3])) + return false ; + if ( ! SetVal( KEY_DIMX, m_dDimX, vString[4])) + return false ; + if ( ! SetVal( KEY_DIMY, m_dDimY, vString[5])) + return false ; + } + catch( ...) { + return false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +PhotoObj::Load( const STRVECTOR& vString) +{ + if ( int( vString.size()) < NKEY) + return false ; + if ( ! GetVal( vString[0], KEY_NAME, m_sName)) + return false ; + if ( ! GetVal( vString[1], KEY_PATH, m_sPath)) + return false ; + if ( ! GetVal( vString[2], KEY_ORIG, m_ptOri)) + return false ; + if ( ! GetVal( vString[3], KEY_CEN, m_ptCen)) + return false ; + if ( ! GetVal( vString[4], KEY_DIMX, m_dDimX)) + return false ; + if ( ! GetVal( vString[5], KEY_DIMY, m_dDimY)) + return false ; + // verifico l'esistenza della texture + if ( ExeExistsTexture( m_sName)) + return true ; + // carico la texture dalla path indicata + if ( ExistsFile( m_sPath)) { + return ExeLoadTexture( m_sName, m_sPath, 0, m_dDimX, m_dDimY, TXR_CLAMP) ; + } + // provo dalla path del progetto corrente + string sFilePath ; + ExeGetCurrFilePath( sFilePath) ; + string sDir = GetDirectory( sFilePath) ; + string sName = GetFileName( m_sPath) ; + return ExeLoadTexture( m_sName, sDir + "\\" + sName, 0, m_dDimX, m_dDimY, TXR_CLAMP) ; +} + +//---------------------------------------------------------------------------- +bool +PhotoObj::SetOwner( int nId, IGeomDB* pGDB) +{ + m_nOwnerId = nId ; + m_pGeomDB = pGDB ; + return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ; +} + +//---------------------------------------------------------------------------- +int +PhotoObj::GetOwner( void) const +{ + return m_nOwnerId ; +} + +//---------------------------------------------------------------------------- +IGeomDB* +PhotoObj::GetGeomDB( void) const +{ + return m_pGeomDB ; +} + +//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +PhotoObj::PhotoObj( void) + : m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr) +{ +} + +//---------------------------------------------------------------------------- +bool +PhotoObj::Set( const string& sName, const string& sPath, + const Point3d& ptOri, const Point3d& ptCen, double dDimX, double dDimY) +{ + m_sName = sName ; + m_sPath = sPath ; + m_ptOri = ptOri ; + m_ptCen = ptCen ; + m_dDimX = dDimX ; + m_dDimY = dDimY ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +PhotoObj::GetPath( string& sPath) +{ + sPath = m_sPath ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +PhotoObj::ChangePath( const string& sPath) +{ + m_sPath = sPath ; + return ( ! m_sPath.empty()) ; +} diff --git a/PhotoObj.h b/PhotoObj.h new file mode 100644 index 0000000..0064a76 --- /dev/null +++ b/PhotoObj.h @@ -0,0 +1,49 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : PhotoObj.h Data : 05.10.15 Versione : 1.6j1 +// Contenuto : Dichiarazione della classe PhotoObj. +// +// +// +// Modifiche : 05.10.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkUserObj.h" +#include "/EgtDev/Include/EGkPoint3d.h" + +//---------------------------------------------------------------------------- +class PhotoObj : public IUserObj +{ + public : // IUserObj + virtual PhotoObj* Clone( void) const ; + virtual const std::string& GetClassName( void) const ; + virtual bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const ; + virtual bool ToSave( void) const { return true ; } + virtual bool Save( STRVECTOR& vString) const ; + virtual bool Load( const STRVECTOR& vString) ; + virtual bool SetOwner( int nId, IGeomDB* pGDB) ; + virtual int GetOwner( void) const ; + virtual IGeomDB* GetGeomDB( void) const ; + + public : + PhotoObj( void) ; + bool Set( const std::string& sName, const std::string& sPath, + const Point3d& ptOri, const Point3d& ptCen, double dDimX, double dDimY) ; + bool GetPath( std::string& sPath) ; + bool ChangePath( const std::string& sPath) ; + + private : + int m_nOwnerId ; + IGeomDB* m_pGeomDB ; + std::string m_sName ; + std::string m_sPath ; + Point3d m_ptOri ; + Point3d m_ptCen ; + double m_dDimX ; + double m_dDimY ; +} ; \ No newline at end of file