EgtGraphics 1.5b3 :

- aggiunto SceExecutor per eseguire file Tsc
- centralizzata gestiopne del logger
- mogliorie varie
This commit is contained in:
Dario Sassi
2014-02-19 11:21:12 +00:00
parent 8560bc5cae
commit 73ee89f9c5
11 changed files with 383 additions and 55 deletions
+20
View File
@@ -0,0 +1,20 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : DllMain.h Data : 17.02.14 Versione : 1.5b3
// Contenuto : Prototipi funzioni per uso locale della DLL.
//
//
//
// Modifiche : 17.02.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EgtILogger.h"
//-----------------------------------------------------------------------------
ILogger* GetEGrLogger( void) ;
+18
View File
@@ -13,6 +13,7 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "/EgtDev/Include/EGrDllMain.h"
#include "/EgtDev/Include/EGnGetModuleVer.h"
#include "/EgtDev/Include/EgtTrace.h"
@@ -65,3 +66,20 @@ GetEGrVersion( void)
return s_szEGrNameVer ;
}
//-----------------------------------------------------------------------------
static ILogger* s_pLogger = nullptr ;
//-----------------------------------------------------------------------------
void
SetEGrLogger( ILogger* pLogger)
{
s_pLogger = pLogger ;
}
//-----------------------------------------------------------------------------
ILogger*
GetEGrLogger( void)
{
return s_pLogger ;
}
BIN
View File
Binary file not shown.
+4
View File
@@ -192,7 +192,10 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClInclude Include="..\Include\EgkObjGraphics.h" />
<ClInclude Include="..\Include\EGkPolyLine.h" />
<ClInclude Include="..\Include\EGrDllMain.h" />
<ClInclude Include="..\Include\EGrSceExecutor.h" />
<ClInclude Include="..\Include\EGrScene.h" />
<ClInclude Include="DllMain.h" />
<ClInclude Include="SceExecutor.h" />
<ClInclude Include="GraphObjs.h" />
<ClInclude Include="ObjEGrGraphics.h" />
<ClInclude Include="ObjNewGraphics.h" />
@@ -204,6 +207,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
</ItemGroup>
<ItemGroup>
<ClCompile Include="EGrDllMain.cpp" />
<ClCompile Include="SceExecutor.cpp" />
<ClCompile Include="ObjNewGraphics.cpp" />
<ClCompile Include="ObjOldGraphics.cpp" />
<ClCompile Include="SceneBasic.cpp" />
+12
View File
@@ -54,6 +54,15 @@
<ClInclude Include="ObjEGrGraphics.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="DllMain.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGrSceExecutor.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="SceExecutor.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
@@ -77,6 +86,9 @@
<ClCompile Include="ObjNewGraphics.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="SceExecutor.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtGraphics.rc">
+222
View File
@@ -0,0 +1,222 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : GraExecutor.cpp Data : 18.02.14 Versione : 1.5b3
// Contenuto : Implementazione della classe GraExecutor.
//
//
//
// Modifiche : 18.02.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "SceExecutor.h"
#include "DllMain.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgrScene.h"
using namespace std ;
//----------------------------------------------------------------------------
ISceExecutor*
CreateSceExecutor( void)
{
return static_cast<ISceExecutor*> ( new SceExecutor) ;
}
//----------------------------------------------------------------------------
SceExecutor::SceExecutor( void)
{
m_pScene = nullptr ;
m_pOtherExec = nullptr ;
}
//----------------------------------------------------------------------------
SceExecutor::~SceExecutor( void)
{
}
//----------------------------------------------------------------------------
bool
SceExecutor::Init( IEGrScene* pScene)
{
m_pScene = pScene ;
return ( m_pScene != nullptr) ;
}
//----------------------------------------------------------------------------
bool
SceExecutor::AddExecutor( ICmdExecutor* pOtherExec)
{
m_pOtherExec = pOtherExec ;
return true ;
}
//----------------------------------------------------------------------------
bool
SceExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR& vsParams)
{
string sOut ;
STRVECTOR::const_iterator theConstIter ;
// output di debug
sOut = " " + sCmd1 ;
if ( ! sCmd2.empty())
sOut += "." + sCmd2 ;
sOut += "( " ;
for ( theConstIter = vsParams.begin() ; theConstIter != vsParams.end() ; ++theConstIter) {
if ( theConstIter != vsParams.begin())
sOut += ", " ;
sOut += *theConstIter ;
}
sOut += ")" ;
LOG_DBG_INFO( GetEGrLogger(), sOut.c_str())
// verifico validita Scene
if ( m_pScene == nullptr) {
LOG_ERROR( GetEGrLogger(), "Error : null Scene.")
return false ;
}
// esecuzione comando
if ( sCmd1 == "PAUSE")
return ExecutePause( sCmd2, vsParams) ;
else if ( sCmd1 == "RD" || sCmd1 == "REDRAW")
return ExecuteRedraw( sCmd2, vsParams) ;
else if ( sCmd1 == "ZM" || sCmd1 == "ZOOM")
return ExecuteZoom( sCmd2, vsParams) ;
else if ( sCmd1 == "CENTER")
return ExecuteCenter( sCmd2, vsParams) ;
else if ( sCmd1 == "CAMERA")
return ExecuteCamera( sCmd2, vsParams) ;
else if ( m_pOtherExec != nullptr)
return m_pOtherExec->Execute( sCmd1, sCmd2, vsParams) ;
return false ;
}
//----------------------------------------------------------------------------
bool
SceExecutor::ExecutePause( const string& sCmd2, const STRVECTOR& vsParams)
{
const int MIN_TIME = 0 ;
const int MAX_TIME = 10000 ;
// 1 parametro : durata della pausa in ms
if ( vsParams.size() != 1)
return false ;
// tempo di attesa
int nTime ;
if ( ! FromString( vsParams[0], nTime))
return false ;
if ( nTime < MIN_TIME)
nTime = MIN_TIME ;
else if ( nTime > MAX_TIME)
nTime = MAX_TIME ;
// eseguo
Sleep( nTime) ;
return true ;
}
//----------------------------------------------------------------------------
bool
SceExecutor::ExecuteRedraw( const string& sCmd2, const STRVECTOR& vsParams)
{
m_pScene->RedrawWindow() ;
return true ;
}
//----------------------------------------------------------------------------
bool
SceExecutor::ExecuteZoom( const string& sCmd2, const STRVECTOR& vsParams)
{
const double COEFF_PLUS = 0.9 ;
const double COEFF_MINUS = 1 / COEFF_PLUS ;
if ( sCmd2 == "ALL")
m_pScene->ZoomAll() ;
else if ( sCmd2 == "PLUS")
m_pScene->ZoomChange( COEFF_PLUS) ;
else if ( sCmd2 == "MINUS")
m_pScene->ZoomChange( COEFF_MINUS) ;
else if ( sCmd2 == "CHANGE") {
// 1 parametro : fattore di zoom
if ( vsParams.size() != 1)
return false ;
// fattore di zoom
double nFactor ;
if ( ! FromString( vsParams[0], nFactor))
return false ;
// eseguo
m_pScene->ZoomChange( nFactor) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
SceExecutor::ExecuteCenter( const string& sCmd2, const STRVECTOR& vsParams)
{
// 3 parametri : le 3 coordinate
if ( vsParams.size() != 3)
return false ;
// recupero le tre coordinate
Point3d ptCen ;
if ( ! FromString( vsParams[0], ptCen.x) ||
! FromString( vsParams[1], ptCen.y) ||
! FromString( vsParams[2], ptCen.z))
return false ;
// eseguo
m_pScene->SetCenter( ptCen) ;
return true ;
}
//----------------------------------------------------------------------------
bool
SceExecutor::ExecuteCamera( const string& sCmd2, const STRVECTOR& vsParams)
{
if ( sCmd2 == "TOP")
m_pScene->SetCamera( CT_TOP) ;
else if ( sCmd2 == "FRONT")
m_pScene->SetCamera( CT_FRONT) ;
else if ( sCmd2 == "RIGHT")
m_pScene->SetCamera( CT_RIGHT) ;
else if ( sCmd2 == "BACK")
m_pScene->SetCamera( CT_BACK) ;
else if ( sCmd2 == "LEFT")
m_pScene->SetCamera( CT_LEFT) ;
else if ( sCmd2 == "BOTTOM")
m_pScene->SetCamera( CT_BOTTOM) ;
else if ( sCmd2 == "ISO_SW")
m_pScene->SetCamera( CT_ISO_SW) ;
else if ( sCmd2 == "ISO_SE")
m_pScene->SetCamera( CT_ISO_SE) ;
else if ( sCmd2 == "ISO_NE")
m_pScene->SetCamera( CT_ISO_NE) ;
else if ( sCmd2 == "ISO_NW")
m_pScene->SetCamera( CT_ISO_NW) ;
else if ( sCmd2.empty() || sCmd2 == "GEN") {
// 2 parametri : i 2 angoli
if ( vsParams.size() != 2)
return false ;
// recupero i due angoli
double dAngVertDeg ;
double dAngOrizzDeg ;
if ( ! FromString( vsParams[0], dAngVertDeg) ||
! FromString( vsParams[1], dAngOrizzDeg))
return false ;
// eseguo
m_pScene->SetCamera( dAngVertDeg, dAngOrizzDeg, 0) ;
}
return true ;
}
+42
View File
@@ -0,0 +1,42 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GraExecutor.h Data : 18.02.14 Versione : 1.5b3
// Contenuto : Dichiarazione della classe GraExecutor.
//
//
//
// Modifiche : 18.02.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EGrSceExecutor.h"
//----------------------------------------------------------------------------
class SceExecutor : public ISceExecutor
{
public :
virtual bool Execute( const std::string& sCmd1, const std::string& sCmd2, const STRVECTOR& vsParams) ;
virtual bool AddExecutor( ICmdExecutor* pOtherExec) ;
virtual bool Init( IEGrScene* pScene) ;
public :
SceExecutor( void) ;
~SceExecutor( void) ;
private :
bool ExecutePause( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteRedraw( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteZoom( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteCenter( const std::string& sCmd2, const STRVECTOR& vsParams) ;
bool ExecuteCamera( const std::string& sCmd2, const STRVECTOR& vsParams) ;
private :
IEGrScene* m_pScene ;
ICmdExecutor* m_pOtherExec ;
} ;
+4 -3
View File
@@ -25,15 +25,16 @@ class Scene : public IEGrScene
public :
// Basic
virtual ~Scene( void) ;
virtual bool Init( IGeomDB* pGeomDB, ILogger* pLogger) ;
virtual bool Init( IGeomDB* pGeomDB) ;
virtual bool CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDepthBits) ;
virtual bool IsValid( void)
{ return ( m_hDC != nullptr && m_hRC != nullptr) ; }
virtual std::string GetOpenGLInfo( void) ;
virtual std::string GetGLSLInfo( void) ;
virtual std::string GetPixelFormatInfo( void) ;
virtual bool Reshape( int nW, int nH) ;
virtual bool RedrawWindow( void) ;
virtual bool SetExtension( const BBox3d& b3Ext) ;
virtual bool Reshape( int nW, int nH) ;
virtual bool Prepare( void) ;
virtual bool Draw( void) ;
virtual bool Project( const Point3d& ptWorld, Point3d& ptView) ;
@@ -73,6 +74,7 @@ class Scene : public IEGrScene
bool AdjustDimView( double dHalfWidth, double dHalfHeight) ;
bool CalcClippingPlanesFromExtView( void) ;
// Camera
bool VerifyCamera( void) ;
bool CalcDirUp( void) ;
// Geometry
bool DrawGroup( int nId) ;
@@ -81,7 +83,6 @@ class Scene : public IEGrScene
private :
IGeomDB* m_pGeomDB ;
ILogger* m_pLogger ;
HDC m_hDC ; // Device Context
HGLRC m_hRC ; // OpenGL Rendering Context
+26 -15
View File
@@ -14,6 +14,7 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "Scene.h"
#include "DllMain.h"
#include "/EgtDev/Include/EgtILogger.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGkFrame3d.h"
@@ -37,7 +38,6 @@ CreateEGrScene( void)
Scene::Scene( void)
{
m_pGeomDB = nullptr ;
m_pLogger = nullptr ;
// Context data
m_hDC = nullptr ;
m_hRC = nullptr ;
@@ -62,10 +62,9 @@ Scene::~Scene( void)
//----------------------------------------------------------------------------
bool
Scene::Init( IGeomDB* pGeomDB, ILogger* pLogger)
Scene::Init( IGeomDB* pGeomDB)
{
m_pGeomDB = pGeomDB ;
m_pLogger = pLogger ;
return true ;
}
@@ -113,7 +112,7 @@ Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDe
WglewInitResult = wglewInit() ;
if ( WglewInitResult != GLEW_OK)
LOG_INFO( m_pLogger, "WGLEW is not initialized !")
LOG_INFO( GetEGrLogger(), "WGLEW is not initialized !")
int attribs[10] ;
if ( nDriver == OD_SOFT) {
@@ -147,7 +146,7 @@ Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDe
else {
//It's not possible to make a GL 3.x context. Use the old style context (GL 2.1 and before)
m_hRC = tempContext ;
LOG_INFO( m_pLogger, "WGL_ARB_create_context missing !")
LOG_INFO( GetEGrLogger(), "WGL_ARB_create_context missing !")
}
// verifico validità Rendering Context
@@ -159,12 +158,12 @@ Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDe
GlewInitResult = glewInit() ;
if ( GlewInitResult != GLEW_OK)
LOG_INFO( m_pLogger, "GLEW is not initialized !")
LOG_INFO( GetEGrLogger(), "GLEW is not initialized !")
// verifico se posso lavorare in modalità nuova
m_bNewWay = ( nDriver == OD_NEW && glewIsSupported( "GL_VERSION_3_0") == 1) ;
if ( ! m_bNewWay)
LOG_INFO( m_pLogger, "OpenGL old way rendering !")
LOG_INFO( GetEGrLogger(), "OpenGL old way rendering !")
// reset stato di errore di OpenGL
glGetError() ;
@@ -310,14 +309,26 @@ Scene::GetPixelFormatInfo( void)
return sInfo ;
}
//----------------------------------------------------------------------------
bool
Scene::RedrawWindow( void)
{
HWND hWnd = ::WindowFromDC( m_hDC) ;
if ( hWnd == nullptr)
return false ;
return ( ::RedrawWindow( hWnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW) != 0) ;
}
//----------------------------------------------------------------------------
bool
Scene::SetExtension( const BBox3d& b3Ext)
{
if ( b3Ext.IsEmpty())
return false ;
m_b3ExtWorld = b3Ext ;
m_b3ExtWorld.Set( -MIN_EXTENSION, -MIN_EXTENSION, -MIN_EXTENSION,
MIN_EXTENSION, MIN_EXTENSION, MIN_EXTENSION) ;
else
m_b3ExtWorld = b3Ext ;
m_bExtViewOk = false ;
return true ;
}
@@ -387,7 +398,7 @@ Scene::AdjustDimView( double dHalfWidth, double dHalfHeight)
GLenum nErr = glGetError() ;
if ( nErr != GL_NO_ERROR) {
string sOut = "First glViewport OpenGL error " + ToString( (int)nErr) ;
LOG_INFO( m_pLogger, sOut.c_str())
LOG_INFO( GetEGrLogger(), sOut.c_str())
}
}
@@ -444,7 +455,7 @@ Scene::Reshape( int nW, int nH)
GLenum nErr = glGetError() ;
if ( nErr != GL_NO_ERROR) {
string sOut = "Reshape OpenGL error " + ToString( (int)nErr) ;
LOG_INFO( m_pLogger, sOut.c_str())
LOG_INFO( GetEGrLogger(), sOut.c_str())
}
// aggiorno
@@ -485,7 +496,7 @@ Scene::Prepare( void)
GLenum nErr = glGetError() ;
if ( nErr != GL_NO_ERROR) {
string sOut = "Prepare OpenGL error " + ToString( (int)nErr) ;
LOG_INFO( m_pLogger, sOut.c_str())
LOG_INFO( GetEGrLogger(), sOut.c_str())
}
return true ;
@@ -512,12 +523,12 @@ Scene::Draw( void)
GLenum nErr = glGetError() ;
if ( nErr != GL_NO_ERROR) {
string sOut = "Draw OpenGL error " + ToString( (int)nErr) ;
LOG_INFO( m_pLogger, sOut.c_str())
LOG_INFO( GetEGrLogger(), sOut.c_str())
}
// scambio i buffer back e front ( eseguita solo se previsti)
if ( ! SwapBuffers( m_hDC))
LOG_INFO( m_pLogger, "Draw SwapBuffers error")
LOG_INFO( GetEGrLogger(), "Draw SwapBuffers error")
return true ;
}
+34 -36
View File
@@ -43,74 +43,72 @@ Scene::SetCamera( double dAngVertDeg, double dAngOrizzDeg, double dDist)
{
// assegno la direzione e la distanza
m_vtDirCamera.FromSpherical( 1, dAngVertDeg, dAngOrizzDeg) ;
if ( dDist < EPS_SMALL)
m_dDistCamera = STD_DIST_CAMERA ;
else
m_dDistCamera = __max( dDist, MIN_DIST_CAMERA) ;
// invalido Up e ExtView
m_bUpOk = false ;
m_bExtViewOk = false ;
// calcolo nuovi dati di Z clipping
CalcClippingPlanesFromExtView() ;
return true ;
m_dDistCamera = dDist ;
return VerifyCamera() ;
}
//----------------------------------------------------------------------------
bool
Scene::SetCamera( int nDir, double dDist)
{
const double ANG_VERT_ISOVIEW = 54.73561032 ;
double dAngVertDeg ;
double dAngOrizzDeg ;
switch ( nDir) {
case CT_TOP :
dAngVertDeg = 0 ;
dAngOrizzDeg = 0 ;
m_vtDirCamera.Set( 0, 0, 1) ;
break ;
case CT_FRONT :
dAngVertDeg = 90 ;
dAngOrizzDeg = -90 ;
m_vtDirCamera.Set( 0, -1, 0) ;
break ;
case CT_RIGHT :
dAngVertDeg = 90 ;
dAngOrizzDeg = 0 ;
m_vtDirCamera.Set( 1, 0, 0) ;
break ;
case CT_BACK :
dAngVertDeg = 90 ;
dAngOrizzDeg = 90 ;
m_vtDirCamera.Set( 0, 1, 0) ;
break ;
case CT_LEFT :
dAngVertDeg = 90 ;
dAngOrizzDeg = 180 ;
m_vtDirCamera.Set( -1, 0, 0) ;
break ;
case CT_BOTTOM :
dAngVertDeg = 180 ;
dAngOrizzDeg = 0 ;
m_vtDirCamera.Set( 0, 0, -1) ;
break ;
case CT_ISO_SW :
dAngVertDeg = ANG_VERT_ISOVIEW ;
dAngOrizzDeg = -135 ;
m_vtDirCamera.Set( - SQRT1_3, - SQRT1_3, SQRT1_3) ;
break ;
case CT_ISO_SE :
dAngVertDeg = ANG_VERT_ISOVIEW ;
dAngOrizzDeg = -45 ;
m_vtDirCamera.Set( SQRT1_3, - SQRT1_3, SQRT1_3) ;
break ;
case CT_ISO_NE :
dAngVertDeg = ANG_VERT_ISOVIEW ;
dAngOrizzDeg = 45 ;
m_vtDirCamera.Set( SQRT1_3, SQRT1_3, SQRT1_3) ;
break ;
case CT_ISO_NW :
dAngVertDeg = ANG_VERT_ISOVIEW ;
dAngOrizzDeg = 135 ;
m_vtDirCamera.Set( - SQRT1_3, SQRT1_3, SQRT1_3) ;
break ;
default :
return false ;
break ;
}
m_dDistCamera = dDist ;
return SetCamera( dAngVertDeg, dAngOrizzDeg, dDist) ;
return VerifyCamera() ;
}
//----------------------------------------------------------------------------
bool
Scene::VerifyCamera( void)
{
// verifico il versore
if ( ! m_vtDirCamera.Normalize())
m_vtDirCamera.Set( 0, 0, 1) ;
// verifico la distanza
if ( m_dDistCamera < EPS_SMALL)
m_dDistCamera = STD_DIST_CAMERA ;
else
m_dDistCamera = __max( m_dDistCamera, MIN_DIST_CAMERA) ;
// invalido Up e ExtView
m_bUpOk = false ;
m_bExtViewOk = false ;
// calcolo nuovi dati di Z clipping
CalcClippingPlanesFromExtView() ;
return true ;
}
//----------------------------------------------------------------------------
+1 -1
View File
@@ -71,7 +71,7 @@ bool
Scene::UpdateExtension( void)
{
BBox3d b3Ext ;
if ( ! m_pGeomDB->GetLocalBBox( GDB_ID_ROOT, b3Ext))
if ( m_pGeomDB == nullptr || ! m_pGeomDB->GetLocalBBox( GDB_ID_ROOT, b3Ext))
return false ;
return SetExtension( b3Ext) ;
}