1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0024548: Ray Tracing mode not available in MFC samples

Ray tracing functionality was added to OCCT MFC samples.
This commit is contained in:
ski 2014-10-30 16:03:24 +03:00 committed by bugmaster
parent a806787bd6
commit 2c5b6d9c12
15 changed files with 140 additions and 1 deletions

View File

@ -42,6 +42,17 @@ BEGIN_MESSAGE_MAP(OCC_3dBaseDoc, OCC_BaseDoc)
//}}AFX_MSG_MAP
ON_COMMAND_EX_RANGE(ID_OBJECT_MATERIAL_BRASS,ID_OBJECT_MATERIAL_DEFAULT, OnObjectMaterialRange)
ON_UPDATE_COMMAND_UI_RANGE(ID_OBJECT_MATERIAL_BRASS,ID_OBJECT_MATERIAL_DEFAULT, OnUpdateObjectMaterialRange)
//RayTracing
ON_COMMAND(ID_OBJECT_RAY_TRACING,OnObjectRayTracing)
ON_COMMAND(ID_OBJECT_SHADOWS,OnObjectShadows)
ON_COMMAND(ID_OBJECT_REFLECTIONS,OnObjectReflections)
ON_COMMAND(ID_OBJECT_ANTI_ALIASING,OnObjectAntiAliasing)
ON_UPDATE_COMMAND_UI(ID_OBJECT_RAY_TRACING, OnUpdateV3dButtons)
ON_UPDATE_COMMAND_UI(ID_OBJECT_SHADOWS, OnUpdateV3dButtons)
ON_UPDATE_COMMAND_UI(ID_OBJECT_REFLECTIONS, OnUpdateV3dButtons)
ON_UPDATE_COMMAND_UI(ID_OBJECT_ANTI_ALIASING, OnUpdateV3dButtons)
END_MESSAGE_MAP()
@ -60,6 +71,11 @@ OCC_3dBaseDoc::OCC_3dBaseDoc()
myViewer->SetDefaultLights();
myViewer->SetLightOn();
myAISContext = new AIS_InteractiveContext (myViewer);
myRayTracingIsOn = false;
myRaytracedShadowsIsOn = true;
myRaytracedReflectionsIsOn = false;
myRaytracedAntialiasingIsOn = false;
}
OCC_3dBaseDoc::~OCC_3dBaseDoc()
@ -424,3 +440,65 @@ void OCC_3dBaseDoc::SetMaterial(Graphic3d_NameOfMaterial Material)
myAISContext->SetMaterial (myAISContext->Current(),
(Graphic3d_NameOfMaterial)(Material));
}
// RayTracing
void OCC_3dBaseDoc::OnObjectRayTracing()
{
myRayTracingIsOn = !myRayTracingIsOn;
if(!myRayTracingIsOn)
{
myRaytracedShadowsIsOn = false;
myRaytracedReflectionsIsOn = false;
myRaytracedAntialiasingIsOn = false;
}
OnObjectRayTracingAction();
}
// Shadows
void OCC_3dBaseDoc::OnObjectShadows()
{
myRaytracedShadowsIsOn = !myRaytracedShadowsIsOn;
OnObjectRayTracingAction();
}
// Reflections
void OCC_3dBaseDoc::OnObjectReflections()
{
myRaytracedReflectionsIsOn = !myRaytracedReflectionsIsOn;
OnObjectRayTracingAction();
}
// Anti-aliasing
void OCC_3dBaseDoc::OnObjectAntiAliasing()
{
myRaytracedAntialiasingIsOn = !myRaytracedAntialiasingIsOn;
OnObjectRayTracingAction();
}
void OCC_3dBaseDoc::OnUpdateV3dButtons (CCmdUI* pCmdUI)
{
if (pCmdUI->m_nID == ID_OBJECT_RAY_TRACING)
{
pCmdUI->SetCheck(myRayTracingIsOn);
} else {
pCmdUI->Enable(myRayTracingIsOn);
if (pCmdUI->m_nID == ID_OBJECT_SHADOWS)
pCmdUI->SetCheck(myRaytracedShadowsIsOn);
if (pCmdUI->m_nID == ID_OBJECT_REFLECTIONS)
pCmdUI->SetCheck(myRaytracedReflectionsIsOn);
if (pCmdUI->m_nID == ID_OBJECT_ANTI_ALIASING)
pCmdUI->SetCheck(myRaytracedAntialiasingIsOn);
}
}
// Common function to change raytracing params and redraw view
void OCC_3dBaseDoc::OnObjectRayTracingAction()
{
myAISContext->CurrentViewer()->InitActiveViews();
Handle(V3d_View) aView = myAISContext->CurrentViewer()->ActiveView();
Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
if (myRayTracingIsOn)
aParams.Method = Graphic3d_RM_RAYTRACING;
else
aParams.Method = Graphic3d_RM_RASTERIZATION;
aParams.IsShadowEnabled = myRaytracedShadowsIsOn;
aParams.IsReflectionEnabled = myRaytracedReflectionsIsOn;
aParams.IsAntialiasingEnabled = myRaytracedAntialiasingIsOn;
myAISContext->UpdateCurrentViewer();
}

View File

