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-06-16 21:24:55 +06:00
|
|
|
// File : GEOMToolsGUI_TransparencyDlg.cxx
|
2003-07-09 20:33:44 +06:00
|
|
|
// Author : Lucien PIGNOLONI
|
|
|
|
// Module : GEOM
|
2003-05-12 21:24:23 +06:00
|
|
|
|
2003-07-09 20:33:44 +06:00
|
|
|
using namespace std;
|
2004-01-07 20:46:21 +05:00
|
|
|
#include "GEOMToolsGUI_TransparencyDlg.h"
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
#include "QAD_RightFrame.h"
|
|
|
|
#include "SALOME_ListIteratorOfListIO.hxx"
|
2004-01-30 14:43:33 +05:00
|
|
|
#include "OCCViewer_Viewer3d.h"
|
2004-01-07 20:46:21 +05:00
|
|
|
#include <AIS_InteractiveContext.hxx>
|
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>
|
|
|
|
|
2003-07-09 20:33:44 +06:00
|
|
|
#include "VTKViewer_ViewFrame.h"
|
|
|
|
#include "VTKViewer_RenderWindowInteractor.h"
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
//=================================================================================
|
2004-06-16 21:24:55 +06:00
|
|
|
// class : GEOMToolsGUI_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 !
|
|
|
|
//
|
|
|
|
//=================================================================================
|
2004-06-16 21:24:55 +06:00
|
|
|
GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, const Handle(AIS_InteractiveContext)& ic, bool modal, WFlags fl)
|
2004-01-07 20:46:21 +05:00
|
|
|
:QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
|
2003-05-12 21:24:23 +06:00
|
|
|
{
|
2004-01-07 20:46:21 +05:00
|
|
|
if(!name)
|
2004-06-16 21:24:55 +06:00
|
|
|
setName("GEOMToolsGUI_TransparencyDlg");
|
2004-01-07 20:46:21 +05:00
|
|
|
resize(152, 107);
|
|
|
|
setCaption(tr("GEOM_TRANSPARENCY_TITLE"));
|
|
|
|
setSizeGripEnabled(TRUE);
|
2004-06-16 21:24:55 +06:00
|
|
|
GEOMToolsGUI_TransparencyDlgLayout = new QGridLayout(this);
|
|
|
|
GEOMToolsGUI_TransparencyDlgLayout->setSpacing(6);
|
|
|
|
GEOMToolsGUI_TransparencyDlgLayout->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 );
|
|
|
|
|
|
|
|
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
|
|
|
|
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 );
|
|
|
|
|
|
|
|
TextLabelOpaque = new QLabel( GroupC1, "TextLabelOpaque" );
|
|
|
|
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 );
|
|
|
|
|
|
|
|
TextLabelTransparent = new QLabel( GroupC1, "TextLabelTransparent" );
|
|
|
|
TextLabelTransparent->setText( tr( "GEOM_TRANSPARENCY_TRANSPARENT" ) );
|
|
|
|
TextLabelTransparent->setAlignment( int( QLabel::AlignRight ) );
|
|
|
|
GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 );
|
|
|
|
|
|
|
|
Slider1 = new QSlider( 0, 10, 1, 5, Horizontal, GroupC1, "Slider1" );
|
|
|
|
Slider1->setMinimumSize( 300, 0 );
|
|
|
|
Slider1->setTickmarks( QSlider::Left );
|
|
|
|
GroupC1Layout->addMultiCellWidget( Slider1, 1, 1, 0, 2 );
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
GEOMToolsGUI_TransparencyDlgLayout->addWidget(GroupC1, 0, 0);
|
|
|
|
GEOMToolsGUI_TransparencyDlgLayout->addWidget(GroupButtons, 1, 0);
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
/* Initialisations */
|
2004-01-07 20:46:21 +05:00
|
|
|
this->myGeomGUI = GEOMContext::GetGeomGUI();
|
|
|
|
this->myGeomBase = new GEOMBase();
|
|
|
|
this->myIc = ic;
|
|
|
|
this->mySel = Sel;
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
/* First call valueChanged() method for initialisation */
|
|
|
|
/* The default value of transparency will change with the selection */
|
2004-01-07 20:46:21 +05:00
|
|
|
this->myFirstInit = true;
|
2003-05-12 21:24:23 +06:00
|
|
|
// Slider1->setMaxValue( 10 );
|
|
|
|
// Slider1->setValue( 5 ) ;
|
2004-01-07 20:46:21 +05:00
|
|
|
this->ValueHasChanged(Slider1->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()));
|
|
|
|
connect(Slider1, SIGNAL(valueChanged(int)), this, SLOT(ValueHasChanged(int)));
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
/* Move widget on the botton right corner of main widget */
|
2004-06-16 21:24:55 +06:00
|
|
|
// int x, y ;
|
|
|
|
// myGeomBase->DefineDlgPosition(this, x, y);
|
|
|
|
// this->move(x, y) ;
|
2003-05-12 21:24:23 +06:00
|
|
|
this->show() ; /* Displays this Dialog */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
2004-06-16 21:24:55 +06:00
|
|
|
// function : ~GEOMToolsGUI_TransparencyDlg()
|
2003-05-12 21:24:23 +06:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-06-16 21:24:55 +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 :
|
|
|
|
//=======================================================================
|
2004-06-16 21:24:55 +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 :
|
|
|
|
//=======================================================================
|
2004-06-16 21:24:55 +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
|
|
|
|
//=================================================================================
|
2004-06-16 21:24:55 +06:00
|
|
|
void GEOMToolsGUI_TransparencyDlg::ValueHasChanged(int newValue)
|
2003-05-12 21:24:23 +06:00
|
|
|
{
|
2004-01-07 20:46:21 +05:00
|
|
|
if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
|
2003-05-12 21:24:23 +06:00
|
|
|
// VTK
|
2004-01-07 20:46:21 +05:00
|
|
|
VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
|
|
|
|
SALOME_ListIteratorOfListIO It(this->mySel->StoredIObjects());
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
Handle(SALOME_InteractiveObject) FirstIOS = mySel->firstIObject();
|
2004-01-07 20:46:21 +05:00
|
|
|
if(!FirstIOS.IsNull()) {
|
2003-05-12 21:24:23 +06:00
|
|
|
/* The first time as initialisation */
|
2004-01-07 20:46:21 +05:00
|
|
|
if(this->myFirstInit) {
|
|
|
|
this->myFirstInit = false;
|
|
|
|
float transp = (myRenderInter->GetTransparency(FirstIOS))*10.0;
|
|
|
|
this->Slider1->setValue(int(transp));
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
QApplication::setOverrideCursor(Qt::waitCursor);
|
|
|
|
for(;It.More(); It.Next()) {
|
2003-05-12 21:24:23 +06:00
|
|
|
Handle(SALOME_InteractiveObject) IOS = It.Value();
|
2004-01-07 20:46:21 +05:00
|
|
|
myRenderInter->SetTransparency(IOS, newValue/10.0);
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
}
|
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
|
2003-05-12 21:24:23 +06:00
|
|
|
// OCC
|
2004-01-07 20:46:21 +05:00
|
|
|
SALOME_ListIteratorOfListIO It(this->mySel->StoredIObjects());
|
|
|
|
Handle(SALOME_InteractiveObject) FirstIOS = mySel->firstIObject();
|
|
|
|
if(!FirstIOS.IsNull()) {
|
2003-05-12 21:24:23 +06:00
|
|
|
|
|
|
|
/* The first time as initialisation */
|
2004-01-07 20:46:21 +05:00
|
|
|
if(this->myFirstInit) {
|
|
|
|
this->myFirstInit = false;
|
2003-05-12 21:24:23 +06:00
|
|
|
Standard_Boolean found;
|
2004-01-07 20:46:21 +05:00
|
|
|
Handle(GEOM_AISShape) Shape = myGeomBase->ConvertIOinGEOMAISShape(FirstIOS, found);
|
|
|
|
if(!found)
|
|
|
|
return;
|
|
|
|
float transp = (int(Shape->Transparency() * 10.0 + 0.001));
|
|
|
|
this->Slider1->setValue(int(transp));
|
|
|
|
return;
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
QApplication::setOverrideCursor(Qt::waitCursor);
|
2004-01-30 14:43:33 +05:00
|
|
|
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
|
|
|
|
Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
|
2004-01-07 20:46:21 +05:00
|
|
|
for(;It.More(); It.Next()) {
|
2003-05-12 21:24:23 +06:00
|
|
|
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
|
|
|
Standard_Boolean found;
|
2004-01-07 20:46:21 +05:00
|
|
|
Handle(GEOM_AISShape) Shape = myGeomBase->ConvertIOinGEOMAISShape(IObject, found);
|
|
|
|
if(!found) {
|
2003-05-12 21:24:23 +06:00
|
|
|
QApplication::restoreOverrideCursor();
|
2004-01-07 20:46:21 +05:00
|
|
|
return;
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
2004-01-30 14:43:33 +05:00
|
|
|
ic->SetTransparency(Shape, newValue / 10.0, false);
|
|
|
|
ic->Redisplay(Shape, Standard_False, Standard_True);
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
2004-01-30 14:43:33 +05:00
|
|
|
ic->UpdateCurrentViewer();
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|
|
|
|
QApplication::restoreOverrideCursor();
|
2004-01-07 20:46:21 +05:00
|
|
|
return;
|
2003-05-12 21:24:23 +06:00
|
|
|
}
|