X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMToolsGUI%2FGEOMToolsGUI_TransparencyDlg.cxx;h=2de71038a5664439c55d384711ea28ee212658e1;hb=882dc8f6ee23cedf50cf3c718fb864dec115b35e;hp=6e39d15d07cf376a35647b8da8d4c2325e0c6d89;hpb=2afbe2f2dc77da963e6bdd80688452e054ceed51;p=modules%2Fgeom.git diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx index 6e39d15d0..2de71038a 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx @@ -1,23 +1,23 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // GEOM GEOMGUI : GUI for Geometry component @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -48,6 +49,7 @@ #include #include #include +#include #include #include @@ -96,8 +98,8 @@ GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg( QWidget* parent ) GroupC1Layout->setMargin( 11 ); QLabel* TextLabelTransparent = new QLabel( tr( "GEOM_TRANSPARENCY_TRANSPARENT" ), GroupC1 ); - TextLabelTransparent->setAlignment( Qt::AlignRight ); - GroupC1Layout->addWidget( TextLabelTransparent, 0, 0 ); + TextLabelTransparent->setAlignment( Qt::AlignLeft ); + GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 ); myValueLab = new QLabel( GroupC1 ); myValueLab->setAlignment( Qt::AlignCenter ); @@ -106,8 +108,8 @@ GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg( QWidget* parent ) GroupC1Layout->addWidget( myValueLab, 0, 1 ); QLabel* TextLabelOpaque = new QLabel( tr( "GEOM_TRANSPARENCY_OPAQUE" ), GroupC1 ); - TextLabelOpaque->setAlignment( Qt::AlignLeft ); - GroupC1Layout->addWidget( TextLabelOpaque, 0, 2 ); + TextLabelOpaque->setAlignment( Qt::AlignRight ); + GroupC1Layout->addWidget( TextLabelOpaque, 0, 0 ); //GroupC1Layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); mySlider = new QSlider( Qt::Horizontal, GroupC1 ); @@ -122,7 +124,7 @@ GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg( QWidget* parent ) //mySlider->setValue( 5 ); mySlider->setTracking(false); - mySlider->setTickPosition( QSlider::TicksLeft ); + mySlider->setTickPosition( QSlider::TicksAbove ); GroupC1Layout->addWidget( mySlider, 1, 0, 1, 3 ); /*************************************************************************/ @@ -241,7 +243,7 @@ void GEOMToolsGUI_TransparencyDlg::SliderHasMoved(int value) //================================================================================= void GEOMToolsGUI_TransparencyDlg::SetTransparency() { - float newValue = ( 100 - mySlider->value() ) / 100.; + float newValue = mySlider->value() / 100.; SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); if ( !app ) @@ -249,6 +251,12 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency() LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); if ( !aSelMgr ) return; + + SalomeApp_Study* aStudy = dynamic_cast(app->activeStudy()); + + if(!aStudy) + return; + SALOME_ListIO selected; aSelMgr->selectedObjects( selected ); if ( selected.IsEmpty() ) @@ -261,7 +269,7 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency() SUIT_ViewWindow* window = app->desktop()->activeWindow(); bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); - + int aMgrId = window->getViewManager()->getGlobalId(); if ( isVTK ) { SVTK_ViewWindow* vtkVW = dynamic_cast( window ); if ( !vtkVW ) @@ -269,7 +277,7 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency() SVTK_View* aView = vtkVW->getView(); if ( myFirstInit ) { myFirstInit = false; - int transp = int (100 - ((aView->GetTransparency(FirstIOS))*100.0) + 0.5); + int transp = int ((aView->GetTransparency(FirstIOS))*100.0 + 0.5); mySlider->setValue(transp); ValueHasChanged(); return; @@ -278,6 +286,7 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency() SUIT_OverrideCursor(); for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { aView->SetTransparency( It.Value(), newValue ); + aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue ); } GeometryGUI::Modified(); aView->Repaint(); @@ -285,14 +294,14 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency() else if ( isOCC ) { GEOMBase* gb = new GEOMBase(); - Standard_Boolean found; Handle(GEOM_AISShape) aisShape; if ( myFirstInit ) { + mySlider->setValue(mySlider->maximum()); myFirstInit = false; - aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, found ); - if( !found ) + aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, true ); + if( aisShape.IsNull() ) return; - int transp = int( 100 - ( aisShape->Transparency() * 100.0 ) + 0.5); + int transp = int( aisShape->Transparency() * 100.0 + 0.5); mySlider->setValue(transp); ValueHasChanged(); return; @@ -304,10 +313,11 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency() return; Handle(AIS_InteractiveContext) ic = vm->getAISContext(); for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { - aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), found ); - if ( found ) { + aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true ); + if ( !aisShape.IsNull() ) { ic->SetTransparency( aisShape, newValue, false ); ic->Redisplay( aisShape, Standard_False, Standard_True ); + aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue ); } } // for... ic->UpdateCurrentViewer();