EgtInterface 1.5h1 :

- primo commit.
This commit is contained in:
Dario Sassi
2014-08-31 10:24:17 +00:00
parent f0ec4bd7d2
commit 2c4de5c4f4
10 changed files with 980 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : EInDllMain.cpp Data : 26.08.14 Versione : 1.5h1
// Contenuto : Inizializzazione della DLL.
//
//
//
// Modifiche : 26.08.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "/EgtDev/Include/EInDllMain.h"
#include "/EgtDev/Include/EGnGetModuleVer.h"
#include "/EgtDev/Include/EgtTrace.h"
//--------------------------- Costanti ----------------------------------------
#if defined( _WIN64)
#if defined( _DEBUG)
const char* EIN_STR = "EgtInterfaceD64.dll ver. " ;
#else
const char* EIN_STR = "EgtInterfaceR64.dll ver. " ;
#endif
#elif defined( _WIN32)
#if defined( _DEBUG)
const char* EIN_STR = "EgtInterfaceD32.dll ver. " ;
#else
const char* EIN_STR = "EgtInterfaceR32.dll ver. " ;
#endif
#endif
const int STR_DIM = 40 ;
//-----------------------------------------------------------------------------
static HINSTANCE s_hModule = NULL ;
static char s_szEInNameVer[STR_DIM] ;
//-----------------------------------------------------------------------------
BOOL APIENTRY
DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
if ( dwReason == DLL_PROCESS_ATTACH) {
s_hModule = hModule ;
EGT_TRACE( "EgtInterface.dll Initializing!\n") ;
}
else if ( dwReason == DLL_PROCESS_DETACH) {
s_hModule = NULL ;
EGT_TRACE( "EgtInterface.dll Terminating!\n") ;
}
return 1 ;
}
//-----------------------------------------------------------------------------
const char*
GetEInVersion( void)
{
std::string sVer ;
GetModuleVersion( s_hModule, sVer) ;
sprintf_s( s_szEInNameVer, STR_DIM, "%s%s", EIN_STR, sVer.c_str()) ;
return s_szEInNameVer ;
}
+88
View File
@@ -0,0 +1,88 @@
// 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 ;
}
BIN
View File
Binary file not shown.
+26
View File
@@ -0,0 +1,26 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtInterface", "EgtInterface.vcxproj", "{DF654897-F85B-4108-A621-F2C4AB099A48}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DF654897-F85B-4108-A621-F2C4AB099A48}.Debug|Win32.ActiveCfg = Debug|Win32
{DF654897-F85B-4108-A621-F2C4AB099A48}.Debug|Win32.Build.0 = Debug|Win32
{DF654897-F85B-4108-A621-F2C4AB099A48}.Debug|x64.ActiveCfg = Debug|x64
{DF654897-F85B-4108-A621-F2C4AB099A48}.Debug|x64.Build.0 = Debug|x64
{DF654897-F85B-4108-A621-F2C4AB099A48}.Release|Win32.ActiveCfg = Release|Win32
{DF654897-F85B-4108-A621-F2C4AB099A48}.Release|Win32.Build.0 = Release|Win32
{DF654897-F85B-4108-A621-F2C4AB099A48}.Release|x64.ActiveCfg = Release|x64
{DF654897-F85B-4108-A621-F2C4AB099A48}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+205
View File
@@ -0,0 +1,205 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{DF654897-F85B-4108-A621-F2C4AB099A48}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>EgtInterface</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
<TargetName>$(ProjectName)D$(PlatformArchitecture)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
<TargetName>$(ProjectName)D$(PlatformArchitecture)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
<TargetName>$(ProjectName)R$(PlatformArchitecture)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
<TargetName>$(ProjectName)R$(PlatformArchitecture)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;I_AM_EIN;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
</Link>
<PostBuildEvent>
<Command>copy $(TargetDir)$(TargetName).pdb \EgtDev\Lib\
copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\
copy $(TargetPath) \EgtProg\Dll32</Command>
</PostBuildEvent>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;_DEB32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;I_AM_EIN;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
</Link>
<PostBuildEvent>
<Command>copy $(TargetDir)$(TargetName).pdb \EgtDev\Lib\
copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\
copy $(TargetPath) \EgtProg\Dll64</Command>
</PostBuildEvent>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;_DEB64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;I_AM_EIN;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
</Link>
<PostBuildEvent>
<Command>copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\
copy $(TargetPath) \EgtProg\Dll32</Command>
</PostBuildEvent>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;NDEB32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;I_AM_EIN;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
</Link>
<PostBuildEvent>
<Command>copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\
copy $(TargetPath) \EgtProg\Dll64</Command>
</PostBuildEvent>
<ResourceCompile>
<PreprocessorDefinitions>_UNICODE;UNICODE;NDEB64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="EgtInterface.cpp" />
<ClCompile Include="EInDllMain.cpp" />
<ClCompile Include="Interface.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtInterface.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
+47
View File
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="File di origine">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="File di intestazione">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="File di risorse">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="EgtInterface.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="EInDllMain.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Interface.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EgtInterface.rc">
<Filter>File di risorse</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
+503
View File
@@ -0,0 +1,503 @@
// 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 EgtSetLog( int nDebug, const wchar_t* sLogFile)
{
// creo il logger generale
s_pLogGen = new Logger( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "EgtInterface") ;
if ( s_pLogGen == nullptr)
return 0 ;
// assegno il file
s_pLogGen->AddOutputStream( new ofstream( sLogFile), true) ;
// lo passo alle DLL
SetEGnLogger( s_pLogGen) ;
SetENkLogger( s_pLogGen) ;
SetEGkLogger( s_pLogGen) ;
SetEExLogger( s_pLogGen) ;
SetEGrLogger( s_pLogGen) ;
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 EgtInit( HWND hWnd, int nDriver, int b2Buff, int nColorBits, int nDepthBits)
{
// inizio programma
LOG_DATETIME( s_pLogGen, " Init")
// versione dell'interfaccia
LOG_INFO( s_pLogGen, GetEInVersion())
// versione delle librerie
LOG_INFO( s_pLogGen, GetEGnVersion())
LOG_INFO( s_pLogGen, GetENkVersion())
LOG_INFO( s_pLogGen, GetEGkVersion())
LOG_INFO( s_pLogGen, GetEExVersion())
LOG_INFO( s_pLogGen, GetEGrVersion())
// inizializzazioni DB geometrico
s_pGeomDB = CreateGeomDB() ;
if ( s_pGeomDB == nullptr)
return 0 ;
s_pGeomDB->Init() ;
s_pGeomDB->SetDefaultMaterial( s_colDef) ;
// 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 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 EgtTestImportExt( 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 == "DXF")
return 1 ;
else if ( sFileExt == "STL")
return 2 ;
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 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 ;
}
BIN
View File
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
// stdafx.cpp : file di origine che include solo le inclusioni standard
// EgtInterface.pch sarà l'intestazione precompilata
// stdafx.obj conterrà le informazioni sui tipi precompilati
#include "stdafx.h"
// TODO: fare riferimento alle intestazioni aggiuntive necessarie in STDAFX.H
// e non in questo file
+35
View File
@@ -0,0 +1,35 @@
// stdafx.h : file di inclusione per file di inclusione di sistema standard
// o file di inclusione specifici del progetto utilizzati di frequente, ma
// modificati raramente
//
#pragma once
#include "/EgtDev/Include/EgtTargetVer.h"
#include <stdio.h>
#include <tchar.h>
#include <float.h>
#include <math.h>
// in Debug riconoscimento memory leakage
#if defined( _DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif
// in Debug controllo iteratori
#if defined( _DEBUG)
#define _SECURE_SCL 1
#else
#define _SECURE_SCL 0
#endif
#include "/EgtDev/Include/EgtLibVer.h"
#pragma comment(lib, EGTLIBDIR "EgtGeneral" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "EgtNumKernel" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "EgtGeomKernel" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "EgtExchange" EGTLIBVER ".lib")
#pragma comment(lib, EGTLIBDIR "EgtGraphics" EGTLIBVER ".lib")