EgtInterface 1.5i2 :

- estensione e razionalizzazione della interfaccia.
This commit is contained in:
Dario Sassi
2014-09-04 12:33:41 +00:00
parent 0e4a7397e8
commit 71254e1c04
12 changed files with 637 additions and 227 deletions
+30 -92
View File
@@ -14,6 +14,7 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "API.h"
#include "API_Macro.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -24,17 +25,11 @@ using namespace std ;
BOOL
__stdcall EgtInitScene( int nGseCtx, HWND hWnd, int nDriver, int b2Buff, int nColorBits, int nDepthBits)
{
// recupero il contesto
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
// verifico GeomDB
if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) {
LOG_ERROR( GetLogger(), "GeomDB invalid (EgtInitScene)")
return FALSE ;
}
VERIFY_CTX_GEOMDB( pGseCtx, FALSE)
// inizializzazione scena OpenGL
PtrOwner<IEGrScene> pScene( CreateEGrScene()) ;
if ( IsNull( pScene))
return FALSE ;
VERIFY_NULL( Get( pScene), "Error in CreateEGrScene", FALSE)
HDC hdc = GetDC( hWnd) ;
if ( ! pScene->CreateContext( hdc, nDriver, ( b2Buff != 0), nColorBits, nDepthBits))
return FALSE ;
@@ -61,17 +56,15 @@ __stdcall EgtInitScene( int nGseCtx, HWND hWnd, int nDriver, int b2Buff, int nCo
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetBackground( int nGseCtx, int nTopRed, int nTopGreen, int nTopBlue,
int nBottomRed, int nBottomGreen, int nBottomBlue)
int nBottomRed, int nBottomGreen, int nBottomBlue, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtSetBackground)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// imposto lo sfondo
pGseCtx->m_pScene->SetBackground( Color( nTopRed, nTopGreen, nTopBlue),
Color( nBottomRed, nBottomGreen, nBottomBlue)) ;
if ( bRedraw)
RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ;
return TRUE ;
}
@@ -79,12 +72,8 @@ __stdcall EgtSetBackground( int nGseCtx, int nTopRed, int nTopGreen, int nTopBlu
BOOL
__stdcall EgtDraw( int nGseCtx)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtDraw)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// eseguo disegno
pGseCtx->m_pScene->Draw() ;
// valido la finestra disegnata
@@ -97,14 +86,10 @@ __stdcall EgtDraw( int nGseCtx)
BOOL
__stdcall EgtResize( int nGseCtx, int nW, int nH)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtResize)")
return FALSE ;
}
IEGrScene* pScene = GetScene( nGseCtx) ;
VERIFY_SCENE( pScene, FALSE)
// eseguo resize
pGseCtx->m_pScene->Resize( nW, nH) ;
pScene->Resize( nW, nH) ;
return TRUE ;
}
@@ -112,12 +97,8 @@ __stdcall EgtResize( int nGseCtx, int nW, int nH)
BOOL
__stdcall EgtSetShowMode( int nGseCtx, int nShowMode, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtSetShowMode)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// imposto il modo di visualizzazione
if ( nShowMode >= SM_WIREFRAME && nShowMode <= SM_SHADING) {
pGseCtx->m_pScene->SetShowMode( nShowMode) ;
@@ -133,12 +114,8 @@ __stdcall EgtSetShowMode( int nGseCtx, int nShowMode, BOOL bRedraw)
BOOL
__stdcall EgtSetShowCurveDirection( int nGseCtx, int nShow, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtSetShowCurveDirection)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// imposto stato
pGseCtx->m_pScene->SetShowCurveDirection( nShow != 0) ;
if ( bRedraw)
@@ -150,12 +127,8 @@ __stdcall EgtSetShowCurveDirection( int nGseCtx, int nShow, BOOL bRedraw)
BOOL
__stdcall EgtZoom( int nGseCtx, int nZoom, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtZoom)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
const double COEFF_IN = 0.9 ;
const double COEFF_OUT = 1 / COEFF_IN ;
@@ -188,12 +161,8 @@ __stdcall EgtZoom( int nGseCtx, int nZoom, BOOL bRedraw)
BOOL
__stdcall EgtZoomOnPoint( int nGseCtx, int nWinX, int nWinY, double dCoeff, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtZoomOnPoint)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// eseguo zoom
pGseCtx->m_pScene->ZoomOnPoint( Point3d( nWinX, nWinY), dCoeff) ;
if ( bRedraw)
@@ -205,12 +174,8 @@ __stdcall EgtZoomOnPoint( int nGseCtx, int nWinX, int nWinY, double dCoeff, BOOL
BOOL
__stdcall EgtSetWinRect( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtSetWinRect)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// disegno finestra per zoom
pGseCtx->m_pScene->SetWinRect( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
if ( bRedraw)
@@ -222,12 +187,8 @@ __stdcall EgtSetWinRect( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nC
BOOL
__stdcall EgtResetWinRect( int nGseCtx, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtResetWinRect)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// cancello finestra per zoom
pGseCtx->m_pScene->ResetWinRect() ;
if ( bRedraw)
@@ -239,12 +200,8 @@ __stdcall EgtResetWinRect( int nGseCtx, BOOL bRedraw)
BOOL
__stdcall EgtZoomWin( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtZoomWin)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// eseguo zoom su finestra
pGseCtx->m_pScene->ZoomWin( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
if ( bRedraw)
@@ -256,12 +213,8 @@ __stdcall EgtZoomWin( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurr
BOOL
__stdcall EgtSetView( int nGseCtx, int nView, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtSetView)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// imposto vista
if ( nView >= CT_TOP && nView <= CT_ISO_NW) {
pGseCtx->m_pScene->SetCamera( nView) ;
@@ -277,12 +230,8 @@ __stdcall EgtSetView( int nGseCtx, int nView, BOOL bRedraw)
BOOL
__stdcall EgtPanCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtPanCamera)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// eseguo panoramica
pGseCtx->m_pScene->PanCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
if ( bRedraw)
@@ -294,12 +243,8 @@ __stdcall EgtPanCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCu
BOOL
__stdcall EgtRotateCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtRotateCamera)")
return FALSE ;
}
VERIFY_CTX_SCENE( pGseCtx, FALSE)
// eseguo rotazione camera
pGseCtx->m_pScene->RotateCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
if ( bRedraw)
@@ -311,15 +256,12 @@ __stdcall EgtRotateCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int
BOOL
__stdcall EgtGetCameraDir( int nGseCtx, int* pnDir)
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtGetCameraDir)")
return FALSE ;
}
IEGrScene* pScene = GetScene( nGseCtx) ;
VERIFY_SCENE( pScene, FALSE)
// recupero direzione di vista
if ( pnDir != nullptr)
*pnDir = pGseCtx->m_pScene->GetCameraDir() ;
if ( pnDir == nullptr)
return FALSE ;
*pnDir = pScene->GetCameraDir() ;
return TRUE ;
}
@@ -327,16 +269,12 @@ __stdcall EgtGetCameraDir( int nGseCtx, int* pnDir)
BOOL
__stdcall EgtUnProjectPoint( int nGseCtx, int nWinX, int nWinY, double ptP[3])
{
// verifico Scena
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) {
LOG_ERROR( GetLogger(), "Scene invalid (EgtUnProjectPoint)")
return FALSE ;
}
IEGrScene* pScene = GetScene( nGseCtx) ;
VERIFY_SCENE( pScene, FALSE)
// eseguo l'inverso della proiezione (considero Z punto su centro)
Point3d ptView( nWinX, nWinY, pGseCtx->m_pScene->GetProjectedCenter().z) ;
Point3d ptView( nWinX, nWinY, pScene->GetProjectedCenter().z) ;
Point3d ptWorld ;
if ( ! pGseCtx->m_pScene->UnProject( ptView, ptWorld))
if ( ! pScene->UnProject( ptView, ptWorld))
return 0 ;
ptP[0] = ptWorld.x ;
ptP[1] = ptWorld.y ;