Salome HOME
Copyright update 2022
[modules/gui.git] / src / OCCViewer / OCCViewer_LightSourceDlg.cxx
index 20afd9cb5450b14148d4ccc228a1f07b65769e45..ef523a40843697b203cdb75f12e04a9e5cf029d7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2015-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 
 // internal includes
 #include "OCCViewer_LightSourceDlg.h"
+#include "OCCViewer.h"
 #include "OCCViewer_ViewWindow.h"
 #include "OCCViewer_ViewModel.h"
 
 // GUI includes
 #include <SUIT_Session.h>
-#include <CAF_Tools.h>
 #include <QtxDoubleSpinBox.h>
 #include <QtxColorButton.h>
 
@@ -76,7 +76,6 @@ OCCViewer_LightSourceDlg::OCCViewer_LightSourceDlg( OCCViewer_ViewWindow* view,
 
   const double min = -RealLast();
   const double max = RealLast();
-  const int precision = 3;
 
   /**********************   Directional light   **********************/
   /* Controls for directional light:
@@ -286,14 +285,16 @@ void OCCViewer_LightSourceDlg::initParam( bool theIsDefault )
     aLight = myModel->getViewer3d()->DefinedLight();
     if ( aLight->Type() == V3d_DIRECTIONAL ) {
       myDirLight = Handle(V3d_DirectionalLight)::DownCast( aLight );
-      myPosLight = new V3d_PositionalLight( myModel->getViewer3d(), 0, 0, 0 );
+      myPosLight = new V3d_PositionalLight( gp_Pnt(0, 0, 0) );
+      myModel->getViewer3d()->AddLight( myPosLight );
       myDirType->setChecked( true );
       myStackedLayout->setCurrentIndex(0);
       break;
     }
     if ( aLight->Type() == V3d_POSITIONAL ) {
       myPosLight = Handle(V3d_PositionalLight)::DownCast( aLight );
-      myDirLight = new V3d_DirectionalLight( myModel->getViewer3d() );
+      myDirLight = new V3d_DirectionalLight();
+      myModel->getViewer3d()->AddLight( myDirLight );
       myPosType->setChecked( true );
       myStackedLayout->setCurrentIndex(1);
       break;
@@ -301,10 +302,10 @@ void OCCViewer_LightSourceDlg::initParam( bool theIsDefault )
     myModel->getViewer3d()->NextDefinedLights();
   }
 
-  double aX, aY, aZ;
+  double aX=0., aY=0., aZ=0.;
   Quantity_Color aColor = aLight->Color();
   if( myDirType->isChecked() ) {
-    myDirColor->setColor( CAF_Tools::color( aColor ) );
+    myDirColor->setColor( OCCViewer::color( aColor ) );
     myDirLight->Direction( aX, aY, aZ );
     myDx->setValue( aX );
     myDy->setValue( aY );
@@ -312,7 +313,7 @@ void OCCViewer_LightSourceDlg::initParam( bool theIsDefault )
     myDirHeadLight->setChecked( myDirLight->Headlight() );
   }
   else if( myPosType->isChecked() ) {
-    myPosColor->setColor( CAF_Tools::color( aColor ) );
+    myPosColor->setColor( OCCViewer::color( aColor ) );
     myPosLight->Position( aX, aY, aZ );
     myX->setValue( aX );
     myY->setValue( aY );
@@ -356,7 +357,7 @@ void OCCViewer_LightSourceDlg::onDirChanged()
   myModel->getViewer3d()->SetLightOff( myDirLight );
   if ( !( myDx->value() == 0 && myDy->value() == 0 && myDz->value() == 0 ) ) {
     myDirLight->SetDirection( myDx->value(), myDy->value(), myDz->value() );
-    myDirLight->SetColor( CAF_Tools::color( myDirColor->color() ) );
+    myDirLight->SetColor( OCCViewer::color( myDirColor->color() ) );
     myDirLight->SetHeadlight( myDirHeadLight->isChecked() );
     myModel->getViewer3d()->SetLightOn( myDirLight );
   }
@@ -372,7 +373,7 @@ void OCCViewer_LightSourceDlg::onPosChanged()
     return;
   myModel->getViewer3d()->SetLightOff( myPosLight );
   myPosLight->SetPosition( myX->value(), myY->value(), myZ->value() );
-  myPosLight->SetColor( CAF_Tools::color( myPosColor->color() ) );
+  myPosLight->SetColor( OCCViewer::color( myPosColor->color() ) );
   myPosLight->SetHeadlight( myPosHeadLight->isChecked() );
   myModel->getViewer3d()->SetLightOn( myPosLight );
   myModel->getViewer3d()->UpdateLights();
@@ -427,5 +428,5 @@ void OCCViewer_LightSourceDlg::ClickOnHelp()
 {
   SUIT_Application* app = SUIT_Session::session()->activeApplication();
   if ( app )
-    app->onHelpContextModule( "GUI", "occ_3d_viewer_page.html", "light_source" );
+    app->onHelpContextModule( "GUI", "occ_3d_viewer.html", "light-source" );
 }