]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Issue 0020446: A button in OCCViewer to keep only ambient light
authorvsr <vsr@opencascade.com>
Tue, 18 Aug 2009 14:23:47 +0000 (14:23 +0000)
committervsr <vsr@opencascade.com>
Tue, 18 Aug 2009 14:23:47 +0000 (14:23 +0000)
src/OCCViewer/Makefile.am
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h
src/OCCViewer/resources/OCCViewer_images.ts
src/OCCViewer/resources/OCCViewer_msg_en.ts
src/OCCViewer/resources/occ_view_ambient.png [new file with mode: 0644]

index 7e77377e21edd18ade767dbbccecd39a8b4bbeda..00ddf2311c282d081535990cd63e8a6f307526f4 100755 (executable)
@@ -84,6 +84,7 @@ dist_salomeres_DATA =                         \
        resources/occ_view_clipping.png         \
        resources/occ_view_clipping_pressed.png \
        resources/occ_view_scaling.png          \
+       resources/occ_view_ambient.png          \
        resources/occ_view_fitall.png           \
        resources/occ_view_fitarea.png          \
        resources/occ_view_front.png            \
index 32298e99b61ec7d94f06f134127893ec8c09091e..f7e311ff2e437f7cb2b26d17718a85218439a83e 100755 (executable)
@@ -50,6 +50,7 @@
 #include <QApplication>
 
 #include <V3d_Plane.hxx>
+#include <V3d_Light.hxx>
 #include <gp_Dir.hxx>
 #include <gp_Pln.hxx>
 #include <TColgp_Array1OfPnt2d.hxx>
@@ -1087,6 +1088,13 @@ void OCCViewer_ViewWindow::createActions()
   aAction->setStatusTip(tr("DSC_SCALING"));
   connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale()));
   toolMgr()->registerAction( aAction, AxialScaleId );
+
+  // Active only ambient light or not
+  aAction = new QtxAction(tr("MNU_AMBIENT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_AMBIENT" ) ),
+                           tr( "MNU_AMBIENT" ), 0, this);
+  aAction->setStatusTip(tr("DSC_AMBIENT"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onAmbientToogle()));
+  toolMgr()->registerAction( aAction, AmbientId );
 }
 
 /*!
@@ -1136,6 +1144,7 @@ void OCCViewer_ViewWindow::createToolBar()
   toolMgr()->append( toolMgr()->separator(), tid );
   toolMgr()->append( ClippingId, tid );
   toolMgr()->append( AxialScaleId, tid );
+  toolMgr()->append( AmbientId, tid );
 }
 
 /*!
@@ -1326,6 +1335,24 @@ void OCCViewer_ViewWindow::onAxialScale()
     myScalingDlg->show();
 }
 
+void OCCViewer_ViewWindow::onAmbientToogle()
+{
+  Handle(V3d_Viewer) viewer = myViewPort->getViewer();
+  viewer->InitDefinedLights();
+  while(viewer->MoreDefinedLights())
+    {
+      Handle(V3d_Light) light = viewer->DefinedLight();
+      if(light->Type() != V3d_AMBIENT)
+       {
+         Handle(V3d_View) aView3d = myViewPort->getView();
+         if( aView3d->IsActiveLight(light) ) viewer->SetLightOff(light);
+         else viewer->SetLightOn(light);
+       }
+      viewer->NextDefinedLights();
+    }
+  viewer->Update();
+}
+
 /*!
   \brief Store view parameters.
 */
index 180e66c1975e09fb4274cb9846579ba7093bf07e..b4c117b713eace90e6c140997d8403f75b2331d6 100755 (executable)
@@ -49,7 +49,7 @@ public:
   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
         ChangeRotationPointId, RotationId,
          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId,
-         TrihedronShowId, AxialScaleId };
+         TrihedronShowId, AxialScaleId, AmbientId };
 
   enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, 
                      PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
@@ -104,6 +104,7 @@ public slots:
   void onCloneView();
   void onClipping( bool on );
   void onAxialScale();
+  void onAmbientToogle();
   void onMemorizeView();
   void onRestoreView();
   void onTrihedronShow();
index 11d0f3438b3ee7c1b9cdf3c5a93b0406ea350e7e..895d4198afc1197d2d6ecee254422956d55ffca3 100644 (file)
         <source>ICON_OCCVIEWER_SCALING</source>
         <translation>occ_view_scaling.png</translation>
     </message>
+    <message>
+        <source>ICON_OCCVIEWER_AMBIENT</source>
+        <translation>occ_view_ambient.png</translation>
+    </message>
 </context>
 </TS>
index 907145fea7afcf59bb316665616abecb371f0dc6..c2fecf77b6b9e7326c8e36264584f10a7da68a0a 100644 (file)
         <source>MNU_SCALING</source>
         <translation>Scaling</translation>
     </message>
+    <message>
+        <source>DSC_AMBIENT</source>
+        <translation>Toogle keep only ambient light</translation>
+    </message>
+    <message>
+        <source>MNU_AMBIENT</source>
+        <translation>Toogle keep only ambient light</translation>
+    </message>
     <message>
         <source>OCC_IMAGE_FILES</source>
         <translation>Images Files (*.bmp *.png *.jpg *.jpeg)</translation>
diff --git a/src/OCCViewer/resources/occ_view_ambient.png b/src/OCCViewer/resources/occ_view_ambient.png
new file mode 100644 (file)
index 0000000..ebcdccc
Binary files /dev/null and b/src/OCCViewer/resources/occ_view_ambient.png differ