From: vsr Date: Tue, 18 Aug 2009 14:23:47 +0000 (+0000) Subject: Issue 0020446: A button in OCCViewer to keep only ambient light X-Git-Tag: V5_1_3rc1~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=027d1200e4093bb5351f4ef5d80e1864bc6f61b6;p=modules%2Fgui.git Issue 0020446: A button in OCCViewer to keep only ambient light --- diff --git a/src/OCCViewer/Makefile.am b/src/OCCViewer/Makefile.am index 7e77377e2..00ddf2311 100755 --- a/src/OCCViewer/Makefile.am +++ b/src/OCCViewer/Makefile.am @@ -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 \ diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 32298e99b..f7e311ff2 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -50,6 +50,7 @@ #include #include +#include #include #include #include @@ -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. */ diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 180e66c19..b4c117b71 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -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(); diff --git a/src/OCCViewer/resources/OCCViewer_images.ts b/src/OCCViewer/resources/OCCViewer_images.ts index 11d0f3438..895d4198a 100644 --- a/src/OCCViewer/resources/OCCViewer_images.ts +++ b/src/OCCViewer/resources/OCCViewer_images.ts @@ -112,5 +112,9 @@ ICON_OCCVIEWER_SCALING occ_view_scaling.png + + ICON_OCCVIEWER_AMBIENT + occ_view_ambient.png + diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index 907145fea..c2fecf77b 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -228,6 +228,14 @@ MNU_SCALING Scaling + + DSC_AMBIENT + Toogle keep only ambient light + + + MNU_AMBIENT + Toogle keep only ambient light + OCC_IMAGE_FILES Images Files (*.bmp *.png *.jpg *.jpeg) diff --git a/src/OCCViewer/resources/occ_view_ambient.png b/src/OCCViewer/resources/occ_view_ambient.png new file mode 100644 index 000000000..ebcdccc92 Binary files /dev/null and b/src/OCCViewer/resources/occ_view_ambient.png differ