24616b55b9
- aggiunta funzione ExeSetGridGeoAdv.
868 lines
26 KiB
C++
868 lines
26 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : EXE_Scene.cpp Data : 05.05.15 Versione : 1.6e1
|
|
// Contenuto : Funzioni Scene per EXE.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 01.09.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "EXE.h"
|
|
#include "EXE_Macro.h"
|
|
#include "DllGraphics.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EXeConst.h"
|
|
#include "/EgtDev/Include/EgtStringConverter.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeInitScene( HWND hWnd, int nDriver, bool b2Buff, int nColorBits, int nDepthBits)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
// inizializzazione scena OpenGL
|
|
PtrOwner<IEGrScene> pScene( MyCreateEGrScene()) ;
|
|
VERIFY_NULL( Get( pScene), "Error in CreateEGrScene", false)
|
|
HDC hdc = GetDC( hWnd) ;
|
|
if ( ! pScene->CreateContext( hdc, nDriver, b2Buff, nColorBits, nDepthBits))
|
|
return false ;
|
|
pScene->SetBackground( WHITE, WHITE) ;
|
|
pScene->SetShowMode( SM_SHADING) ;
|
|
pScene->SetShowCurveDirection( false) ;
|
|
pScene->SetCamera( CT_TOP) ;
|
|
pScene->ZoomAll() ;
|
|
pScene->SetWinRectAttribs( true, BLACK) ;
|
|
pScene->SetMark( YELLOW) ;
|
|
pScene->Init( pGseCtx->m_pGeomDB) ;
|
|
// assegno la scena al contesto
|
|
pGseCtx->m_hWnd = hWnd ;
|
|
pGseCtx->m_pScene = Release( pScene) ;
|
|
// log con info sulla scena
|
|
string sSceneInfo = pGseCtx->m_pScene->GetOpenGLInfo() + '\n' +
|
|
pGseCtx->m_pScene->GetGLSLInfo() + '\n' +
|
|
pGseCtx->m_pScene->GetPixelFormatInfo() ;
|
|
LOG_INFO( GetLogger(), sSceneInfo.c_str())
|
|
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetSceneInfo( string& sInfo)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// verifico parametro di ritorno
|
|
if ( &sInfo == nullptr)
|
|
return false ;
|
|
// recupero le informazioni sulla scena
|
|
sInfo += pScene->GetOpenGLInfo() ;
|
|
sInfo += "\r\n" ;
|
|
sInfo += pScene->GetGLSLInfo() ;
|
|
sInfo += "\r\n" ;
|
|
sInfo += pScene->GetPixelFormatInfo() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetBackground( Color TopCol, Color BottomCol, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto lo sfondo
|
|
pScene->SetBackground( TopCol, BottomCol) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetBackground( Color& TopCol, Color& BottomCol)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// recupero lo sfondo
|
|
pScene->GetBackground( TopCol, BottomCol) ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetLineAttribs( int nWidth)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto lo spessore delle linee
|
|
return pScene->SetLineWidth( nWidth) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetMarkAttribs( Color MarkCol)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto il colore del Mark
|
|
return pScene->SetMark( MarkCol) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetSelSurfAttribs( Color SelSurfCol)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto il colore del Mark
|
|
return pScene->SetSelSurf( SelSurfCol) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetGeoLineAttribs( Color GlCol)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto il colore della linea geometrica gestita direttamente dalla scena
|
|
return pScene->SetGeoLineAttribs( GlCol) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetGeoTriaAttribs( Color GtCol)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto il colore del triangolo immediato
|
|
return pScene->SetGeoTriaAttribs( GtCol) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetWinRectAttribs( bool bOutline, Color WrCol)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto il colore della linea geometrica gestita direttamente dalla scena
|
|
return pScene->SetWinRectAttribs( bOutline, WrCol) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetGlobFrameShow( bool bShow)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto stato visualizzazione griglia
|
|
return pScene->SetGlobFrameShow( bShow) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetGridShow( bool bShowGrid, bool bShowFrame)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto stato visualizzazione griglia
|
|
return pScene->SetGridShow( bShowGrid, bShowFrame) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
|
|
// imposto i parametri geometrici di griglia
|
|
return pScene->SetGridGeo( dSnapStep, nMinLineSstep, nMajLineSstep, nExtSstep) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetGridGeoAdv( double dSnapStep, int nMinLineSstep, int nMajLineSstep,
|
|
double dXmin, double dXmax, double dYmin, double dYmax)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
|
|
// imposto i parametri geometrici di griglia
|
|
return pScene->SetGridGeoAdv( dSnapStep, nMinLineSstep, nMajLineSstep, dXmin, dXmax, dYmin, dYmax) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetGridColor( Color colMin, Color colMaj)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto i colori di griglia
|
|
return pScene->SetGridColor( colMin, colMaj) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeResize( int nW, int nH)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// eseguo resize
|
|
pScene->Resize( nW, nH) ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeDraw( void)
|
|
{
|
|
// se interfaccia disabilitata, esco subito
|
|
if ( ! ExeGetEnableUI())
|
|
return true ;
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_SCENE( pGseCtx, false)
|
|
// eseguo disegno
|
|
pGseCtx->m_pScene->Draw() ;
|
|
// valido la finestra disegnata
|
|
ValidateRgn( pGseCtx->m_hWnd, NULL) ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSelect( int nWinX, int nWinY, int nSelW, int nSelH, int* pnSel)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// verifico parametro di ritorno
|
|
if ( pnSel == nullptr)
|
|
return false ;
|
|
// eseguo la selezione
|
|
return pScene->Select( Point3d( nWinX, nWinY), nSelW, nSelH, *pnSel) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetObjFilterForSelWin( bool bZerodim, bool bCurve, bool bSurf, bool bVolume, bool bExtra)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto il filtro
|
|
return pScene->SetObjFilterForSelect( bZerodim, bCurve, bSurf, bVolume, bExtra) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeUnselectableRemove( int nId)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// tolgo dai non selezionabili
|
|
return pScene->UnselectableRemove( nId) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeUnselectableAdd( int nId)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// aggiungo ai non selezionabili
|
|
return pScene->UnselectableAdd( nId) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeUnselectableClearAll( void)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// cancello tutti i non selezionabili
|
|
return pScene->UnselectableClearAll() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetFirstObjInSelWin( void)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, GDB_ID_NULL)
|
|
// restituisco il primo oggetto selezionato
|
|
return pScene->GetFirstSelectedObj() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetNextObjInSelWin( void)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, GDB_ID_NULL)
|
|
// restituisco il successivo oggetto selezionato
|
|
return pScene->GetNextSelectedObj() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetPointFromSelect( int nSelId, int nWinX, int nWinY, Point3d& ptSel, int* pnAux)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// trovo il punto usato in selezione
|
|
if ( &ptSel == nullptr || pnAux == nullptr)
|
|
return false ;
|
|
return pScene->GetPointFromSelect( nSelId, Point3d( nWinX, nWinY), ptSel, *pnAux) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetGraphicSnapPoint( int nSnap, int nWinX, int nWinY, int nSelW, int nSelH, Point3d& ptP)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// trovo il punto snap da selezione
|
|
if ( &ptP == nullptr)
|
|
return false ;
|
|
return pScene->GetGraphicSnapPoint( nSnap, Point3d( nWinX, nWinY), nSelW, nSelH, ptP) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetGridSnapPointZ( bool bSketch, int nWinX, int nWinY, const Point3d& ptGrid, Point3d& ptP)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// trovo il punto snap da griglia con elevazione in Z
|
|
if ( &ptP == nullptr)
|
|
return false ;
|
|
return pScene->GetGridSnapPointZ( bSketch, Point3d( nWinX, nWinY), ptGrid, ptP) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetLastSnapId( void)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, GDB_ID_NULL)
|
|
// restituisco Id di ultima entità generatrice di punto snap
|
|
return pScene->GetLastSnapId() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetLastSnapDir( Vector3d& vtV)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// restituisco, se definita, direzione associata ad ultimo punto di snap
|
|
if ( &vtV == nullptr)
|
|
return false ;
|
|
return pScene->GetLastSnapDir( vtV) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetPlaneSnapPoint( int nWinX, int nWinY, const Plane3d& Plane, Point3d& ptP)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// trovo il punto snap da piano indicato
|
|
if ( &ptP == nullptr)
|
|
return false ;
|
|
return pScene->GetPlaneSnapPoint( Point3d( nWinX, nWinY), Plane, ptP) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetShowMode( int nShowMode, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto il modo di visualizzazione
|
|
if ( nShowMode >= SM_WIREFRAME && nShowMode <= SM_SHADING) {
|
|
pScene->SetShowMode( nShowMode) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
else
|
|
return false ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetShowMode( void)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, SM_WIREFRAME)
|
|
// recupero il modo di visualizzazione
|
|
return pScene->GetShowMode() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetShowCurveDirection( bool bShow, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto stato
|
|
pScene->SetShowCurveDirection( bShow) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetShowCurveDirection( void)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// recupero lo stato
|
|
return pScene->GetShowCurveDirection() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetShowTriaAdv( bool bAdvanced, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto stato
|
|
pScene->SetShowTriaAdvanced( bAdvanced) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetShowTriaAdv( void)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// recupero lo stato
|
|
return pScene->GetShowTriaAdvanced() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetShowZmap( int nMode, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto stato
|
|
pScene->SetShowZmap( nMode) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return TRUE ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetShowZmap( void)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// recupero lo stato
|
|
return pScene->GetShowZmap() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeZoomRadius( double dRadius, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// eseguo lo zoom
|
|
pScene->ZoomRadius( dRadius) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeZoom( int nZoom, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
|
|
const double COEFF_IN = 0.5 ;
|
|
const double COEFF_OUT = 1 / COEFF_IN ;
|
|
|
|
switch ( nZoom) {
|
|
case ZM_ALL :
|
|
pScene->ZoomAll() ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
break ;
|
|
case ZM_IN :
|
|
pScene->ZoomChange( COEFF_IN) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
break ;
|
|
case ZM_OUT :
|
|
pScene->ZoomChange( COEFF_OUT) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
break ;
|
|
}
|
|
|
|
return false ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeZoomObject( int nId, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// eseguo zoom
|
|
bool bOk = pScene->ZoomObject( nId) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeZoomOnPoint( int nWinX, int nWinY, double dCoeff, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// eseguo zoom
|
|
pScene->ZoomOnPoint( Point3d( nWinX, nWinY), dCoeff) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetGeoLine( const Point3d& ptP1, const Point3d& ptP2, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// disegno linea per distanza o similari
|
|
pScene->SetGeoLine( ptP1, ptP2) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeResetGeoLine( bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// cancello linea per distanza o similari
|
|
pScene->ResetGeoLine() ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetGeoTria( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// disegno triangolo immediato
|
|
pScene->SetGeoTria( ptP1, ptP2, ptP3) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeResetGeoTria( bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// cancello triangolo immediato
|
|
pScene->ResetGeoTria() ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetWinRect( int nPrevX, int nPrevY, int nCurrX, int nCurrY, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// disegno finestra per zoom
|
|
pScene->SetWinRect( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeResetWinRect( bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// cancello finestra per zoom
|
|
pScene->ResetWinRect() ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeZoomWin( int nPrevX, int nPrevY, int nCurrX, int nCurrY, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// eseguo zoom su finestra
|
|
pScene->ZoomWin( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetView( int nDir, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto vista
|
|
if ( nDir >= CT_TOP && nDir <= CT_CPLANE) {
|
|
pScene->SetCamera( nDir) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
else
|
|
return false ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetGenericView( double dAngVertDeg, double dAngHorizDeg, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto vista
|
|
pScene->SetCamera( dAngVertDeg, dAngHorizDeg, 0) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetViewCenter( const Point3d& ptP, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// imposto vista
|
|
pScene->SetCenter( ptP) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExePanView( int nPrevX, int nPrevY, int nCurrX, int nCurrY, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// eseguo panoramica
|
|
pScene->PanCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeRotateView( int nPrevX, int nPrevY, int nCurrX, int nCurrY, bool bRedraw)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// eseguo rotazione camera
|
|
pScene->RotateCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
|
if ( bRedraw)
|
|
pScene->RedrawWindow() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetView( int* pnDir)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// recupero direzione di vista
|
|
if ( pnDir == nullptr)
|
|
return false ;
|
|
*pnDir = pScene->GetCameraDir() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetGenericView( double* pdAngVertDeg, double* pdAngHorizDeg)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// recupero direzione di vista
|
|
if ( pdAngVertDeg == nullptr || pdAngHorizDeg == nullptr)
|
|
return false ;
|
|
pScene->GetCamera( pdAngVertDeg, pdAngHorizDeg) ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetViewUp( Vector3d& vtUp)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// recupero direzione in alto di vista
|
|
if ( &vtUp == nullptr)
|
|
return false ;
|
|
vtUp = pScene->GetCameraUp() ;
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeProjectPoint( const Point3d& ptP, Point3d& ptWin)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// eseguo la proiezione
|
|
if ( &ptWin == nullptr)
|
|
return false ;
|
|
Point3d ptView ;
|
|
return pScene->Project( ptP, ptView) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeUnProjectPoint( int nWinX, int nWinY, Point3d& ptP)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// eseguo l'inverso della proiezione (considero Z punto su centro)
|
|
if ( &ptP == nullptr)
|
|
return false ;
|
|
Point3d ptView( nWinX, nWinY, pScene->GetProjectedCenter().z) ;
|
|
return pScene->UnProject( ptView, ptP) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetTextureMaxLinPixels( int nMaxLinPix)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// lancio il caricamento della texture
|
|
return pScene->SetTextureMaxLinPixels( nMaxLinPix) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
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, nRepeat) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeUnloadTexture( const string& sName)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// lancio lo scaricamento della texture
|
|
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 string& sName, int& nWidth, int& nHeight)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// recupero la dimensione in pixels della texture
|
|
return pScene->GetTexturePixels( sName, nWidth, nHeight) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetTextureImagePixels( const string& sName, int& nWidth, int& nHeight)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// recupero la dimensione in pixels della immagine da cui è derivata la texture
|
|
return pScene->GetTextureImagePixels( sName, nWidth, nHeight) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetTextureDimensions( const string& sName, double& dDimX, double& dDimY)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// recupero la dimensione fisica della texture
|
|
return pScene->GetTextureDimensions( sName, dDimX, dDimY) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeChangeTextureDimensions( const string& sName, double dDimX, double dDimY)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// modifico le dimensioni della texture
|
|
return pScene->ChangeTextureDimensions( sName, dDimX, dDimY) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetImage( int nShowMode, Color colBackTop, Color colBackBottom,
|
|
int nWidth, int nHeight, const string& sFile)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene() ;
|
|
VERIFY_SCENE( pScene, false)
|
|
// creo e salvo una immagine della scena
|
|
return pScene->GetImage( nShowMode, colBackTop, colBackBottom, nWidth, nHeight, sFile) ;
|
|
}
|