2003-07-09 20:33:44 +06:00
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 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 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
|
|
|
|
//
|
|
|
|
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
2004-12-01 15:39:14 +05:00
|
|
|
// File : GEOMBase_TransparencyDlg.cxx
|
2003-07-09 20:33:44 +06:00
|
|
|
// Author : Lucien PIGNOLONI
|
|
|
|
// Module : GEOM
|
2003-05-12 21:24:23 +06:00
|
|
|
|
2005-08-22 17:23:41 +06:00
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
#include "GEOMToolsGUI_TransparencyDlg.h"
|
2005-06-02 13:17:09 +06:00
|
|
|
#include "GEOMBase.h"
|
|
|
|
#include "GEOM_AISShape.hxx"
|
2003-05-12 21:24:23 +06:00
|
|
|
|
2006-02-07 20:58:35 +05:00
|
|
|
#include "SALOME_ListIO.hxx"
|
|
|
|
#include "SALOME_ListIteratorOfListIO.hxx"
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2005-10-05 12:28:23 +06:00
|
|
|
#include <SVTK_ViewModel.h>
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <SVTK_ViewWindow.h>
|
2006-02-07 20:58:35 +05:00
|
|
|
#include <SVTK_View.h>
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2005-10-05 12:28:23 +06:00
|
|
|
#include <OCCViewer_ViewModel.h>
|
|
|
|
#include <OCCViewer_ViewWindow.h>
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <SUIT_ViewManager.h>
|
|
|
|
#include <SUIT_Application.h>
|
|
|
|
#include <SUIT_Desktop.h>
|
|
|
|
#include <SUIT_ResourceMgr.h>
|
|
|
|
#include <SUIT_Session.h>
|
|
|
|
#include <SUIT_OverrideCursor.h>
|
|
|
|
|
|
|
|
#include <SalomeApp_Application.h>
|
2005-11-03 13:30:14 +05:00
|
|
|
#include <LightApp_SelectionMgr.h>
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
#include <qframe.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qslider.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qvariant.h>
|
|
|
|
#include <qtooltip.h>
|
|
|
|
#include <qwhatsthis.h>
|
|
|
|
#include <qapplication.h>
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <AIS_InteractiveContext.hxx>
|
2005-08-22 17:23:41 +06:00
|
|
|
using namespace std;
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// class : GEOMBase_TransparencyDlg()
|
2004-01-07 20:46:21 +05:00
|
|
|
// purpose : Constructs a GEOMBase_SUBSHAPE which is a child of 'parent', with the
|
2003-05-12 21:24:23 +06:00
|
|
|
// name 'name' and widget flags set to 'f'.
|
|
|
|
//
|
|
|
|
// : WARNING : this dialog is modal !
|
|
|
|
//
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg( QWidget* parent )
|
|
|
|
:QDialog( parent, "GEOMBase_TransparencyDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
|
2003-05-12 21:24:23 +06:00
|
|
|
{
|
2004-01-07 20:46:21 +05:00
|
|
|
resize(152, 107);
|
|
|
|
setCaption(tr("GEOM_TRANSPARENCY_TITLE"));
|
|
|
|
setSizeGripEnabled(TRUE);
|
2005-06-02 13:17:09 +06:00
|
|
|
QGridLayout* lay = new QGridLayout(this);
|
|
|
|
lay->setSpacing(6);
|
|
|
|
lay->setMargin(11);
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
|
|
|
|
GroupButtons->setColumnLayout(0, Qt::Vertical );
|
|
|
|
GroupButtons->layout()->setSpacing( 0 );
|
|
|
|
GroupButtons->layout()->setMargin( 0 );
|
|
|
|
QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
|
|
|
|
GroupButtonsLayout->setAlignment( Qt::AlignTop );
|
|
|
|
GroupButtonsLayout->setSpacing( 6 );
|
|
|
|
GroupButtonsLayout->setMargin( 11 );
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
QPushButton* buttonOk = new QPushButton( GroupButtons, "buttonOk" );
|
2003-05-12 21:24:23 +06:00
|
|
|
buttonOk->setText( tr( "GEOM_BUT_OK" ) );
|
|
|
|
buttonOk->setAutoDefault( TRUE );
|
|
|
|
buttonOk->setDefault( TRUE );
|
|
|
|
GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0 );
|
|
|
|
GroupButtonsLayout->addWidget( buttonOk, 0, 1 );
|
|
|
|
GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2 );
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
|
|
|
|
GroupC1->setColumnLayout(0, Qt::Vertical );
|
|
|
|
GroupC1->layout()->setSpacing( 0 );
|
|
|
|
GroupC1->layout()->setMargin( 0 );
|
|
|
|
QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
|
|
|
|
GroupC1Layout->setAlignment( Qt::AlignTop );
|
|
|
|
GroupC1Layout->setSpacing( 6 );
|
|
|
|
GroupC1Layout->setMargin( 11 );
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
QLabel* TextLabelOpaque = new QLabel( GroupC1, "TextLabelOpaque" );
|
2003-05-12 21:24:23 +06:00
|
|
|
TextLabelOpaque->setText( tr( "GEOM_TRANSPARENCY_OPAQUE" ) );
|
|
|
|
TextLabelOpaque->setAlignment( int( QLabel::AlignLeft ) );
|
|
|
|
GroupC1Layout->addWidget( TextLabelOpaque, 0, 0 );
|
|
|
|
GroupC1Layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
QLabel* TextLabelTransparent = new QLabel( GroupC1, "TextLabelTransparent" );
|
2003-05-12 21:24:23 +06:00
|
|
|
TextLabelTransparent->setText( tr( "GEOM_TRANSPARENCY_TRANSPARENT" ) );
|
|
|
|
TextLabelTransparent->setAlignment( int( QLabel::AlignRight ) );
|
|
|
|
GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 );
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
mySlider = new QSlider( 0, 10, 1, 5, Horizontal, GroupC1, "mySlider" );
|
|
|
|
mySlider->setMinimumSize( 300, 0 );
|
|
|
|
mySlider->setTickmarks( QSlider::Left );
|
|
|
|
GroupC1Layout->addMultiCellWidget( mySlider, 1, 1, 0, 2 );
|
2003-05-12 21:24:23 +06:00
|
|
|
/*************************************************************************/
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
lay->addWidget(GroupC1, 0, 0);
|
|
|
|
lay->addWidget(GroupButtons, 1, 0);
|
|
|
|
|
2003-05-12 21:24:23 +06:00
|
|
|
/* First call valueChanged() method for initialisation */
|
|
|
|
/* The default value of transparency will change with the selection */
|
2005-06-02 13:17:09 +06:00
|
|
|
myFirstInit = true;
|
|
|
|
// mySlider->setMaxValue( 10 );
|
|
|
|
// mySlider->setValue( 5 ) ;
|
|
|
|
ValueHasChanged(mySlider->value());
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
// signals and slots connections : after ValueHasChanged()
|
2004-01-07 20:46:21 +05:00
|
|
|
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
2005-06-02 13:17:09 +06:00
|
|
|
connect(mySlider, SIGNAL(valueChanged(int)), this, SLOT(ValueHasChanged(int)));
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : ~GEOMBase_TransparencyDlg()
|
2003-05-12 21:24:23 +06:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOMToolsGUI_TransparencyDlg::~GEOMToolsGUI_TransparencyDlg()
|
2003-05-12 21:24:23 +06:00
|
|
|
{
|
|
|
|
// no need to delete child widgets, Qt does it all for us
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=======================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void GEOMToolsGUI_TransparencyDlg::ClickOnOk()
|
2003-05-12 21:24:23 +06:00
|
|
|
{
|
2004-01-07 20:46:21 +05:00
|
|
|
accept();
|
|
|
|
return;
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : ClickOnClose()
|
|
|
|
// purpose :
|
|
|
|
//=======================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void GEOMToolsGUI_TransparencyDlg::ClickOnClose()
|
2003-05-12 21:24:23 +06:00
|
|
|
{
|
2004-01-07 20:46:21 +05:00
|
|
|
accept();
|
|
|
|
return;
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ValueHasChanged()
|
|
|
|
// purpose : Called when value of slider change
|
|
|
|
// : or the first time as initilisation
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void GEOMToolsGUI_TransparencyDlg::ValueHasChanged( int newValue )
|
2003-05-12 21:24:23 +06:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app )
|
|
|
|
return;
|
2005-11-03 13:30:14 +05:00
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( !aSelMgr )
|
|
|
|
return;
|
|
|
|
SALOME_ListIO selected;
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( selected.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Handle(SALOME_InteractiveObject) FirstIOS = selected.First();
|
|
|
|
if ( FirstIOS.IsNull() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SUIT_ViewWindow* window = app->desktop()->activeWindow();
|
|
|
|
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
|
2005-10-05 12:28:23 +06:00
|
|
|
bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
if ( isVTK ) {
|
|
|
|
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
|
|
|
|
if ( !vtkVW )
|
|
|
|
return;
|
2006-02-07 20:58:35 +05:00
|
|
|
SVTK_View* aView = vtkVW->getView();
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( myFirstInit ) {
|
|
|
|
myFirstInit = false;
|
2006-02-07 20:58:35 +05:00
|
|
|
float transp = (aView->GetTransparency(FirstIOS))*10.0;
|
2005-06-02 13:17:09 +06:00
|
|
|
mySlider->setValue(int(transp));
|
|
|
|
return;
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
2006-02-07 20:58:35 +05:00
|
|
|
aView->SetTransparency( It.Value(), newValue/10.0 );
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
2006-02-07 20:58:35 +05:00
|
|
|
aView->Repaint();
|
2005-06-02 13:17:09 +06:00
|
|
|
} // if ( isVTK )
|
|
|
|
|
|
|
|
else if ( isOCC ) {
|
|
|
|
GEOMBase* gb = new GEOMBase();
|
|
|
|
Standard_Boolean found;
|
|
|
|
Handle(GEOM_AISShape) aisShape;
|
|
|
|
if ( myFirstInit ) {
|
|
|
|
myFirstInit = false;
|
|
|
|
aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, found );
|
|
|
|
if( !found )
|
2004-01-07 20:46:21 +05:00
|
|
|
return;
|
2005-06-02 13:17:09 +06:00
|
|
|
float transp = (int(aisShape->Transparency() * 10.0 + 0.001));
|
|
|
|
mySlider->setValue(int(transp));
|
|
|
|
return;
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
|
|
|
|
if ( !vm )
|
|
|
|
return;
|
|
|
|
Handle(AIS_InteractiveContext) ic = vm->getAISContext();
|
|
|
|
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
|
|
|
aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), found );
|
|
|
|
if ( found ) {
|
|
|
|
ic->SetTransparency( aisShape, newValue / 10.0, false );
|
|
|
|
ic->Redisplay( aisShape, Standard_False, Standard_True );
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
} // for...
|
2004-01-30 14:43:33 +05:00
|
|
|
ic->UpdateCurrentViewer();
|
2005-06-02 13:17:09 +06:00
|
|
|
} // if ( isOCC )
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|