EgtExecutor 1.6j1 :

- aggiunta gestione Photo
- aggiunta gestione Textures con applicazione a superfici basata su riferimenti
- corrette Pack di Nesting con primo pezzo più grande in X del pannello 
- aggiunte funzioni per Photo e Texture su superfici in LUA.
This commit is contained in:
Dario Sassi
2015-10-11 17:58:37 +00:00
parent f6dff2cefd
commit d4cb542d16
20 changed files with 801 additions and 126 deletions
+74 -2
View File
@@ -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) ;
}
+4
View File
@@ -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
+1 -112
View File
@@ -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)
+10 -2
View File
@@ -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
+4
View File
@@ -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 ;
+97
View File
@@ -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<PhotoObj*>( 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<PhotoObj*>( pGeomDB->GetUserObj( nId)) ;
if ( pPhoto == nullptr)
return false ;
// imposto la nuova path della fotografia
return pPhoto->ChangePath( sPath) ;
}
+17 -7
View File
@@ -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) ;
}
BIN
View File
Binary file not shown.
+4
View File
@@ -222,6 +222,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="GseContext.h" />
<ClInclude Include="LUA.h" />
<ClInclude Include="LUA_Base.h" />
<ClInclude Include="PhotoObj.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="stdafx.h" />
</ItemGroup>
@@ -245,6 +246,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="EXE_MachMgr.cpp" />
<ClCompile Include="EXE_Messages.cpp" />
<ClCompile Include="EXE_Nesting.cpp" />
<ClCompile Include="EXE_Photo.cpp" />
<ClCompile Include="EXE_Scene.cpp" />
<ClCompile Include="EXE_TscExec.cpp" />
<ClCompile Include="AuxTools.cpp" />
@@ -274,8 +276,10 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="LUA_GeoTransform.cpp" />
<ClCompile Include="LUA_MachMgr.cpp" />
<ClCompile Include="LUA_Nesting.cpp" />
<ClCompile Include="LUA_Photo.cpp" />
<ClCompile Include="LUA_Scene.cpp" />
<ClCompile Include="LUA_UiUnits.cpp" />
<ClCompile Include="PhotoObj.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+15
View File
@@ -31,6 +31,9 @@
<Filter Include="File di origine\EXE">
<UniqueIdentifier>{77e59e94-e3d5-4510-8bcb-d1360cf74848}</UniqueIdentifier>
</Filter>
<Filter Include="File di origine\UserCustom">
<UniqueIdentifier>{f7a8e338-3240-4d1b-a19f-792efb144a8a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@@ -84,6 +87,9 @@
<ClInclude Include="..\Include\EXeConst.h">
<Filter>File di intestazione\Include</Filter>
</ClInclude>
<ClInclude Include="PhotoObj.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="LUA_Exchange.cpp">
@@ -239,6 +245,15 @@
<ClCompile Include="LUA_Nesting.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
<ClCompile Include="PhotoObj.cpp">
<Filter>File di origine\UserCustom</Filter>
</ClCompile>
<ClCompile Include="EXE_Photo.cpp">
<Filter>File di origine\EXE</Filter>
</ClCompile>
<ClCompile Include="LUA_Photo.cpp">
<Filter>File di origine\LUA</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtExecutor.rc">
+112
View File
@@ -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)
+8
View File
@@ -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) ;
+3
View File
@@ -72,5 +72,8 @@ bool LuaInstallNesting( LuaMgr& luaMgr) ;
//-------------------------- Scene -------------------------------------------
bool LuaInstallScene( LuaMgr& luaMgr) ;
//-------------------------- Photo -------------------------------------------
bool LuaInstallPhoto( LuaMgr& luaMgr) ;
//-------------------------- Exchange ----------------------------------------
bool LuaInstallExchange( LuaMgr& luaMgr) ;
+4
View File
@@ -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 ;
+1 -1
View File
@@ -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.
//
//
//
+97
View File
@@ -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 ;
}
+3 -2
View File
@@ -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) ;
+100
View File
@@ -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 ;
}
+198
View File
@@ -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()) ;
}
+49
View File
@@ -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 ;
} ;