From 027d1200e4093bb5351f4ef5d80e1864bc6f61b6 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 18 Aug 2009 14:23:47 +0000 Subject: [PATCH] Issue 0020446: A button in OCCViewer to keep only ambient light --- src/OCCViewer/Makefile.am | 1 + src/OCCViewer/OCCViewer_ViewWindow.cxx | 27 +++++++++++++++++++ src/OCCViewer/OCCViewer_ViewWindow.h | 3 ++- src/OCCViewer/resources/OCCViewer_images.ts | 4 +++ src/OCCViewer/resources/OCCViewer_msg_en.ts | 8 ++++++ src/OCCViewer/resources/occ_view_ambient.png | Bin 0 -> 642 bytes 6 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/OCCViewer/resources/occ_view_ambient.png 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 0000000000000000000000000000000000000000..ebcdccc92c4265e8509c3a0e2e2f49cbe3cd4a5d GIT binary patch literal 642 zcmV-|0)737P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXS@ z2m%#KB)b^^00II@L_t(I%bk?LYZFlrhre|t#6D|fWo>L^LtrIPP+EfPMJPQ;V^X~+ ztq1>s+MIfA8=9)8>ZwLgf+&I(^q>tSM~@Yj2BnA4fHaU2TnUP7Tf}uew1tpf-ezEU zk74-u&HFJ=K|V%+6p#Q^zy_WHPJ5H$y7)4*bb5fXRE$L8G^(m#+YW^%Uum`W9s+ZL zf#II%Behm*kL2(Q_4@B|pa^hGcHVgGC8|B_kz`WG^L(n+pOi~mjE-)11w35-DIf`WKouwf cpJagl0Rtl1H-%KHWB>pF07*qoM6N<$g7v5p`v3p{ literal 0 HcmV?d00001 -- 2.39.2