EgtExecutor :
- aggiunta funzione exe/lua GetImageEx (per fare bitmap di vista progetto in contesti senza Scene).
This commit is contained in:
+111
-19
@@ -16,11 +16,14 @@
|
||||
#include "EXE.h"
|
||||
#include "EXE_Macro.h"
|
||||
#include "DllGraphics.h"
|
||||
#include "DllMain.h"
|
||||
#include "resource.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <Windowsx.h>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -211,6 +214,31 @@ ExeSetGridColor( Color colMin, Color colMaj)
|
||||
return pScene->SetGridColor( colMin, colMaj) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSetCameraType( bool bOrthoOrPersp, bool bRedraw)
|
||||
{
|
||||
IEGrScene* pScene = GetCurrScene() ;
|
||||
VERIFY_SCENE( pScene, false)
|
||||
pScene->SetCameraType( bOrthoOrPersp) ;
|
||||
if ( bRedraw)
|
||||
pScene->RedrawWindow() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSetZoomType( int nMode, bool bRedraw)
|
||||
{
|
||||
IEGrScene* pScene = GetCurrScene() ;
|
||||
VERIFY_SCENE( pScene, false)
|
||||
if ( ! pScene->SetZoomType( nMode))
|
||||
return false ;
|
||||
if ( bRedraw)
|
||||
pScene->RedrawWindow() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeResize( int nW, int nH)
|
||||
@@ -958,27 +986,91 @@ ExeGetImage( int nShowMode, Color colBackTop, Color colBackBottom,
|
||||
return pScene->GetImage( nShowMode, colBackTop, colBackBottom, nWidth, nHeight, sFile) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSetCameraType( bool bOrthoOrPersp, bool bRedraw)
|
||||
{
|
||||
IEGrScene* pScene = GetCurrScene() ;
|
||||
VERIFY_SCENE( pScene, false)
|
||||
pScene->SetCameraType( bOrthoOrPersp) ;
|
||||
if ( bRedraw)
|
||||
pScene->RedrawWindow() ;
|
||||
return true ;
|
||||
//-------------------------------------------------------------------------------
|
||||
static int s_nContext = 0 ;
|
||||
static int s_nDriver = 3 ;
|
||||
static bool s_b2Buff = true ;
|
||||
static int s_nColorBits = 32 ;
|
||||
static int s_nDepthBits = 24 ;
|
||||
static int s_nShowMode = SM_SHADING ;
|
||||
static Color s_colBackTop = WHITE ;
|
||||
static Color s_colBackBottom = WHITE ;
|
||||
static int s_nCameraDir = CT_TOP ;
|
||||
static int s_nWidth = 1024 ;
|
||||
static int s_nHeight = 1024 ;
|
||||
static string s_sImageFile ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
CALLBACK SceneBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch ( message) {
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
// imposto dimensione box e picture
|
||||
const int WIN_MAX_DIM = 1024 ;
|
||||
int nWinW = ( s_nWidth >= s_nHeight ? WIN_MAX_DIM : ( WIN_MAX_DIM * s_nWidth) / s_nHeight) ;
|
||||
int nWinH = ( s_nHeight >= s_nWidth ? WIN_MAX_DIM : ( WIN_MAX_DIM * s_nHeight) / s_nWidth) ;
|
||||
HWND hPic = GetDlgItem( hwndDlg, IDC_PICTURE1) ;
|
||||
SetWindowPos( hwndDlg, HWND_TOP, 0, 0, nWinW, nWinH, SWP_NOMOVE | SWP_NOREPOSITION) ;
|
||||
SetWindowPos( hPic, HWND_TOP, 0, 0, nWinW, nWinH, SWP_NOMOVE | SWP_NOREPOSITION) ;
|
||||
// imposto scena
|
||||
int nContext = GetIndCurrGseContext() ;
|
||||
GseContext* pGseCtx = GetGseContext( nContext) ;
|
||||
if ( pGseCtx != nullptr && pGseCtx->m_pScene == nullptr) {
|
||||
ExeInitScene( hPic, s_nDriver, s_b2Buff, s_nColorBits, s_nDepthBits) ;
|
||||
if ( pGseCtx->m_pGeomDB != nullptr && pGseCtx->m_pScene != nullptr) {
|
||||
s_nContext = nContext ;
|
||||
pGseCtx->m_pScene->SetCamera( s_nCameraDir) ;
|
||||
pGseCtx->m_pScene->ZoomAll() ;
|
||||
pGseCtx->m_pScene->GetImage( s_nShowMode, s_colBackTop, s_colBackBottom, s_nWidth, s_nHeight, s_sImageFile) ;
|
||||
MyResetGroupObjGraphics( pGseCtx->m_pGeomDB, GDB_ID_ROOT) ;
|
||||
EndDialog( hwndDlg, wParam) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
s_nContext = 0 ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSetZoomType( int nMode, bool bRedraw)
|
||||
ExeGetImageEx( int nDriver, bool b2Buff, int nColorBits, int nDepthBits,
|
||||
int nShowMode, Color colBackTop, Color colBackBottom,
|
||||
int nCameraDir, int nWidth, int nHeight, const string& sFile)
|
||||
{
|
||||
IEGrScene* pScene = GetCurrScene() ;
|
||||
VERIFY_SCENE( pScene, false)
|
||||
if ( ! pScene->SetZoomType( nMode))
|
||||
return false ;
|
||||
if ( bRedraw)
|
||||
pScene->RedrawWindow() ;
|
||||
return true ;
|
||||
// Se il contesto corrente possiede già una scena
|
||||
if ( GetCurrScene() != nullptr) {
|
||||
return ExeGetImage( nShowMode, colBackTop, colBackBottom, nWidth, nHeight, sFile) ;
|
||||
}
|
||||
// altrimenti ne creo una temporanea
|
||||
else {
|
||||
// salvo i parametri
|
||||
s_nDriver = nDriver ;
|
||||
s_b2Buff = b2Buff ;
|
||||
s_nColorBits = nColorBits ;
|
||||
s_nDepthBits = nDepthBits ;
|
||||
s_nShowMode = nShowMode ;
|
||||
s_colBackTop = colBackTop ;
|
||||
s_colBackBottom = colBackBottom ;
|
||||
s_nCameraDir = nCameraDir ;
|
||||
s_nWidth = nWidth ;
|
||||
s_nHeight = nHeight ;
|
||||
s_sImageFile = sFile ;
|
||||
// lancio dialogo
|
||||
HWND hTopWnd = ExeGetMainWindowHandle() ;
|
||||
DialogBox( GetModuleIstance(), MAKEINTRESOURCE( IDD_LUASCENE), hTopWnd, (DLGPROC)SceneBoxProc) ;
|
||||
bool bOk = ( s_nContext != 0) ;
|
||||
// elimino la scena dal contesto
|
||||
GseContext* pGseCtx = GetGseContext( s_nContext) ;
|
||||
if ( pGseCtx != nullptr) {
|
||||
delete pGseCtx->m_pScene ;
|
||||
pGseCtx->m_pScene = nullptr ;
|
||||
}
|
||||
s_nContext = 0 ;
|
||||
return bOk ;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
+4
-4
@@ -30,8 +30,8 @@
|
||||
#include "/EgtDev/Include/EgtIniFile.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#include "Windowsx.h"
|
||||
#include "shlobj.h"
|
||||
#include <Windowsx.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -1330,7 +1330,7 @@ CALLBACK DialogBoxProc( HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam
|
||||
break ;
|
||||
}
|
||||
}
|
||||
// continua di seguito
|
||||
[[fallthrough]] ;
|
||||
case IDCANCEL :
|
||||
EndDialog( hwndDlg, wParam) ;
|
||||
return TRUE ;
|
||||
@@ -1433,11 +1433,11 @@ LuaInstallGeneral( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVerifyKeyOption", LuaVerifyKeyOption) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSetDefaultFont", LuaSetDefaultFont) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetDefaultFont", LuaGetDefaultFont) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtDialogBox", LuaDialogBox) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtWinExec", LuaWinExec) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCloseExe", LuaCloseExe) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCreateMutex", LuaCreateMutex) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtReleaseMutex", LuaReleaseMutex) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtDialogBox", LuaDialogBox) ;
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -322,6 +322,42 @@ LuaGetImage( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetImageEx( lua_State* L)
|
||||
{
|
||||
// 11 argomenti : nDriver, b2Buff, nColorBits, nDepthBits, nShowMode, colBackTop, colBackBottom, nCameraDir, nWidth, nHeight, sFile
|
||||
int nDriver ;
|
||||
LuaCheckParam( L, 1, nDriver)
|
||||
bool b2Buff ;
|
||||
LuaCheckParam( L, 2, b2Buff)
|
||||
int nColorBits ;
|
||||
LuaCheckParam( L, 3, nColorBits)
|
||||
int nDepthBits ;
|
||||
LuaCheckParam( L, 4, nDepthBits)
|
||||
int nShowMode ;
|
||||
LuaCheckParam( L, 5, nShowMode)
|
||||
Color colBackTop ;
|
||||
LuaCheckParam( L, 6, colBackTop)
|
||||
Color colBackBottom ;
|
||||
LuaCheckParam( L, 7, colBackBottom)
|
||||
int nCameraDir ;
|
||||
LuaCheckParam( L, 8, nCameraDir)
|
||||
int nWidth ;
|
||||
LuaCheckParam( L, 9, nWidth)
|
||||
int nHeight ;
|
||||
LuaCheckParam( L, 10, nHeight)
|
||||
string sFile ;
|
||||
LuaCheckParam( L, 11, sFile)
|
||||
LuaClearStack( L) ;
|
||||
// creo e salvo una immagine della scena
|
||||
bool bOk = ExeGetImageEx( nDriver, b2Buff, nColorBits, nDepthBits, nShowMode,
|
||||
colBackTop, colBackBottom, nCameraDir, nWidth, nHeight, sFile) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallScene( LuaMgr& luaMgr)
|
||||
@@ -344,5 +380,6 @@ LuaInstallScene( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetView", LuaGetView) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetGenericView", LuaGetGenericView) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetImage", LuaGetImage) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetImageEx", LuaGetImageEx) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
+3
-1
@@ -4,6 +4,7 @@
|
||||
//
|
||||
#define VS_VERSION_INFO 1
|
||||
#define IDD_LUADLG 101
|
||||
#define IDD_LUASCENE 102
|
||||
#define IDC_TEXT1 1001
|
||||
#define IDC_TEXT2 1002
|
||||
#define IDC_TEXT3 1003
|
||||
@@ -36,6 +37,7 @@
|
||||
#define IDC_CHECK6 1036
|
||||
#define IDC_CHECK7 1037
|
||||
#define IDC_CHECK8 1038
|
||||
#define IDC_PICTURE1 1041
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
@@ -44,6 +46,6 @@
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1030
|
||||
#define _APS_NEXT_SYMED_VALUE 113
|
||||
#define _APS_NEXT_SYMED_VALUE 115
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user