@ -57,6 +57,8 @@ public:
int OnFileImportBrep_WithInitDir (const wchar_t* InitialDir);
void OnObjectRayTracingAction();
// Generated message map functions
protected:
//{{AFX_MSG(OCC_3dBaseDoc)
@ -81,11 +83,20 @@ protected:
afx_msg void OnObjectRemove();
afx_msg void OnUpdateObjectRemove(CCmdUI* pCmdUI);
afx_msg void OnUpdateV3dButtons(CCmdUI* pCmdUI);
afx_msg void OnObjectRayTracing();
afx_msg void OnObjectShadows();
afx_msg void OnObjectReflections();
afx_msg void OnObjectAntiAliasing();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
protected:
bool myRayTracingIsOn;
bool myRaytracedShadowsIsOn;
bool myRaytracedReflectionsIsOn;
bool myRaytracedAntialiasingIsOn;
int myPopupMenuNumber;
};

View File

@ -47,5 +47,17 @@ int OCC_3dChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
// Create toolbar for RayTracing functionality
if (!m_RTToolBar.Create(this) || !m_RTToolBar.LoadToolBar(IDR_RAY_TRACING))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_RTToolBar.SetBarStyle(m_RTToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_RTToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_RTToolBar);
return 0;
}

View File

@ -31,6 +31,9 @@ public:
DECLARE_MESSAGE_MAP()
//Attributes
protected:
CToolBar m_RTToolBar;
};
#endif // !defined(AFX_OCC_3DCHILDFRAME_H__84879CFC_7EE3_11D7_8632_0060B0EE281E__INCLUDED_)

View File

@ -25,6 +25,7 @@
#define IDR_TB_AIS 149
#define IDD_GrilleRectangulaire 150
#define IDD_GrilleCirculaire 151
#define IDR_RAY_TRACING 182
#define IDD_COLORMESH 552
#define IDB_coloredmesh 554
#define IDC_RICHEDIT_ResultDialog 1001
@ -126,6 +127,10 @@
#define ID_BUTTON2DGridRectPoints 32779
#define ID_BUTTON2DGridCircLines 32780
#define ID_OBJECT_REMOVE 32796
#define ID_OBJECT_RAY_TRACING 32898
#define ID_OBJECT_SHADOWS 32899
#define ID_OBJECT_REFLECTIONS 32900
#define ID_OBJECT_ANTI_ALIASING 32902
#define ID_BUTTONZoomAll 40000
#define ID_OBJECT_ERASE 40001
#define ID_BUTTONZoomWin 40002

View File

@ -67,6 +67,7 @@ IDR_2dCHILDFRAME BITMAP "2dChildFrameTB.bmp"
IDR_3dCHILDFRAME BITMAP "3dChildFrameTB.bmp"
IDR_TB_AIS BITMAP "AIS_TB.bmp"
IDB_coloredmesh BITMAP "coloredm.bmp"
IDR_RAY_TRACING BITMAP "ToolbarRayTracing.bmp"
/////////////////////////////////////////////////////////////////////////////
//
@ -280,6 +281,7 @@ BEGIN
PUSHBUTTON "Change dimension color",IDC_DimensionColor,105,156,63,24,BS_MULTILINE
CONTROL "",IDC_Flyout,"msctls_trackbar32",TBS_TOP | TBS_TOOLTIPS | WS_TABSTOP,73,112,100,20
END
IDD_DIALOG_STEREO DIALOGEX 0, 0, 166, 177
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Configure stereo"
@ -386,6 +388,14 @@ BEGIN
BUTTON ID_OBJECT_DIM
END
IDR_RAY_TRACING TOOLBAR 20, 20
BEGIN
BUTTON ID_OBJECT_RAY_TRACING
BUTTON ID_OBJECT_SHADOWS
BUTTON ID_OBJECT_REFLECTIONS
BUTTON ID_OBJECT_ANTI_ALIASING
END
/////////////////////////////////////////////////////////////////////////////
//

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 B

View File

@ -781,6 +781,7 @@
<None Include="..\..\..\..\Common\res\coloredm.bmp" />
<None Include="..\..\..\..\Common\res\MainFrame.ico" />
<None Include="..\..\..\..\Common\res\occ_logo.bmp" />
<None Include="..\..\..\..\Common\res\ToolbarRayTracing.bmp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -285,5 +285,8 @@
<None Include="..\..\..\..\Common\res\occ_logo.bmp">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\..\..\Common\res\ToolbarRayTracing.bmp">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -785,6 +785,7 @@
<None Include="..\..\..\..\Common\res\coloredm.bmp" />
<None Include="..\..\..\..\Common\res\MainFrame.ico" />
<None Include="..\..\..\..\Common\res\occ_logo.bmp" />
<None Include="..\..\..\..\Common\res\ToolbarRayTracing.bmp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -285,5 +285,8 @@
<None Include="..\..\..\..\Common\res\occ_logo.bmp">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\..\..\Common\res\ToolbarRayTracing.bmp">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -785,6 +785,7 @@
<None Include="..\..\..\..\Common\res\coloredm.bmp" />
<None Include="..\..\..\..\Common\res\MainFrame.ico" />
<None Include="..\..\..\..\Common\res\occ_logo.bmp" />
<None Include="..\..\..\..\Common\res\ToolbarRayTracing.bmp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -285,5 +285,8 @@
<None Include="..\..\..\..\Common\res\occ_logo.bmp">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\..\..\Common\res\ToolbarRayTracing.bmp">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -1957,6 +1957,10 @@
RelativePath="..\..\..\..\Common\res\occ_logo.bmp"
>
</File>
<File
RelativePath="..\..\..\..\Common\res\ToolbarRayTracing.bmp"
>
</File>
</Filter>
</Files>
<Globals>

View File

@ -1954,6 +1954,10 @@
RelativePath="..\..\..\..\Common\res\occ_logo.bmp"
>
</File>
<File
RelativePath="..\..\..\..\Common\res\ToolbarRayTracing.bmp"
>
</File>
</Filter>
</Files>
<Globals>