597cc68124
- sistemate minuscole/maiuscole in #include.
201 lines
6.2 KiB
C++
201 lines
6.2 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2013-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : GraExecutor.cpp Data : 15.04.14 Versione : 1.5d4
|
|
// Contenuto : Implementazione della classe GraExecutor.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 18.02.14 DS Creazione modulo.
|
|
// 15.04.14 DS Agg. ExecuteShowMode.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- 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( nothrow) SceExecutor) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
SceExecutor::SceExecutor( void)
|
|
{
|
|
m_pScene = nullptr ;
|
|
m_pParser = nullptr ;
|
|
// assegno chiavi a funzioni di esecuzione
|
|
m_ExecMgr.Init( 16) ;
|
|
m_ExecMgr.Insert( "RD", &SceExecutor::ExecuteRedraw) ;
|
|
m_ExecMgr.Insert( "REDRAW", &SceExecutor::ExecuteRedraw) ;
|
|
m_ExecMgr.Insert( "ZM", &SceExecutor::ExecuteZoom) ;
|
|
m_ExecMgr.Insert( "ZOOM", &SceExecutor::ExecuteZoom) ;
|
|
m_ExecMgr.Insert( "CENTER", &SceExecutor::ExecuteCenter) ;
|
|
m_ExecMgr.Insert( "CAMERA", &SceExecutor::ExecuteCamera) ;
|
|
m_ExecMgr.Insert( "SM", &SceExecutor::ExecuteShowMode) ;
|
|
m_ExecMgr.Insert( "SHOWMODE", &SceExecutor::ExecuteShowMode) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
SceExecutor::~SceExecutor( void)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
SceExecutor::SetScene( IEGrScene* pScene)
|
|
{
|
|
m_pScene = pScene ;
|
|
|
|
return ( m_pScene != nullptr) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
SceExecutor::SetCmdParser( ICmdParser* pParser)
|
|
{
|
|
m_pParser = pParser ;
|
|
return ( m_pParser != nullptr) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
SceExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR& vsParams)
|
|
{
|
|
// verifico validità Scene
|
|
if ( m_pScene == nullptr) {
|
|
LOG_ERROR( GetEGrLogger(), "Error : null Scene in SceExecutor.")
|
|
return ER_ERR ;
|
|
}
|
|
// verifico validità CmdParser
|
|
if ( m_pParser == nullptr) {
|
|
LOG_ERROR( GetEGrLogger(), "Error : null CmdParser in SceExecutor.")
|
|
return ER_ERR ;
|
|
}
|
|
|
|
// esecuzione comando
|
|
return m_ExecMgr.Execute( *this, sCmd1, sCmd2, vsParams) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
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_IN = 0.9 ;
|
|
const double COEFF_OUT = 1 / COEFF_IN ;
|
|
|
|
if ( sCmd2 == "ALL")
|
|
m_pScene->ZoomAll() ;
|
|
else if ( sCmd2 == "IN")
|
|
m_pScene->ZoomChange( COEFF_IN) ;
|
|
else if ( sCmd2 == "OUT")
|
|
m_pScene->ZoomChange( COEFF_OUT) ;
|
|
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) ;
|
|
}
|
|
else
|
|
return false ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
SceExecutor::ExecuteShowMode( const string& sCmd2, const STRVECTOR& vsParams)
|
|
{
|
|
if ( sCmd2 == "WF" || sCmd2 == "WIREFRTAME")
|
|
m_pScene->SetShowMode( SM_WIREFRAME) ;
|
|
else if ( sCmd2 == "HL" || sCmd2 == "HIDDENLINE")
|
|
m_pScene->SetShowMode( SM_HIDDENLINE) ;
|
|
else if ( sCmd2 == "SH" || sCmd2 == "SHADING")
|
|
m_pScene->SetShowMode( SM_SHADING) ;
|
|
else
|
|
return false ;
|
|
|
|
return true ;
|
|
}
|