EgtInterface.cpp :
- aggiornamento per sorgenti eliminati.
This commit is contained in:
@@ -1,88 +0,0 @@
|
||||
// EgtInterface.cpp: definisce le funzioni esportate per l'applicazione DLL.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include <string>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
double
|
||||
__stdcall Summ( double dA, double dB)
|
||||
{
|
||||
return ( dA + dB) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall Summ2( double& dA, double dB)
|
||||
{
|
||||
dA += dB ;
|
||||
bool bOk = false ;
|
||||
return ( bOk ? 1 : 0) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall Append( const wchar_t* wsA, wchar_t*& wsB)
|
||||
{
|
||||
wstring wsMy = wsA + wstring( L"_dalC++") ;
|
||||
wsB = _wcsdup( wsMy.c_str()) ;
|
||||
return (( wsB == nullptr) ? 0 : 1) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall FreeMemory( void* pMem)
|
||||
{
|
||||
if ( pMem == nullptr)
|
||||
return 0 ;
|
||||
free( pMem) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall SetPoint( double ptP[3])
|
||||
{
|
||||
ptP[0] += 10 ;
|
||||
ptP[1] += 20 ;
|
||||
ptP[2] += 30 ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall OutText( HWND hWnd, const wchar_t* wsA)
|
||||
{
|
||||
SetWindowText( hWnd, wsA) ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall DrawCross( HWND hWnd, int nX, int nY, int nDim)
|
||||
{
|
||||
RECT rc ;
|
||||
GetClientRect( hWnd, &rc) ;
|
||||
|
||||
HDC hdc = GetDC( hWnd) ;
|
||||
|
||||
HGDIOBJ hPen = CreatePen( PS_SOLID, 1, RGB( 255,0,0)) ;
|
||||
HGDIOBJ hPenOld = SelectObject( hdc, hPen) ;
|
||||
|
||||
MoveToEx( hdc, nX - nDim, nY, (LPPOINT) NULL) ;
|
||||
LineTo( hdc, nX + nDim, nY);
|
||||
MoveToEx( hdc, nX, nY - nDim, (LPPOINT) NULL) ;
|
||||
LineTo( hdc, nX, nY + nDim);
|
||||
|
||||
SelectObject( hdc, hPenOld) ;
|
||||
DeleteObject( hPen) ;
|
||||
|
||||
ReleaseDC( hWnd, hdc) ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
-560
@@ -1,560 +0,0 @@
|
||||
// Interface.cpp: definisce le funzioni esportate per l'applicazione DLL.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EInDllMain.h"
|
||||
#include "/EgtDev/Include/EGkDllMain.h"
|
||||
#include "/EgtDev/Include/ENkDllMain.h"
|
||||
#include "/EgtDev/Include/EGnDllMain.h"
|
||||
#include "/EgtDev/Include/EExDllMain.h"
|
||||
#include "/EgtDev/Include/EGrDllMain.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EExImportStl.h"
|
||||
#include "/EgtDev/Include/EExImportDxf.h"
|
||||
#include "/EgtDev/Include/EExExportStl.h"
|
||||
#include "/EgtDev/Include/EExExportDxf.h"
|
||||
#include "/EgtDev/Include/EGrScene.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtLogger.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <fstream>
|
||||
|
||||
using namespace std ;
|
||||
using namespace egtlogger ;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static Logger* s_pLogGen = nullptr ;
|
||||
static IGeomDB* s_pGeomDB = nullptr ;
|
||||
static HWND s_hWnd = nullptr ;
|
||||
static IEGrScene* s_pScene = nullptr ;
|
||||
static Color s_colDef = BLACK ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtInitGeomDB( void)
|
||||
{
|
||||
// inizializzazioni DB geometrico
|
||||
s_pGeomDB = CreateGeomDB() ;
|
||||
if ( s_pGeomDB == nullptr)
|
||||
return 0 ;
|
||||
s_pGeomDB->Init() ;
|
||||
s_pGeomDB->SetDefaultMaterial( s_colDef) ;
|
||||
|
||||
// log avvio DB geometrico
|
||||
LOG_INFO( s_pLogGen, "GeomDB started")
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtSetFont( const wchar_t* sNfeFontDir, const wchar_t* sDefaultFont)
|
||||
{
|
||||
// inizializzazioni gestore font Nfe
|
||||
InitFontManager( LPSTR( WtoA( sNfeFontDir)), LPSTR( WtoA( sDefaultFont))) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtInitScene( HWND hWnd, int nDriver, int b2Buff, int nColorBits, int nDepthBits)
|
||||
{
|
||||
// verifico GeomDB
|
||||
if ( s_pGeomDB == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "GeomDB invalid (EgtInitScene)")
|
||||
return 0 ;
|
||||
}
|
||||
// inizializzazione scena OpenGL
|
||||
s_pScene = CreateEGrScene() ;
|
||||
if ( s_pScene == nullptr)
|
||||
return 0 ;
|
||||
s_hWnd = hWnd ;
|
||||
HDC hdc = GetDC( hWnd) ;
|
||||
if ( ! s_pScene->CreateContext( hdc, nDriver, ( b2Buff != 0), nColorBits, nDepthBits))
|
||||
return 0 ;
|
||||
s_pScene->SetBackground( WHITE, WHITE) ;
|
||||
s_pScene->SetShowMode( SM_SHADING) ;
|
||||
s_pScene->SetShowCurveDirection( false) ;
|
||||
s_pScene->SetCamera( CT_TOP) ;
|
||||
s_pScene->ZoomAll() ;
|
||||
s_pScene->SetWinRectAttribs( true, BLACK) ;
|
||||
s_pScene->SetMark( YELLOW) ;
|
||||
s_pScene->Init( s_pGeomDB) ;
|
||||
// log con info sulla scena
|
||||
string sSceneInfo = s_pScene->GetOpenGLInfo() + '\n' +
|
||||
s_pScene->GetGLSLInfo() + '\n' +
|
||||
s_pScene->GetPixelFormatInfo() ;
|
||||
LOG_INFO( s_pLogGen, sSceneInfo.c_str())
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtInitTscExec( void)
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtExit( void)
|
||||
{
|
||||
// fine programma
|
||||
LOG_DATETIME( s_pLogGen, " Exit")
|
||||
|
||||
// scena
|
||||
if ( s_pScene != nullptr) {
|
||||
s_pScene->Destroy() ;
|
||||
delete s_pScene ;
|
||||
s_pScene = nullptr ;
|
||||
}
|
||||
s_hWnd = nullptr ;
|
||||
// geomDB
|
||||
if ( s_pGeomDB != nullptr) {
|
||||
delete s_pGeomDB ;
|
||||
s_pGeomDB = nullptr ;
|
||||
}
|
||||
// logger
|
||||
if ( s_pLogGen != nullptr) {
|
||||
delete s_pLogGen ;
|
||||
s_pLogGen = nullptr ;
|
||||
}
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtSetDefaultMaterial( int nRed, int nGreen, int nBlue)
|
||||
{
|
||||
// verifico GeomDB
|
||||
if ( s_pGeomDB == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "GeomDB invalid (EgtSetDefaultMaterial)")
|
||||
return 0 ;
|
||||
}
|
||||
// imposto il materiale di default
|
||||
s_colDef.Set( nRed, nGreen, nBlue) ;
|
||||
s_pGeomDB->SetDefaultMaterial( s_colDef) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtSetBackground( int nTopRed, int nTopGreen, int nTopBlue,
|
||||
int nBottomRed, int nBottomGreen, int nBottomBlue)
|
||||
{
|
||||
// verifico GeomDB
|
||||
if ( s_pGeomDB == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "GeomDB invalid (EgtSetDefaultMaterial)")
|
||||
return 0 ;
|
||||
}
|
||||
// imposto lo sfondo
|
||||
s_pScene->SetBackground( Color( nTopRed, nTopGreen, nTopBlue), Color( nBottomRed, nBottomGreen, nBottomBlue)) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtNewFile( void)
|
||||
{
|
||||
// verifico GeomDB
|
||||
if ( s_pGeomDB == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "GeomDB invalid (EgtNewFile)")
|
||||
return 0 ;
|
||||
}
|
||||
// reinizializzazione (con pulizia) del DB geometrico
|
||||
s_pGeomDB->Init() ;
|
||||
s_pGeomDB->SetDefaultMaterial( s_colDef) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtOpenFile( const wchar_t* sFilePath)
|
||||
{
|
||||
// reinizializzazione (con pulizia) del DB geometrico
|
||||
if ( ! EgtNewFile())
|
||||
return 0 ;
|
||||
// carico il file
|
||||
if ( s_pGeomDB->Load( LPSTR( WtoA( sFilePath))))
|
||||
return 1 ;
|
||||
else
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtSaveFile( const wchar_t* sFilePath, int nFlag)
|
||||
{
|
||||
// verifico GeomDB
|
||||
if ( s_pGeomDB == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "GeomDB invalid (EgtSaveFile)")
|
||||
return 0 ;
|
||||
}
|
||||
// salvo il file
|
||||
if ( s_pGeomDB->Save( LPSTR( WtoA( sFilePath)), nFlag))
|
||||
return 1 ;
|
||||
else
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtGetFileType( const wchar_t* sFilePath)
|
||||
{
|
||||
// divido in nome e direttorio
|
||||
string sFileDir, sFileName ;
|
||||
SplitLast( LPSTR( WtoA( sFilePath)), "\\", sFileDir, sFileName) ;
|
||||
|
||||
// recupero l'estensione
|
||||
string sFileTitle, sFileExt ;
|
||||
SplitLast( sFileName, ".", sFileTitle, sFileExt) ;
|
||||
ToUpper( sFileExt) ;
|
||||
|
||||
if ( sFileExt == "NGE")
|
||||
return 1 ;
|
||||
else if ( sFileExt == "NFE")
|
||||
return 2 ;
|
||||
else if ( sFileExt == "DXF")
|
||||
return 11 ;
|
||||
else if ( sFileExt == "STL")
|
||||
return 12 ;
|
||||
else {
|
||||
// emetto info
|
||||
string sInfo = "File type (" + sFileExt + ") not recognized" ;
|
||||
LOG_INFO( s_pLogGen, sInfo.c_str())
|
||||
return 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtImportDxf( const wchar_t* sFilePath)
|
||||
{
|
||||
// verifico GeomDB
|
||||
if ( s_pGeomDB == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "GeomDB invalid (ImportFile)")
|
||||
return 0 ;
|
||||
}
|
||||
// importo il file DXF
|
||||
// aggiungo un gruppo pezzo
|
||||
int nPartId = s_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
||||
// preparo l'importatore
|
||||
PtrOwner<IImportDxf> pImpDxf( CreateImportDxf()) ;
|
||||
if ( IsNull( pImpDxf)) {
|
||||
LOG_ERROR( s_pLogGen, "Error : CreateImportDxf")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo l'importazione
|
||||
if ( pImpDxf->Import( LPSTR( WtoA( sFilePath)), s_pGeomDB, nPartId))
|
||||
return 1 ;
|
||||
else
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtImportStl( const wchar_t* sFilePath)
|
||||
{
|
||||
// verifico GeomDB
|
||||
if ( s_pGeomDB == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "GeomDB invalid (EgtImportStl)")
|
||||
return 0 ;
|
||||
}
|
||||
// importo il file STL
|
||||
// aggiungo un gruppo pezzo e un gruppo layer
|
||||
int nPartId = s_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
||||
int nLayerId = s_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ;
|
||||
// preparo l'importatore
|
||||
PtrOwner<IImportStl> pImpStl( CreateImportStl()) ;
|
||||
if ( IsNull( pImpStl)) {
|
||||
LOG_ERROR( s_pLogGen, "Error : CreateImportStl")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo l'importazione
|
||||
if ( pImpStl->Import( LPSTR( WtoA( sFilePath)), s_pGeomDB, nLayerId))
|
||||
return 1 ;
|
||||
else
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtExportDxf( int nId, const wchar_t* sFilePath)
|
||||
{
|
||||
// verifico GeomDB
|
||||
if ( s_pGeomDB == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "GeomDB invalid (ImportFile)")
|
||||
return 0 ;
|
||||
}
|
||||
// esporto il file DXF
|
||||
// preparo l'esportatore
|
||||
PtrOwner<IExportDxf> pExpDxf( CreateExportDxf()) ;
|
||||
if ( IsNull( pExpDxf)) {
|
||||
LOG_ERROR( s_pLogGen, "Error : CreateExportDxf")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo l'esportazione
|
||||
if ( pExpDxf->Export( s_pGeomDB, nId, LPSTR( WtoA( sFilePath))))
|
||||
return 1 ;
|
||||
else
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtExportStl( int nId, const wchar_t* sFilePath)
|
||||
{
|
||||
// verifico GeomDB
|
||||
if ( s_pGeomDB == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "GeomDB invalid (ImportFile)")
|
||||
return 0 ;
|
||||
}
|
||||
// esporto il file STL
|
||||
// preparo l'esportatore
|
||||
PtrOwner<IExportStl> pExpStl( CreateExportStl()) ;
|
||||
if ( IsNull( pExpStl)) {
|
||||
LOG_ERROR( s_pLogGen, "Error : CreateExportStl")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo l'esportazione
|
||||
if ( pExpStl->Export( s_pGeomDB, nId, LPSTR( WtoA( sFilePath))))
|
||||
return 1 ;
|
||||
else
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtDraw( void)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtDraw)")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo disegno
|
||||
s_pScene->Draw() ;
|
||||
// valido la finestra disegnata
|
||||
ValidateRgn( s_hWnd, NULL) ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtResize( int nW, int nH)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtResize)")
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
s_pScene->Resize( nW, nH) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtSetShowMode( int nShowMode)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtSetShowMode)")
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
if ( nShowMode >= SM_WIREFRAME && nShowMode <= SM_SHADING) {
|
||||
s_pScene->SetShowMode( nShowMode) ;
|
||||
return 1 ;
|
||||
}
|
||||
else
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtSetShowCurveDirection( int nShow)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtZoom)")
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
s_pScene->SetShowCurveDirection( nShow != 0) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtZoom( int nZoom)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtZoom)")
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
const double COEFF_IN = 0.9 ;
|
||||
const double COEFF_OUT = 1 / COEFF_IN ;
|
||||
|
||||
switch ( nZoom) {
|
||||
case 1 :
|
||||
s_pScene->ZoomAll() ;
|
||||
return 1 ;
|
||||
break ;
|
||||
case 2 :
|
||||
s_pScene->ZoomChange( COEFF_IN) ;
|
||||
return 1 ;
|
||||
break ;
|
||||
case 3 :
|
||||
s_pScene->ZoomChange( COEFF_OUT) ;
|
||||
return 1 ;
|
||||
break ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtZoomOnPoint( int nWinX, int nWinY, double dCoeff)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtZoomOnPoint)")
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
s_pScene->ZoomOnPoint( Point3d( nWinX, nWinY), dCoeff) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtSetWinRect( int nPrevX, int nPrevY, int nCurrX, int nCurrY)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtSetWinRect)")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo panoramica
|
||||
s_pScene->SetWinRect( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtResetWinRect( void)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtResetWinRect)")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo panoramica
|
||||
s_pScene->ResetWinRect() ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtZoomWin( int nPrevX, int nPrevY, int nCurrX, int nCurrY)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtZoomWin)")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo panoramica
|
||||
s_pScene->ZoomWin( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtSetView( int nView)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtSetView)")
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
if ( nView >= CT_TOP && nView <= CT_ISO_NW) {
|
||||
s_pScene->SetCamera( nView) ;
|
||||
return 1 ;
|
||||
}
|
||||
else
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtPanCamera( int nPrevX, int nPrevY, int nCurrX, int nCurrY)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtPanCamera)")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo panoramica
|
||||
s_pScene->PanCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtRotateCamera( int nPrevX, int nPrevY, int nCurrX, int nCurrY)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtRotateCamera)")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo panoramica
|
||||
s_pScene->RotateCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtGetCameraDir( int* pnDir)
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtGetCameraDir)")
|
||||
return 0 ;
|
||||
}
|
||||
// recupero direzione di vista
|
||||
if ( pnDir != nullptr)
|
||||
*pnDir = s_pScene->GetCameraDir() ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtUnProject( int nWinX, int nWinY, double ptP[3])
|
||||
{
|
||||
// verifico Scena
|
||||
if ( s_pScene == nullptr) {
|
||||
LOG_ERROR( s_pLogGen, "Scene invalid (EgtGetCameraDir)")
|
||||
return 0 ;
|
||||
}
|
||||
// eseguo l'inverso della proiezione (considero Z punto su centro)
|
||||
Point3d ptView( nWinX, nWinY, s_pScene->GetProjectedCenter().z) ;
|
||||
Point3d ptWorld ;
|
||||
if ( ! s_pScene->UnProject( ptView, ptWorld))
|
||||
return 0 ;
|
||||
ptP[0] = ptWorld.x ;
|
||||
ptP[1] = ptWorld.y ;
|
||||
ptP[2] = ptWorld.z ;
|
||||
return 1 ;
|
||||
}
|
||||
Reference in New Issue
Block a user