]> OCCT Git - occt-copy.git/commitdiff
0024548: Ray Tracing mode not available in MFC samples
authorski <ski@opencascade.com>
Thu, 30 Oct 2014 13:03:24 +0000 (16:03 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 5 Nov 2014 14:17:47 +0000 (17:17 +0300)
Ray tracing functionality was added to OCCT MFC samples.

15 files changed:
samples/mfc/standard/Common/OCC_3dBaseDoc.cpp
samples/mfc/standard/Common/OCC_3dBaseDoc.h
samples/mfc/standard/Common/OCC_3dChildFrame.cpp
samples/mfc/standard/Common/OCC_3dChildFrame.h
samples/mfc/standard/Common/res/OCC_Resource.h
samples/mfc/standard/Common/res/OCC_Resource.rc
samples/mfc/standard/Common/res/ToolbarRayTracing.bmp [new file with mode: 0644]
samples/mfc/standard/mfcsample/adm/win/vc10/mfcsample.vcxproj
samples/mfc/standard/mfcsample/adm/win/vc10/mfcsample.vcxproj.filters
samples/mfc/standard/mfcsample/adm/win/vc11/mfcsample.vcxproj
samples/mfc/standard/mfcsample/adm/win/vc11/mfcsample.vcxproj.filters
samples/mfc/standard/mfcsample/adm/win/vc12/mfcsample.vcxproj
samples/mfc/standard/mfcsample/adm/win/vc12/mfcsample.vcxproj.filters
samples/mfc/standard/mfcsample/adm/win/vc8/mfcsample.vcproj
samples/mfc/standard/mfcsample/adm/win/vc9/mfcsample.vcproj

index 407ac625372df0b5b824f88affe89b7d10038a56..6e225fd6e85d36d06113a134951d1b9a088596da 100755 (executable)
@@ -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();
+}
index e590141a2eb29245ab7b42aa9911a5a1654ad354..eff59545b14213fd378898a47e576d15df7b45b4 100755 (executable)
@@ -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;
 };
 
index 77f6a8ae2bd3e7a564fba8b58a54485d27943b33..c4d34095840b5a48f5bdf69580b9f50554b09ec2 100755 (executable)
@@ -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;
 }
\ No newline at end of file
index 170cd0da7a3deda1913fcaf2ed322e2b4050a5fb..ecc5b1a3bf08c391ea5a2a9c0b3982270412fd7b 100755 (executable)
@@ -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_)
index f4fd5c518ddf826d6649d2465d00131fee570617..974db147b0ff4bb0211785f6d2c80b796f5bdf50 100755 (executable)
@@ -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
 #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
index 3667b0a6b7ea680b3cae39c41655484eee30f908..38898aac7a716d6633bfb67095bc32e498a5f54f 100755 (executable)
@@ -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
+
 
 /////////////////////////////////////////////////////////////////////////////
 //
diff --git a/samples/mfc/standard/Common/res/ToolbarRayTracing.bmp b/samples/mfc/standard/Common/res/ToolbarRayTracing.bmp
new file mode 100644 (file)
index 0000000..809af47
Binary files /dev/null and b/samples/mfc/standard/Common/res/ToolbarRayTracing.bmp differ
index 78e53eafb03648849907dd03782bfb24b3e4aa54..e5f5c8e9a1daa8a5fc3305485510af31bacc7812 100644 (file)
     <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">
index 3a5573ca694add519cad5b9bd8918d3199d29cb8..9dfbb7d9a2685a804ffc5af7fd4115f0fd274f05 100644 (file)
     <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>
\ No newline at end of file
index 972ded5e248c99ce23720d42e2b31860c0708495..246c776171f72f976ab0429b02053f21c0f5f25a 100644 (file)
     <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">
index 1e4879dfd85f65e60537972125865ea0e52eb6c0..8c55ba18265f4850dbc2b591e0df39cfca0dcc4d 100644 (file)
     <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>
\ No newline at end of file
index c97f8604393027498a64c62f881b7228352e91c3..34c2e3931f0155471ed257d627e862a1600bf69d 100644 (file)
     <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">
index 1e4879dfd85f65e60537972125865ea0e52eb6c0..8c55ba18265f4850dbc2b591e0df39cfca0dcc4d 100644 (file)
     <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>
\ No newline at end of file
index 9c5d36a2746dfe1bb92086168ada604e78310279..ab5526103e9d2143a512c1239d59099d124afa0d 100644 (file)
                                RelativePath="..\..\..\..\Common\res\occ_logo.bmp"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\..\..\Common\res\ToolbarRayTracing.bmp"
+                               >
+                       </File>
                </Filter>
        </Files>
        <Globals>
index 2006d98994ea20d717d30eec8004e4aafd5ba7b7..16d410e35d446e6f550b788062171e9540c31839 100644 (file)
                                RelativePath="..\..\..\..\Common\res\occ_logo.bmp"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\..\..\Common\res\ToolbarRayTracing.bmp"
+                               >
+                       </File>
                </Filter>
        </Files>
        <Globals>