Salome HOME
0023124: EDF 11219 GEOM: Ray tracing in the OCC viewer
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewPort3d.cxx
index cc6d7bf5a496d68a28ce9401c1e20304d940803b..5e927fbb3eda784eef72f747ab9e65b2e29dd368 100755 (executable)
@@ -28,6 +28,8 @@
 
 #include <SUIT_ViewManager.h>
 #include <SUIT_ViewModel.h>
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
 
 #include <QColor>
 #include <QFileInfo>
@@ -88,7 +90,7 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V
   }
 #endif
 
-  setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
+  setDefaultParams();
 
   myCursor = NULL;
 }
@@ -803,3 +805,26 @@ QCursor* OCCViewer_ViewPort3d::getDefaultCursor() const
 {
   return myCursor;
 }
+
+/*
+ * Set default parameters from preferences
+ */
+void OCCViewer_ViewPort3d::setDefaultParams()
+{
+  setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
+
+  // get ray tracing parameters from preferences
+  int aDepth = SUIT_Session::session()->resourceMgr()->integerValue( "OCCViewer", "rt_depth", 3 );
+  bool aReflection = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_reflection", true );
+  bool anAntialiasing = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_antialiasing", false );
+  bool aShadow = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_shadow", true );
+  bool aTransparentShadow = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_trans_shadow", true );
+
+  Graphic3d_RenderingParams& aParams = myActiveView->ChangeRenderingParams();
+  aParams.RaytracingDepth = aDepth;
+  aParams.IsReflectionEnabled = aReflection;
+  aParams.IsAntialiasingEnabled = anAntialiasing;
+  aParams.IsShadowEnabled = aShadow;
+  aParams.IsTransparentShadowEnabled = aTransparentShadow;
+  myActiveView->Redraw();
+}