From: dln Date: Tue, 3 Jun 2014 06:11:33 +0000 (+0400) Subject: 0024699: Visualization - prototype interoperation of TKOpenGl viewer with Direct3D... X-Git-Tag: V6_8_0_beta~6 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=15534713ba8b6057a50c8e680e360aedcd705eca;p=occt.git 0024699: Visualization - prototype interoperation of TKOpenGl viewer with Direct3D viewer Add new C# sample which allow to render the OCCT scene to a Direct3D context in a WPF application. DirectX SDK is required in order to build this sample. --- diff --git a/dox/FILES_HTML.txt b/dox/FILES_HTML.txt index c3e94b4bba..06b73266f8 100644 --- a/dox/FILES_HTML.txt +++ b/dox/FILES_HTML.txt @@ -9,6 +9,7 @@ overview/overview.md ../samples/mfc/standard/ReadMe.md ../samples/CSharp/ReadMe.md +../samples/CSharp/ReadMe_D3D.md tutorial/tutorial.md diff --git a/dox/overview/overview.md b/dox/overview/overview.md index 4aaa8d5df7..12c94e6b63 100644 --- a/dox/overview/overview.md +++ b/dox/overview/overview.md @@ -623,5 +623,9 @@ Export: * Stl * Vrml -See \subpage samples_csharp "Readme" for details. +See \subpage samples_csharp_occt "Readme" for details. + +Also there is an other C# example with the same functionality which demonstrates integration of Direct3D Viewer into .NET applications using WPF front end. + +See \subpage samples_csharp_direct3d "Readme" for details. diff --git a/samples/CSharp/CSharp-vc10.sln b/samples/CSharp/CSharp-vc10.sln deleted file mode 100644 index cefb3f1069..0000000000 --- a/samples/CSharp/CSharp-vc10.sln +++ /dev/null @@ -1,45 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE_WPF", "WPF\IE_WPF.csproj", "{D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE_WinForms", "WinForms\IE_WinForms.csproj", "{B9914BB3-B886-4B41-B48D-350EBEBEFD1F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCCTProxy", "OCCTProxy\OCCTProxy.vcxproj", "{969912D9-78E7-4AB8-B4FF-6B52B4F03991}" -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 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|Win32.ActiveCfg = Debug|x86 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|Win32.Build.0 = Debug|x86 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|x64.ActiveCfg = Debug|x64 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|x64.Build.0 = Debug|x64 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|Win32.ActiveCfg = Release|x86 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|Win32.Build.0 = Release|x86 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|x64.ActiveCfg = Release|x64 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|x64.Build.0 = Release|x64 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Win32.ActiveCfg = Debug|x86 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Win32.Build.0 = Debug|x86 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|x64.ActiveCfg = Debug|x64 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|x64.Build.0 = Debug|x64 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Win32.ActiveCfg = Release|x86 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Win32.Build.0 = Release|x86 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|x64.ActiveCfg = Release|x64 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|x64.Build.0 = Release|x64 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.ActiveCfg = Debug|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.Build.0 = Debug|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|x64.ActiveCfg = Debug|x64 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|x64.Build.0 = Debug|x64 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.ActiveCfg = Release|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.Build.0 = Release|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|x64.ActiveCfg = Release|x64 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/CSharp/CSharp-vc9.sln b/samples/CSharp/CSharp-vc9.sln deleted file mode 100644 index 6ec2e629d4..0000000000 --- a/samples/CSharp/CSharp-vc9.sln +++ /dev/null @@ -1,45 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE_WPF", "WPF\IE_WPF.csproj", "{D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE_WinForms", "WinForms\IE_WinForms.csproj", "{B9914BB3-B886-4B41-B48D-350EBEBEFD1F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCCTProxy", "OCCTProxy\OCCTProxy.vcproj", "{969912D9-78E7-4AB8-B4FF-6B52B4F03991}" -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 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|Win32.ActiveCfg = Debug|x86 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|Win32.Build.0 = Debug|x86 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|x64.ActiveCfg = Debug|x64 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|x64.Build.0 = Debug|x64 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|Win32.ActiveCfg = Release|x86 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|Win32.Build.0 = Release|x86 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|x64.ActiveCfg = Release|x64 - {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|x64.Build.0 = Release|x64 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Win32.ActiveCfg = Debug|x86 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Win32.Build.0 = Debug|x86 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|x64.ActiveCfg = Debug|x64 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|x64.Build.0 = Debug|x64 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Win32.ActiveCfg = Release|x86 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Win32.Build.0 = Release|x86 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|x64.ActiveCfg = Release|x64 - {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|x64.Build.0 = Release|x64 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.ActiveCfg = Debug|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.Build.0 = Debug|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|x64.ActiveCfg = Debug|x64 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|x64.Build.0 = Debug|x64 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.ActiveCfg = Release|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.Build.0 = Release|Win32 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|x64.ActiveCfg = Release|x64 - {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/CSharp/CSharp.sln b/samples/CSharp/CSharp.sln new file mode 100644 index 0000000000..e67bae1fa2 --- /dev/null +++ b/samples/CSharp/CSharp.sln @@ -0,0 +1,45 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE_WPF_WinForms", "WPF_WinForms\IE_WPF_WinForms.csproj", "{D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE_WinForms", "WinForms\IE_WinForms.csproj", "{B9914BB3-B886-4B41-B48D-350EBEBEFD1F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCCTProxy", "OCCTProxy\OCCTProxy.vcxproj", "{969912D9-78E7-4AB8-B4FF-6B52B4F03991}" +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 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|Win32.ActiveCfg = Debug|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|Win32.Build.0 = Debug|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|x64.ActiveCfg = Debug|x64 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|x64.Build.0 = Debug|x64 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|Win32.ActiveCfg = Release|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|Win32.Build.0 = Release|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|x64.ActiveCfg = Release|x64 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|x64.Build.0 = Release|x64 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Win32.ActiveCfg = Debug|x86 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|Win32.Build.0 = Debug|x86 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|x64.ActiveCfg = Debug|x64 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Debug|x64.Build.0 = Debug|x64 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Win32.ActiveCfg = Release|x86 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|Win32.Build.0 = Release|x86 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|x64.ActiveCfg = Release|x64 + {B9914BB3-B886-4B41-B48D-350EBEBEFD1F}.Release|x64.Build.0 = Release|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.ActiveCfg = Debug|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.Build.0 = Debug|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|x64.ActiveCfg = Debug|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|x64.Build.0 = Debug|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.ActiveCfg = Release|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.Build.0 = Release|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|x64.ActiveCfg = Release|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/CSharp/CSharp_D3D.sln b/samples/CSharp/CSharp_D3D.sln new file mode 100644 index 0000000000..a0fedddcac --- /dev/null +++ b/samples/CSharp/CSharp_D3D.sln @@ -0,0 +1,35 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE_WPF_D3D", "WPF_D3D\IE_WPF_D3D.csproj", "{D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCCTProxy_D3D", "OCCTProxy_D3D\OCCTProxy_D3D.vcxproj", "{969912D9-78E7-4AB8-B4FF-6B52B4F03991}" +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 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|Win32.ActiveCfg = Debug|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|Win32.Build.0 = Debug|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|x64.ActiveCfg = Debug|x64 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Debug|x64.Build.0 = Debug|x64 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|Win32.ActiveCfg = Release|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|Win32.Build.0 = Release|x86 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|x64.ActiveCfg = Release|x64 + {D12A8897-5BF8-4345-BBB0-8ADE4B9FB9A7}.Release|x64.Build.0 = Release|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.ActiveCfg = Debug|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|Win32.Build.0 = Debug|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|x64.ActiveCfg = Debug|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Debug|x64.Build.0 = Debug|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.ActiveCfg = Release|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|Win32.Build.0 = Release|Win32 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|x64.ActiveCfg = Release|x64 + {969912D9-78E7-4AB8-B4FF-6B52B4F03991}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/CSharp/OCCTProxy/OCCTProxy.cpp b/samples/CSharp/OCCTProxy/OCCTProxy.cpp index 3dd453842a..e7bc2a6e0b 100644 --- a/samples/CSharp/OCCTProxy/OCCTProxy.cpp +++ b/samples/CSharp/OCCTProxy/OCCTProxy.cpp @@ -1094,5 +1094,5 @@ private: NCollection_Haft myViewer; NCollection_Haft myView; NCollection_Haft myAISContext; - NCollection_Haft myGraphicDriver; + NCollection_Haft myGraphicDriver; }; diff --git a/samples/CSharp/OCCTProxy/OCCTProxy.vcxproj b/samples/CSharp/OCCTProxy/OCCTProxy.vcxproj index 91100d2960..6c7f46996c 100644 --- a/samples/CSharp/OCCTProxy/OCCTProxy.vcxproj +++ b/samples/CSharp/OCCTProxy/OCCTProxy.vcxproj @@ -78,8 +78,6 @@ ..\win64\bin\ obj\$(Platform)\$(Configuration)\ false - D:\builds\vc10\CR25067-master-occt\inc;$(IncludePath) - D:\builds\vc10\CR25067-master-occt\win32\vc10\lib;$(LibraryPath) diff --git a/samples/CSharp/OCCTProxy_D3D/BridgeFBO.cxx b/samples/CSharp/OCCTProxy_D3D/BridgeFBO.cxx new file mode 100644 index 0000000000..12fa944964 --- /dev/null +++ b/samples/CSharp/OCCTProxy_D3D/BridgeFBO.cxx @@ -0,0 +1,152 @@ +#include "BridgeFBO.hxx" + +#include + +#include + +#include + +// list of required libraries +#pragma comment(lib, "TKOpenGl.lib") +#pragma comment(lib, "opengl32.lib") + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +Standard_Boolean BridgeFBO::Init (const Handle(OpenGl_Context)& theGlContext, + void* theD3DDevice) +{ + const OpenGl_GlFunctions* aFuncs = (const OpenGl_GlFunctions* )theGlContext->core11; + if (aFuncs->wglDXOpenDeviceNV == NULL) + { + return Standard_False; + } + + myGlD3DHandle = aFuncs->wglDXOpenDeviceNV (theD3DDevice); + if (myGlD3DHandle == NULL) + { + std::cerr << "Could not create the GL <-> DirectX Interop" << std::endl; + return Standard_False; + } + + theGlContext->arbFBO->glGenFramebuffers (1, &myGlFBufferId); + return Standard_True; +} + +// ======================================================================= +// function : Release +// purpose : +// ======================================================================= +void BridgeFBO::Release (OpenGl_Context* theGlContext) +{ + if (myGlD3DHandle != NULL) + { + const OpenGl_GlFunctions* aFuncs = (const OpenGl_GlFunctions* )theGlContext->core11; + if (myGlD3DSharedColorHandle != NULL) + { + aFuncs->wglDXUnregisterObjectNV (myGlD3DHandle, myGlD3DSharedColorHandle); + myGlD3DSharedColorHandle = NULL; + } + + aFuncs->wglDXCloseDeviceNV (myGlD3DHandle); + myGlD3DHandle = NULL; + } + + OpenGl_FrameBuffer::Release (theGlContext); +} + +// ======================================================================= +// function : RegisterD3DColorBuffer +// purpose : +// ======================================================================= +Standard_Boolean BridgeFBO::RegisterD3DColorBuffer (const Handle(OpenGl_Context)& theGlContext, + void* theD3DBuffer, + void* theBufferShare) +{ + const OpenGl_GlFunctions* aFuncs = (const OpenGl_GlFunctions* )theGlContext->core11; + if (myGlD3DSharedColorHandle != NULL) + { + if (!aFuncs->wglDXUnregisterObjectNV (myGlD3DHandle, myGlD3DSharedColorHandle)) + { + return Standard_False; + } + myGlD3DSharedColorHandle = NULL; + } + + if (!aFuncs->wglDXSetResourceShareHandleNV (theD3DBuffer, theBufferShare)) + { + return Standard_False; + } + + myColorTexture->Release (theGlContext.operator->()); + myColorTexture->Create (theGlContext); + + myGlD3DSharedColorHandle = aFuncs->wglDXRegisterObjectNV (myGlD3DHandle, + theD3DBuffer, myColorTexture->TextureId(), GL_TEXTURE_2D, WGL_ACCESS_WRITE_DISCARD_NV); + + if (myGlD3DSharedColorHandle == NULL) + { + std::cerr << "Could not register color buffer" << std::endl; + return Standard_False; + } + + return Standard_True; +} + +// ======================================================================= +// function : Resize +// purpose : +// ======================================================================= +void BridgeFBO::Resize (const Handle(OpenGl_Context)& theGlContext, + int theSizeX, + int theSizeY) +{ + myVPSizeX = theSizeX; + myVPSizeY = theSizeY; + + myDepthStencilTexture->Init (theGlContext, GL_DEPTH24_STENCIL8, + GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, + myVPSizeX, myVPSizeY, Graphic3d_TOT_2D); +} + +// ======================================================================= +// function : BindBuffer +// purpose : +// ======================================================================= +void BridgeFBO::BindBuffer (const Handle(OpenGl_Context)& theGlContext) +{ + if (myGlD3DSharedColorHandle != NULL) + { + // Lock for OpenGL + const OpenGl_GlFunctions* aFuncs = (const OpenGl_GlFunctions* )theGlContext->core11; + aFuncs->wglDXLockObjectsNV (myGlD3DHandle, 1, &myGlD3DSharedColorHandle); + } + + OpenGl_FrameBuffer::BindBuffer (theGlContext); + theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, myColorTexture->TextureId(), 0); + theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + GL_TEXTURE_2D, myDepthStencilTexture->TextureId(), 0); + if (theGlContext->arbFBO->glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) + { + std::cerr << "Invalid FBO can not be bound!\n"; + Release (theGlContext.operator->()); + } +} + +// ======================================================================= +// function : UnbindBuffer +// purpose : +// ======================================================================= +void BridgeFBO::UnbindBuffer (const Handle(OpenGl_Context)& theGlContext) +{ + // Unbind the frame buffer + OpenGl_FrameBuffer::UnbindBuffer (theGlContext); + if (myGlD3DSharedColorHandle != NULL) + { + // Unlock for Direct3D + const OpenGl_GlFunctions* aFuncs = (const OpenGl_GlFunctions* )theGlContext->core11; + aFuncs->wglDXUnlockObjectsNV (myGlD3DHandle, 1, &myGlD3DSharedColorHandle); + } +} diff --git a/samples/CSharp/OCCTProxy_D3D/BridgeFBO.hxx b/samples/CSharp/OCCTProxy_D3D/BridgeFBO.hxx new file mode 100644 index 0000000000..9860015179 --- /dev/null +++ b/samples/CSharp/OCCTProxy_D3D/BridgeFBO.hxx @@ -0,0 +1,53 @@ +#ifndef BRIDGE_FBO_HEADER +#define BRIDGE_FBO_HEADER + +#include +#include + +//! Implements bridge FBO for direct rendering to Direct3D surfaces. +class BridgeFBO : public OpenGl_FrameBuffer +{ +public: + + //! Creates new bridge FBO. + BridgeFBO() : OpenGl_FrameBuffer() + { + // + } + + //! Releases resources of bridge FBO. + ~BridgeFBO() + { + Release (NULL); + } + + //! Releases resources of bridge FBO. + virtual void Release (OpenGl_Context* theGlContext); + + //! Initializes OpenGL FBO for Direct3D interoperability. + Standard_Boolean Init (const Handle(OpenGl_Context)& theGlContext, + void* theD3DDevice); + + //! Binds Direcr3D color buffer to OpenGL texture. + Standard_Boolean RegisterD3DColorBuffer (const Handle(OpenGl_Context)& theGlContext, + void* theD3DBuffer, + void* theBufferShare); + + //! Locks Direct3D objects for OpenGL drawing. + virtual void BindBuffer (const Handle(OpenGl_Context)& theGlContext); + + //! Unlocks Direct3D objects after OpenGL drawing. + virtual void UnbindBuffer (const Handle(OpenGl_Context)& theGlContext); + + //! Resizes buffer according to Direct3D surfaces. + void Resize (const Handle(OpenGl_Context)& theGlContext, + int theSizeX, + int theSizeY); + +private: + + HANDLE myGlD3DHandle; + HANDLE myGlD3DSharedColorHandle; +}; + +#endif \ No newline at end of file diff --git a/samples/CSharp/OCCTProxy_D3D/Direct3DProxy.cpp b/samples/CSharp/OCCTProxy_D3D/Direct3DProxy.cpp new file mode 100644 index 0000000000..407d93f7ab --- /dev/null +++ b/samples/CSharp/OCCTProxy_D3D/Direct3DProxy.cpp @@ -0,0 +1,278 @@ +#include +#include +#include + +using namespace System::Runtime::InteropServices; + +typedef HRESULT (WINAPI *DIRECT3DCREATE9EX)(UINT SDKVersion, IDirect3D9Ex**); + +LRESULT WINAPI MsgProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + return DefWindowProcW (hWnd, msg, wParam, lParam); +} + +WNDCLASSEXW THE_WNDCLASS_D3D = +{ + sizeof (WNDCLASSEXW), + CS_CLASSDC, MsgProc, NULL, NULL, + GetModuleHandle (NULL), + NULL, NULL, NULL, NULL, L"D3D", NULL +}; + +// ======================================================================= +// function : GetVertexProcessingCaps +// purpose : +// ======================================================================= +DWORD GetVertexProcessingCaps (LPDIRECT3D9 theD3D) +{ + D3DCAPS9 aCaps; + return !SUCCEEDED (theD3D->GetDeviceCaps (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &aCaps)) + || !(aCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) + ? D3DCREATE_SOFTWARE_VERTEXPROCESSING + : D3DCREATE_HARDWARE_VERTEXPROCESSING; +} + +//! Encapsulates state of Direct3D renderer. +class D3DRender +{ +public: + + D3DRender (int theSizeX = 512, + int theSizeY = 512) + : D3D (NULL), + D3DEx (NULL), + D3DDevice (NULL), + D3DDeviceEx (NULL), + D3DColorSurf (NULL), + D3DColorSurfShare (NULL), + FuncCreate9Ex (NULL), + WinSizeX (theSizeX), + WinSizeY (theSizeY) + { + CheckRegisterClass(); + WinHandle = CreateWindowW (L"D3D", L"D3D", + WS_OVERLAPPEDWINDOW, 0, 0, 1, 1, + NULL, NULL, THE_WNDCLASS_D3D.hInstance, NULL); + Init(); + } + + ~D3DRender() + { + // do not release class instance shared between all renderers + //UnregisterClass (NULL, THE_WNDCLASS_D3D.hInstance); + if (D3DDevice != NULL) + { + D3DDevice->Release(); + } + if (D3DDeviceEx != NULL) + { + D3DDeviceEx->Release(); + } + if (D3D != NULL) + { + D3D->Release(); + } + if (D3DEx != NULL) + { + D3DEx->Release(); + } + if (D3DColorSurf != NULL) + { + D3DColorSurf->Release(); + D3DColorSurfShare = NULL; + } + } + + //! Creates Direct3D render target. + bool CreateRenderTarget() + { + if (!SetWindowPos (WinHandle, 0, 0, 0, WinSizeX, WinSizeY, 0)) + { + return false; + } + + if (D3DColorSurf != NULL) + { + D3DColorSurf->Release(); + D3DColorSurfShare = NULL; + } + + // Note: Render target surface should be lockable on + // Windows XP and non-lockable on Windows Vista or higher + if (FAILED (D3DDevice->CreateRenderTarget (WinSizeX, WinSizeY, + D3DFMT_X8R8G8B8, D3DMULTISAMPLE_NONE, 0, FuncCreate9Ex != NULL, + &D3DColorSurf, FuncCreate9Ex == NULL ? NULL : &D3DColorSurfShare))) + { + return false; + } + + D3DDevice->SetRenderTarget (0, D3DColorSurf); + return true; + } + +private: + + void Init() + { + // Vista requires the D3D "Ex" functions for optimal performance. + // The Ex functions are only supported with WDDM drivers, so they will not be available on XP. + HMODULE aD3D9 = GetModuleHandleW (L"d3d9"); + FuncCreate9Ex = (DIRECT3DCREATE9EX )GetProcAddress (aD3D9, "Direct3DCreate9Ex"); + + // Set up the structure used to create the D3DDevice + D3DPRESENT_PARAMETERS aParams; + ZeroMemory (&aParams, sizeof(aParams)); + aParams.Windowed = TRUE; + aParams.BackBufferHeight = 1; + aParams.BackBufferWidth = 1; + aParams.SwapEffect = D3DSWAPEFFECT_DISCARD; + aParams.BackBufferFormat = D3DFMT_X8R8G8B8; + (FuncCreate9Ex != NULL) ? InitializeD3DEx (aParams) : InitializeD3D (aParams); + } + + bool InitializeD3D (D3DPRESENT_PARAMETERS theParams) + { + D3D = Direct3DCreate9 (D3D_SDK_VERSION); + if (D3D == NULL) + return false; + + DWORD aVertProcessCaps = GetVertexProcessingCaps (D3D); + HRESULT aResult = D3D->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, WinHandle, + aVertProcessCaps | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE, + &theParams, &D3DDevice); + return SUCCEEDED (aResult); + } + + bool InitializeD3DEx (D3DPRESENT_PARAMETERS theParams) + { + if (FAILED (FuncCreate9Ex (D3D_SDK_VERSION, &D3DEx)) + || FAILED (D3DEx->QueryInterface (__uuidof (IDirect3D9), reinterpret_cast (&D3D)))) + { + return false; + } + + DWORD aVertProcessCaps = GetVertexProcessingCaps (D3D); + if (FAILED (D3DEx->CreateDeviceEx (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, WinHandle, + aVertProcessCaps | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE, + &theParams, NULL, &D3DDeviceEx))) + return false; + + return SUCCEEDED (D3DDeviceEx->QueryInterface (__uuidof (IDirect3DDevice9), reinterpret_cast (&D3DDevice))); + } + + static void CheckRegisterClass() + { + static bool isRegistered = false; + if (!isRegistered) + { + RegisterClassExW (&THE_WNDCLASS_D3D); + isRegistered = true; + } + } + +public: + + LPDIRECT3D9 D3D; + LPDIRECT3D9EX D3DEx; + LPDIRECT3DDEVICE9 D3DDevice; + LPDIRECT3DDEVICE9EX D3DDeviceEx; + + LPDIRECT3DSURFACE9 D3DColorSurf; + HANDLE D3DColorSurfShare; + + DIRECT3DCREATE9EX FuncCreate9Ex; + + HWND WinHandle; + INT WinSizeX; + INT WinSizeY; + +}; + +public ref struct WndSize +{ +public: + + WndSize(int theSizeX, int theSizeY) + { + mySize = new SIZE(); + mySize->cx = theSizeX; + mySize->cy = theSizeY; + } + + ~WndSize() + { + delete mySize; + } + + property int cx + { + int get() { return mySize->cx; } + } + + property int cy + { + int get() { return mySize->cy; } + } + + LPSIZE GetPointer() + { + return mySize; + } + +private: + + LPSIZE mySize; +}; + +public ref class Direct3DProxy +{ +public : + + Direct3DProxy() + { + // + } + + // ======================================================================= + // function : InitializeScene + // purpose : + // ======================================================================= + static System::IntPtr InitRender ([Out] System::IntPtr% theWinHandle, + [Out] System::IntPtr% theD3DDevice) + { + D3DRender* aRender = new D3DRender(); + theWinHandle = System::IntPtr(aRender->WinHandle); + theD3DDevice = System::IntPtr(aRender->D3DDevice); + + return System::IntPtr(aRender); + } + + // ======================================================================= + // function : ResizeWindow + // purpose : + // ======================================================================= + static void ResizeWindow ([In] System::IntPtr% theRender, + [In] WndSize^% theWndSize, + [Out] System::IntPtr% theColorSurf, + [Out] System::IntPtr% theColorSurfShare) + { + D3DRender* aRender = reinterpret_cast (theRender.ToPointer()); + LPSIZE aSize = theWndSize->GetPointer(); + aRender->WinSizeX = aSize->cx; + aRender->WinSizeY = aSize->cy; + aRender->CreateRenderTarget(); + + theColorSurf = System::IntPtr(aRender->D3DColorSurf); + theColorSurfShare = System::IntPtr(aRender->D3DColorSurfShare); + } + + // ======================================================================= + // function : ReleaseRender + // purpose : + // ======================================================================= + static void ReleaseRender ([In] System::IntPtr% theRender) + { + D3DRender* aRender = reinterpret_cast (theRender.ToPointer()); + delete aRender; + } +}; \ No newline at end of file diff --git a/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp b/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp new file mode 100644 index 0000000000..98da86ee09 --- /dev/null +++ b/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp @@ -0,0 +1,1109 @@ +#include "BridgeFBO.hxx" + +// include required OCCT headers +#include +#include +//for OCC graphic +#include +#include +#include +#include +#include +#include +#include +//for object display +#include +#include +#include +#include +#include +//topology +#include +#include +//brep tools +#include +#include +#include +#include +//csfdb I/E +#include +#include +#include +#include +#include +// iges I/E +#include +#include +#include +#include +#include +//step I/E +#include +#include +//for stl export +#include +//for vrml export +#include +//wrapper of pure C++ classes to ref classes +#include + +// list of required OCCT libraries +#pragma comment(lib, "TKernel.lib") +#pragma comment(lib, "TKMath.lib") +#pragma comment(lib, "TKBRep.lib") +#pragma comment(lib, "PTKernel.lib") +#pragma comment(lib, "TKPShape.lib") +#pragma comment(lib, "TKShapeSchema.lib") +#pragma comment(lib, "TKXSBase.lib") +#pragma comment(lib, "TKService.lib") +#pragma comment(lib, "TKV3d.lib") +#pragma comment(lib, "TKOpenGl.lib") +#pragma comment(lib, "TKIGES.lib") +#pragma comment(lib, "TKSTEP.lib") +#pragma comment(lib, "TKStl.lib") +#pragma comment(lib, "TKVrml.lib") + +/// +/// Proxy class encapsulating calls to OCCT C++ classes within +/// C++/CLI class visible from .Net (CSharp) +/// +public ref class OCCTProxyD3D +{ +public: + + OCCTProxyD3D() : myBridgeFBO (NULL) + { + // + } + + // ============================================ + // Viewer functionality + // ============================================ + + /// + ///Initialize a viewer + /// + /// System.IntPtr that contains the window handle (HWND) of the control + bool InitViewer (System::IntPtr theWnd) + { + myGraphicDriver() = new OpenGl_GraphicDriver (Handle(Aspect_DisplayConnection)()); + //myGraphicDriver()->ChangeOptions().contextDebug = true; + + TCollection_ExtendedString a3DName ("Visu3D"); + myViewer() = new V3d_Viewer (myGraphicDriver(), a3DName.ToExtString(), "", 1000.0, + V3d_XposYnegZpos, Quantity_NOC_GRAY30, + V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, + Standard_True, Standard_False); + + myViewer()->SetDefaultLights(); + myViewer()->SetLightOn(); + myView() = myViewer()->CreateView(); + Handle(WNT_Window) aWNTWindow = new WNT_Window (reinterpret_cast (theWnd.ToPointer())); + myView()->SetWindow(aWNTWindow); + if (!aWNTWindow->IsMapped()) + { + aWNTWindow->Map(); + } + myAISContext() = new AIS_InteractiveContext (myViewer()); + myAISContext()->UpdateCurrentViewer(); + myView()->MustBeResized(); + return true; + } + + /// Initializes OCCT viewer for OpenGL-Direct3D interoperability. + bool InitViewer (System::IntPtr theHWND, + System::IntPtr theD3DDevice) + { + if (!InitViewer (theHWND)) + { + return false; + } + + Graphic3d_CView* aCView = reinterpret_cast (myView()->View()->CView()); + OpenGl_CView* aCViewGl = reinterpret_cast (aCView->ptrView); + Handle(OpenGl_Context) aGlContext = aCViewGl->WS->GetGlContext(); + if (aGlContext.IsNull()) + { + return false; + } + if (!aGlContext->IsCurrent()) + { + aGlContext->MakeCurrent(); + } + + myBridgeFBO = new BridgeFBO(); + if (!myBridgeFBO->Init (aGlContext, theD3DDevice.ToPointer())) + { + return false; + } + + aCView->ptrFBO = myBridgeFBO; + return true; + } + + /// Resizes custom FBO for Direct3D output. + bool ResizeBridgeFBO (int theWinSizeX, + int theWinSizeY, + System::IntPtr theColorSurf, + System::IntPtr theColorSurfShare) + { + if (myBridgeFBO == NULL) + { + return false; + } + + OpenGl_CView* aCView = reinterpret_cast (reinterpret_cast (myView()->View()->CView())->ptrView); + Handle(OpenGl_Context) aGlContext = aCView->WS->GetGlContext(); + if (aGlContext.IsNull() + || !aGlContext->MakeCurrent()) + { + return false; + } + + myBridgeFBO->Resize (aGlContext, theWinSizeX, theWinSizeY); + if (!myBridgeFBO->RegisterD3DColorBuffer (aGlContext, theColorSurf.ToPointer(), theColorSurfShare.ToPointer())) + { + return false; + } + + myView()->Camera()->SetAspect (Standard_Real (theWinSizeX) / Standard_Real (theWinSizeY)); + return true; + } + + /// + /// Make dump of current view to file + /// + /// Name of dump file + bool Dump (const char* theFileName) + { + if (myView().IsNull()) + { + return false; + } + myView()->Redraw(); + return myView()->Dump (theFileName) != Standard_False; + } + + /// + ///Redraw view + /// + void RedrawView() + { + if (!myView().IsNull()) + { + myView()->Redraw(); + } + } + + /// + ///Update view + /// + void UpdateView(void) + { + if (!myView().IsNull()) + { + myView()->MustBeResized(); + } + } + + /// + ///Set computed mode in false + /// + void SetDegenerateModeOn() + { + if (!myView().IsNull()) + { + myView()->SetComputedMode (Standard_False); + } + } + + /// + ///Set computed mode in true + /// + void SetDegenerateModeOff() + { + if (!myView().IsNull()) + { + myView()->SetComputedMode (Standard_True); + } + } + + /// + ///Fit all + /// + void WindowFitAll (int theXmin, int theYmin, + int theXmax, int theYmax) + { + if (!myView().IsNull()) + { + myView()->WindowFitAll (theXmin, theYmin, theXmax, theYmax); + } + } + + /// + ///Current place of window + /// + /// Current zoom + void Place (int theX, int theY, float theZoomFactor) + { + Quantity_Factor aZoomFactor = theZoomFactor; + if (!myView().IsNull()) + { + myView()->Place (theX, theY, aZoomFactor); + } + } + + /// + ///Set Zoom + /// + void Zoom (int theX1, int theY1, int theX2, int theY2) + { + if (!myView().IsNull()) + { + myView()->Zoom (theX1, theY1, theX2, theY2); + } + } + + /// + ///Set Pan + /// + void Pan (int theX, int theY) + { + if (!myView().IsNull()) + { + myView()->Pan (theX, theY); + } + } + + /// + ///Rotation + /// + void Rotation (int theX, int theY) + { + if (!myView().IsNull()) + { + myView()->Rotation (theX, theY); + } + } + + /// + ///Start rotation + /// + void StartRotation (int theX, int theY) + { + if (!myView().IsNull()) + { + myView()->StartRotation (theX, theY); + } + } + + /// + ///Select by rectangle + /// + void Select (int theX1, int theY1, int theX2, int theY2) + { + if (!myAISContext().IsNull()) + { + myAISContext()->Select (theX1, theY1, theX2, theY2, myView()); + } + } + + /// + ///Select by click + /// + void Select() + { + if (!myAISContext().IsNull()) + { + myAISContext()->Select(); + } + } + + /// + ///Move view + /// + void MoveTo (int theX, int theY) + { + if (!myAISContext().IsNull() && !myView().IsNull()) + { + myAISContext()->MoveTo (theX, theY, myView()); + } + } + + /// + ///Select by rectangle with pressed "Shift" key + /// + void ShiftSelect (int theX1, int theY1, int theX2, int theY2) + { + if (!myAISContext().IsNull() && !myView().IsNull()) + { + myAISContext()->ShiftSelect (theX1, theY1, theX2, theY2, myView()); + } + } + + /// + ///Select by "Shift" key + /// + void ShiftSelect() + { + if (!myAISContext().IsNull()) + { + myAISContext()->ShiftSelect(); + } + } + + /// + ///Set background color + /// + void BackgroundColor (int& theRed, int& theGreen, int& theBlue) + { + if (!myView().IsNull()) + { + Quantity_Color aColor = myView()->BackgroundColor(); + theRed = (int )aColor.Red() * 255; + theGreen = (int )aColor.Green() * 255; + theBlue = (int )aColor.Blue() * 255; + } + } + + /// + ///Get background color Red + /// + int GetBGColR() + { + int anRgb[3]; + BackgroundColor (anRgb[0], anRgb[1], anRgb[2]); + return anRgb[0]; + } + + /// + ///Get background color Green + /// + int GetBGColG() + { + int anRgb[3]; + BackgroundColor (anRgb[0], anRgb[1], anRgb[2]); + return anRgb[1]; + } + + /// + ///Get background color Blue + /// + int GetBGColB() + { + int anRgb[3]; + BackgroundColor (anRgb[0], anRgb[1], anRgb[2]); + return anRgb[2]; + } + + /// + ///Update current viewer + /// + void UpdateCurrentViewer() + { + if (!myAISContext().IsNull()) + { + myAISContext()->UpdateCurrentViewer(); + } + } + + /// + ///Front side + /// + void FrontView() + { + if (!myView().IsNull()) + { + myView()->SetProj (V3d_Xpos); + } + } + + /// + ///Top side + /// + void TopView() + { + if (!myView().IsNull()) + { + myView()->SetProj (V3d_Zpos); + } + } + + /// + ///Left side + /// + void LeftView() + { + if (!myView().IsNull()) + { + myView()->SetProj (V3d_Ypos); + } + } + + /// + ///Back side + /// + void BackView() + { + if (!myView().IsNull()) + { + myView()->SetProj (V3d_Xneg); + } + } + + /// + ///Right side + /// + void RightView() + { + if (!myView().IsNull()) + { + myView()->SetProj (V3d_Yneg); + } + } + + /// + ///Bottom side + /// + void BottomView() + { + if (!myView().IsNull()) + { + myView()->SetProj (V3d_Zneg); + } + } + + /// + ///Axo side + /// + void AxoView() + { + if (!myView().IsNull()) + { + myView()->SetProj (V3d_XposYnegZpos); + } + } + + /// + ///Scale + /// + float Scale() + { + return myView().IsNull() + ? -1.0f + : float(myView()->Scale()); + } + + /// + ///Zoom in all view + /// + void ZoomAllView() + { + if (!myView().IsNull()) + { + myView()->FitAll(); + myView()->ZFitAll(); + } + } + + /// + ///Reset view + /// + void Reset() + { + if (!myView().IsNull()) + { + myView()->Reset(); + } + } + + /// + ///Set display mode of objects + /// + /// Set current mode + void SetDisplayMode (int theMode) + { + if (myAISContext().IsNull()) + { + return; + } + + AIS_DisplayMode aCurrentMode = theMode == 0 + ? AIS_WireFrame + : AIS_Shaded; + if (myAISContext()->NbCurrents() == 0 + || myAISContext()->NbSelected() == 0) + { + myAISContext()->SetDisplayMode (aCurrentMode); + } + else + { + for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + myAISContext()->SetDisplayMode (myAISContext()->Current(), theMode, Standard_False); + } + } + myAISContext()->UpdateCurrentViewer(); + } + + /// + ///Set color + /// + void SetColor (int theR, int theG, int theB) + { + if (myAISContext().IsNull()) + { + return; + } + + Quantity_Color aCol (theR / 255.0, theG / 255.0, theB / 255.0, Quantity_TOC_RGB); + for (; myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + myAISContext()->SetColor (myAISContext()->Current(), aCol.Name()); + } + } + + /// + ///Get object color red + /// + int GetObjColR() + { + int anRgb[3]; + ObjectColor (anRgb[0], anRgb[1], anRgb[2]); + return anRgb[0]; + } + + /// + ///Get object color green + /// + int GetObjColG() + { + int anRgb[3]; + ObjectColor (anRgb[0], anRgb[1], anRgb[2]); + return anRgb[1]; + } + + /// + ///Get object color blue + /// + int GetObjColB() + { + int anRgb[3]; + ObjectColor (anRgb[0], anRgb[1], anRgb[2]); + return anRgb[2]; + } + + /// + ///Get object color R/G/B + /// + void ObjectColor (int& theRed, int& theGreen, int& theBlue) + { + if (myAISContext().IsNull()) + { + return; + } + + theRed = 255; + theGreen = 255; + theBlue = 255; + myAISContext()->InitCurrent(); + if (!myAISContext()->MoreCurrent()) + { + return; + } + + Handle(AIS_InteractiveObject) aCurrent = myAISContext()->Current(); + if (aCurrent->HasColor()) + { + Quantity_Color anObjCol = myAISContext()->Color (myAISContext()->Current()); + theRed = int(anObjCol.Red() * 255.0); + theGreen = int(anObjCol.Green() * 255.0); + theBlue = int(anObjCol.Blue() * 255.0); + } + } + + /// + ///Set background color R/G/B + /// + void SetBackgroundColor (int theRed, int theGreen, int theBlue) + { + if (!myView().IsNull()) + { + myView()->SetBackgroundColor (Quantity_TOC_RGB, theRed / 255.0, theGreen / 255.0, theBlue / 255.0); + } + } + + /// + ///Erase objects + /// + void EraseObjects() + { + if (myAISContext().IsNull()) + { + return; + } + for(myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + myAISContext()->Erase (myAISContext()->Current(), Standard_True); + } + myAISContext()->ClearCurrents(); + } + + /// + ///Get version + /// + float GetOCCVersion() + { + return (float )OCC_VERSION; + } + + /// + ///set material + /// + void SetMaterial (int theMaterial) + { + if (myAISContext().IsNull()) + { + return; + } + for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + myAISContext()->SetMaterial (myAISContext()->Current(), (Graphic3d_NameOfMaterial )theMaterial); + } + myAISContext()->UpdateCurrentViewer(); + } + + /// + ///set transparency + /// + void SetTransparency (int theTrans) + { + if (myAISContext().IsNull()) + { + return; + } + for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextSelected()) + { + myAISContext()->SetTransparency (myAISContext()->Current(), ((Standard_Real )theTrans) / 10.0); + } + } + + /// + ///Return true if object is selected + /// + bool IsObjectSelected() + { + if (myAISContext().IsNull()) + { + return false; + } + myAISContext()->InitCurrent(); + return myAISContext()->MoreCurrent() != Standard_False; + } + + /// + ///Return display mode + /// + int DisplayMode() + { + if (myAISContext().IsNull()) + { + return -1; + } + + bool isOneOrMoreInShading = false; + bool isOneOrMoreInWireframe = false; + for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + if (myAISContext()->IsDisplayed (myAISContext()->Current(), AIS_Shaded)) + { + isOneOrMoreInShading = true; + } + if (myAISContext()->IsDisplayed (myAISContext()->Current(), AIS_WireFrame)) + { + isOneOrMoreInWireframe = true; + } + } + if (isOneOrMoreInShading + && isOneOrMoreInWireframe) + { + return 10; + } + else if (isOneOrMoreInShading) + { + return 1; + } + else if (isOneOrMoreInWireframe) + { + return 0; + } + return -1; + } + + /// + ///Create new view + /// + /// System.IntPtr that contains the window handle (HWND) of the control + void CreateNewView (System::IntPtr theWnd) + { + if (myAISContext().IsNull()) + { + return; + } + + myView() = myAISContext()->CurrentViewer()->CreateView(); + if (myGraphicDriver().IsNull()) + { + myGraphicDriver() = new OpenGl_GraphicDriver (Handle(Aspect_DisplayConnection)()); + //myGraphicDriver()->ChangeOptions().contextDebug = true; + } + Handle(WNT_Window) aWNTWindow = new WNT_Window (reinterpret_cast (theWnd.ToPointer())); + myView()->SetWindow (aWNTWindow); + Standard_Integer aWidth = 100, aHeight = 100; + aWNTWindow->Size (aWidth, aHeight); + if (!aWNTWindow->IsMapped()) + { + aWNTWindow->Map(); + } + } + + /// + ///Set AISContext + /// + bool SetAISContext (OCCTProxyD3D^ theViewer) + { + this->myAISContext() = theViewer->GetContext(); + if (myAISContext().IsNull()) + { + return false; + } + return true; + } + + /// + ///Get AISContext + /// + Handle_AIS_InteractiveContext GetContext() + { + return myAISContext(); + } + +public: + // ============================================ + // Import / export functionality + // ============================================ + + /// + ///Import BRep file + /// + /// Name of import file + bool ImportBrep (System::String^ theFileName) + { + bool isResult = false; + int aLength = theFileName->Length; + char* aFilename = new char[aLength + 1]; + for(int i = 0; i < aLength; ++i) + { + aFilename[i] = (char )theFileName->ToCharArray()[i]; + } + aFilename[aLength] = '\0'; + isResult = ImportBrep (aFilename); + delete[] aFilename; + return isResult; + } + + /// + ///Import BRep file + /// + /// Name of import file + bool ImportBrep (char* theFileName) + { + TopoDS_Shape aShape; + BRep_Builder aBuilder; + if (!BRepTools::Read (aShape, theFileName, aBuilder)) + { + return false; + } + if (myAISContext()->HasOpenedContext()) + { + myAISContext()->CloseLocalContext(); + } + Handle(AIS_Shape) aPrs = new AIS_Shape (aShape); + myAISContext()->SetMaterial (aPrs, Graphic3d_NOM_GOLD); + myAISContext()->SetDisplayMode(aPrs, AIS_Shaded, Standard_False); + myAISContext()->Display (aPrs); + return true; + } + + /// + ///Import Csfdb file + /// + /// Name of import file + bool ImportCsfdb (char* theFileName) + { + TCollection_AsciiString aName (theFileName); + if (FSD_File::IsGoodFileType (aName) != Storage_VSOk) + { + return false; + } + + FSD_File aFileDriver; + if (aFileDriver.Open (aName, Storage_VSRead) != Storage_VSOk) + { + return false; + } + + Handle(ShapeSchema) aSchema = new ShapeSchema(); + Handle(Storage_Data) aData = aSchema->Read (aFileDriver); + if (aData->ErrorStatus() != Storage_VSOk) + { + return false; + } + aFileDriver.Close(); + + Handle(Storage_HSeqOfRoot) aRoots = aData->Roots(); + for (Standard_Integer aRootIter = 1; aRootIter <= aRoots->Length(); ++aRootIter) + { + Handle(Storage_Root) aStorRoot = aRoots->Value (aRootIter); + Handle(Standard_Persistent) aStandPersistent = aStorRoot->Object(); + Handle(PTopoDS_HShape) aPShape = Handle(PTopoDS_HShape)::DownCast (aStandPersistent); + if (!aPShape.IsNull()) + { + PTColStd_PersistentTransientMap aMap; + TopoDS_Shape aTShape; + MgtBRep::Translate (aPShape, aMap, aTShape, MgtBRep_WithTriangle); + myAISContext()->Display (new AIS_Shape (aTShape), Standard_True); + } + } + + return true; + } + + /// + ///Import Step file + /// + /// Name of import file + bool ImportStep (char* theFileName) + { + STEPControl_Reader aReader; + if (aReader.ReadFile (theFileName) != IFSelect_RetDone) + { + return false; + } + + bool isFailsonly = false; + aReader.PrintCheckLoad( isFailsonly, IFSelect_ItemsByEntity ); + + int aNbRoot = aReader.NbRootsForTransfer(); + aReader.PrintCheckTransfer (isFailsonly, IFSelect_ItemsByEntity); + for (Standard_Integer aRootIter = 1; aRootIter <= aNbRoot; ++aRootIter) + { + aReader.TransferRoot (aRootIter); + int aNbShap = aReader.NbShapes(); + if (aNbShap > 0) + { + for (int aShapeIter = 1; aShapeIter <= aNbShap; ++aShapeIter) + { + myAISContext()->Display (new AIS_Shape (aReader.Shape (aShapeIter)), Standard_True); + } + } + } + return true; + } + + /// + ///Import Iges file + /// + /// Name of import file + bool ImportIges (char* theFileName) + { + IGESControl_Reader aReader; + if (aReader.ReadFile (theFileName) != IFSelect_RetDone) + { + return false; + } + + aReader.TransferRoots(); + TopoDS_Shape aShape = aReader.OneShape(); + myAISContext()->Display (new AIS_Shape (aShape), Standard_False); + myAISContext()->UpdateCurrentViewer(); + return true; + } + + /// + ///Export BRep file + /// + /// Name of export file + bool ExportBRep (char* theFileName) + { + myAISContext()->InitCurrent(); + if (!myAISContext()->MoreCurrent()) + { + return false; + } + + Handle(AIS_Shape) anIS = Handle(AIS_Shape)::DownCast (myAISContext()->Current()); + return !anIS.IsNull() + && BRepTools::Write (anIS->Shape(), theFileName); + } + + /// + ///Export Step file + /// + /// Name of export file + bool ExportStep (char* theFileName) + { + STEPControl_StepModelType aType = STEPControl_AsIs; + STEPControl_Writer aWriter; + for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + Handle(AIS_Shape) anIS = Handle(AIS_Shape)::DownCast (myAISContext()->Current()); + if (anIS.IsNull()) + { + return false; + } + + TopoDS_Shape aShape = anIS->Shape(); + if (aWriter.Transfer (aShape, aType) != IFSelect_RetDone) + { + return false; + } + } + return aWriter.Write (theFileName) == IFSelect_RetDone; + } + + /// + ///Export Iges file + /// + /// Name of export file + bool ExportIges (char* theFileName) + { + IGESControl_Controller::Init(); + IGESControl_Writer aWriter (Interface_Static::CVal ("XSTEP.iges.unit"), + Interface_Static::IVal ("XSTEP.iges.writebrep.mode")); + for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + Handle(AIS_Shape) anIS = Handle(AIS_Shape)::DownCast (myAISContext()->Current()); + if (anIS.IsNull()) + { + return false; + } + + aWriter.AddShape (anIS->Shape()); + } + + aWriter.ComputeModel(); + return aWriter.Write (theFileName) != Standard_False; + } + + /// + ///Export Vrml file + /// + /// Name of export file + bool ExportVrml (char* theFileName) + { + TopoDS_Compound aRes; + BRep_Builder aBuilder; + aBuilder.MakeCompound (aRes); + for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + Handle(AIS_Shape) anIS = Handle(AIS_Shape)::DownCast (myAISContext()->Current()); + if (anIS.IsNull()) + { + return false; + } + aBuilder.Add (aRes, anIS->Shape()); + } + + VrmlAPI_Writer aWriter; + aWriter.Write (aRes, theFileName); + return true; + } + + /// + ///Export Stl file + /// + /// Name of export file + bool ExportStl (char* theFileName) + { + TopoDS_Compound aComp; + BRep_Builder aBuilder; + aBuilder.MakeCompound (aComp); + for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent()) + { + Handle(AIS_Shape) anIS = Handle(AIS_Shape)::DownCast (myAISContext()->Current()); + if (anIS.IsNull()) + { + return false; + } + aBuilder.Add (aComp, anIS->Shape()); + } + + StlAPI_Writer aWriter; + aWriter.Write (aComp, theFileName); + return true; + } + + /// + ///Define which Import/Export function must be called + /// + /// Name of Import/Export file + /// Determines format of Import/Export file + /// Determines is Import or not + bool TranslateModel (System::String^ theFileName, int theFormat, bool theIsImport) + { + bool isResult = false; + int aLength = theFileName->Length; + char* aFilename = new char[aLength + 1]; + for (int aCharIter = 0; aCharIter < aLength; ++aCharIter) + { + aFilename[aCharIter] = (char)theFileName->ToCharArray()[aCharIter]; + } + aFilename[aLength] = '\0'; + + if (theIsImport) + { + switch (theFormat) + { + case 0: isResult = ImportBrep (aFilename); break; + case 1: isResult = ImportCsfdb (aFilename); break; + case 2: isResult = ImportStep (aFilename); break; + case 3: isResult = ImportIges (aFilename); break; + } + } + else + { + switch (theFormat) + { + case 0: isResult = ExportBRep (aFilename); break; + case 2: isResult = ExportStep (aFilename); break; + case 3: isResult = ExportIges (aFilename); break; + case 4: isResult = ExportVrml (aFilename); break; + case 5: isResult = ExportStl (aFilename); break; + case 6: isResult = Dump (aFilename); break; + } + } + delete[] aFilename; + return isResult; + } + + /// + ///Initialize OCCTProxyD3D + /// + void InitOCCTProxy() + { + myGraphicDriver().Nullify(); + myViewer().Nullify(); + myView().Nullify(); + myAISContext().Nullify(); + } + +private: + + NCollection_Haft myViewer; + NCollection_Haft myView; + NCollection_Haft myAISContext; + NCollection_Haft myGraphicDriver; + BridgeFBO* myBridgeFBO; //!< Provides output to Direct3D buffers + +}; diff --git a/samples/CSharp/OCCTProxy_D3D/OCCTProxy_D3D.vcproj b/samples/CSharp/OCCTProxy_D3D/OCCTProxy_D3D.vcproj new file mode 100644 index 0000000000..db2b50a78d --- /dev/null +++ b/samples/CSharp/OCCTProxy_D3D/OCCTProxy_D3D.vcproj @@ -0,0 +1,379 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/CSharp/OCCTProxy_D3D/OCCTProxy_D3D.vcxproj b/samples/CSharp/OCCTProxy_D3D/OCCTProxy_D3D.vcxproj new file mode 100644 index 0000000000..e5176b4aad --- /dev/null +++ b/samples/CSharp/OCCTProxy_D3D/OCCTProxy_D3D.vcxproj @@ -0,0 +1,203 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {969912D9-78E7-4AB8-B4FF-6B52B4F03991} + OCCTProxy_D3D + Win32Proj + OCCTProxy_D3D + + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + true + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + ..\win32\bind\ + obj\$(Platform)\$(Configuration)\ + false + ..\win64\bind\ + obj\$(Platform)\$(Configuration)\ + false + ..\win32\bin\ + obj\$(Platform)\$(Configuration)\ + false + ..\win64\bin\ + obj\$(Platform)\$(Configuration)\ + false + + + + Disabled + ..\OCC\;$(CSF_OPT_INC);$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories) + WNT;_DEBUG;%(PreprocessorDefinitions) + false + Default + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + + + $(OutDir)OCCTProxy_D3D.dll + $(CSF_OPT_LIB32D);$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories) + true + true + $(OutDir)OCCTProxy_D3D.pdb + Windows + false + + + $(OutDir)OCCTProxy_D3D.lib + MachineX86 + d3d9.lib;d3dx9d.lib;%(AdditionalDependencies) + + + + + X64 + + + Disabled + ..\OCC\;$(CSF_OPT_INC);$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories) + WNT;_DEBUG;%(PreprocessorDefinitions) + false + Default + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + + + $(OutDir)OCCTProxy_D3D.dll + $(CSF_OPT_LIB64D);%(AdditionalLibraryDirectories) + true + true + $(OutDir)OCCTProxy_D3D.pdb + Windows + false + + + $(OutDir)OCCTProxy_D3D.lib + MachineX64 + + + + + ..\OCC\;$(CSF_OPT_INC);$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories) + WNT;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + + + $(OutDir)OCCTProxy_D3D.dll + $(CSF_OPT_LIB32);%(AdditionalLibraryDirectories) + true + Windows + true + true + false + + + $(OutDir)OCCTProxy_D3D.lib + MachineX86 + + + + + X64 + + + ..\OCC\;$(CSF_OPT_INC);$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories) + WNT;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + + + $(OutDir)OCCTProxy_D3D.dll + $(CSF_OPT_LIB64);%(AdditionalLibraryDirectories) + true + Windows + true + true + false + + + $(OutDir)OCCTProxy_D3D.lib + MachineX64 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/CSharp/ReadMe.md b/samples/CSharp/ReadMe.md index 97cd8d36c5..f5605f5b78 100644 --- a/samples/CSharp/ReadMe.md +++ b/samples/CSharp/ReadMe.md @@ -1,4 +1,4 @@ -OCCT CSharp sample {#samples_csharp} +OCCT CSharp sample {#samples_csharp_occt} ================== This sample demonstrates simple way of using OCCT libraries in .Net application @@ -14,7 +14,7 @@ The sample implements two approaches for organizing user interface with C#. Both applications provide the same functionality as the standard OCCT Import/Export sample. First project is called "IE_WinForms" and uses Windows Forms for GUI. -Second application is called "IE_WPF" and uses Windows Presentation Foundation. +Second application is called "IE_WPF_WinForms" and uses Windows Presentation Foundation. Note a few important details: @@ -39,7 +39,7 @@ Note a few important details: control embedding OCCT viewer. Run msvc.bat to start MS Visual Studio for building the sample. -Note that project files are provided only for VS 2008, you can open them in +Note that project files are provided only for VS 2010, you can open them in newer versions of Visual Studio using automatic converter. After conversion check option "Target framework" in properties of C# projects (tab "Application") to ensure that it corresponds to the version set in @@ -51,4 +51,4 @@ Note that all batch scripts use configuration defined in OCCT custom.bat file as default; you can provide arguments specifying VS version, bitness, and mode to override these settings, e.g.: -> msvc.bat vc9 win64 Debug +> msvc.bat vc10 win64 Debug diff --git a/samples/CSharp/ReadMe_D3D.md b/samples/CSharp/ReadMe_D3D.md new file mode 100644 index 0000000000..4a1a7ebc3e --- /dev/null +++ b/samples/CSharp/ReadMe_D3D.md @@ -0,0 +1,56 @@ +Direct3D CSharp sample {#samples_csharp_direct3d} +================== + +This sample demonstrates simple way of using OCCT and DirectX libraries in .Net application +whitten using CSharp and Windows Presentation Foundation (WPF). + +The connection between .Net, OCCT (C++) and DirectX level is provided by proxy libraies, +OCCProxy and D3DProxy, written in C++/CLI. The proxy OCCProxy library contains single ref class +encapsulating OCCT viewer and providing functionality to manipulate this viewer +and to import / export OCCT shapes from / to several supported formats of CAD +files (IGES, STEP, BREP). And the proxy D3DProxy library contains helper methods for rendering +via DirectX. + +Organizing of user interface in this sample is provided by Windows Presentation Foundation (WPF). +And it has the same functionality as the standard OCCT Import/Export sample. The project is +called "IE_WPF_D3D". + +Note a few important details: + +- to build this sample you should to download and install DirectX SDK + http://www.microsoft.com/en-us/download/details.aspx?id=6812 + +- to encapsulate C++ class into a field of ref class, template class + NCollection_Haft provided by OCCT is used + +- in order to work consistently on 64-bit systems with OCCT libraries built in + 32-bit mode, C# assemblies need to have platform target explicitly set to "x86" + (in project Properties / Build) + +- this sample demonstrates indirect method of wrapping C++ to C# using manually + created proxy library. Alternative method is available, wrapping individual + OCCT classes to C# equivalents so that their full API is available to C# user + and the code can be programmed on C# level similarly to C++ one. See desciption + of OCCT C# Wrapper in Advanced Samples and Tools on OCCT web site at + http://www.opencascade.org/support/products/advsamples + +- in WPF sample, WinForms control is used to encapsulate OCC viewer since WPF + does not provide necessary interface to embed OpenGl view. Other possible + solution could be to render OpenGl scene in off-screen buffer and map it + to WPF control as image. That approach would allow using all WPF features in + control embedding OCCT viewer. + +Run msvc.bat to start MS Visual Studio for building the sample. +Note that project files are provided only for VS 2010, you can open them in +newer versions of Visual Studio using automatic converter. +After conversion check option "Target framework" in properties of C# projects +(tab "Application") to ensure that it corresponds to the version set in +the properties of the C++ projects (e.g. ".Net Framework 4.0" for VS 2010). + +Run run_wpf-D3D.bat to launch the corresponding sample. + +Note that all batch scripts use configuration defined in OCCT custom.bat file +as default; you can provide arguments specifying VS version, bitness, and mode +to override these settings, e.g.: + +> msvc.bat vc10 win64 Debug diff --git a/samples/CSharp/WPF/About.xaml b/samples/CSharp/WPF/About.xaml deleted file mode 100644 index 59f2a05356..0000000000 --- a/samples/CSharp/WPF/About.xaml +++ /dev/null @@ -1,18 +0,0 @@ - - - - diff --git a/samples/CSharp/WPF/MainWindow.xaml.cs b/samples/CSharp/WPF/MainWindow.xaml.cs deleted file mode 100644 index d2535d3208..0000000000 --- a/samples/CSharp/WPF/MainWindow.xaml.cs +++ /dev/null @@ -1,614 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using System.ComponentModel; -using System.Windows.Forms.Integration; - -namespace IE_WPF -{ - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow : Window, INotifyPropertyChanged - { - public event PropertyChangedEventHandler PropertyChanged; - protected void RaisePropertyChanged( string thePropertyName ) - { - if ( PropertyChanged != null ) - { - PropertyChanged( this, new PropertyChangedEventArgs( thePropertyName ) ); - } - } - - public MainWindow() - { - InitializeComponent(); - - StatusBarText = String.Empty; - IsHlrOffPushed = false; - IsHlrOnPushed = true; - IsZoomWinEnabled = true; - - #region menu operations - - CommandBinding aBind_New = new CommandBinding( IECommands.New ); - aBind_New.Executed += NewCommand_Executed; - CommandBindings.Add( aBind_New ); - - CommandBinding aBind_Close = new CommandBinding( IECommands.Close ); - aBind_Close.Executed += CloseCommand_Executed; - aBind_Close.CanExecute += CloseCommand_CanExecute; - CommandBindings.Add( aBind_Close ); - - CommandBinding aBind_Quit = new CommandBinding( IECommands.Quit ); - aBind_Quit.Executed += QuitCommand_Executed; - CommandBindings.Add( aBind_Quit ); - - CommandBinding aBind_About = new CommandBinding( IECommands.About ); - aBind_About.Executed += AboutCommand_Executed; - CommandBindings.Add( aBind_About ); - - # endregion - - PreviewKeyDown += new KeyEventHandler( OnPreviewKeyDown ); - PreviewKeyUp += new KeyEventHandler( OnPreviewKeyUp ); - } - - private String myStatusBarText; - public String StatusBarText - { - get - { - return myStatusBarText; - } - private set - { - myStatusBarText = value; - RaisePropertyChanged( "StatusBarText" ); - } - } - - private bool isHlrOffPushed; - public Boolean IsHlrOffPushed - { - get - { - return isHlrOffPushed; - } - set - { - isHlrOffPushed = value; - RaisePropertyChanged("isHlrOffPushed"); - } - } - - private bool isHlrOnPushed; - public Boolean IsHlrOnPushed - { - get - { - return isHlrOnPushed; - } - set - { - isHlrOnPushed = value; - RaisePropertyChanged("IsHlrOnPushed"); - } - } - - private bool isZoomWinEnabled; - public Boolean IsZoomWinEnabled - { - get - { - return isZoomWinEnabled; - } - set - { - isZoomWinEnabled = value; - RaisePropertyChanged("IsZoomWinEnabled"); - } - } - - private OCCViewer ActiveViewer - { - get - { - if ( !IsDocumentOpen ) - { - return null; - } - - WindowsFormsHost aHost = ( ViewPanel.SelectedContent ) as WindowsFormsHost; - if( aHost == null ) - { - return null; - } - - return aHost.Child as OCCViewer; - } - } - - public Boolean IsDocumentOpen - { - get - { - return ViewPanel.Items.Count > 0; - } - } - - private int myDocumentCounter = 1; - - private void NewCommand_Executed( object sender, ExecutedRoutedEventArgs e ) - { - WindowsFormsHost aHost = new WindowsFormsHost(); - OCCViewer aForm = new OCCViewer(); - aForm.Show(); - aHost.Child = aForm; - - TabItem aNewTab = new TabItem(); - aNewTab.Content = aHost; - aNewTab.IsSelected = true; - aNewTab.Header = "Document " + myDocumentCounter.ToString(); - myDocumentCounter++; - - ViewPanel.Items.Add( aNewTab ); - - // update XAML property - RaisePropertyChanged("IsDocumentOpen"); - } - - private void CloseCommand_Executed(object sender, ExecutedRoutedEventArgs e) - { - if ( ViewPanel.Items.Count > 0 ) - { - ViewPanel.Items.Remove( ViewPanel.SelectedItem ); - } - - // update XAML property - RaisePropertyChanged( "IsDocumentOpen" ); - } - - private void CloseCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e) - { - e.CanExecute = IsDocumentOpen; - } - - private void QuitCommand_Executed( object sender, ExecutedRoutedEventArgs e ) - { - this.Close(); - } - - private void ImportBRep_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.ImportModel( ModelFormat.BREP ); - } - } - - private void ImportIges_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.ImportModel( ModelFormat.IGES ); - } - } - - private void ImportStep_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.ImportModel( ModelFormat.STEP ); - } - } - - private void ExportBRep_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.ExportModel( ModelFormat.BREP ); - } - } - - private void ExportStep_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.ExportModel( ModelFormat.STEP ); - } - } - - private void ExportIges_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.ExportModel( ModelFormat.IGES ); - } - } - - private void ExportStl_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.ExportModel( ModelFormat.STL ); - } - } - - private void ExportVrml_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.ExportModel( ModelFormat.VRML ); - } - } - - private void ExportImage_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.ExportModel( ModelFormat.IMAGE ); - } - } - - private void FitAllBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.FitAll(); - } - } - - private void ZoomWindowBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - IsZoomWinEnabled = false; - ActiveViewer.ZoomWindow(); - } - } - - private void DynamicZoomingBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.DynamicZooming(); - } - } - - private void DynamicPanningBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.DynamicPanning(); - } - } - - private void GlobalPanningBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.GlobalPanning(); - } - } - - private void FrontBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.FrontView(); - } - } - - private void BackBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.BackView(); - } - } - - private void TopBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.TopView(); - } - } - - private void BottomBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.BottomView(); - } - } - - private void LeftBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.LeftView(); - } - } - - private void RightBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.RightView(); - } - } - - private void AxoBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.AxoView(); - } - } - - private void ResetBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.Reset(); - } - } - - private void DynamicRotationBtn_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.DynamicRotation(); - } - } - - private void HiddenOffBtn_Click( object sender, RoutedEventArgs e ) - { - IsHlrOffPushed = true; - IsHlrOnPushed = false; - if ( ActiveViewer != null ) - { - ActiveViewer.HiddenOff(); - } - } - - private void HiddenOnBtn_Click( object sender, RoutedEventArgs e ) - { - IsHlrOffPushed = false; - IsHlrOnPushed = true; - if (ActiveViewer != null) - { - ActiveViewer.HiddenOn(); - } - } - - private void AboutCommand_Executed( object sender, ExecutedRoutedEventArgs e ) - { - AboutDialog aDlg = new AboutDialog(); - aDlg.ShowDialog(); - } - - private void ToolBar_MouseEnter( object sender, MouseEventArgs e ) - { - StatusBarText = "Toolbar"; - } - - private void DocumentToolBar_MouseEnter(object sender, MouseEventArgs e) - { - StatusBarText = "Document toolbar"; - } - - private void ViewToolBar_MouseEnter(object sender, MouseEventArgs e) - { - StatusBarText = "View toolbar"; - } - - private void ToolBar_MouseLeave( object sender, MouseEventArgs e ) - { - StatusBarText = ""; - } - - public void OnZoomingFinished( object sender, EventArgs e ) - { - IsZoomWinEnabled = true; - } - - public bool IsWireframeEnabled - { - get - { - if ( ActiveViewer != null ) - { - return ActiveViewer.IsWireframeEnabled; - } - return false; - } - } - - private void Wireframe_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.Wireframe(); - } - } - - private void Shading_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.Shading(); - } - } - - public bool IsShadingEnabled - { - get - { - if ( ActiveViewer != null ) - { - return ActiveViewer.IsShadingEnabled; - } - return false; - } - } - - private void Color_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.Color(); - } - } - - public bool IsColorEnabled - { - get - { - if ( ActiveViewer != null ) - { - return ActiveViewer.IsColorEnabled; - } - return false; - } - } - - private void Material_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.Material(); - } - } - - public bool IsMaterialEnabled - { - get - { - if ( ActiveViewer != null ) - { - return ActiveViewer.IsMaterialEnabled; - } - return false; - } - } - - private void Transparency_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.Transparency(); - } - } - - public bool IsTransparencyEnabled - { - get - { - if ( ActiveViewer != null ) - { - return ActiveViewer.IsTransparencyEnabled; - } - return false; - } - } - - private void Delete_Click( object sender, RoutedEventArgs e ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.Delete(); - } - } - - public bool IsDeleteEnabled - { - get - { - if ( ActiveViewer != null ) - { - return ActiveViewer.IsDeleteEnabled; - } - return false; - } - } - - private void AvaliabiltyOfOperationToolbarChanged() - { - RaisePropertyChanged( "IsWireframeEnabled" ); - RaisePropertyChanged( "IsShadingEnabled" ); - RaisePropertyChanged( "IsTransparencyEnabled" ); - RaisePropertyChanged( "IsColorEnabled" ); - RaisePropertyChanged( "IsMaterialEnabled" ); - RaisePropertyChanged( "IsDeleteEnabled" ); - } - - public void OnAvaliabiltyOfOperationsChanged( object sender, EventArgs e ) - { - AvaliabiltyOfOperationToolbarChanged(); - } - - private void OnViewerChanged( object sender, SelectionChangedEventArgs e ) - { - if ( e.RemovedItems.Count > 0 ) - { - WindowsFormsHost aHost = ( ( e.RemovedItems[0] as TabItem).Content ) as WindowsFormsHost; - if( aHost == null ) - { - return; - } - OCCViewer aViewer = aHost.Child as OCCViewer; - if( aViewer != null ) - { - aViewer.ZoomingFinished -= new EventHandler( OnZoomingFinished ); - aViewer.AvaliabiltyOfOperationsChanged -= new EventHandler( OnAvaliabiltyOfOperationsChanged ); - } - } - - if ( e.AddedItems.Count > 0 ) - { - WindowsFormsHost aHost = ( (e.AddedItems[0] as TabItem).Content ) as WindowsFormsHost; - if ( aHost == null ) - { - return; - } - OCCViewer aViewer = aHost.Child as OCCViewer; - if ( aViewer != null ) - { - aViewer.ZoomingFinished += new EventHandler( OnZoomingFinished ); - aViewer.AvaliabiltyOfOperationsChanged += new EventHandler( OnAvaliabiltyOfOperationsChanged ); - } - } - - AvaliabiltyOfOperationToolbarChanged(); - } - - private void OnPreviewKeyDown( object sender, KeyEventArgs args ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.OnKeyDown( args.Key ); - } - } - - private void OnPreviewKeyUp( object sender, KeyEventArgs args ) - { - if ( ActiveViewer != null ) - { - ActiveViewer.OnKeyUp(); - } - } - } -} diff --git a/samples/CSharp/WPF/MaterialDlg.xaml b/samples/CSharp/WPF/MaterialDlg.xaml deleted file mode 100644 index ef50086bee..0000000000 --- a/samples/CSharp/WPF/MaterialDlg.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/CSharp/WPF/MaterialDlg.xaml.cs b/samples/CSharp/WPF/MaterialDlg.xaml.cs deleted file mode 100644 index 0a8bebb419..0000000000 --- a/samples/CSharp/WPF/MaterialDlg.xaml.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -namespace IE_WPF -{ - public enum Material - { - Brass, - Bronze, - Copper, - Gold, - Pewter, - Plaster, - Plastic, - Silver - } - - /// - /// Interaction logic for MaterialDlg.xaml - /// - public partial class MaterialDlg : Window - { - public MaterialDlg( OCCTProxy theView ) - { - this.InitializeComponent(); - - if ( theView == null ) - { - MessageBox.Show( "Fatal Error during the graphic initialisation", "Error!" ); - } - - View = theView; - - SetInitialState(); - } - - public OCCTProxy View { get; private set; } - - private void PlasterBtn_Checked( object sender, RoutedEventArgs e ) - { - View.SetMaterial( (int)Material.Plaster ); - View.UpdateCurrentViewer(); - } - - private void BrassBtn_Checked( object sender, RoutedEventArgs e ) - { - View.SetMaterial( (int)Material.Brass ); - View.UpdateCurrentViewer(); - } - - private void BronzeBtn_Checked( object sender, RoutedEventArgs e ) - { - View.SetMaterial( (int)Material.Bronze ); - View.UpdateCurrentViewer(); - } - - private void CopperBtn_Checked( object sender, RoutedEventArgs e ) - { - View.SetMaterial( (int)Material.Copper ); - View.UpdateCurrentViewer(); - } - - private void GoldBtn_Checked( object sender, RoutedEventArgs e ) - { - View.SetMaterial( (int)Material.Gold ); - View.UpdateCurrentViewer(); - } - - private void PewterBtn_Checked( object sender, RoutedEventArgs e ) - { - View.SetMaterial( (int)Material.Pewter ); - View.UpdateCurrentViewer(); - } - - private void PlasticBtn_Checked( object sender, RoutedEventArgs e ) - { - View.SetMaterial( (int)Material.Plastic ); - View.UpdateCurrentViewer(); - } - - private void SilverBtn_Checked( object sender, RoutedEventArgs e ) - { - View.SetMaterial( (int)Material.Silver ); - View.UpdateCurrentViewer(); - } - - private void SetInitialState() - { - // TODO - } - } -} \ No newline at end of file diff --git a/samples/CSharp/WPF/OCCViewer.cs b/samples/CSharp/WPF/OCCViewer.cs deleted file mode 100644 index 649b6a413b..0000000000 --- a/samples/CSharp/WPF/OCCViewer.cs +++ /dev/null @@ -1,840 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Forms; - -namespace IE_WPF -{ - public enum CurrentAction3d - { - CurAction3d_Nothing, - CurAction3d_DynamicZooming, - CurAction3d_WindowZooming, - CurAction3d_DynamicPanning, - CurAction3d_GlobalPanning, - CurAction3d_DynamicRotation - } - public enum CurrentPressedKey - { - CurPressedKey_Nothing, - CurPressedKey_Ctrl, - CurPressedKey_Shift - } - public enum ModelFormat - { - BREP, - CSFDB, - STEP, - IGES, - VRML, - STL, - IMAGE - } - - public enum DisplayMode - { - Wireframe, - Shading - } - - public class OCCViewer : System.Windows.Forms.Form - { - public event EventHandler ZoomingFinished; - protected void RaiseZoomingFinished() - { - if ( ZoomingFinished != null ) - { - ZoomingFinished( this, EventArgs.Empty ); - } - } - - public event EventHandler AvaliabiltyOfOperationsChanged; - protected void RaiseAvaliabiltyOfOperationsChanged() - { - if ( AvaliabiltyOfOperationsChanged != null ) - { - AvaliabiltyOfOperationsChanged( this, EventArgs.Empty ); - } - } - - public OCCTProxy View { get; private set; } - public CurrentAction3d CurrentMode { get; private set; } - private CurrentPressedKey CurrentPressedKey { get; set; } - private bool IsRectVisible { get; set; } - public bool DegenerateMode { get; private set; } - - public bool IsWireframeEnabled { get; private set; } - public bool IsShadingEnabled { get; private set; } - public bool IsTransparencyEnabled { get; private set; } - public bool IsColorEnabled { get; private set; } - public bool IsMaterialEnabled { get; private set; } - public bool IsDeleteEnabled { get; private set; } - - private float myCurZoom;// ~ Quantity_Factor - private int myXmin; - private int myYmin; - private int myXmax; - private int myYmax; - private int myRectDownX; - private int myRectDownY; - private int myButtonDownX; - private int myButtonDownY; - - private ContextMenu Popup { get; set; } - private MenuItem ContextWireframe; - private MenuItem ContextShading; - private MenuItem ContextColor; - private MenuItem ContextMaterial; - private MenuItem ContextDelete; - private MenuItem ContextBackground; - private MenuItem ContextTransparency; - - - public OCCViewer() - { - InitializeComponent(); - - View = new OCCTProxy(); - View.InitOCCTProxy(); - if ( !View.InitViewer( this.Handle ) ) - { - MessageBox.Show( "Fatal Error during the graphic initialisation", "Error!" ); - } - - CurrentMode = CurrentAction3d.CurAction3d_Nothing; - CurrentPressedKey = CurrentPressedKey.CurPressedKey_Nothing; - IsRectVisible = false; - DegenerateMode = true; - } - - private void InitializeComponent() - { - ControlBox = false; - TopLevel = false; - - this.ImeMode = System.Windows.Forms.ImeMode.NoControl; - - SizeChanged += new System.EventHandler( OnSizeChanged ); - Paint += new System.Windows.Forms.PaintEventHandler( OnPaint ); - - MouseDown += new System.Windows.Forms.MouseEventHandler( OnMouseDown ); - MouseUp += new System.Windows.Forms.MouseEventHandler( OnMouseUp ); - MouseMove += new System.Windows.Forms.MouseEventHandler( OnMouseMove ); - - Popup = new ContextMenu(); - ContextWireframe = new MenuItem(); - ContextShading = new MenuItem(); - ContextColor = new MenuItem(); - ContextMaterial = new MenuItem(); - ContextTransparency = new MenuItem(); - ContextDelete = new MenuItem(); - ContextBackground = new MenuItem(); - - ContextWireframe.Text = "Wireframe"; - ContextShading.Text = "Shading"; - ContextColor.Text = "Color"; - ContextMaterial.Text = "Material"; - ContextTransparency.Text = "Transparency"; - ContextDelete.Text = "Delete"; - ContextBackground.Text = "Background"; - - ContextWireframe.Click += new System.EventHandler( ContextWireframe_Click ); - ContextShading.Click += new System.EventHandler( ContextShading_Click ); - ContextColor.Click += new System.EventHandler( ContextColor_Click ); - ContextMaterial.Click += new System.EventHandler( ContextMaterial_Click ); - ContextTransparency.Click += new System.EventHandler( ContextTransparency_Click ); - ContextDelete.Click += new System.EventHandler( ContextDelete_Click ); - ContextBackground.Click += new System.EventHandler( ContextBackground_Click ); - - Popup.MenuItems.AddRange( new MenuItem[] { ContextWireframe, - ContextShading, - ContextColor, - ContextMaterial, - ContextTransparency, - ContextDelete, - ContextBackground } ); - Popup.Popup += new System.EventHandler( OnPopup ); - } - - private void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e) - { - View.RedrawView(); - View.UpdateView(); - } - - private void OnSizeChanged(object sender, System.EventArgs e) - { - View.UpdateView(); - } - - public void ImportModel( ModelFormat theFormat ) - { - int aFormat = 10; - OpenFileDialog anOpenDialog = new OpenFileDialog(); - string aDataDir = ( (Environment.GetEnvironmentVariable("CASROOT")) + "\\..\\data" ); - string aFilter = ""; - - switch ( theFormat ) - { - case ModelFormat.BREP: - anOpenDialog.InitialDirectory = (aDataDir + "\\occ"); - aFormat = 0; - aFilter = "BREP Files (*.brep *.rle)|*.brep; *.rle"; - break; - case ModelFormat.CSFDB: - aFormat = 1; - aFilter = "CSFDB Files (*.csfdb)|*.csfdb"; - break; - case ModelFormat.STEP: - anOpenDialog.InitialDirectory = (aDataDir + "\\step"); - aFormat = 2; - aFilter = "STEP Files (*.stp *.step)|*.stp; *.step"; - break; - case ModelFormat.IGES: - anOpenDialog.InitialDirectory = (aDataDir + "\\iges"); - aFormat = 3; - aFilter = "IGES Files (*.igs *.iges)|*.igs; *.iges"; - break; - default: - break; - } - - anOpenDialog.Filter = aFilter + "|All files (*.*)|*.*"; - if (anOpenDialog.ShowDialog() == DialogResult.OK) - { - string aFileName = anOpenDialog.FileName; - if (aFileName == "") - { - return; - } - - Cursor = System.Windows.Forms.Cursors.WaitCursor; - if ( !View.TranslateModel( aFileName, aFormat, true ) ) - { - MessageBox.Show( "Cann't read this file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning ); - } - Cursor = System.Windows.Forms.Cursors.Default; - } - View.ZoomAllView(); - } - - public void ExportModel( ModelFormat theFormat ) - { - int aFormat = 10; - SaveFileDialog saveDialog = new SaveFileDialog(); - string aDataDir = ( (Environment.GetEnvironmentVariable("CASROOT") ) + "\\..\\data" ); - string aFilter = ""; - - switch ( theFormat ) - { - case ModelFormat.BREP: - saveDialog.InitialDirectory = ( aDataDir + "\\occ" ); - aFormat = 0; - aFilter = "BREP Files (*.brep *.rle)|*.brep; *.rle"; - break; - case ModelFormat.CSFDB: - aFormat = 1; - aFilter = "CSFDB Files (*.csfdb)|*.csfdb"; - break; - case ModelFormat.STEP: - saveDialog.InitialDirectory = ( aDataDir + "\\step" ); - aFormat = 2; - aFilter = "STEP Files (*.stp *.step)|*.step; *.stp"; - break; - case ModelFormat.IGES: - saveDialog.InitialDirectory = ( aDataDir + "\\iges" ); - aFormat = 3; - aFilter = "IGES Files (*.igs *.iges)| *.iges; *.igs"; - break; - case ModelFormat.VRML: - saveDialog.InitialDirectory = ( aDataDir + "\\vrml" ); - aFormat = 4; - aFilter = "VRML Files (*.vrml)|*.vrml"; - break; - case ModelFormat.STL: - saveDialog.InitialDirectory = ( aDataDir + "\\stl" ); - aFormat = 5; - aFilter = "STL Files (*.stl)|*.stl"; - break; - case ModelFormat.IMAGE: - saveDialog.InitialDirectory = ( aDataDir + "\\images" ); - aFormat = 6; - aFilter = "Images Files (*.bmp)|*.bmp"; - break; - default: - break; - } - - saveDialog.Filter = aFilter; - if ( saveDialog.ShowDialog() == DialogResult.OK ) - { - string aFileName = saveDialog.FileName; - if ( aFileName == "" ) - { - return; - } - - Cursor = System.Windows.Forms.Cursors.WaitCursor; - if ( !View.TranslateModel( aFileName, aFormat, false ) ) - { - MessageBox.Show( "Can not write this file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning ); - } - Cursor = System.Windows.Forms.Cursors.Default; - } - } - - public void FitAll() - { - View.ZoomAllView(); - } - - public void ZoomWindow() - { - CurrentMode = CurrentAction3d.CurAction3d_WindowZooming; - } - - public void DynamicZooming() - { - CurrentMode = CurrentAction3d.CurAction3d_DynamicZooming; - } - - public void DynamicPanning() - { - CurrentMode = CurrentAction3d.CurAction3d_DynamicPanning; - } - - public void GlobalPanning() - { - myCurZoom = View.Scale(); - CurrentMode = CurrentAction3d.CurAction3d_GlobalPanning; - } - - public void AxoView() - { - View.AxoView(); - } - - public void FrontView() - { - View.FrontView(); - } - - public void TopView() - { - View.TopView(); - } - - public void LeftView() - { - View.LeftView(); - } - - public void BackView() - { - View.BackView(); - } - - public void RightView() - { - View.RightView(); - } - - public void Reset() - { - View.Reset(); - } - - public void BottomView() - { - View.BottomView(); - } - - public void HiddenOff() - { - View.SetDegenerateModeOff(); - DegenerateMode = false; - } - - public void HiddenOn() - { - View.SetDegenerateModeOn(); - DegenerateMode = true; - } - - public void DynamicRotation() - { - CurrentMode = CurrentAction3d.CurAction3d_DynamicRotation; - } - - public void SelectionChanged() - { - switch ( View.DisplayMode() ) - { - case -1: - IsShadingEnabled = false; - IsWireframeEnabled = false; - break; - case 0: - IsWireframeEnabled = false; - IsShadingEnabled = true; - IsTransparencyEnabled = false; - break; - case 1: - IsWireframeEnabled = true; - IsShadingEnabled = false; - IsTransparencyEnabled = true; - break; - case 10: - IsWireframeEnabled = true; - IsShadingEnabled = true; - IsTransparencyEnabled = true; - break; - default: - break; - } - - if ( View.IsObjectSelected() ) - { - IsColorEnabled = true; - IsMaterialEnabled = true; - IsDeleteEnabled = true; - } - else - { - IsColorEnabled = false; - IsMaterialEnabled = false; - IsTransparencyEnabled = false; - IsDeleteEnabled = false; - } - - RaiseAvaliabiltyOfOperationsChanged(); - } - - public void ChangeColor( bool IsObjectColor ) - { - int r, g, b; - if ( IsObjectColor ) - { - r = View.GetObjColR(); - g = View.GetObjColG(); - b = View.GetObjColB(); - } - else - { - r = View.GetBGColR(); - g = View.GetBGColG(); - b = View.GetBGColB(); - } - System.Windows.Forms.ColorDialog ColDlg = new System.Windows.Forms.ColorDialog(); - ColDlg.Color = System.Drawing.Color.FromArgb( r, g, b ); - if ( ColDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK ) - { - System.Drawing.Color c = ColDlg.Color; - r = c.R; - g = c.G; - b = c.B; - if ( IsObjectColor ) - { - View.SetColor( r, g, b ); - } - else - { - View.SetBackgroundColor( r, g, b ); - } - } - View.UpdateCurrentViewer(); - } - - public void Wireframe() - { - View.SetDisplayMode( (int)DisplayMode.Wireframe ); - View.UpdateCurrentViewer(); - - SelectionChanged(); - RaiseZoomingFinished(); - } - - public void Shading() - { - View.SetDisplayMode( (int)DisplayMode.Shading ); - View.UpdateCurrentViewer(); - - SelectionChanged(); - RaiseZoomingFinished(); - } - - public void Color() - { - ChangeColor( true ); - } - - public void Background() - { - ChangeColor( false ); - } - - public void Material() - { - MaterialDlg aDlg = new MaterialDlg( View ); - aDlg.ShowDialog(); - } - - public void Transparency() - { - TransparencyDialog dlg = new TransparencyDialog(); - dlg.View = View; - dlg.ShowDialog( this ); - } - - public void Delete() - { - View.EraseObjects(); - } - - public void OnKeyDown( System.Windows.Input.Key theKey ) - { - if ( theKey == System.Windows.Input.Key.LeftShift || - theKey == System.Windows.Input.Key.RightShift ) - { - CurrentPressedKey = CurrentPressedKey.CurPressedKey_Shift; - } - else if (theKey == System.Windows.Input.Key.LeftCtrl || - theKey == System.Windows.Input.Key.RightCtrl ) - { - CurrentPressedKey = CurrentPressedKey.CurPressedKey_Ctrl; - } - } - - public void OnKeyUp() - { - CurrentPressedKey = CurrentPressedKey.CurPressedKey_Nothing; - } - - protected void MultiDragEvent( int x, int y, int theState ) - { - if ( theState == -1 ) //mouse is down - { - myButtonDownX = x; - myButtonDownY = y; - } - else if ( theState == 1) //mouse is up - { - View.ShiftSelect( Math.Min( myButtonDownX, x ), Math.Min( myButtonDownY, y ), - Math.Max( myButtonDownX, x ), Math.Max( myButtonDownY, y ) ); - } - } - - protected void DragEvent( int x, int y, int theState ) - { - if ( theState == -1 ) //mouse is down - { - myButtonDownX = x; - myButtonDownY = y; - } - else if ( theState == 1 ) //mouse is up - { - View.Select( Math.Min( myButtonDownX, x ), Math.Min( myButtonDownY, y ), - Math.Max( myButtonDownX, x ), Math.Max( myButtonDownY, y ) ); - } - } - - private void DrawRectangle( bool draw ) - { - System.Drawing.Graphics gr = System.Drawing.Graphics.FromHwnd(Handle); - System.Drawing.Pen p = null; - if ( IsRectVisible || !draw )//erase the rect - { - int r = View.GetBGColR(); - int g = View.GetBGColG(); - int b = View.GetBGColB(); - p = new System.Drawing.Pen( System.Drawing.Color.FromArgb(r, g, b) ); - IsRectVisible = false; - View.UpdateView(); - } - else if ( draw ) - { - p = new System.Drawing.Pen( System.Drawing.Color.White ); - IsRectVisible = true; - } - if ( p == null ) - { - return; - } - int x = Math.Min( myXmin, myXmax ); - int y = Math.Min( myYmin, myYmax ); - gr.DrawRectangle( p, x, y, Math.Abs(myXmax - myXmin), Math.Abs(myYmax - myYmin) ); - myRectDownX = Math.Max( myXmin, myXmax ); - myRectDownY = Math.Max( myYmin, myYmax ); - } - - private void OnMouseDown( object sender, System.Windows.Forms.MouseEventArgs e ) - { - if ( e.Button == MouseButtons.Left ) - { - myXmin = e.X; - myXmax = e.X; - myYmin = e.Y; - myYmax = e.Y; - if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) - { - // start the dinamic zooming.... - CurrentMode = CurrentAction3d.CurAction3d_DynamicZooming; - } - else - { - switch ( CurrentMode ) - { - case CurrentAction3d.CurAction3d_Nothing: - if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift ) - { - MultiDragEvent( myXmax, myYmax, -1 ); - } - else - { - DragEvent( myXmax, myYmax, -1 ); - } - break; - case CurrentAction3d.CurAction3d_DynamicRotation: - if ( !DegenerateMode ) - { - View.SetDegenerateModeOn(); - } - View.StartRotation( e.X, e.Y ); - break; - case CurrentAction3d.CurAction3d_WindowZooming: - Cursor = Cursors.Hand; - break; - default: - break; - } - } - } - else if ( e.Button == MouseButtons.Right ) - { - if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) - { - if ( !DegenerateMode ) - { - View.SetDegenerateModeOn(); - } - View.StartRotation( e.X, e.Y ); - } - else - { - Popup.Show( this, new System.Drawing.Point( e.X, e.Y ) ); - } - } - } - - private void OnMouseUp( object sender, System.Windows.Forms.MouseEventArgs e ) - { - if ( e.Button == MouseButtons.Left ) - { - if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) - { - return; - } - switch ( CurrentMode ) - { - case CurrentAction3d.CurAction3d_Nothing: - if ( e.X == myXmin && e.Y == myYmin ) - { - myXmax = e.X; - myYmax = e.Y; - if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift ) - { - View.ShiftSelect(); - } - else - { - View.Select(); - } - } - else - { - myXmax = e.X; - myYmax = e.Y; - DrawRectangle( false ); - if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift ) - { - MultiDragEvent( myXmax, myYmax, 1 ); - } - else - { - DragEvent( myXmax, myYmax, 1 ); - } - } - break; - case CurrentAction3d.CurAction3d_DynamicZooming: - CurrentMode = CurrentAction3d.CurAction3d_Nothing; - break; - case CurrentAction3d.CurAction3d_WindowZooming: - myXmax = e.X; - myYmax = e.Y; - DrawRectangle( false ); - int ValZWMin = 1; - if ( Math.Abs(myXmax - myXmin) > ValZWMin && - Math.Abs(myXmax - myYmax) > ValZWMin ) - { - View.WindowFitAll( myXmin, myYmin, myXmax, myYmax ); - } - Cursor = Cursors.Arrow; - RaiseZoomingFinished(); - CurrentMode = CurrentAction3d.CurAction3d_Nothing; - break; - case CurrentAction3d.CurAction3d_DynamicPanning: - CurrentMode = CurrentAction3d.CurAction3d_Nothing; - break; - case CurrentAction3d.CurAction3d_GlobalPanning: - View.Place( e.X, e.Y, myCurZoom ); - CurrentMode = CurrentAction3d.CurAction3d_Nothing; - break; - case CurrentAction3d.CurAction3d_DynamicRotation: - CurrentMode = CurrentAction3d.CurAction3d_Nothing; - if ( !DegenerateMode ) - { - View.SetDegenerateModeOff(); - } - else - { - View.SetDegenerateModeOn(); - } - break; - default: - break; - } - } - else if ( e.Button == MouseButtons.Right ) - { - if ( !DegenerateMode ) - { - View.SetDegenerateModeOff(); - } - else - { - View.SetDegenerateModeOn(); - } - } - - SelectionChanged(); - } - - private void OnMouseMove( object sender, System.Windows.Forms.MouseEventArgs e ) - { - if ( e.Button == MouseButtons.Left ) //left button is pressed - { - if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) - { - View.Zoom(myXmax, myYmax, e.X, e.Y); - myXmax = e.X; - myYmax = e.Y; - } - else - { - switch ( CurrentMode ) - { - case CurrentAction3d.CurAction3d_Nothing: - DrawRectangle( false ); - myXmax = e.X; - myYmax = e.Y; - DrawRectangle( true ); - break; - case CurrentAction3d.CurAction3d_DynamicZooming: - View.Zoom( myXmax, myYmax, e.X, e.Y ); - myXmax = e.X; - myYmax = e.Y; - break; - case CurrentAction3d.CurAction3d_WindowZooming: - DrawRectangle( false ); - myXmax = e.X; - myYmax = e.Y; - DrawRectangle( true );//add brush here - break; - case CurrentAction3d.CurAction3d_DynamicPanning: - View.Pan( e.X - myXmax, myYmax - e.Y ); - myXmax = e.X; - myYmax = e.Y; - break; - case CurrentAction3d.CurAction3d_GlobalPanning: - break; - case CurrentAction3d.CurAction3d_DynamicRotation: - View.Rotation( e.X, e.Y ); - View.RedrawView(); - break; - default: - break; - } - } - } - else if ( e.Button == MouseButtons.Middle ) //middle button is pressed - { - if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) - { - View.Pan( e.X - myXmax, myYmax - e.Y ); - myXmax = e.X; - myYmax = e.Y; - } - } - else if ( e.Button == MouseButtons.Right ) //right button is pressed - { - if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl) - { - View.Rotation( e.X, e.Y ); - } - } - else // no buttons are pressed - { - myXmax = e.X; - myYmax = e.Y; - View.MoveTo( e.X, e.Y ); - } - } - - private void OnPopup( object sender, System.EventArgs e ) - { - ContextWireframe.Enabled = IsWireframeEnabled; - ContextShading.Enabled = IsShadingEnabled; - ContextColor.Enabled = IsColorEnabled; - ContextMaterial.Enabled = IsMaterialEnabled; - ContextDelete.Enabled = IsDeleteEnabled; - ContextTransparency.Enabled = IsTransparencyEnabled; - ContextBackground.Enabled = true; - } - - private void ContextWireframe_Click( object sender, System.EventArgs e ) - { - Wireframe(); - } - - private void ContextShading_Click( object sender, System.EventArgs e ) - { - Shading(); - } - - private void ContextColor_Click( object sender, System.EventArgs e ) - { - Color(); - } - - private void ContextMaterial_Click( object sender, System.EventArgs e ) - { - Material(); - } - - private void ContextTransparency_Click( object sender, System.EventArgs e ) - { - Transparency(); - } - - private void ContextDelete_Click( object sender, System.EventArgs e ) - { - Delete(); - } - - private void ContextBackground_Click( object sender, System.EventArgs e ) - { - Background(); - } - } -} diff --git a/samples/CSharp/WPF/Properties/AssemblyInfo.cs b/samples/CSharp/WPF/Properties/AssemblyInfo.cs deleted file mode 100644 index 02445ca672..0000000000 --- a/samples/CSharp/WPF/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("IE")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("IE")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/CSharp/WPF/Properties/Resources.Designer.cs b/samples/CSharp/WPF/Properties/Resources.Designer.cs deleted file mode 100644 index 5855aaffdf..0000000000 --- a/samples/CSharp/WPF/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.5472 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace IE_WPF.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IE_WPF.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/samples/CSharp/WPF/Properties/Resources.resx b/samples/CSharp/WPF/Properties/Resources.resx deleted file mode 100644 index af7dbebbac..0000000000 --- a/samples/CSharp/WPF/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/samples/CSharp/WPF/Properties/Settings.Designer.cs b/samples/CSharp/WPF/Properties/Settings.Designer.cs deleted file mode 100644 index 7228f90b91..0000000000 --- a/samples/CSharp/WPF/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.5472 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace IE_WPF.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/samples/CSharp/WPF/Properties/Settings.settings b/samples/CSharp/WPF/Properties/Settings.settings deleted file mode 100644 index 033d7a5e9e..0000000000 --- a/samples/CSharp/WPF/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/samples/CSharp/WPF/Simple Styles.xaml b/samples/CSharp/WPF/Simple Styles.xaml deleted file mode 100644 index b130cea606..0000000000 --- a/samples/CSharp/WPF/Simple Styles.xaml +++ /dev/null @@ -1,1134 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/CSharp/WPF/TransparencyDialog.cs b/samples/CSharp/WPF/TransparencyDialog.cs deleted file mode 100644 index 0b328d5cc9..0000000000 --- a/samples/CSharp/WPF/TransparencyDialog.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; - -namespace IE_WPF -{ - /// - /// Summary description for TransparencyDialog. - /// - public class TransparencyDialog : System.Windows.Forms.Form - { - private System.Windows.Forms.NumericUpDown MyTransparency; - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - private OCCTProxy myView; - - public TransparencyDialog() - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - // - // TODO: Add any constructor code after InitializeComponent call - // - myView = null; - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose(bool disposing) - { - if (disposing) - { - if (components != null) - { - components.Dispose(); - } - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TransparencyDialog)); - this.MyTransparency = new System.Windows.Forms.NumericUpDown(); - ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).BeginInit(); - this.SuspendLayout(); - // - // MyTransparency - // - this.MyTransparency.Location = new System.Drawing.Point(16, 16); - this.MyTransparency.Maximum = new System.Decimal(new int[] { - 10, - 0, - 0, - 0}); - this.MyTransparency.Name = "MyTransparency"; - this.MyTransparency.Size = new System.Drawing.Size(96, 20); - this.MyTransparency.TabIndex = 0; - this.MyTransparency.ValueChanged += new System.EventHandler(this.MyTransparency_ValueChanged); - // - // TransparencyDialog - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(128, 53); - this.Controls.Add(this.MyTransparency); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "TransparencyDialog"; - this.Text = "TransparencyDialog"; - ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).EndInit(); - this.ResumeLayout(false); - - } - #endregion - - private void MyTransparency_ValueChanged(object sender, System.EventArgs e) - { - if (this.myView == null) - return; - int transp = (int)this.MyTransparency.Value; - this.myView.SetTransparency(transp); - } - - public OCCTProxy View - { - set - { - this.myView = value; - } - } - - } -} diff --git a/samples/CSharp/WPF/TransparencyDialog.resx b/samples/CSharp/WPF/TransparencyDialog.resx deleted file mode 100644 index 688fd72e80..0000000000 --- a/samples/CSharp/WPF/TransparencyDialog.resx +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - False - - - Private - - - Private - - - False - - - (Default) - - - False - - - False - - - 8, 8 - - - True - - - 80 - - - True - - - Private - - - TransparencyDialog - - - - AAABAAEAMDAAAAAAAACoDgAAFgAAACgAAAAwAAAAYAAAAAEACAAAAAAAgAoAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYABAQEAAgICAAMDAwAERERABYW - FgAcHBwAIiIiACkpKQBVVVUATU1NAEJCQgA5OTkAgHz/AFBQ/wCTANYA/+zMAMbW7wDW5+cAkKmtAAAA - MwAAAGYAAACZAAAAzAAAMwAAADMzAAAzZgAAM5kAADPMAAAz/wAAZgAAAGYzAABmZgAAZpkAAGbMAABm - /wAAmQAAAJkzAACZZgAAmZkAAJnMAACZ/wAAzAAAAMwzAADMZgAAzJkAAMzMAADM/wAA/2YAAP+ZAAD/ - zAAzAAAAMwAzADMAZgAzAJkAMwDMADMA/wAzMwAAMzMzADMzZgAzM5kAMzPMADMz/wAzZgAAM2YzADNm - ZgAzZpkAM2bMADNm/wAzmQAAM5kzADOZZgAzmZkAM5nMADOZ/wAzzAAAM8wzADPMZgAzzJkAM8zMADPM - /wAz/zMAM/9mADP/mQAz/8wAM///AGYAAABmADMAZgBmAGYAmQBmAMwAZgD/AGYzAABmMzMAZjNmAGYz - mQBmM8wAZjP/AGZmAABmZjMAZmZmAGZmmQBmZswAZpkAAGaZMwBmmWYAZpmZAGaZzABmmf8AZswAAGbM - MwBmzJkAZszMAGbM/wBm/wAAZv8zAGb/mQBm/8wAzAD/AP8AzACZmQAAmTOZAJkAmQCZAMwAmQAAAJkz - MwCZAGYAmTPMAJkA/wCZZgAAmWYzAJkzZgCZZpkAmWbMAJkz/wCZmTMAmZlmAJmZmQCZmcwAmZn/AJnM - AACZzDMAZsxmAJnMmQCZzMwAmcz/AJn/AACZ/zMAmcxmAJn/mQCZ/8wAmf//AMwAAACZADMAzABmAMwA - mQDMAMwAmTMAAMwzMwDMM2YAzDOZAMwzzADMM/8AzGYAAMxmMwCZZmYAzGaZAMxmzACZZv8AzJkAAMyZ - MwDMmWYAzJmZAMyZzADMmf8AzMwAAMzMMwDMzGYAzMyZAMzMzADMzP8AzP8AAMz/MwCZ/2YAzP+ZAMz/ - zADM//8AzAAzAP8AZgD/AJkAzDMAAP8zMwD/M2YA/zOZAP8zzAD/M/8A/2YAAP9mMwDMZmYA/2aZAP9m - zADMZv8A/5kAAP+ZMwD/mWYA/5mZAP+ZzAD/mf8A/8wAAP/MMwD/zGYA/8yZAP/MzAD/zP8A//8zAMz/ - ZgD//5kA///MAGZm/wBm/2YAZv//AP9mZgD/Zv8A//9mACEApQBfX18Ad3d3AIaGhgCWlpYAy8vLALKy - sgDX19cA3d3dAOPj4wDq6uoA8fHxAPj4+ADw+/8ApKCgAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// - AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMT - ExMTExMTEyIiQiI8HTyCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALwDODg4Nzc4MQMdAAAA - AADDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOw4ODgyOCQAAAAdAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAODIyMSIAHewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAA7DI3MSIdCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAADEyMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs4JAALAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALwxJAAhAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4IgC8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAJAxJB0LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - ALwLCx0dIh0dCwATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACx0dAB0dIiIiIiId - CxMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAvAsdAB0dIiQkAyQkIiIiHSIAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAIgMxMVhZmZqZAyQiHR0AAAAAkAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAvAsdISIDMThZWVmgvaCZWVIkIh0AAB0dIh0hCwALCwALtgAAAAAAAAAAAAAAAOwAAB0iMTEx - ODhYWZrDw8Ofn1hSJCIAHQAdACIAHSIkAwsdOAAAAADeExMTCwsLIiIkMTEyODg3MllZmprDw8PDwllS - MSQdHQAAAB0AIiQkAAAAvDi8AAAxAzExMTExMTI4Nzg4ODc4ODhZXpnDw8PDml1YNwMkIh0AAB0hIiQA - AAAAACIAAAA4ODc4Nzg4ODg4ODg4ODg4ODhZWV6avb2gmllZODcxJCIAAAAdIgMLAAAAACIAAACGE0+G - T4bs7Oy8vLy8vAAxODg4ODg4NzIyMSQdHQAAvADsCwAiJDExAAAAwjjsAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAALMSQAAAAAAAAAAAAAAAAAEyI4MQsiOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALMSQAAAAA - AAAAAAAAAAAAAAC8CwsAEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC8AAsAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////AAD///////8AAP///////wAA//////// - AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP// - /////wAA//8AAH//AAD//wAAf/8AAP//4AP//wAA///4B///AAD///gP//8AAP///B///wAA///8H/// - AAD///wf//8AAP///h///wAA///8H///AAD//+AD//8AAP//wAD//wAA//4AAD//AAD//AAAB/8AAP/w - AAAAAwAA/8AAAAABAADAAAAAADgAAMAAAAAAPAAAwAAAAAA8AADAAAAAIDgAAP///j/+AQAA///+P/+D - AAD///4///8AAP///////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP// - /////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA - - - \ No newline at end of file diff --git a/samples/CSharp/WPF/app.config b/samples/CSharp/WPF/app.config deleted file mode 100644 index e365603337..0000000000 --- a/samples/CSharp/WPF/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/samples/CSharp/WPF/res/MainFrame.ico b/samples/CSharp/WPF/res/MainFrame.ico deleted file mode 100644 index 99dbceb637..0000000000 Binary files a/samples/CSharp/WPF/res/MainFrame.ico and /dev/null differ diff --git a/samples/CSharp/WPF/res/document.png b/samples/CSharp/WPF/res/document.png deleted file mode 100644 index 1ba28fff33..0000000000 Binary files a/samples/CSharp/WPF/res/document.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/help.png b/samples/CSharp/WPF/res/help.png deleted file mode 100644 index e57336285e..0000000000 Binary files a/samples/CSharp/WPF/res/help.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/lamp.png b/samples/CSharp/WPF/res/lamp.png deleted file mode 100644 index a5a6775c33..0000000000 Binary files a/samples/CSharp/WPF/res/lamp.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/new.png b/samples/CSharp/WPF/res/new.png deleted file mode 100644 index 953757a62f..0000000000 Binary files a/samples/CSharp/WPF/res/new.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/occ_logo.bmp b/samples/CSharp/WPF/res/occ_logo.bmp deleted file mode 100644 index 443a7de612..0000000000 Binary files a/samples/CSharp/WPF/res/occ_logo.bmp and /dev/null differ diff --git a/samples/CSharp/WPF/res/tool_color.png b/samples/CSharp/WPF/res/tool_color.png deleted file mode 100644 index b37ad7d480..0000000000 Binary files a/samples/CSharp/WPF/res/tool_color.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/tool_delete.png b/samples/CSharp/WPF/res/tool_delete.png deleted file mode 100644 index aaab07fc9f..0000000000 Binary files a/samples/CSharp/WPF/res/tool_delete.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/tool_material.png b/samples/CSharp/WPF/res/tool_material.png deleted file mode 100644 index 41e936855e..0000000000 Binary files a/samples/CSharp/WPF/res/tool_material.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/tool_shading.png b/samples/CSharp/WPF/res/tool_shading.png deleted file mode 100644 index 6bb9dc46de..0000000000 Binary files a/samples/CSharp/WPF/res/tool_shading.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/tool_transparency.png b/samples/CSharp/WPF/res/tool_transparency.png deleted file mode 100644 index 6b42536eae..0000000000 Binary files a/samples/CSharp/WPF/res/tool_transparency.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/tool_wireframe.png b/samples/CSharp/WPF/res/tool_wireframe.png deleted file mode 100644 index 57c560f15a..0000000000 Binary files a/samples/CSharp/WPF/res/tool_wireframe.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_axo.png b/samples/CSharp/WPF/res/view_axo.png deleted file mode 100644 index c9a9226180..0000000000 Binary files a/samples/CSharp/WPF/res/view_axo.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_back.png b/samples/CSharp/WPF/res/view_back.png deleted file mode 100644 index 0798f52938..0000000000 Binary files a/samples/CSharp/WPF/res/view_back.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_bottom.png b/samples/CSharp/WPF/res/view_bottom.png deleted file mode 100644 index c7cfdc208a..0000000000 Binary files a/samples/CSharp/WPF/res/view_bottom.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_comp_off.png b/samples/CSharp/WPF/res/view_comp_off.png deleted file mode 100644 index c900b196f0..0000000000 Binary files a/samples/CSharp/WPF/res/view_comp_off.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_comp_on.png b/samples/CSharp/WPF/res/view_comp_on.png deleted file mode 100644 index 73ca4c83d0..0000000000 Binary files a/samples/CSharp/WPF/res/view_comp_on.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_fitall.png b/samples/CSharp/WPF/res/view_fitall.png deleted file mode 100644 index 21d2f423ef..0000000000 Binary files a/samples/CSharp/WPF/res/view_fitall.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_fitarea.png b/samples/CSharp/WPF/res/view_fitarea.png deleted file mode 100644 index f20f5c0554..0000000000 Binary files a/samples/CSharp/WPF/res/view_fitarea.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_front.png b/samples/CSharp/WPF/res/view_front.png deleted file mode 100644 index a9e99c59b6..0000000000 Binary files a/samples/CSharp/WPF/res/view_front.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_glpan.png b/samples/CSharp/WPF/res/view_glpan.png deleted file mode 100644 index 02a9c1cb8d..0000000000 Binary files a/samples/CSharp/WPF/res/view_glpan.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_left.png b/samples/CSharp/WPF/res/view_left.png deleted file mode 100644 index 7d25b6ab2f..0000000000 Binary files a/samples/CSharp/WPF/res/view_left.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_pan.png b/samples/CSharp/WPF/res/view_pan.png deleted file mode 100644 index 0e9a6a5a03..0000000000 Binary files a/samples/CSharp/WPF/res/view_pan.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_reset.png b/samples/CSharp/WPF/res/view_reset.png deleted file mode 100644 index 38849fd694..0000000000 Binary files a/samples/CSharp/WPF/res/view_reset.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_right.png b/samples/CSharp/WPF/res/view_right.png deleted file mode 100644 index 5540220cfa..0000000000 Binary files a/samples/CSharp/WPF/res/view_right.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_rotate.png b/samples/CSharp/WPF/res/view_rotate.png deleted file mode 100644 index 7e5d013b9f..0000000000 Binary files a/samples/CSharp/WPF/res/view_rotate.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_top.png b/samples/CSharp/WPF/res/view_top.png deleted file mode 100644 index b788de36fb..0000000000 Binary files a/samples/CSharp/WPF/res/view_top.png and /dev/null differ diff --git a/samples/CSharp/WPF/res/view_zoom.png b/samples/CSharp/WPF/res/view_zoom.png deleted file mode 100644 index 1b50a37bc8..0000000000 Binary files a/samples/CSharp/WPF/res/view_zoom.png and /dev/null differ diff --git a/samples/CSharp/WPF_D3D/About.xaml b/samples/CSharp/WPF_D3D/About.xaml new file mode 100644 index 0000000000..c9f4fb29fe --- /dev/null +++ b/samples/CSharp/WPF_D3D/About.xaml @@ -0,0 +1,18 @@ + + + + diff --git a/samples/CSharp/WPF_D3D/MainWindow.xaml.cs b/samples/CSharp/WPF_D3D/MainWindow.xaml.cs new file mode 100644 index 0000000000..913241709c --- /dev/null +++ b/samples/CSharp/WPF_D3D/MainWindow.xaml.cs @@ -0,0 +1,695 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Windows.Forms.Integration; +using System.Windows.Interop; +using System.Runtime.InteropServices; + +namespace IE_WPF_D3D +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window, INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + protected void RaisePropertyChanged (string thePropertyName) + { + if (PropertyChanged != null) + { + PropertyChanged (this, new PropertyChangedEventArgs (thePropertyName)); + } + } + + public MainWindow () + { + InitializeComponent (); + + StatusBarText = String.Empty; + IsHlrOffPushed = false; + IsHlrOnPushed = true; + IsZoomWinEnabled = true; + + #region menu operations + + CommandBinding aBind_New = new CommandBinding (IECommands.New); + aBind_New.Executed += NewCommand_Executed; + CommandBindings.Add (aBind_New); + + CommandBinding aBind_Close = new CommandBinding (IECommands.Close); + aBind_Close.Executed += CloseCommand_Executed; + aBind_Close.CanExecute += CloseCommand_CanExecute; + CommandBindings.Add (aBind_Close); + + CommandBinding aBind_Quit = new CommandBinding (IECommands.Quit); + aBind_Quit.Executed += QuitCommand_Executed; + CommandBindings.Add (aBind_Quit); + + CommandBinding aBind_About = new CommandBinding (IECommands.About); + aBind_About.Executed += AboutCommand_Executed; + CommandBindings.Add (aBind_About); + + #endregion + } + + private String myStatusBarText; + public String StatusBarText + { + get + { + return myStatusBarText; + } + private set + { + myStatusBarText = value; + RaisePropertyChanged ("StatusBarText"); + } + } + + private bool isHlrOffPushed; + public Boolean IsHlrOffPushed + { + get + { + return isHlrOffPushed; + } + set + { + isHlrOffPushed = value; + RaisePropertyChanged ("isHlrOffPushed"); + } + } + + private bool isHlrOnPushed; + public Boolean IsHlrOnPushed + { + get + { + return isHlrOnPushed; + } + set + { + isHlrOnPushed = value; + RaisePropertyChanged ("IsHlrOnPushed"); + } + } + + private bool isZoomWinEnabled; + public Boolean IsZoomWinEnabled + { + get + { + return isZoomWinEnabled; + } + set + { + isZoomWinEnabled = value; + RaisePropertyChanged ("IsZoomWinEnabled"); + } + } + + private OCCViewer ActiveViewer + { + get + { + if (!IsDocumentOpen) + { + return null; + } + + Grid aGrid = (ViewPanel.SelectedContent) as Grid; + + if (aGrid == null) + { + return null; + } + + return Map[aGrid].Viewer; + } + } + + public Boolean IsDocumentOpen + { + get + { + return ViewPanel.Items.Count > 0; + } + } + + private int myDocumentCounter = 1; + + Dictionary Map = new Dictionary (); + + private void NewCommand_Executed (object sender, ExecutedRoutedEventArgs e) + { + D3DViewer aViwer = new D3DViewer (); + + Grid g = new Grid (); + + Map.Add (g, aViwer); + + ImageBrush anImage = new ImageBrush (aViwer.Image); + + anImage.RelativeTransform = new ScaleTransform (1.0, -1.0, 0.5, 0.5); + + g.Background = anImage; + g.MouseMove += new MouseEventHandler (g_MouseMove); + g.MouseDown += new MouseButtonEventHandler (g_MouseDown); + g.MouseUp += new MouseButtonEventHandler (g_MouseUp); + + g.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; + + + TabItem aNewTab = new TabItem (); + aNewTab.Content = g; + + aNewTab.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; + aNewTab.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; + aNewTab.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch; + + g.SizeChanged += new SizeChangedEventHandler (g_SizeChanged); + + aNewTab.IsSelected = true; + aNewTab.Header = "Document " + myDocumentCounter.ToString (); + myDocumentCounter++; + + ViewPanel.Items.Add (aNewTab); + + ViewPanel.Focus (); + + // update XAML property + RaisePropertyChanged ("IsDocumentOpen"); + } + + void g_SizeChanged (object sender, SizeChangedEventArgs e) + { + if (!IsDocumentOpen) + return; + + Grid aGrid = (ViewPanel.SelectedContent) as Grid; + + if (aGrid == null) + return; + + Map[aGrid].Resize (Convert.ToInt32 (e.NewSize.Width), + Convert.ToInt32 (e.NewSize.Height)); + } + + void g_MouseUp (object sender, MouseButtonEventArgs e) + { + Grid aGrid = (ViewPanel.SelectedContent) as Grid; + + if (aGrid != null) + { + ActiveViewer.OnMouseUp(aGrid, e); + } + } + + void g_MouseDown (object sender, MouseButtonEventArgs e) + { + Grid aGrid = (ViewPanel.SelectedContent) as Grid; + + if (aGrid != null) + { + ActiveViewer.OnMouseDown(ViewPanel, e); + } + } + + void g_MouseMove (object sender, MouseEventArgs e) + { + Grid aGrid = (ViewPanel.SelectedContent) as Grid; + + if (aGrid != null) + { + ActiveViewer.OnMouseMove (aGrid, e); + } + } + + private void CloseCommand_Executed (object sender, ExecutedRoutedEventArgs e) + { + if (ViewPanel.Items.Count > 0) + { + Grid aGrid = (ViewPanel.SelectedContent) as Grid; + + if (aGrid == null) + { + return; + } + + Map[aGrid].StopRenderingScene (); + + ViewPanel.Items.Remove (ViewPanel.SelectedItem); + } + + // update XAML property + RaisePropertyChanged ("IsDocumentOpen"); + } + + private void CloseCommand_CanExecute (object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = IsDocumentOpen; + } + + private void QuitCommand_Executed (object sender, ExecutedRoutedEventArgs e) + { + this.Close (); + } + + private void ImportBRep_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.ImportModel (ModelFormat.BREP); + } + } + + private void ImportIges_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.ImportModel (ModelFormat.IGES); + } + } + + private void ImportStep_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.ImportModel (ModelFormat.STEP); + } + } + + private void ExportBRep_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.ExportModel (ModelFormat.BREP); + } + } + + private void ExportStep_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.ExportModel (ModelFormat.STEP); + } + } + + private void ExportIges_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.ExportModel (ModelFormat.IGES); + } + } + + private void ExportStl_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.ExportModel (ModelFormat.STL); + } + } + + private void ExportVrml_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.ExportModel (ModelFormat.VRML); + } + } + + private void ExportImage_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.ExportModel (ModelFormat.IMAGE); + } + } + + private void FitAllBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.FitAll (); + } + } + + private void ZoomWindowBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + IsZoomWinEnabled = false; + ActiveViewer.ZoomWindow (); + } + } + + private void DynamicZoomingBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.DynamicZooming (); + } + } + + private void DynamicPanningBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.DynamicPanning (); + } + } + + private void GlobalPanningBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.GlobalPanning (); + } + } + + private void FrontBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.FrontView (); + } + } + + private void BackBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.BackView (); + } + } + + private void TopBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.TopView (); + } + } + + private void BottomBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.BottomView (); + } + } + + private void LeftBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.LeftView (); + } + } + + private void RightBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.RightView (); + } + } + + private void AxoBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.AxoView (); + } + } + + private void ResetBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.Reset (); + } + } + + private void DynamicRotationBtn_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.DynamicRotation (); + } + } + + private void HiddenOffBtn_Click (object sender, RoutedEventArgs e) + { + IsHlrOffPushed = true; + IsHlrOnPushed = false; + if (ActiveViewer != null) + { + ActiveViewer.HiddenOff (); + } + } + + private void HiddenOnBtn_Click (object sender, RoutedEventArgs e) + { + IsHlrOffPushed = false; + IsHlrOnPushed = true; + if (ActiveViewer != null) + { + ActiveViewer.HiddenOn (); + } + } + + private void AboutCommand_Executed (object sender, ExecutedRoutedEventArgs e) + { + AboutDialog aDlg = new AboutDialog (); + aDlg.ShowDialog (); + } + + private void ToolBar_MouseEnter (object sender, MouseEventArgs e) + { + StatusBarText = "Toolbar"; + } + + private void DocumentToolBar_MouseEnter (object sender, MouseEventArgs e) + { + StatusBarText = "Document toolbar"; + } + + private void ViewToolBar_MouseEnter (object sender, MouseEventArgs e) + { + StatusBarText = "View toolbar"; + } + + private void ToolBar_MouseLeave (object sender, MouseEventArgs e) + { + StatusBarText = ""; + } + + public void OnZoomingFinished (object sender, EventArgs e) + { + IsZoomWinEnabled = true; + } + + public bool IsWireframeEnabled + { + get + { + if (ActiveViewer != null) + { + return ActiveViewer.IsWireframeEnabled; + } + return false; + } + } + + private void Wireframe_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.Wireframe (); + } + } + + private void Shading_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.Shading (); + } + } + + public bool IsShadingEnabled + { + get + { + if (ActiveViewer != null) + { + return ActiveViewer.IsShadingEnabled; + } + return false; + } + } + + private void Color_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.Color (); + } + } + + public bool IsColorEnabled + { + get + { + if (ActiveViewer != null) + { + return ActiveViewer.IsColorEnabled; + } + return false; + } + } + + private void Material_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.Material (); + } + } + + public bool IsMaterialEnabled + { + get + { + if (ActiveViewer != null) + { + return ActiveViewer.IsMaterialEnabled; + } + return false; + } + } + + private void Transparency_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.Transparency (); + } + } + + public bool IsTransparencyEnabled + { + get + { + if (ActiveViewer != null) + { + return ActiveViewer.IsTransparencyEnabled; + } + return false; + } + } + + private void Delete_Click (object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.Delete (); + } + } + + private void Background_Click(object sender, RoutedEventArgs e) + { + if (ActiveViewer != null) + { + ActiveViewer.Background(); + } + } + + public bool IsDeleteEnabled + { + get + { + if (ActiveViewer != null) + { + return ActiveViewer.IsDeleteEnabled; + } + return false; + } + } + + private void AvaliabiltyOfOperationToolbarChanged () + { + RaisePropertyChanged ("IsWireframeEnabled"); + RaisePropertyChanged ("IsShadingEnabled"); + RaisePropertyChanged ("IsTransparencyEnabled"); + RaisePropertyChanged ("IsColorEnabled"); + RaisePropertyChanged ("IsMaterialEnabled"); + RaisePropertyChanged ("IsDeleteEnabled"); + } + + public void OnAvaliabiltyOfOperationsChanged (object sender, EventArgs e) + { + AvaliabiltyOfOperationToolbarChanged (); + } + + private void OnViewerChanged (object sender, SelectionChangedEventArgs e) + { + if (e.RemovedItems.Count > 0) + { + Grid aHost = ((e.RemovedItems[0] as TabItem).Content) as Grid; + if (aHost == null) + { + return; + } + + OCCViewer aViewer = Map[aHost].Viewer; + if (aViewer != null) + { + aViewer.ZoomingFinished -= new EventHandler (OnZoomingFinished); + aViewer.AvaliabiltyOfOperationsChanged -= new EventHandler (OnAvaliabiltyOfOperationsChanged); + } + } + + if (e.AddedItems.Count > 0) + { + Grid aHost = ((e.AddedItems[0] as TabItem).Content) as Grid; + if (aHost == null) + { + return; + } + + OCCViewer aViewer = Map[aHost].Viewer; + if (aViewer != null) + { + aViewer.ZoomingFinished += new EventHandler (OnZoomingFinished); + aViewer.AvaliabiltyOfOperationsChanged += new EventHandler (OnAvaliabiltyOfOperationsChanged); + } + } + + AvaliabiltyOfOperationToolbarChanged (); + } + + private void OnContextOpened(object sender, RoutedEventArgs e) + { + this.WireframeItem.IsEnabled = IsWireframeEnabled; + this.ShadingItem.IsEnabled = IsShadingEnabled; + this.ColorItem.IsEnabled = IsColorEnabled; + this.MaterialItem.IsEnabled = IsMaterialEnabled; + this.TransparencyItem.IsEnabled = IsTransparencyEnabled; + this.DeleteItem.IsEnabled = IsDeleteEnabled; + } + } +} diff --git a/samples/CSharp/WPF_D3D/MaterialDlg.xaml b/samples/CSharp/WPF_D3D/MaterialDlg.xaml new file mode 100644 index 0000000000..dafa734a31 --- /dev/null +++ b/samples/CSharp/WPF_D3D/MaterialDlg.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/CSharp/WPF_D3D/MaterialDlg.xaml.cs b/samples/CSharp/WPF_D3D/MaterialDlg.xaml.cs new file mode 100644 index 0000000000..4751ed8376 --- /dev/null +++ b/samples/CSharp/WPF_D3D/MaterialDlg.xaml.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace IE_WPF_D3D +{ + public enum Material + { + Brass, + Bronze, + Copper, + Gold, + Pewter, + Plaster, + Plastic, + Silver + } + + /// + /// Interaction logic for MaterialDlg.xaml + /// + public partial class MaterialDlg : Window + { + public MaterialDlg( OCCTProxyD3D theView ) + { + this.InitializeComponent(); + + if ( theView == null ) + { + MessageBox.Show( "Fatal Error during the graphic initialisation", "Error!" ); + } + + View = theView; + + SetInitialState(); + } + + public OCCTProxyD3D View { get; private set; } + + private void PlasterBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Plaster ); + View.UpdateCurrentViewer(); + } + + private void BrassBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Brass ); + View.UpdateCurrentViewer(); + } + + private void BronzeBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Bronze ); + View.UpdateCurrentViewer(); + } + + private void CopperBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Copper ); + View.UpdateCurrentViewer(); + } + + private void GoldBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Gold ); + View.UpdateCurrentViewer(); + } + + private void PewterBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Pewter ); + View.UpdateCurrentViewer(); + } + + private void PlasticBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Plastic ); + View.UpdateCurrentViewer(); + } + + private void SilverBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Silver ); + View.UpdateCurrentViewer(); + } + + private void SetInitialState() + { + // TODO + } + } +} \ No newline at end of file diff --git a/samples/CSharp/WPF_D3D/OCCViewer.cs b/samples/CSharp/WPF_D3D/OCCViewer.cs new file mode 100644 index 0000000000..19fdebde9b --- /dev/null +++ b/samples/CSharp/WPF_D3D/OCCViewer.cs @@ -0,0 +1,673 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Windows.Input; +using System.Drawing; + +namespace IE_WPF_D3D +{ + public enum CurrentAction3d + { + CurAction3d_Nothing, + CurAction3d_DynamicZooming, + CurAction3d_WindowZooming, + CurAction3d_DynamicPanning, + CurAction3d_GlobalPanning, + CurAction3d_DynamicRotation + } + public enum CurrentPressedKey + { + CurPressedKey_Nothing, + CurPressedKey_Ctrl, + CurPressedKey_Shift + } + public enum ModelFormat + { + BREP, + CSFDB, + STEP, + IGES, + VRML, + STL, + IMAGE + } + + public enum DisplayMode + { + Wireframe, + Shading + } + + public class OCCViewer + { + public event EventHandler ZoomingFinished; + protected void RaiseZoomingFinished () + { + if (ZoomingFinished != null) + { + ZoomingFinished (this, EventArgs.Empty); + } + } + + public event EventHandler AvaliabiltyOfOperationsChanged; + protected void RaiseAvaliabiltyOfOperationsChanged () + { + if (AvaliabiltyOfOperationsChanged != null) + { + AvaliabiltyOfOperationsChanged (this, EventArgs.Empty); + } + } + + public OCCTProxyD3D View { get; private set; } + public CurrentAction3d CurrentMode { get; private set; } + private bool IsRectVisible { get; set; } + public bool DegenerateMode { get; private set; } + + public bool IsWireframeEnabled { get; private set; } + public bool IsShadingEnabled { get; private set; } + public bool IsTransparencyEnabled { get; private set; } + public bool IsColorEnabled { get; private set; } + public bool IsMaterialEnabled { get; private set; } + public bool IsDeleteEnabled { get; private set; } + + private float myCurZoom;// ~ Quantity_Factor + private int myXmin; + private int myYmin; + private int myXmax; + private int myYmax; + private int myButtonDownX; + private int myButtonDownY; + public OCCViewer() + { + View = new OCCTProxyD3D (); + View.InitOCCTProxy (); + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + IsRectVisible = false; + DegenerateMode = true; + } + + public bool InitInterop (IntPtr theHWND, IntPtr theD3DDevice) + { + return View.InitViewer (theHWND, theD3DDevice); + } + + public void ImportModel (ModelFormat theFormat) + { + int aFormat = 10; + OpenFileDialog anOpenDialog = new OpenFileDialog (); + string aDataDir = ((Environment.GetEnvironmentVariable ("CASROOT")) + "\\..\\data"); + string aFilter = ""; + + switch (theFormat) + { + case ModelFormat.BREP: + anOpenDialog.InitialDirectory = (aDataDir + "\\occ"); + aFormat = 0; + aFilter = "BREP Files (*.brep *.rle)|*.brep; *.rle"; + break; + case ModelFormat.CSFDB: + aFormat = 1; + aFilter = "CSFDB Files (*.csfdb)|*.csfdb"; + break; + case ModelFormat.STEP: + anOpenDialog.InitialDirectory = (aDataDir + "\\step"); + aFormat = 2; + aFilter = "STEP Files (*.stp *.step)|*.stp; *.step"; + break; + case ModelFormat.IGES: + anOpenDialog.InitialDirectory = (aDataDir + "\\iges"); + aFormat = 3; + aFilter = "IGES Files (*.igs *.iges)|*.igs; *.iges"; + break; + default: + break; + } + + anOpenDialog.Filter = aFilter + "|All files (*.*)|*.*"; + if (anOpenDialog.ShowDialog () == DialogResult.OK) + { + string aFileName = anOpenDialog.FileName; + if (aFileName == "") + { + return; + } + + if (!View.TranslateModel (aFileName, aFormat, true)) + { + MessageBox.Show ("Cann't read this file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + View.ZoomAllView (); + } + + public void ExportModel (ModelFormat theFormat) + { + int aFormat = 10; + SaveFileDialog saveDialog = new SaveFileDialog (); + string aDataDir = ((Environment.GetEnvironmentVariable ("CASROOT")) + "\\..\\data"); + string aFilter = ""; + + switch (theFormat) + { + case ModelFormat.BREP: + saveDialog.InitialDirectory = (aDataDir + "\\occ"); + aFormat = 0; + aFilter = "BREP Files (*.brep *.rle)|*.brep; *.rle"; + break; + case ModelFormat.CSFDB: + aFormat = 1; + aFilter = "CSFDB Files (*.csfdb)|*.csfdb"; + break; + case ModelFormat.STEP: + saveDialog.InitialDirectory = (aDataDir + "\\step"); + aFormat = 2; + aFilter = "STEP Files (*.stp *.step)|*.step; *.stp"; + break; + case ModelFormat.IGES: + saveDialog.InitialDirectory = (aDataDir + "\\iges"); + aFormat = 3; + aFilter = "IGES Files (*.igs *.iges)| *.iges; *.igs"; + break; + case ModelFormat.VRML: + saveDialog.InitialDirectory = (aDataDir + "\\vrml"); + aFormat = 4; + aFilter = "VRML Files (*.vrml)|*.vrml"; + break; + case ModelFormat.STL: + saveDialog.InitialDirectory = (aDataDir + "\\stl"); + aFormat = 5; + aFilter = "STL Files (*.stl)|*.stl"; + break; + case ModelFormat.IMAGE: + saveDialog.InitialDirectory = (aDataDir + "\\images"); + aFormat = 6; + aFilter = "Images Files (*.bmp)|*.bmp"; + break; + default: + break; + } + + saveDialog.Filter = aFilter; + if (saveDialog.ShowDialog () == DialogResult.OK) + { + string aFileName = saveDialog.FileName; + if (aFileName == "") + { + return; + } + + if (!View.TranslateModel (aFileName, aFormat, false)) + { + MessageBox.Show ("Can not write this file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + } + + public void FitAll () + { + View.ZoomAllView (); + } + + public void ZoomWindow () + { + CurrentMode = CurrentAction3d.CurAction3d_WindowZooming; + } + + public void DynamicZooming () + { + CurrentMode = CurrentAction3d.CurAction3d_DynamicZooming; + } + + public void DynamicPanning () + { + CurrentMode = CurrentAction3d.CurAction3d_DynamicPanning; + } + + public void GlobalPanning () + { + myCurZoom = View.Scale (); + CurrentMode = CurrentAction3d.CurAction3d_GlobalPanning; + } + + public void AxoView () + { + View.AxoView (); + } + + public void FrontView () + { + View.FrontView (); + } + + public void TopView () + { + View.TopView (); + } + + public void LeftView () + { + View.LeftView (); + } + + public void BackView () + { + View.BackView (); + } + + public void RightView () + { + View.RightView (); + } + + public void Reset () + { + View.Reset (); + } + + public void BottomView () + { + View.BottomView (); + } + + public void HiddenOff () + { + View.SetDegenerateModeOff (); + DegenerateMode = false; + } + + public void HiddenOn () + { + View.SetDegenerateModeOn (); + DegenerateMode = true; + } + + public void DynamicRotation () + { + CurrentMode = CurrentAction3d.CurAction3d_DynamicRotation; + } + + public void SelectionChanged () + { + switch (View.DisplayMode ()) + { + case -1: + IsShadingEnabled = false; + IsWireframeEnabled = false; + break; + case 0: + IsWireframeEnabled = false; + IsShadingEnabled = true; + IsTransparencyEnabled = false; + break; + case 1: + IsWireframeEnabled = true; + IsShadingEnabled = false; + IsTransparencyEnabled = true; + break; + case 10: + IsWireframeEnabled = true; + IsShadingEnabled = true; + IsTransparencyEnabled = true; + break; + default: + break; + } + + if (View.IsObjectSelected ()) + { + IsColorEnabled = true; + IsMaterialEnabled = true; + IsDeleteEnabled = true; + } + else + { + IsColorEnabled = false; + IsMaterialEnabled = false; + IsTransparencyEnabled = false; + IsDeleteEnabled = false; + } + + RaiseAvaliabiltyOfOperationsChanged (); + } + + public void ChangeColor (bool IsObjectColor) + { + int r, g, b; + if (IsObjectColor) + { + r = View.GetObjColR (); + g = View.GetObjColG (); + b = View.GetObjColB (); + } + else + { + r = View.GetBGColR (); + g = View.GetBGColG (); + b = View.GetBGColB (); + } + System.Windows.Forms.ColorDialog ColDlg = new System.Windows.Forms.ColorDialog (); + ColDlg.Color = System.Drawing.Color.FromArgb (r, g, b); + if (ColDlg.ShowDialog () == System.Windows.Forms.DialogResult.OK) + { + System.Drawing.Color c = ColDlg.Color; + r = c.R; + g = c.G; + b = c.B; + if (IsObjectColor) + { + View.SetColor (r, g, b); + } + else + { + View.SetBackgroundColor (r, g, b); + } + } + View.UpdateCurrentViewer (); + } + + public void Wireframe () + { + View.SetDisplayMode ((int)DisplayMode.Wireframe); + View.UpdateCurrentViewer (); + + SelectionChanged (); + RaiseZoomingFinished (); + } + + public void Shading () + { + View.SetDisplayMode ((int)DisplayMode.Shading); + View.UpdateCurrentViewer (); + + SelectionChanged (); + RaiseZoomingFinished (); + } + + public void Color () + { + ChangeColor (true); + } + + public void Background () + { + ChangeColor (false); + } + + public void Material () + { + MaterialDlg aDlg = new MaterialDlg (View); + aDlg.ShowDialog (); + } + + public void Transparency () + { + TransparencyDialog dlg = new TransparencyDialog (); + dlg.View = View; + dlg.ShowDialog (); + } + + public void Delete () + { + View.EraseObjects (); + } + + protected void MultiDragEvent (int x, int y, int theState) + { + if (theState == -1) //mouse is down + { + myButtonDownX = x; + myButtonDownY = y; + } + else if (theState == 1) //mouse is up + { + View.ShiftSelect (Math.Min (myButtonDownX, x), Math.Min (myButtonDownY, y), + Math.Max (myButtonDownX, x), Math.Max (myButtonDownY, y)); + } + } + + protected void DragEvent (int x, int y, int theState) + { + if (theState == -1) //mouse is down + { + myButtonDownX = x; + myButtonDownY = y; + } + else if (theState == 1) //mouse is up + { + View.Select (Math.Min (myButtonDownX, x), Math.Min (myButtonDownY, y), + Math.Max (myButtonDownX, x), Math.Max (myButtonDownY, y)); + } + } + + public void OnMouseDown (System.Windows.IInputElement sender, MouseButtonEventArgs e) + { + System.Windows.Controls.TabControl aTabControl = sender as System.Windows.Controls.TabControl; + System.Windows.Controls.Grid aGrid = aTabControl.SelectedContent as System.Windows.Controls.Grid; + + Point p = new Point((int)e.GetPosition(aGrid).X, (int)e.GetPosition(aGrid).Y); + + // to avoid the context menu opening + aTabControl.ContextMenu.Visibility = System.Windows.Visibility.Collapsed; + aTabControl.ContextMenu.IsOpen = false; + + if (e.LeftButton == MouseButtonState.Pressed) + { + myXmin = p.X; + myXmax = p.X; + myYmin = p.Y; + myYmax = p.Y; + + if (Keyboard.IsKeyDown (Key.LeftCtrl) || Keyboard.IsKeyDown (Key.RightCtrl)) + { + // start the dinamic zooming.... + CurrentMode = CurrentAction3d.CurAction3d_DynamicZooming; + } + else + { + switch (CurrentMode) + { + case CurrentAction3d.CurAction3d_Nothing: + if (Keyboard.IsKeyDown (Key.LeftShift) || Keyboard.IsKeyDown (Key.RightShift)) + { + MultiDragEvent (myXmax, myYmax, -1); + } + else + { + DragEvent (myXmax, myYmax, -1); + } + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + if (!DegenerateMode) + { + View.SetDegenerateModeOn (); + } + View.StartRotation (p.X, p.Y); + break; + default: + break; + } + } + } + else if (e.RightButton == MouseButtonState.Pressed) + { + if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) + { + if (!DegenerateMode) + { + View.SetDegenerateModeOn(); + } + View.StartRotation(p.X, p.Y); + } + else + { + // show context menu only in this case + aTabControl.ContextMenu.Visibility = System.Windows.Visibility.Visible; + } + } + } + + public void OnMouseUp(System.Windows.IInputElement sender, MouseButtonEventArgs e) + { + Point p = new Point((int)e.GetPosition(sender).X, (int)e.GetPosition(sender).Y); + + if (e.ChangedButton == MouseButton.Left) + { + if (Keyboard.IsKeyDown (Key.LeftCtrl) || Keyboard.IsKeyDown (Key.RightCtrl)) + { + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + return; + } + switch (CurrentMode) + { + case CurrentAction3d.CurAction3d_Nothing: + if (p.X == myXmin && p.Y == myYmin) + { + myXmax = p.X; + myYmax = p.Y; + if (Keyboard.IsKeyDown (Key.LeftShift) || Keyboard.IsKeyDown (Key.RightShift)) + { + View.ShiftSelect (); + } + else + { + View.Select (); + } + } + else + { + myXmax = p.X; + myYmax = p.Y; + if (Keyboard.IsKeyDown (Key.LeftShift) || Keyboard.IsKeyDown (Key.RightShift)) + { + MultiDragEvent (myXmax, myYmax, 1); + } + else + { + DragEvent (myXmax, myYmax, 1); + } + } + break; + case CurrentAction3d.CurAction3d_DynamicZooming: + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_WindowZooming: + myXmax = p.X; + myYmax = p.Y; + int ValZWMin = 1; + if (Math.Abs (myXmax - myXmin) > ValZWMin && + Math.Abs (myXmax - myYmax) > ValZWMin) + { + View.WindowFitAll (myXmin, myYmin, myXmax, myYmax); + } + RaiseZoomingFinished (); + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_DynamicPanning: + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_GlobalPanning: + View.Place (p.X, p.Y, myCurZoom); + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + if (!DegenerateMode) + { + View.SetDegenerateModeOff (); + } + else + { + View.SetDegenerateModeOn (); + } + break; + default: + break; + } + } + else if (e.ChangedButton == MouseButton.Right) + { + if (!DegenerateMode) + { + View.SetDegenerateModeOff (); + } + else + { + View.SetDegenerateModeOn (); + } + } + + SelectionChanged (); + } + + public void OnMouseMove (System.Windows.IInputElement sender, System.Windows.Input.MouseEventArgs e) + { + Point p = new Point ((int)e.GetPosition (sender).X, (int)e.GetPosition (sender).Y); + + if (e.LeftButton == MouseButtonState.Pressed) //left button is pressed + { + if (Keyboard.IsKeyDown (Key.LeftCtrl) || Keyboard.IsKeyDown (Key.RightCtrl)) + { + View.Zoom (myXmax, myYmax, p.X, p.Y); + myXmax = p.X; + myYmax = p.Y; + } + else + { + switch (CurrentMode) + { + case CurrentAction3d.CurAction3d_Nothing: + myXmax = p.X; + myYmax = p.Y; + break; + case CurrentAction3d.CurAction3d_DynamicZooming: + View.Zoom (myXmax, myYmax, p.X, p.Y); + myXmax = p.X; + myYmax = p.Y; + break; + case CurrentAction3d.CurAction3d_WindowZooming: + myXmax = p.X; + myYmax = p.Y; + break; + case CurrentAction3d.CurAction3d_DynamicPanning: + View.Pan (p.X - myXmax, myYmax - p.Y); + myXmax = p.X; + myYmax = p.Y; + break; + case CurrentAction3d.CurAction3d_GlobalPanning: + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + View.Rotation (p.X, p.Y); + View.RedrawView (); + break; + default: + break; + } + } + } + else if (e.MiddleButton == MouseButtonState.Pressed) //middle button is pressed + { + if (Keyboard.IsKeyDown (Key.LeftCtrl) || Keyboard.IsKeyDown (Key.RightCtrl)) + { + View.Pan (p.X - myXmax, myYmax - p.Y); + myXmax = p.X; + myYmax = p.Y; + } + } + else if (e.RightButton == MouseButtonState.Pressed) //right button is pressed + { + if (Keyboard.IsKeyDown (Key.LeftCtrl) || Keyboard.IsKeyDown (Key.RightCtrl)) + { + View.Rotation (p.X, p.Y); + } + } + else // no buttons are pressed + { + myXmax = p.X; + myYmax = p.Y; + View.MoveTo (p.X, p.Y); + } + } + } +} diff --git a/samples/CSharp/WPF_D3D/Properties/AssemblyInfo.cs b/samples/CSharp/WPF_D3D/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..02445ca672 --- /dev/null +++ b/samples/CSharp/WPF_D3D/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IE")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("IE")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/CSharp/WPF_D3D/Properties/Resources.Designer.cs b/samples/CSharp/WPF_D3D/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..1388afa068 --- /dev/null +++ b/samples/CSharp/WPF_D3D/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18444 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IE_WPF_D3D.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IE_WPF_D3D.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/samples/CSharp/WPF_D3D/Properties/Resources.resx b/samples/CSharp/WPF_D3D/Properties/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/samples/CSharp/WPF_D3D/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/CSharp/WPF_D3D/Properties/Settings.Designer.cs b/samples/CSharp/WPF_D3D/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..34d904b27f --- /dev/null +++ b/samples/CSharp/WPF_D3D/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18444 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IE_WPF_D3D.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/samples/CSharp/WPF_D3D/Properties/Settings.settings b/samples/CSharp/WPF_D3D/Properties/Settings.settings new file mode 100644 index 0000000000..033d7a5e9e --- /dev/null +++ b/samples/CSharp/WPF_D3D/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/samples/CSharp/WPF_D3D/Simple Styles.xaml b/samples/CSharp/WPF_D3D/Simple Styles.xaml new file mode 100644 index 0000000000..b130cea606 --- /dev/null +++ b/samples/CSharp/WPF_D3D/Simple Styles.xaml @@ -0,0 +1,1134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/CSharp/WPF_D3D/TransparencyDialog.cs b/samples/CSharp/WPF_D3D/TransparencyDialog.cs new file mode 100644 index 0000000000..ab885b7f98 --- /dev/null +++ b/samples/CSharp/WPF_D3D/TransparencyDialog.cs @@ -0,0 +1,108 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace IE_WPF_D3D +{ + /// + /// Summary description for TransparencyDialog. + /// + public class TransparencyDialog : System.Windows.Forms.Form + { + private System.Windows.Forms.NumericUpDown MyTransparency; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + private OCCTProxyD3D myView; + + public TransparencyDialog() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + myView = null; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TransparencyDialog)); + this.MyTransparency = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).BeginInit(); + this.SuspendLayout(); + // + // MyTransparency + // + this.MyTransparency.Location = new System.Drawing.Point(16, 16); + this.MyTransparency.Maximum = new System.Decimal(new int[] { + 10, + 0, + 0, + 0}); + this.MyTransparency.Name = "MyTransparency"; + this.MyTransparency.Size = new System.Drawing.Size(96, 20); + this.MyTransparency.TabIndex = 0; + this.MyTransparency.ValueChanged += new System.EventHandler(this.MyTransparency_ValueChanged); + // + // TransparencyDialog + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(128, 53); + this.Controls.Add(this.MyTransparency); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TransparencyDialog"; + this.Text = "TransparencyDialog"; + ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).EndInit(); + this.ResumeLayout(false); + + } + #endregion + + private void MyTransparency_ValueChanged(object sender, System.EventArgs e) + { + if (this.myView == null) + return; + int transp = (int)this.MyTransparency.Value; + this.myView.SetTransparency(transp); + } + + public OCCTProxyD3D View + { + set + { + this.myView = value; + } + } + + } +} diff --git a/samples/CSharp/WPF_D3D/TransparencyDialog.resx b/samples/CSharp/WPF_D3D/TransparencyDialog.resx new file mode 100644 index 0000000000..688fd72e80 --- /dev/null +++ b/samples/CSharp/WPF_D3D/TransparencyDialog.resx @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Private + + + Private + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + 80 + + + True + + + Private + + + TransparencyDialog + + + + AAABAAEAMDAAAAAAAACoDgAAFgAAACgAAAAwAAAAYAAAAAEACAAAAAAAgAoAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYABAQEAAgICAAMDAwAERERABYW + FgAcHBwAIiIiACkpKQBVVVUATU1NAEJCQgA5OTkAgHz/AFBQ/wCTANYA/+zMAMbW7wDW5+cAkKmtAAAA + MwAAAGYAAACZAAAAzAAAMwAAADMzAAAzZgAAM5kAADPMAAAz/wAAZgAAAGYzAABmZgAAZpkAAGbMAABm + /wAAmQAAAJkzAACZZgAAmZkAAJnMAACZ/wAAzAAAAMwzAADMZgAAzJkAAMzMAADM/wAA/2YAAP+ZAAD/ + zAAzAAAAMwAzADMAZgAzAJkAMwDMADMA/wAzMwAAMzMzADMzZgAzM5kAMzPMADMz/wAzZgAAM2YzADNm + ZgAzZpkAM2bMADNm/wAzmQAAM5kzADOZZgAzmZkAM5nMADOZ/wAzzAAAM8wzADPMZgAzzJkAM8zMADPM + /wAz/zMAM/9mADP/mQAz/8wAM///AGYAAABmADMAZgBmAGYAmQBmAMwAZgD/AGYzAABmMzMAZjNmAGYz + mQBmM8wAZjP/AGZmAABmZjMAZmZmAGZmmQBmZswAZpkAAGaZMwBmmWYAZpmZAGaZzABmmf8AZswAAGbM + MwBmzJkAZszMAGbM/wBm/wAAZv8zAGb/mQBm/8wAzAD/AP8AzACZmQAAmTOZAJkAmQCZAMwAmQAAAJkz + MwCZAGYAmTPMAJkA/wCZZgAAmWYzAJkzZgCZZpkAmWbMAJkz/wCZmTMAmZlmAJmZmQCZmcwAmZn/AJnM + AACZzDMAZsxmAJnMmQCZzMwAmcz/AJn/AACZ/zMAmcxmAJn/mQCZ/8wAmf//AMwAAACZADMAzABmAMwA + mQDMAMwAmTMAAMwzMwDMM2YAzDOZAMwzzADMM/8AzGYAAMxmMwCZZmYAzGaZAMxmzACZZv8AzJkAAMyZ + MwDMmWYAzJmZAMyZzADMmf8AzMwAAMzMMwDMzGYAzMyZAMzMzADMzP8AzP8AAMz/MwCZ/2YAzP+ZAMz/ + zADM//8AzAAzAP8AZgD/AJkAzDMAAP8zMwD/M2YA/zOZAP8zzAD/M/8A/2YAAP9mMwDMZmYA/2aZAP9m + zADMZv8A/5kAAP+ZMwD/mWYA/5mZAP+ZzAD/mf8A/8wAAP/MMwD/zGYA/8yZAP/MzAD/zP8A//8zAMz/ + ZgD//5kA///MAGZm/wBm/2YAZv//AP9mZgD/Zv8A//9mACEApQBfX18Ad3d3AIaGhgCWlpYAy8vLALKy + sgDX19cA3d3dAOPj4wDq6uoA8fHxAPj4+ADw+/8ApKCgAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMT + ExMTExMTEyIiQiI8HTyCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALwDODg4Nzc4MQMdAAAA + AADDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOw4ODgyOCQAAAAdAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAODIyMSIAHewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAA7DI3MSIdCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAADEyMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs4JAALAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALwxJAAhAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4IgC8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAJAxJB0LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + ALwLCx0dIh0dCwATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACx0dAB0dIiIiIiId + CxMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAvAsdAB0dIiQkAyQkIiIiHSIAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAIgMxMVhZmZqZAyQiHR0AAAAAkAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAvAsdISIDMThZWVmgvaCZWVIkIh0AAB0dIh0hCwALCwALtgAAAAAAAAAAAAAAAOwAAB0iMTEx + ODhYWZrDw8Ofn1hSJCIAHQAdACIAHSIkAwsdOAAAAADeExMTCwsLIiIkMTEyODg3MllZmprDw8PDwllS + MSQdHQAAAB0AIiQkAAAAvDi8AAAxAzExMTExMTI4Nzg4ODc4ODhZXpnDw8PDml1YNwMkIh0AAB0hIiQA + AAAAACIAAAA4ODc4Nzg4ODg4ODg4ODg4ODhZWV6avb2gmllZODcxJCIAAAAdIgMLAAAAACIAAACGE0+G + T4bs7Oy8vLy8vAAxODg4ODg4NzIyMSQdHQAAvADsCwAiJDExAAAAwjjsAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAALMSQAAAAAAAAAAAAAAAAAEyI4MQsiOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALMSQAAAAA + AAAAAAAAAAAAAAC8CwsAEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC8AAsAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////AAD///////8AAP///////wAA//////// + AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP// + /////wAA//8AAH//AAD//wAAf/8AAP//4AP//wAA///4B///AAD///gP//8AAP///B///wAA///8H/// + AAD///wf//8AAP///h///wAA///8H///AAD//+AD//8AAP//wAD//wAA//4AAD//AAD//AAAB/8AAP/w + AAAAAwAA/8AAAAABAADAAAAAADgAAMAAAAAAPAAAwAAAAAA8AADAAAAAIDgAAP///j/+AQAA///+P/+D + AAD///4///8AAP///////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP// + /////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA + + + \ No newline at end of file diff --git a/samples/CSharp/WPF_D3D/app.config b/samples/CSharp/WPF_D3D/app.config new file mode 100644 index 0000000000..e365603337 --- /dev/null +++ b/samples/CSharp/WPF_D3D/app.config @@ -0,0 +1,3 @@ + + + diff --git a/samples/CSharp/WPF_D3D/res/MainFrame.ico b/samples/CSharp/WPF_D3D/res/MainFrame.ico new file mode 100644 index 0000000000..99dbceb637 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/MainFrame.ico differ diff --git a/samples/CSharp/WPF_D3D/res/document.png b/samples/CSharp/WPF_D3D/res/document.png new file mode 100644 index 0000000000..1ba28fff33 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/document.png differ diff --git a/samples/CSharp/WPF_D3D/res/help.png b/samples/CSharp/WPF_D3D/res/help.png new file mode 100644 index 0000000000..e57336285e Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/help.png differ diff --git a/samples/CSharp/WPF_D3D/res/lamp.png b/samples/CSharp/WPF_D3D/res/lamp.png new file mode 100644 index 0000000000..a5a6775c33 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/lamp.png differ diff --git a/samples/CSharp/WPF_D3D/res/new.png b/samples/CSharp/WPF_D3D/res/new.png new file mode 100644 index 0000000000..953757a62f Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/new.png differ diff --git a/samples/CSharp/WPF_D3D/res/occ_logo.bmp b/samples/CSharp/WPF_D3D/res/occ_logo.bmp new file mode 100644 index 0000000000..443a7de612 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/occ_logo.bmp differ diff --git a/samples/CSharp/WPF_D3D/res/tool_color.png b/samples/CSharp/WPF_D3D/res/tool_color.png new file mode 100644 index 0000000000..b37ad7d480 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/tool_color.png differ diff --git a/samples/CSharp/WPF_D3D/res/tool_delete.png b/samples/CSharp/WPF_D3D/res/tool_delete.png new file mode 100644 index 0000000000..aaab07fc9f Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/tool_delete.png differ diff --git a/samples/CSharp/WPF_D3D/res/tool_material.png b/samples/CSharp/WPF_D3D/res/tool_material.png new file mode 100644 index 0000000000..41e936855e Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/tool_material.png differ diff --git a/samples/CSharp/WPF_D3D/res/tool_shading.png b/samples/CSharp/WPF_D3D/res/tool_shading.png new file mode 100644 index 0000000000..6bb9dc46de Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/tool_shading.png differ diff --git a/samples/CSharp/WPF_D3D/res/tool_transparency.png b/samples/CSharp/WPF_D3D/res/tool_transparency.png new file mode 100644 index 0000000000..6b42536eae Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/tool_transparency.png differ diff --git a/samples/CSharp/WPF_D3D/res/tool_wireframe.png b/samples/CSharp/WPF_D3D/res/tool_wireframe.png new file mode 100644 index 0000000000..57c560f15a Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/tool_wireframe.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_axo.png b/samples/CSharp/WPF_D3D/res/view_axo.png new file mode 100644 index 0000000000..c9a9226180 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_axo.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_back.png b/samples/CSharp/WPF_D3D/res/view_back.png new file mode 100644 index 0000000000..0798f52938 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_back.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_bottom.png b/samples/CSharp/WPF_D3D/res/view_bottom.png new file mode 100644 index 0000000000..c7cfdc208a Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_bottom.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_comp_off.png b/samples/CSharp/WPF_D3D/res/view_comp_off.png new file mode 100644 index 0000000000..c900b196f0 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_comp_off.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_comp_on.png b/samples/CSharp/WPF_D3D/res/view_comp_on.png new file mode 100644 index 0000000000..73ca4c83d0 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_comp_on.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_fitall.png b/samples/CSharp/WPF_D3D/res/view_fitall.png new file mode 100644 index 0000000000..21d2f423ef Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_fitall.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_fitarea.png b/samples/CSharp/WPF_D3D/res/view_fitarea.png new file mode 100644 index 0000000000..f20f5c0554 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_fitarea.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_front.png b/samples/CSharp/WPF_D3D/res/view_front.png new file mode 100644 index 0000000000..a9e99c59b6 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_front.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_glpan.png b/samples/CSharp/WPF_D3D/res/view_glpan.png new file mode 100644 index 0000000000..02a9c1cb8d Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_glpan.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_left.png b/samples/CSharp/WPF_D3D/res/view_left.png new file mode 100644 index 0000000000..7d25b6ab2f Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_left.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_pan.png b/samples/CSharp/WPF_D3D/res/view_pan.png new file mode 100644 index 0000000000..0e9a6a5a03 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_pan.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_reset.png b/samples/CSharp/WPF_D3D/res/view_reset.png new file mode 100644 index 0000000000..38849fd694 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_reset.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_right.png b/samples/CSharp/WPF_D3D/res/view_right.png new file mode 100644 index 0000000000..5540220cfa Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_right.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_rotate.png b/samples/CSharp/WPF_D3D/res/view_rotate.png new file mode 100644 index 0000000000..7e5d013b9f Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_rotate.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_top.png b/samples/CSharp/WPF_D3D/res/view_top.png new file mode 100644 index 0000000000..b788de36fb Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_top.png differ diff --git a/samples/CSharp/WPF_D3D/res/view_zoom.png b/samples/CSharp/WPF_D3D/res/view_zoom.png new file mode 100644 index 0000000000..1b50a37bc8 Binary files /dev/null and b/samples/CSharp/WPF_D3D/res/view_zoom.png differ diff --git a/samples/CSharp/WPF_WinForms/About.xaml b/samples/CSharp/WPF_WinForms/About.xaml new file mode 100644 index 0000000000..950405f605 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/About.xaml @@ -0,0 +1,18 @@ + + + + diff --git a/samples/CSharp/WPF_WinForms/MainWindow.xaml.cs b/samples/CSharp/WPF_WinForms/MainWindow.xaml.cs new file mode 100644 index 0000000000..c4a40742af --- /dev/null +++ b/samples/CSharp/WPF_WinForms/MainWindow.xaml.cs @@ -0,0 +1,614 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Windows.Forms.Integration; + +namespace IE_WPF_WinForms +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window, INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + protected void RaisePropertyChanged( string thePropertyName ) + { + if ( PropertyChanged != null ) + { + PropertyChanged( this, new PropertyChangedEventArgs( thePropertyName ) ); + } + } + + public MainWindow() + { + InitializeComponent(); + + StatusBarText = String.Empty; + IsHlrOffPushed = false; + IsHlrOnPushed = true; + IsZoomWinEnabled = true; + + #region menu operations + + CommandBinding aBind_New = new CommandBinding( IECommands.New ); + aBind_New.Executed += NewCommand_Executed; + CommandBindings.Add( aBind_New ); + + CommandBinding aBind_Close = new CommandBinding( IECommands.Close ); + aBind_Close.Executed += CloseCommand_Executed; + aBind_Close.CanExecute += CloseCommand_CanExecute; + CommandBindings.Add( aBind_Close ); + + CommandBinding aBind_Quit = new CommandBinding( IECommands.Quit ); + aBind_Quit.Executed += QuitCommand_Executed; + CommandBindings.Add( aBind_Quit ); + + CommandBinding aBind_About = new CommandBinding( IECommands.About ); + aBind_About.Executed += AboutCommand_Executed; + CommandBindings.Add( aBind_About ); + + # endregion + + PreviewKeyDown += new KeyEventHandler( OnPreviewKeyDown ); + PreviewKeyUp += new KeyEventHandler( OnPreviewKeyUp ); + } + + private String myStatusBarText; + public String StatusBarText + { + get + { + return myStatusBarText; + } + private set + { + myStatusBarText = value; + RaisePropertyChanged( "StatusBarText" ); + } + } + + private bool isHlrOffPushed; + public Boolean IsHlrOffPushed + { + get + { + return isHlrOffPushed; + } + set + { + isHlrOffPushed = value; + RaisePropertyChanged("isHlrOffPushed"); + } + } + + private bool isHlrOnPushed; + public Boolean IsHlrOnPushed + { + get + { + return isHlrOnPushed; + } + set + { + isHlrOnPushed = value; + RaisePropertyChanged("IsHlrOnPushed"); + } + } + + private bool isZoomWinEnabled; + public Boolean IsZoomWinEnabled + { + get + { + return isZoomWinEnabled; + } + set + { + isZoomWinEnabled = value; + RaisePropertyChanged("IsZoomWinEnabled"); + } + } + + private OCCViewer ActiveViewer + { + get + { + if ( !IsDocumentOpen ) + { + return null; + } + + WindowsFormsHost aHost = ( ViewPanel.SelectedContent ) as WindowsFormsHost; + if( aHost == null ) + { + return null; + } + + return aHost.Child as OCCViewer; + } + } + + public Boolean IsDocumentOpen + { + get + { + return ViewPanel.Items.Count > 0; + } + } + + private int myDocumentCounter = 1; + + private void NewCommand_Executed( object sender, ExecutedRoutedEventArgs e ) + { + WindowsFormsHost aHost = new WindowsFormsHost(); + OCCViewer aForm = new OCCViewer(); + aForm.Show(); + aHost.Child = aForm; + + TabItem aNewTab = new TabItem(); + aNewTab.Content = aHost; + aNewTab.IsSelected = true; + aNewTab.Header = "Document " + myDocumentCounter.ToString(); + myDocumentCounter++; + + ViewPanel.Items.Add( aNewTab ); + + // update XAML property + RaisePropertyChanged("IsDocumentOpen"); + } + + private void CloseCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + if ( ViewPanel.Items.Count > 0 ) + { + ViewPanel.Items.Remove( ViewPanel.SelectedItem ); + } + + // update XAML property + RaisePropertyChanged( "IsDocumentOpen" ); + } + + private void CloseCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = IsDocumentOpen; + } + + private void QuitCommand_Executed( object sender, ExecutedRoutedEventArgs e ) + { + this.Close(); + } + + private void ImportBRep_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ImportModel( ModelFormat.BREP ); + } + } + + private void ImportIges_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ImportModel( ModelFormat.IGES ); + } + } + + private void ImportStep_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ImportModel( ModelFormat.STEP ); + } + } + + private void ExportBRep_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.BREP ); + } + } + + private void ExportStep_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.STEP ); + } + } + + private void ExportIges_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.IGES ); + } + } + + private void ExportStl_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.STL ); + } + } + + private void ExportVrml_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.VRML ); + } + } + + private void ExportImage_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.ExportModel( ModelFormat.IMAGE ); + } + } + + private void FitAllBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.FitAll(); + } + } + + private void ZoomWindowBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + IsZoomWinEnabled = false; + ActiveViewer.ZoomWindow(); + } + } + + private void DynamicZoomingBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.DynamicZooming(); + } + } + + private void DynamicPanningBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.DynamicPanning(); + } + } + + private void GlobalPanningBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.GlobalPanning(); + } + } + + private void FrontBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.FrontView(); + } + } + + private void BackBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.BackView(); + } + } + + private void TopBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.TopView(); + } + } + + private void BottomBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.BottomView(); + } + } + + private void LeftBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.LeftView(); + } + } + + private void RightBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.RightView(); + } + } + + private void AxoBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.AxoView(); + } + } + + private void ResetBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Reset(); + } + } + + private void DynamicRotationBtn_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.DynamicRotation(); + } + } + + private void HiddenOffBtn_Click( object sender, RoutedEventArgs e ) + { + IsHlrOffPushed = true; + IsHlrOnPushed = false; + if ( ActiveViewer != null ) + { + ActiveViewer.HiddenOff(); + } + } + + private void HiddenOnBtn_Click( object sender, RoutedEventArgs e ) + { + IsHlrOffPushed = false; + IsHlrOnPushed = true; + if (ActiveViewer != null) + { + ActiveViewer.HiddenOn(); + } + } + + private void AboutCommand_Executed( object sender, ExecutedRoutedEventArgs e ) + { + AboutDialog aDlg = new AboutDialog(); + aDlg.ShowDialog(); + } + + private void ToolBar_MouseEnter( object sender, MouseEventArgs e ) + { + StatusBarText = "Toolbar"; + } + + private void DocumentToolBar_MouseEnter(object sender, MouseEventArgs e) + { + StatusBarText = "Document toolbar"; + } + + private void ViewToolBar_MouseEnter(object sender, MouseEventArgs e) + { + StatusBarText = "View toolbar"; + } + + private void ToolBar_MouseLeave( object sender, MouseEventArgs e ) + { + StatusBarText = ""; + } + + public void OnZoomingFinished( object sender, EventArgs e ) + { + IsZoomWinEnabled = true; + } + + public bool IsWireframeEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsWireframeEnabled; + } + return false; + } + } + + private void Wireframe_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Wireframe(); + } + } + + private void Shading_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Shading(); + } + } + + public bool IsShadingEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsShadingEnabled; + } + return false; + } + } + + private void Color_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Color(); + } + } + + public bool IsColorEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsColorEnabled; + } + return false; + } + } + + private void Material_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Material(); + } + } + + public bool IsMaterialEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsMaterialEnabled; + } + return false; + } + } + + private void Transparency_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Transparency(); + } + } + + public bool IsTransparencyEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsTransparencyEnabled; + } + return false; + } + } + + private void Delete_Click( object sender, RoutedEventArgs e ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.Delete(); + } + } + + public bool IsDeleteEnabled + { + get + { + if ( ActiveViewer != null ) + { + return ActiveViewer.IsDeleteEnabled; + } + return false; + } + } + + private void AvaliabiltyOfOperationToolbarChanged() + { + RaisePropertyChanged( "IsWireframeEnabled" ); + RaisePropertyChanged( "IsShadingEnabled" ); + RaisePropertyChanged( "IsTransparencyEnabled" ); + RaisePropertyChanged( "IsColorEnabled" ); + RaisePropertyChanged( "IsMaterialEnabled" ); + RaisePropertyChanged( "IsDeleteEnabled" ); + } + + public void OnAvaliabiltyOfOperationsChanged( object sender, EventArgs e ) + { + AvaliabiltyOfOperationToolbarChanged(); + } + + private void OnViewerChanged( object sender, SelectionChangedEventArgs e ) + { + if ( e.RemovedItems.Count > 0 ) + { + WindowsFormsHost aHost = ( ( e.RemovedItems[0] as TabItem).Content ) as WindowsFormsHost; + if( aHost == null ) + { + return; + } + OCCViewer aViewer = aHost.Child as OCCViewer; + if( aViewer != null ) + { + aViewer.ZoomingFinished -= new EventHandler( OnZoomingFinished ); + aViewer.AvaliabiltyOfOperationsChanged -= new EventHandler( OnAvaliabiltyOfOperationsChanged ); + } + } + + if ( e.AddedItems.Count > 0 ) + { + WindowsFormsHost aHost = ( (e.AddedItems[0] as TabItem).Content ) as WindowsFormsHost; + if ( aHost == null ) + { + return; + } + OCCViewer aViewer = aHost.Child as OCCViewer; + if ( aViewer != null ) + { + aViewer.ZoomingFinished += new EventHandler( OnZoomingFinished ); + aViewer.AvaliabiltyOfOperationsChanged += new EventHandler( OnAvaliabiltyOfOperationsChanged ); + } + } + + AvaliabiltyOfOperationToolbarChanged(); + } + + private void OnPreviewKeyDown( object sender, KeyEventArgs args ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.OnKeyDown( args.Key ); + } + } + + private void OnPreviewKeyUp( object sender, KeyEventArgs args ) + { + if ( ActiveViewer != null ) + { + ActiveViewer.OnKeyUp(); + } + } + } +} diff --git a/samples/CSharp/WPF_WinForms/MaterialDlg.xaml b/samples/CSharp/WPF_WinForms/MaterialDlg.xaml new file mode 100644 index 0000000000..8b2249dfc9 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/MaterialDlg.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/CSharp/WPF_WinForms/MaterialDlg.xaml.cs b/samples/CSharp/WPF_WinForms/MaterialDlg.xaml.cs new file mode 100644 index 0000000000..e89ace7d59 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/MaterialDlg.xaml.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace IE_WPF_WinForms +{ + public enum Material + { + Brass, + Bronze, + Copper, + Gold, + Pewter, + Plaster, + Plastic, + Silver + } + + /// + /// Interaction logic for MaterialDlg.xaml + /// + public partial class MaterialDlg : Window + { + public MaterialDlg( OCCTProxy theView ) + { + this.InitializeComponent(); + + if ( theView == null ) + { + MessageBox.Show( "Fatal Error during the graphic initialisation", "Error!" ); + } + + View = theView; + + SetInitialState(); + } + + public OCCTProxy View { get; private set; } + + private void PlasterBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Plaster ); + View.UpdateCurrentViewer(); + } + + private void BrassBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Brass ); + View.UpdateCurrentViewer(); + } + + private void BronzeBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Bronze ); + View.UpdateCurrentViewer(); + } + + private void CopperBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Copper ); + View.UpdateCurrentViewer(); + } + + private void GoldBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Gold ); + View.UpdateCurrentViewer(); + } + + private void PewterBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Pewter ); + View.UpdateCurrentViewer(); + } + + private void PlasticBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Plastic ); + View.UpdateCurrentViewer(); + } + + private void SilverBtn_Checked( object sender, RoutedEventArgs e ) + { + View.SetMaterial( (int)Material.Silver ); + View.UpdateCurrentViewer(); + } + + private void SetInitialState() + { + // TODO + } + } +} \ No newline at end of file diff --git a/samples/CSharp/WPF_WinForms/OCCViewer.cs b/samples/CSharp/WPF_WinForms/OCCViewer.cs new file mode 100644 index 0000000000..c0aa2e38a9 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/OCCViewer.cs @@ -0,0 +1,840 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace IE_WPF_WinForms +{ + public enum CurrentAction3d + { + CurAction3d_Nothing, + CurAction3d_DynamicZooming, + CurAction3d_WindowZooming, + CurAction3d_DynamicPanning, + CurAction3d_GlobalPanning, + CurAction3d_DynamicRotation + } + public enum CurrentPressedKey + { + CurPressedKey_Nothing, + CurPressedKey_Ctrl, + CurPressedKey_Shift + } + public enum ModelFormat + { + BREP, + CSFDB, + STEP, + IGES, + VRML, + STL, + IMAGE + } + + public enum DisplayMode + { + Wireframe, + Shading + } + + public class OCCViewer : System.Windows.Forms.Form + { + public event EventHandler ZoomingFinished; + protected void RaiseZoomingFinished() + { + if ( ZoomingFinished != null ) + { + ZoomingFinished( this, EventArgs.Empty ); + } + } + + public event EventHandler AvaliabiltyOfOperationsChanged; + protected void RaiseAvaliabiltyOfOperationsChanged() + { + if ( AvaliabiltyOfOperationsChanged != null ) + { + AvaliabiltyOfOperationsChanged( this, EventArgs.Empty ); + } + } + + public OCCTProxy View { get; private set; } + public CurrentAction3d CurrentMode { get; private set; } + private CurrentPressedKey CurrentPressedKey { get; set; } + private bool IsRectVisible { get; set; } + public bool DegenerateMode { get; private set; } + + public bool IsWireframeEnabled { get; private set; } + public bool IsShadingEnabled { get; private set; } + public bool IsTransparencyEnabled { get; private set; } + public bool IsColorEnabled { get; private set; } + public bool IsMaterialEnabled { get; private set; } + public bool IsDeleteEnabled { get; private set; } + + private float myCurZoom;// ~ Quantity_Factor + private int myXmin; + private int myYmin; + private int myXmax; + private int myYmax; + private int myRectDownX; + private int myRectDownY; + private int myButtonDownX; + private int myButtonDownY; + + private ContextMenu Popup { get; set; } + private MenuItem ContextWireframe; + private MenuItem ContextShading; + private MenuItem ContextColor; + private MenuItem ContextMaterial; + private MenuItem ContextDelete; + private MenuItem ContextBackground; + private MenuItem ContextTransparency; + + + public OCCViewer() + { + InitializeComponent(); + + View = new OCCTProxy(); + View.InitOCCTProxy(); + if ( !View.InitViewer( this.Handle ) ) + { + MessageBox.Show( "Fatal Error during the graphic initialisation", "Error!" ); + } + + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + CurrentPressedKey = CurrentPressedKey.CurPressedKey_Nothing; + IsRectVisible = false; + DegenerateMode = true; + } + + private void InitializeComponent() + { + ControlBox = false; + TopLevel = false; + + this.ImeMode = System.Windows.Forms.ImeMode.NoControl; + + SizeChanged += new System.EventHandler( OnSizeChanged ); + Paint += new System.Windows.Forms.PaintEventHandler( OnPaint ); + + MouseDown += new System.Windows.Forms.MouseEventHandler( OnMouseDown ); + MouseUp += new System.Windows.Forms.MouseEventHandler( OnMouseUp ); + MouseMove += new System.Windows.Forms.MouseEventHandler( OnMouseMove ); + + Popup = new ContextMenu(); + ContextWireframe = new MenuItem(); + ContextShading = new MenuItem(); + ContextColor = new MenuItem(); + ContextMaterial = new MenuItem(); + ContextTransparency = new MenuItem(); + ContextDelete = new MenuItem(); + ContextBackground = new MenuItem(); + + ContextWireframe.Text = "Wireframe"; + ContextShading.Text = "Shading"; + ContextColor.Text = "Color"; + ContextMaterial.Text = "Material"; + ContextTransparency.Text = "Transparency"; + ContextDelete.Text = "Delete"; + ContextBackground.Text = "Background"; + + ContextWireframe.Click += new System.EventHandler( ContextWireframe_Click ); + ContextShading.Click += new System.EventHandler( ContextShading_Click ); + ContextColor.Click += new System.EventHandler( ContextColor_Click ); + ContextMaterial.Click += new System.EventHandler( ContextMaterial_Click ); + ContextTransparency.Click += new System.EventHandler( ContextTransparency_Click ); + ContextDelete.Click += new System.EventHandler( ContextDelete_Click ); + ContextBackground.Click += new System.EventHandler( ContextBackground_Click ); + + Popup.MenuItems.AddRange( new MenuItem[] { ContextWireframe, + ContextShading, + ContextColor, + ContextMaterial, + ContextTransparency, + ContextDelete, + ContextBackground } ); + Popup.Popup += new System.EventHandler( OnPopup ); + } + + private void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e) + { + View.RedrawView(); + View.UpdateView(); + } + + private void OnSizeChanged(object sender, System.EventArgs e) + { + View.UpdateView(); + } + + public void ImportModel( ModelFormat theFormat ) + { + int aFormat = 10; + OpenFileDialog anOpenDialog = new OpenFileDialog(); + string aDataDir = ( (Environment.GetEnvironmentVariable("CASROOT")) + "\\..\\data" ); + string aFilter = ""; + + switch ( theFormat ) + { + case ModelFormat.BREP: + anOpenDialog.InitialDirectory = (aDataDir + "\\occ"); + aFormat = 0; + aFilter = "BREP Files (*.brep *.rle)|*.brep; *.rle"; + break; + case ModelFormat.CSFDB: + aFormat = 1; + aFilter = "CSFDB Files (*.csfdb)|*.csfdb"; + break; + case ModelFormat.STEP: + anOpenDialog.InitialDirectory = (aDataDir + "\\step"); + aFormat = 2; + aFilter = "STEP Files (*.stp *.step)|*.stp; *.step"; + break; + case ModelFormat.IGES: + anOpenDialog.InitialDirectory = (aDataDir + "\\iges"); + aFormat = 3; + aFilter = "IGES Files (*.igs *.iges)|*.igs; *.iges"; + break; + default: + break; + } + + anOpenDialog.Filter = aFilter + "|All files (*.*)|*.*"; + if (anOpenDialog.ShowDialog() == DialogResult.OK) + { + string aFileName = anOpenDialog.FileName; + if (aFileName == "") + { + return; + } + + Cursor = System.Windows.Forms.Cursors.WaitCursor; + if ( !View.TranslateModel( aFileName, aFormat, true ) ) + { + MessageBox.Show( "Cann't read this file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning ); + } + Cursor = System.Windows.Forms.Cursors.Default; + } + View.ZoomAllView(); + } + + public void ExportModel( ModelFormat theFormat ) + { + int aFormat = 10; + SaveFileDialog saveDialog = new SaveFileDialog(); + string aDataDir = ( (Environment.GetEnvironmentVariable("CASROOT") ) + "\\..\\data" ); + string aFilter = ""; + + switch ( theFormat ) + { + case ModelFormat.BREP: + saveDialog.InitialDirectory = ( aDataDir + "\\occ" ); + aFormat = 0; + aFilter = "BREP Files (*.brep *.rle)|*.brep; *.rle"; + break; + case ModelFormat.CSFDB: + aFormat = 1; + aFilter = "CSFDB Files (*.csfdb)|*.csfdb"; + break; + case ModelFormat.STEP: + saveDialog.InitialDirectory = ( aDataDir + "\\step" ); + aFormat = 2; + aFilter = "STEP Files (*.stp *.step)|*.step; *.stp"; + break; + case ModelFormat.IGES: + saveDialog.InitialDirectory = ( aDataDir + "\\iges" ); + aFormat = 3; + aFilter = "IGES Files (*.igs *.iges)| *.iges; *.igs"; + break; + case ModelFormat.VRML: + saveDialog.InitialDirectory = ( aDataDir + "\\vrml" ); + aFormat = 4; + aFilter = "VRML Files (*.vrml)|*.vrml"; + break; + case ModelFormat.STL: + saveDialog.InitialDirectory = ( aDataDir + "\\stl" ); + aFormat = 5; + aFilter = "STL Files (*.stl)|*.stl"; + break; + case ModelFormat.IMAGE: + saveDialog.InitialDirectory = ( aDataDir + "\\images" ); + aFormat = 6; + aFilter = "Images Files (*.bmp)|*.bmp"; + break; + default: + break; + } + + saveDialog.Filter = aFilter; + if ( saveDialog.ShowDialog() == DialogResult.OK ) + { + string aFileName = saveDialog.FileName; + if ( aFileName == "" ) + { + return; + } + + Cursor = System.Windows.Forms.Cursors.WaitCursor; + if ( !View.TranslateModel( aFileName, aFormat, false ) ) + { + MessageBox.Show( "Can not write this file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning ); + } + Cursor = System.Windows.Forms.Cursors.Default; + } + } + + public void FitAll() + { + View.ZoomAllView(); + } + + public void ZoomWindow() + { + CurrentMode = CurrentAction3d.CurAction3d_WindowZooming; + } + + public void DynamicZooming() + { + CurrentMode = CurrentAction3d.CurAction3d_DynamicZooming; + } + + public void DynamicPanning() + { + CurrentMode = CurrentAction3d.CurAction3d_DynamicPanning; + } + + public void GlobalPanning() + { + myCurZoom = View.Scale(); + CurrentMode = CurrentAction3d.CurAction3d_GlobalPanning; + } + + public void AxoView() + { + View.AxoView(); + } + + public void FrontView() + { + View.FrontView(); + } + + public void TopView() + { + View.TopView(); + } + + public void LeftView() + { + View.LeftView(); + } + + public void BackView() + { + View.BackView(); + } + + public void RightView() + { + View.RightView(); + } + + public void Reset() + { + View.Reset(); + } + + public void BottomView() + { + View.BottomView(); + } + + public void HiddenOff() + { + View.SetDegenerateModeOff(); + DegenerateMode = false; + } + + public void HiddenOn() + { + View.SetDegenerateModeOn(); + DegenerateMode = true; + } + + public void DynamicRotation() + { + CurrentMode = CurrentAction3d.CurAction3d_DynamicRotation; + } + + public void SelectionChanged() + { + switch ( View.DisplayMode() ) + { + case -1: + IsShadingEnabled = false; + IsWireframeEnabled = false; + break; + case 0: + IsWireframeEnabled = false; + IsShadingEnabled = true; + IsTransparencyEnabled = false; + break; + case 1: + IsWireframeEnabled = true; + IsShadingEnabled = false; + IsTransparencyEnabled = true; + break; + case 10: + IsWireframeEnabled = true; + IsShadingEnabled = true; + IsTransparencyEnabled = true; + break; + default: + break; + } + + if ( View.IsObjectSelected() ) + { + IsColorEnabled = true; + IsMaterialEnabled = true; + IsDeleteEnabled = true; + } + else + { + IsColorEnabled = false; + IsMaterialEnabled = false; + IsTransparencyEnabled = false; + IsDeleteEnabled = false; + } + + RaiseAvaliabiltyOfOperationsChanged(); + } + + public void ChangeColor( bool IsObjectColor ) + { + int r, g, b; + if ( IsObjectColor ) + { + r = View.GetObjColR(); + g = View.GetObjColG(); + b = View.GetObjColB(); + } + else + { + r = View.GetBGColR(); + g = View.GetBGColG(); + b = View.GetBGColB(); + } + System.Windows.Forms.ColorDialog ColDlg = new System.Windows.Forms.ColorDialog(); + ColDlg.Color = System.Drawing.Color.FromArgb( r, g, b ); + if ( ColDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK ) + { + System.Drawing.Color c = ColDlg.Color; + r = c.R; + g = c.G; + b = c.B; + if ( IsObjectColor ) + { + View.SetColor( r, g, b ); + } + else + { + View.SetBackgroundColor( r, g, b ); + } + } + View.UpdateCurrentViewer(); + } + + public void Wireframe() + { + View.SetDisplayMode( (int)DisplayMode.Wireframe ); + View.UpdateCurrentViewer(); + + SelectionChanged(); + RaiseZoomingFinished(); + } + + public void Shading() + { + View.SetDisplayMode( (int)DisplayMode.Shading ); + View.UpdateCurrentViewer(); + + SelectionChanged(); + RaiseZoomingFinished(); + } + + public void Color() + { + ChangeColor( true ); + } + + public void Background() + { + ChangeColor( false ); + } + + public void Material() + { + MaterialDlg aDlg = new MaterialDlg( View ); + aDlg.ShowDialog(); + } + + public void Transparency() + { + TransparencyDialog dlg = new TransparencyDialog(); + dlg.View = View; + dlg.ShowDialog( this ); + } + + public void Delete() + { + View.EraseObjects(); + } + + public void OnKeyDown( System.Windows.Input.Key theKey ) + { + if ( theKey == System.Windows.Input.Key.LeftShift || + theKey == System.Windows.Input.Key.RightShift ) + { + CurrentPressedKey = CurrentPressedKey.CurPressedKey_Shift; + } + else if (theKey == System.Windows.Input.Key.LeftCtrl || + theKey == System.Windows.Input.Key.RightCtrl ) + { + CurrentPressedKey = CurrentPressedKey.CurPressedKey_Ctrl; + } + } + + public void OnKeyUp() + { + CurrentPressedKey = CurrentPressedKey.CurPressedKey_Nothing; + } + + protected void MultiDragEvent( int x, int y, int theState ) + { + if ( theState == -1 ) //mouse is down + { + myButtonDownX = x; + myButtonDownY = y; + } + else if ( theState == 1) //mouse is up + { + View.ShiftSelect( Math.Min( myButtonDownX, x ), Math.Min( myButtonDownY, y ), + Math.Max( myButtonDownX, x ), Math.Max( myButtonDownY, y ) ); + } + } + + protected void DragEvent( int x, int y, int theState ) + { + if ( theState == -1 ) //mouse is down + { + myButtonDownX = x; + myButtonDownY = y; + } + else if ( theState == 1 ) //mouse is up + { + View.Select( Math.Min( myButtonDownX, x ), Math.Min( myButtonDownY, y ), + Math.Max( myButtonDownX, x ), Math.Max( myButtonDownY, y ) ); + } + } + + private void DrawRectangle( bool draw ) + { + System.Drawing.Graphics gr = System.Drawing.Graphics.FromHwnd(Handle); + System.Drawing.Pen p = null; + if ( IsRectVisible || !draw )//erase the rect + { + int r = View.GetBGColR(); + int g = View.GetBGColG(); + int b = View.GetBGColB(); + p = new System.Drawing.Pen( System.Drawing.Color.FromArgb(r, g, b) ); + IsRectVisible = false; + View.UpdateView(); + } + else if ( draw ) + { + p = new System.Drawing.Pen( System.Drawing.Color.White ); + IsRectVisible = true; + } + if ( p == null ) + { + return; + } + int x = Math.Min( myXmin, myXmax ); + int y = Math.Min( myYmin, myYmax ); + gr.DrawRectangle( p, x, y, Math.Abs(myXmax - myXmin), Math.Abs(myYmax - myYmin) ); + myRectDownX = Math.Max( myXmin, myXmax ); + myRectDownY = Math.Max( myYmin, myYmax ); + } + + private void OnMouseDown( object sender, System.Windows.Forms.MouseEventArgs e ) + { + if ( e.Button == MouseButtons.Left ) + { + myXmin = e.X; + myXmax = e.X; + myYmin = e.Y; + myYmax = e.Y; + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) + { + // start the dinamic zooming.... + CurrentMode = CurrentAction3d.CurAction3d_DynamicZooming; + } + else + { + switch ( CurrentMode ) + { + case CurrentAction3d.CurAction3d_Nothing: + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift ) + { + MultiDragEvent( myXmax, myYmax, -1 ); + } + else + { + DragEvent( myXmax, myYmax, -1 ); + } + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + if ( !DegenerateMode ) + { + View.SetDegenerateModeOn(); + } + View.StartRotation( e.X, e.Y ); + break; + case CurrentAction3d.CurAction3d_WindowZooming: + Cursor = Cursors.Hand; + break; + default: + break; + } + } + } + else if ( e.Button == MouseButtons.Right ) + { + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) + { + if ( !DegenerateMode ) + { + View.SetDegenerateModeOn(); + } + View.StartRotation( e.X, e.Y ); + } + else + { + Popup.Show( this, new System.Drawing.Point( e.X, e.Y ) ); + } + } + } + + private void OnMouseUp( object sender, System.Windows.Forms.MouseEventArgs e ) + { + if ( e.Button == MouseButtons.Left ) + { + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) + { + return; + } + switch ( CurrentMode ) + { + case CurrentAction3d.CurAction3d_Nothing: + if ( e.X == myXmin && e.Y == myYmin ) + { + myXmax = e.X; + myYmax = e.Y; + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift ) + { + View.ShiftSelect(); + } + else + { + View.Select(); + } + } + else + { + myXmax = e.X; + myYmax = e.Y; + DrawRectangle( false ); + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Shift ) + { + MultiDragEvent( myXmax, myYmax, 1 ); + } + else + { + DragEvent( myXmax, myYmax, 1 ); + } + } + break; + case CurrentAction3d.CurAction3d_DynamicZooming: + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_WindowZooming: + myXmax = e.X; + myYmax = e.Y; + DrawRectangle( false ); + int ValZWMin = 1; + if ( Math.Abs(myXmax - myXmin) > ValZWMin && + Math.Abs(myXmax - myYmax) > ValZWMin ) + { + View.WindowFitAll( myXmin, myYmin, myXmax, myYmax ); + } + Cursor = Cursors.Arrow; + RaiseZoomingFinished(); + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_DynamicPanning: + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_GlobalPanning: + View.Place( e.X, e.Y, myCurZoom ); + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + CurrentMode = CurrentAction3d.CurAction3d_Nothing; + if ( !DegenerateMode ) + { + View.SetDegenerateModeOff(); + } + else + { + View.SetDegenerateModeOn(); + } + break; + default: + break; + } + } + else if ( e.Button == MouseButtons.Right ) + { + if ( !DegenerateMode ) + { + View.SetDegenerateModeOff(); + } + else + { + View.SetDegenerateModeOn(); + } + } + + SelectionChanged(); + } + + private void OnMouseMove( object sender, System.Windows.Forms.MouseEventArgs e ) + { + if ( e.Button == MouseButtons.Left ) //left button is pressed + { + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) + { + View.Zoom(myXmax, myYmax, e.X, e.Y); + myXmax = e.X; + myYmax = e.Y; + } + else + { + switch ( CurrentMode ) + { + case CurrentAction3d.CurAction3d_Nothing: + DrawRectangle( false ); + myXmax = e.X; + myYmax = e.Y; + DrawRectangle( true ); + break; + case CurrentAction3d.CurAction3d_DynamicZooming: + View.Zoom( myXmax, myYmax, e.X, e.Y ); + myXmax = e.X; + myYmax = e.Y; + break; + case CurrentAction3d.CurAction3d_WindowZooming: + DrawRectangle( false ); + myXmax = e.X; + myYmax = e.Y; + DrawRectangle( true );//add brush here + break; + case CurrentAction3d.CurAction3d_DynamicPanning: + View.Pan( e.X - myXmax, myYmax - e.Y ); + myXmax = e.X; + myYmax = e.Y; + break; + case CurrentAction3d.CurAction3d_GlobalPanning: + break; + case CurrentAction3d.CurAction3d_DynamicRotation: + View.Rotation( e.X, e.Y ); + View.RedrawView(); + break; + default: + break; + } + } + } + else if ( e.Button == MouseButtons.Middle ) //middle button is pressed + { + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl ) + { + View.Pan( e.X - myXmax, myYmax - e.Y ); + myXmax = e.X; + myYmax = e.Y; + } + } + else if ( e.Button == MouseButtons.Right ) //right button is pressed + { + if ( CurrentPressedKey == CurrentPressedKey.CurPressedKey_Ctrl) + { + View.Rotation( e.X, e.Y ); + } + } + else // no buttons are pressed + { + myXmax = e.X; + myYmax = e.Y; + View.MoveTo( e.X, e.Y ); + } + } + + private void OnPopup( object sender, System.EventArgs e ) + { + ContextWireframe.Enabled = IsWireframeEnabled; + ContextShading.Enabled = IsShadingEnabled; + ContextColor.Enabled = IsColorEnabled; + ContextMaterial.Enabled = IsMaterialEnabled; + ContextDelete.Enabled = IsDeleteEnabled; + ContextTransparency.Enabled = IsTransparencyEnabled; + ContextBackground.Enabled = true; + } + + private void ContextWireframe_Click( object sender, System.EventArgs e ) + { + Wireframe(); + } + + private void ContextShading_Click( object sender, System.EventArgs e ) + { + Shading(); + } + + private void ContextColor_Click( object sender, System.EventArgs e ) + { + Color(); + } + + private void ContextMaterial_Click( object sender, System.EventArgs e ) + { + Material(); + } + + private void ContextTransparency_Click( object sender, System.EventArgs e ) + { + Transparency(); + } + + private void ContextDelete_Click( object sender, System.EventArgs e ) + { + Delete(); + } + + private void ContextBackground_Click( object sender, System.EventArgs e ) + { + Background(); + } + } +} diff --git a/samples/CSharp/WPF_WinForms/Properties/AssemblyInfo.cs b/samples/CSharp/WPF_WinForms/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..02445ca672 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IE")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("IE")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/CSharp/WPF_WinForms/Properties/Resources.Designer.cs b/samples/CSharp/WPF_WinForms/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..e6c1eac679 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18444 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IE_WPF_WinForms.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IE_WPF_WinForms.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/samples/CSharp/WPF_WinForms/Properties/Resources.resx b/samples/CSharp/WPF_WinForms/Properties/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/samples/CSharp/WPF_WinForms/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/CSharp/WPF_WinForms/Properties/Settings.Designer.cs b/samples/CSharp/WPF_WinForms/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..117456a5c0 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18444 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace IE_WPF_WinForms.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/samples/CSharp/WPF_WinForms/Properties/Settings.settings b/samples/CSharp/WPF_WinForms/Properties/Settings.settings new file mode 100644 index 0000000000..033d7a5e9e --- /dev/null +++ b/samples/CSharp/WPF_WinForms/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/samples/CSharp/WPF_WinForms/Simple Styles.xaml b/samples/CSharp/WPF_WinForms/Simple Styles.xaml new file mode 100644 index 0000000000..b130cea606 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/Simple Styles.xaml @@ -0,0 +1,1134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/CSharp/WPF_WinForms/TransparencyDialog.cs b/samples/CSharp/WPF_WinForms/TransparencyDialog.cs new file mode 100644 index 0000000000..ba7a456252 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/TransparencyDialog.cs @@ -0,0 +1,108 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; + +namespace IE_WPF_WinForms +{ + /// + /// Summary description for TransparencyDialog. + /// + public class TransparencyDialog : System.Windows.Forms.Form + { + private System.Windows.Forms.NumericUpDown MyTransparency; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + private OCCTProxy myView; + + public TransparencyDialog() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + myView = null; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(TransparencyDialog)); + this.MyTransparency = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).BeginInit(); + this.SuspendLayout(); + // + // MyTransparency + // + this.MyTransparency.Location = new System.Drawing.Point(16, 16); + this.MyTransparency.Maximum = new System.Decimal(new int[] { + 10, + 0, + 0, + 0}); + this.MyTransparency.Name = "MyTransparency"; + this.MyTransparency.Size = new System.Drawing.Size(96, 20); + this.MyTransparency.TabIndex = 0; + this.MyTransparency.ValueChanged += new System.EventHandler(this.MyTransparency_ValueChanged); + // + // TransparencyDialog + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(128, 53); + this.Controls.Add(this.MyTransparency); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TransparencyDialog"; + this.Text = "TransparencyDialog"; + ((System.ComponentModel.ISupportInitialize)(this.MyTransparency)).EndInit(); + this.ResumeLayout(false); + + } + #endregion + + private void MyTransparency_ValueChanged(object sender, System.EventArgs e) + { + if (this.myView == null) + return; + int transp = (int)this.MyTransparency.Value; + this.myView.SetTransparency(transp); + } + + public OCCTProxy View + { + set + { + this.myView = value; + } + } + + } +} diff --git a/samples/CSharp/WPF_WinForms/TransparencyDialog.resx b/samples/CSharp/WPF_WinForms/TransparencyDialog.resx new file mode 100644 index 0000000000..688fd72e80 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/TransparencyDialog.resx @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Private + + + Private + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + 80 + + + True + + + Private + + + TransparencyDialog + + + + AAABAAEAMDAAAAAAAACoDgAAFgAAACgAAAAwAAAAYAAAAAEACAAAAAAAgAoAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYABAQEAAgICAAMDAwAERERABYW + FgAcHBwAIiIiACkpKQBVVVUATU1NAEJCQgA5OTkAgHz/AFBQ/wCTANYA/+zMAMbW7wDW5+cAkKmtAAAA + MwAAAGYAAACZAAAAzAAAMwAAADMzAAAzZgAAM5kAADPMAAAz/wAAZgAAAGYzAABmZgAAZpkAAGbMAABm + /wAAmQAAAJkzAACZZgAAmZkAAJnMAACZ/wAAzAAAAMwzAADMZgAAzJkAAMzMAADM/wAA/2YAAP+ZAAD/ + zAAzAAAAMwAzADMAZgAzAJkAMwDMADMA/wAzMwAAMzMzADMzZgAzM5kAMzPMADMz/wAzZgAAM2YzADNm + ZgAzZpkAM2bMADNm/wAzmQAAM5kzADOZZgAzmZkAM5nMADOZ/wAzzAAAM8wzADPMZgAzzJkAM8zMADPM + /wAz/zMAM/9mADP/mQAz/8wAM///AGYAAABmADMAZgBmAGYAmQBmAMwAZgD/AGYzAABmMzMAZjNmAGYz + mQBmM8wAZjP/AGZmAABmZjMAZmZmAGZmmQBmZswAZpkAAGaZMwBmmWYAZpmZAGaZzABmmf8AZswAAGbM + MwBmzJkAZszMAGbM/wBm/wAAZv8zAGb/mQBm/8wAzAD/AP8AzACZmQAAmTOZAJkAmQCZAMwAmQAAAJkz + MwCZAGYAmTPMAJkA/wCZZgAAmWYzAJkzZgCZZpkAmWbMAJkz/wCZmTMAmZlmAJmZmQCZmcwAmZn/AJnM + AACZzDMAZsxmAJnMmQCZzMwAmcz/AJn/AACZ/zMAmcxmAJn/mQCZ/8wAmf//AMwAAACZADMAzABmAMwA + mQDMAMwAmTMAAMwzMwDMM2YAzDOZAMwzzADMM/8AzGYAAMxmMwCZZmYAzGaZAMxmzACZZv8AzJkAAMyZ + MwDMmWYAzJmZAMyZzADMmf8AzMwAAMzMMwDMzGYAzMyZAMzMzADMzP8AzP8AAMz/MwCZ/2YAzP+ZAMz/ + zADM//8AzAAzAP8AZgD/AJkAzDMAAP8zMwD/M2YA/zOZAP8zzAD/M/8A/2YAAP9mMwDMZmYA/2aZAP9m + zADMZv8A/5kAAP+ZMwD/mWYA/5mZAP+ZzAD/mf8A/8wAAP/MMwD/zGYA/8yZAP/MzAD/zP8A//8zAMz/ + ZgD//5kA///MAGZm/wBm/2YAZv//AP9mZgD/Zv8A//9mACEApQBfX18Ad3d3AIaGhgCWlpYAy8vLALKy + sgDX19cA3d3dAOPj4wDq6uoA8fHxAPj4+ADw+/8ApKCgAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMT + ExMTExMTEyIiQiI8HTyCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALwDODg4Nzc4MQMdAAAA + AADDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOw4ODgyOCQAAAAdAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAODIyMSIAHewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAA7DI3MSIdCwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAADEyMQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs4JAALAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALwxJAAhAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4IgC8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAJAxJB0LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + ALwLCx0dIh0dCwATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACx0dAB0dIiIiIiId + CxMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAvAsdAB0dIiQkAyQkIiIiHSIAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAIgMxMVhZmZqZAyQiHR0AAAAAkAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAvAsdISIDMThZWVmgvaCZWVIkIh0AAB0dIh0hCwALCwALtgAAAAAAAAAAAAAAAOwAAB0iMTEx + ODhYWZrDw8Ofn1hSJCIAHQAdACIAHSIkAwsdOAAAAADeExMTCwsLIiIkMTEyODg3MllZmprDw8PDwllS + MSQdHQAAAB0AIiQkAAAAvDi8AAAxAzExMTExMTI4Nzg4ODc4ODhZXpnDw8PDml1YNwMkIh0AAB0hIiQA + AAAAACIAAAA4ODc4Nzg4ODg4ODg4ODg4ODhZWV6avb2gmllZODcxJCIAAAAdIgMLAAAAACIAAACGE0+G + T4bs7Oy8vLy8vAAxODg4ODg4NzIyMSQdHQAAvADsCwAiJDExAAAAwjjsAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAALMSQAAAAAAAAAAAAAAAAAEyI4MQsiOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALMSQAAAAA + AAAAAAAAAAAAAAC8CwsAEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC8AAsAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////AAD///////8AAP///////wAA//////// + AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP// + /////wAA//8AAH//AAD//wAAf/8AAP//4AP//wAA///4B///AAD///gP//8AAP///B///wAA///8H/// + AAD///wf//8AAP///h///wAA///8H///AAD//+AD//8AAP//wAD//wAA//4AAD//AAD//AAAB/8AAP/w + AAAAAwAA/8AAAAABAADAAAAAADgAAMAAAAAAPAAAwAAAAAA8AADAAAAAIDgAAP///j/+AQAA///+P/+D + AAD///4///8AAP///////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP// + /////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAP///////wAA + + + \ No newline at end of file diff --git a/samples/CSharp/WPF_WinForms/app.config b/samples/CSharp/WPF_WinForms/app.config new file mode 100644 index 0000000000..e365603337 --- /dev/null +++ b/samples/CSharp/WPF_WinForms/app.config @@ -0,0 +1,3 @@ + + + diff --git a/samples/CSharp/WPF_WinForms/res/MainFrame.ico b/samples/CSharp/WPF_WinForms/res/MainFrame.ico new file mode 100644 index 0000000000..99dbceb637 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/MainFrame.ico differ diff --git a/samples/CSharp/WPF_WinForms/res/document.png b/samples/CSharp/WPF_WinForms/res/document.png new file mode 100644 index 0000000000..1ba28fff33 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/document.png differ diff --git a/samples/CSharp/WPF_WinForms/res/help.png b/samples/CSharp/WPF_WinForms/res/help.png new file mode 100644 index 0000000000..e57336285e Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/help.png differ diff --git a/samples/CSharp/WPF_WinForms/res/lamp.png b/samples/CSharp/WPF_WinForms/res/lamp.png new file mode 100644 index 0000000000..a5a6775c33 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/lamp.png differ diff --git a/samples/CSharp/WPF_WinForms/res/new.png b/samples/CSharp/WPF_WinForms/res/new.png new file mode 100644 index 0000000000..953757a62f Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/new.png differ diff --git a/samples/CSharp/WPF_WinForms/res/occ_logo.bmp b/samples/CSharp/WPF_WinForms/res/occ_logo.bmp new file mode 100644 index 0000000000..443a7de612 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/occ_logo.bmp differ diff --git a/samples/CSharp/WPF_WinForms/res/tool_color.png b/samples/CSharp/WPF_WinForms/res/tool_color.png new file mode 100644 index 0000000000..b37ad7d480 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/tool_color.png differ diff --git a/samples/CSharp/WPF_WinForms/res/tool_delete.png b/samples/CSharp/WPF_WinForms/res/tool_delete.png new file mode 100644 index 0000000000..aaab07fc9f Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/tool_delete.png differ diff --git a/samples/CSharp/WPF_WinForms/res/tool_material.png b/samples/CSharp/WPF_WinForms/res/tool_material.png new file mode 100644 index 0000000000..41e936855e Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/tool_material.png differ diff --git a/samples/CSharp/WPF_WinForms/res/tool_shading.png b/samples/CSharp/WPF_WinForms/res/tool_shading.png new file mode 100644 index 0000000000..6bb9dc46de Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/tool_shading.png differ diff --git a/samples/CSharp/WPF_WinForms/res/tool_transparency.png b/samples/CSharp/WPF_WinForms/res/tool_transparency.png new file mode 100644 index 0000000000..6b42536eae Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/tool_transparency.png differ diff --git a/samples/CSharp/WPF_WinForms/res/tool_wireframe.png b/samples/CSharp/WPF_WinForms/res/tool_wireframe.png new file mode 100644 index 0000000000..57c560f15a Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/tool_wireframe.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_axo.png b/samples/CSharp/WPF_WinForms/res/view_axo.png new file mode 100644 index 0000000000..c9a9226180 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_axo.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_back.png b/samples/CSharp/WPF_WinForms/res/view_back.png new file mode 100644 index 0000000000..0798f52938 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_back.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_bottom.png b/samples/CSharp/WPF_WinForms/res/view_bottom.png new file mode 100644 index 0000000000..c7cfdc208a Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_bottom.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_comp_off.png b/samples/CSharp/WPF_WinForms/res/view_comp_off.png new file mode 100644 index 0000000000..c900b196f0 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_comp_off.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_comp_on.png b/samples/CSharp/WPF_WinForms/res/view_comp_on.png new file mode 100644 index 0000000000..73ca4c83d0 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_comp_on.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_fitall.png b/samples/CSharp/WPF_WinForms/res/view_fitall.png new file mode 100644 index 0000000000..21d2f423ef Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_fitall.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_fitarea.png b/samples/CSharp/WPF_WinForms/res/view_fitarea.png new file mode 100644 index 0000000000..f20f5c0554 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_fitarea.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_front.png b/samples/CSharp/WPF_WinForms/res/view_front.png new file mode 100644 index 0000000000..a9e99c59b6 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_front.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_glpan.png b/samples/CSharp/WPF_WinForms/res/view_glpan.png new file mode 100644 index 0000000000..02a9c1cb8d Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_glpan.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_left.png b/samples/CSharp/WPF_WinForms/res/view_left.png new file mode 100644 index 0000000000..7d25b6ab2f Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_left.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_pan.png b/samples/CSharp/WPF_WinForms/res/view_pan.png new file mode 100644 index 0000000000..0e9a6a5a03 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_pan.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_reset.png b/samples/CSharp/WPF_WinForms/res/view_reset.png new file mode 100644 index 0000000000..38849fd694 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_reset.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_right.png b/samples/CSharp/WPF_WinForms/res/view_right.png new file mode 100644 index 0000000000..5540220cfa Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_right.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_rotate.png b/samples/CSharp/WPF_WinForms/res/view_rotate.png new file mode 100644 index 0000000000..7e5d013b9f Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_rotate.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_top.png b/samples/CSharp/WPF_WinForms/res/view_top.png new file mode 100644 index 0000000000..b788de36fb Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_top.png differ diff --git a/samples/CSharp/WPF_WinForms/res/view_zoom.png b/samples/CSharp/WPF_WinForms/res/view_zoom.png new file mode 100644 index 0000000000..1b50a37bc8 Binary files /dev/null and b/samples/CSharp/WPF_WinForms/res/view_zoom.png differ diff --git a/samples/CSharp/msvc.bat b/samples/CSharp/msvc.bat index 5232ec7ebe..01b2c18e5e 100644 --- a/samples/CSharp/msvc.bat +++ b/samples/CSharp/msvc.bat @@ -1,7 +1,7 @@ call "%~dp0..\..\env.bat" %1 %2 %3 if ["%CASDEB%"] == [""] ( - call "%~dp0..\..\msvc.bat" %VCVER% win%ARCH% Release "%~dp0\CSharp-%VCVER%.sln" + call "%~dp0..\..\msvc.bat" %VCVER% win%ARCH% Release %~dp0\CSharp.sln ) else ( - call "%~dp0..\..\msvc.bat" %VCVER% win%ARCH% Debug "%~dp0\CSharp-%VCVER%.sln" + call "%~dp0..\..\msvc.bat" %VCVER% win%ARCH% Debug %~dp0\CSharp.sln ) \ No newline at end of file diff --git a/samples/CSharp/msvc_D3D.bat b/samples/CSharp/msvc_D3D.bat new file mode 100644 index 0000000000..1e7d2a3247 --- /dev/null +++ b/samples/CSharp/msvc_D3D.bat @@ -0,0 +1,14 @@ +@echo off + +if NOT DEFINED DXSDK_DIR ( + echo ERROR: DirectX SDK is required in order to build the sample but it is not found in your system. Please install DirectX SDK and retry. + exit /B +) + +call "%~dp0..\..\env.bat" %1 %2 %3 + +if ["%CASDEB%"] == [""] ( + call "%~dp0..\..\msvc.bat" %VCVER% win%ARCH% Release %~dp0\CSharp_D3D.sln +) else ( + call "%~dp0..\..\msvc.bat" %VCVER% win%ARCH% Debug %~dp0\CSharp_D3D.sln +) \ No newline at end of file diff --git a/samples/CSharp/run_wpf.bat b/samples/CSharp/run_wpf.bat index 4cbccd9163..07ddc2a5db 100644 --- a/samples/CSharp/run_wpf.bat +++ b/samples/CSharp/run_wpf.bat @@ -10,7 +10,7 @@ if "%1" == "-h" ( call "%~dp0..\..\env.bat" %1 %2 %3 -set "EXEC=%~dp0\win%ARCH%\bin%CASDEB%\IE_WPF.exe" +set "EXEC=%~dp0\win%ARCH%\bin%CASDEB%\IE_WPF_WinForms.exe" if not exist "%EXEC%" goto err_exe diff --git a/samples/CSharp/run_wpf_D3D.bat b/samples/CSharp/run_wpf_D3D.bat new file mode 100644 index 0000000000..37c8904598 --- /dev/null +++ b/samples/CSharp/run_wpf_D3D.bat @@ -0,0 +1,27 @@ +@echo off + +if "%1" == "-h" ( + echo Launch WPF sample as follows: + echo %~n0 ^[vc9^] ^[win32^|win64^] ^[Debug^|Release^] + echo By default configuration set in ..\..\custom.bat is used + echo Run %~n0 -h to get this help + exit /B +) + +call "%~dp0..\..\env.bat" %1 %2 %3 + +set "EXEC=%~dp0\win%ARCH%\bin%CASDEB%\IE_WPF_D3D.exe" + +if not exist "%EXEC%" goto err_exe + +"%EXEC%" + +goto eof + +:err_exe +echo Executable %EXEC% not found. +echo Check that OCCT and sample are built with the selected configuration: +echo compiler=%VCVER% platform=win%ARCH% %3 +exit /B + +:eof \ No newline at end of file