//---------------------------------------------------------------------------- // EgalTech 2017-2017 //---------------------------------------------------------------------------- // File : EXE_Picture.cpp Data : 26.12.17 Versione : 1.8l3 // Contenuto : Funzioni per gestione immagine. // // // // Modifiche : 26.12.17 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "PictureObj.h" #include "EXE.h" #include "EXE_Macro.h" #include "AuxTools.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeConst.h" using namespace std ; //---------------------------------------------------------------------------- int MyAddPicture( int nParentId, const string& sName, const string& sPath, double dDimX, double dDimY, int nRefType) { 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, 0, dDimX, dDimY, TXR_CLAMP)) return GDB_ID_NULL ; // Inserisco la regione rettangolare della foto (tutti i dati sono in Globale) Point3d ptIni = ORIG ; Point3d ptCross = ptIni + Vector3d( dDimX, dDimY, 0) ; int nId = ExeCreateSurfFrRectangle( nParentId, ptIni, ptCross, nRefType) ; if ( nId == GDB_ID_NULL) { pScene->UnloadTexture( 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()) ; // Installo e inizializzo il gestore della foto PictureObj* pPic = new( nothrow) PictureObj ; if ( pPic == nullptr) { pGeomDB->Erase( nId) ; pScene->UnloadTexture( sName) ; return GDB_ID_NULL ; } pPic->Set( sName, sPath, dDimX, dDimY) ; pGeomDB->SetUserObj( nId, pPic) ; return nId ; } //---------------------------------------------------------------------------- int ExeAddPicture( int nParentId, const string& sName, const string& sPath, double dDimX, double dDimY, int nRefType) { // lancio esecuzione int nId = MyAddPicture( nParentId, sName, sPath, dDimX, dDimY, nRefType) ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAddPicture(" + IdToString( nParentId) + ",'" + StringToLuaString( sName) + "','" + StringToLuaString( sPath) + "'," + ToString( dDimX) + "," + ToString( dDimY) + "," + IdToString( nParentId) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato return nId ; }