//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : API_Scene.cpp Data : 01.09.14 Versione : 1.5i1 // Contenuto : Funzioni Scene per API. // // // // Modifiche : 01.09.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EgtStringConverter.h" using namespace std ; //----------------------------------------------------------------------------- BOOL __stdcall EgtInitScene( HWND hWnd, int nDriver, BOOL b2Buff, int nColorBits, int nDepthBits) { return ( ExeInitScene( hWnd, nDriver, ( b2Buff != FALSE), nColorBits, nDepthBits) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetSceneInfo( wchar_t*& wsInfo) { // verifico parametro di ritorno if ( &wsInfo == nullptr) return FALSE ; // recupero le informazioni string sInfo ; if ( ! ExeGetSceneInfo( sInfo)) return FALSE ; // alloco buffer di ritorno ed eseguo copia wsInfo = _wcsdup( stringtoW( sInfo)) ; return (( wsInfo == nullptr) ? FALSE : TRUE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetBackground( const int TopCol[4], const int BottomCol[4], BOOL bRedraw) { return ( ExeSetBackground( Color( TopCol), Color( BottomCol), ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetLineAttribs( int nWidth) { return ( ExeSetLineAttribs( nWidth) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetMarkAttribs( const int MarkCol[4], const int Mark2Col[4]) { return ( ExeSetMarkAttribs( Color( MarkCol), Color( Mark2Col)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetSelSurfAttribs( const int SelSurfCol[4]) { return ( ExeSetSelSurfAttribs( Color( SelSurfCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGeoLineAttribs( const int GlCol[4]) { return ( ExeSetGeoLineAttribs( Color( GlCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGeoTriaAttribs( const int GtCol[4]) { return ( ExeSetGeoTriaAttribs( Color( GtCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetWinRectAttribs( BOOL bOutline, const int WrCol[4]) { return ( ExeSetWinRectAttribs( ( bOutline != FALSE), Color( WrCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGlobFrameShow( BOOL bShow) { return ( ExeSetGlobFrameShow( ( bShow != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGridShow( BOOL bShowGrid, BOOL bShowFrame) { return ( ExeSetGridShow( ( bShowGrid != FALSE), ( bShowFrame != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep) { return ( ExeSetGridGeo( dSnapStep, nMinLineSstep, nMajLineSstep, nExtSstep) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGridGeoAdv( double dSnapStep, int nMinLineSstep, int nMajLineSstep, double dXmin, double dXmax, double dYmin, double dYmax) { return ( ExeSetGridGeoAdv( dSnapStep, nMinLineSstep, nMajLineSstep, dXmin, dXmax, dYmin, dYmax) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGridColor( const int nMinCol[4], const int nMajCol[4]) { return ( ExeSetGridColor( Color( nMinCol), Color( nMajCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResize( int nW, int nH) { return ( ExeResize( nW, nH) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtDraw( void) { return ( ExeDraw() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRedraw( void) { return ( ExeRedraw() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSelect( int nWinX, int nWinY, int nSelW, int nSelH, int* pnSel) { return ( ExeSelect( nWinX, nWinY, nSelW, nSelH, pnSel) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetObjFilterForSelWin( BOOL bZerodim, BOOL bCurve, BOOL bSurf, BOOL bVolume, BOOL bExtra) { return ( ExeSetObjFilterForSelWin( ( bZerodim != FALSE), ( bCurve != FALSE), ( bSurf != FALSE), ( bVolume != FALSE), ( bExtra != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtUnselectableRemove( int nId) { return ( ExeUnselectableRemove( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtUnselectableAdd( int nId) { return ( ExeUnselectableAdd( nId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtUnselectableClearAll( void) { return ( ExeUnselectableClearAll() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetFirstObjInSelWin( void) { return ExeGetFirstObjInSelWin() ; } //----------------------------------------------------------------------------- int __stdcall EgtGetNextObjInSelWin( void) { return ExeGetNextObjInSelWin() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetPointFromSelect( int nSelId, int nWinX, int nWinY, double ptSel[3], int* pnAux) { // verifico parametri di ritorno if ( ptSel == nullptr || pnAux == nullptr) return FALSE ; Point3d ptTmp ; if ( ! ExeGetPointFromSelect( nSelId, nWinX, nWinY, ptTmp, pnAux)) return FALSE ; VEC_FROM_3D( ptSel, ptTmp) return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetGraphicSnapPoint( int nSnap, int nWinX, int nWinY, int nSelW, int nSelH, double ptP[3]) { // verifico parametro di ritorno if ( ptP == nullptr) return FALSE ; Point3d ptSnap ; if ( ! ExeGetGraphicSnapPoint( nSnap, nWinX, nWinY, nSelW, nSelH, ptSnap)) return FALSE ; VEC_FROM_3D( ptP, ptSnap) return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetGridSnapPointZ( BOOL bSketch, int nWinX, int nWinY, const double ptGrid[3], double ptP[3]) { // verifico parametro di ritorno if ( ptP == nullptr) return FALSE ; Point3d ptSnap ; if ( ! ExeGetGridSnapPointZ( ( bSketch != FALSE), nWinX, nWinY, ptGrid, ptSnap)) return FALSE ; VEC_FROM_3D( ptP, ptSnap) return TRUE ; } //----------------------------------------------------------------------------- int __stdcall EgtGetLastSnapId( void) { return ExeGetLastSnapId() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetLastSnapDir( double vtV[3]) { // verifico parametro di ritorno if ( vtV == nullptr) return FALSE ; Vector3d vtDir ; if ( ! ExeGetLastSnapDir( vtDir)) return FALSE ; VEC_FROM_3D( vtV, vtDir) return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetPlaneSnapPoint( int nWinX, int nWinY, const double vtN[3], double dDist, double ptP[3]) { if ( ptP == nullptr) return FALSE ; Plane3d Plane ; Plane.Set( dDist, vtN) ; Point3d ptTmp ; if ( ! ExeGetPlaneSnapPoint( nWinX, nWinY, Plane, ptTmp)) return FALSE ; VEC_FROM_3D( ptP, ptTmp) return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetShowMode( int nShowMode, BOOL bRedraw) { return ( ExeSetShowMode( nShowMode, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetShowMode( void) { return ExeGetShowMode() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetShowCurveDirection( BOOL bShow, BOOL bRedraw) { return ( ExeSetShowCurveDirection( ( bShow != FALSE), ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetShowCurveDirection( void) { return ( ExeGetShowCurveDirection() ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetShowTriaAdv( BOOL bAdvanced, BOOL bRedraw) { return ( ExeSetShowTriaAdv( ( bAdvanced != FALSE), ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetShowTriaAdv( void) { return ( ExeGetShowTriaAdv() ? TRUE : FALSE) ; } //---------------------------------------------------------------------------- BOOL __stdcall EgtSetShowSurfBezierTol( double dLinTol, BOOL bRedraw) { return ( ExeSetShowSurfBezierTol( dLinTol, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- double __stdcall EgtGetShowSurfBezierTol( void) { return ExeGetShowSurfBezierTol() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetShowZmap( int nMode, BOOL bRedraw) { return ( ExeSetShowZmap( nMode, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- int __stdcall EgtGetShowZmap( void) { return ExeGetShowZmap() ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtZoom( int nZoom, BOOL bRedraw) { return ( ExeZoom( nZoom, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtZoomRadius( double dRadius, BOOL bRedraw) { return ( ExeZoomRadius( dRadius, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtZoomObject( int nId, BOOL bRedraw) { return ( ExeZoomObject( nId, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtZoomOnPoint( int nWinX, int nWinY, double dCoeff, BOOL bRedraw) { return ( ExeZoomOnPoint( nWinX, nWinY, dCoeff, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGeoLine( const double ptP1[3], const double ptP2[3], BOOL bRedraw) { return ( ExeSetGeoLine( ptP1, ptP2, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetGeoLine( BOOL bRedraw) { return ( ExeResetGeoLine( ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGeoTria( const double ptP1[3], const double ptP2[3], const double ptP3[3], BOOL bRedraw) { return ( ExeSetGeoTria( ptP1, ptP2, ptP3, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetGeoTria( BOOL bRedraw) { return ( ExeResetGeoTria( ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetWinRect( int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { return ( ExeSetWinRect( nPrevX, nPrevY, nCurrX, nCurrY, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetWinRect( BOOL bRedraw) { return ( ExeResetWinRect( ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtZoomWin( int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { return ( ExeZoomWin( nPrevX, nPrevY, nCurrX, nCurrY, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetView( int nDir, BOOL bRedraw) { return ( ExeSetView( nDir, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGenericView( double dAngVertDeg, double dAngHorizDeg, BOOL bRedraw) { return ( ExeSetGenericView( dAngVertDeg, dAngHorizDeg, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetViewCenter( const double ptP[3], BOOL bRedraw) { return ( ExeSetViewCenter( ptP, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtPanView( int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { return ( ExePanView( nPrevX, nPrevY, nCurrX, nCurrY, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtRotateView( int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { return ( ExeRotateView( nPrevX, nPrevY, nCurrX, nCurrY, ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetView( int* pnDir) { return ( ExeGetView( pnDir) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetGenericView( double* pdAngVertDeg, double* pdAngHorizDeg) { return ( ExeGetGenericView( pdAngVertDeg, pdAngHorizDeg) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetViewUp( double vtUp[3]) { if ( vtUp == nullptr) return FALSE ; Vector3d vtTmp ; if ( ! ExeGetViewUp( vtTmp)) return FALSE ; VEC_FROM_3D( vtUp, vtTmp) return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtProjectPoint( const double ptP[3], double ptWin[3]) { if ( ptWin == nullptr) return FALSE ; Point3d ptView ; if ( ! ExeProjectPoint( ptP, ptView)) return FALSE ; VEC_FROM_3D( ptWin, ptView) return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtUnProjectPoint( int nWinX, int nWinY, double ptP[3]) { if ( ptP == nullptr) return FALSE ; Point3d ptWorld ; if ( ! ExeUnProjectPoint( nWinX, nWinY, ptWorld)) return FALSE ; VEC_FROM_3D( ptP, ptWorld) return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetTextureMaxLinPixels( int nMaxLinPix) { return ( ExeSetTextureMaxLinPixels( nMaxLinPix) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtLoadTexture( const wchar_t* wsName, const wchar_t* wsFile, double dMMxPix, double dDimX, double dDimY, int nRepeat) { return ( ExeLoadTexture( wstrztoA( wsName), wstrztoA( wsFile), dMMxPix, dDimX, dDimY, nRepeat) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtUnloadTexture( const wchar_t* wsName) { return ( ExeUnloadTexture( wstrztoA( wsName)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetTexturePixels( const wchar_t* wsName, int* pnWidth, int* pnHeight) { int nWidth, nHeight ; if ( ! ExeGetTexturePixels( wstrztoA( wsName), nWidth, nHeight)) return FALSE ; if ( pnWidth != nullptr) *pnWidth = nWidth ; if ( pnHeight != nullptr) *pnHeight = nHeight ; return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetTextureImagePixels( const wchar_t* wsName, int* pnWidth, int* pnHeight) { int nWidth, nHeight ; if ( ! ExeGetTextureImagePixels( wstrztoA( wsName), nWidth, nHeight)) return FALSE ; if ( pnWidth != nullptr) *pnWidth = nWidth ; if ( pnHeight != nullptr) *pnHeight = nHeight ; return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetTextureDimensions( const wchar_t* wsName, double* pdDimX, double* pdDimY) { double dDimX, dDimY ; if ( ! ExeGetTextureDimensions( wstrztoA( wsName), dDimX, dDimY)) return FALSE ; if ( pdDimX != nullptr) *pdDimX = dDimX ; if ( pdDimY != nullptr) *pdDimY = dDimY ; return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtChangeTextureDimensions( const wchar_t* wsName, double dDimX, double dDimY) { return ( ExeChangeTextureDimensions( wstrztoA( wsName), dDimX, dDimY) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetImage( int nShowMode, const int TopCol[4], const int BottomCol[4], int nWidth, int nHeight, const wchar_t* wsName) { return ( ExeGetImage( nShowMode, Color( TopCol), Color( BottomCol), nWidth, nHeight, wstrztoA( wsName)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetCameraType( BOOL bOrthoOrPersp, BOOL bRedraw) { return ( ExeSetCameraType( ( bOrthoOrPersp != FALSE), ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetZoomType( int nZoomType, BOOL bRedraw) { return ( ExeSetZoomType( nZoomType, ( bRedraw != FALSE)) ? TRUE : FALSE) ; }