2003-07-10 19:18:22 +06:00
|
|
|
// SMESH SMESHGUI : GUI for SMESH component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
2005-06-07 19:22:20 +06:00
|
|
|
// 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
|
|
|
|
//
|
2006-06-01 17:39:17 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2003-07-10 19:18:22 +06:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : SMESHGUI_TransparencyDlg.cxx
|
|
|
|
// Author : Nicolas REJNERI
|
|
|
|
// Module : SMESH
|
2003-05-19 20:07:00 +06:00
|
|
|
// $Header$
|
|
|
|
|
|
|
|
#include "SMESHGUI_TransparencyDlg.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
#include "SMESHGUI.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SMESHGUI_VTKUtils.h"
|
2005-06-08 16:45:19 +06:00
|
|
|
#include "SMESHGUI_Utils.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
#include "SMESH_Actor.h"
|
|
|
|
|
2005-06-08 16:45:19 +06:00
|
|
|
#include "SUIT_Desktop.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
#include "SUIT_OverrideCursor.h"
|
2006-05-06 14:51:48 +06:00
|
|
|
#include "SUIT_Session.h"
|
|
|
|
#include "SUIT_MessageBox.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
#include "SALOME_ListIO.hxx"
|
|
|
|
#include "SALOME_ListIteratorOfListIO.hxx"
|
|
|
|
#include "SALOME_InteractiveObject.hxx"
|
|
|
|
|
|
|
|
#include "SalomeApp_Study.h"
|
2006-05-06 14:51:48 +06:00
|
|
|
#include "LightApp_Application.h"
|
2005-11-03 13:38:17 +05:00
|
|
|
#include "LightApp_SelectionMgr.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
#include "SVTK_ViewWindow.h"
|
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
// QT Includes
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qslider.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
using namespace std;
|
2003-05-19 20:07:00 +06:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// class : SMESHGUI_TransparencyDlg()
|
2005-06-07 19:22:20 +06:00
|
|
|
// purpose :
|
2003-05-19 20:07:00 +06:00
|
|
|
//
|
|
|
|
//=================================================================================
|
2005-06-08 16:45:19 +06:00
|
|
|
SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg( SMESHGUI* theModule,
|
2003-05-19 20:07:00 +06:00
|
|
|
const char* name,
|
|
|
|
bool modal,
|
2005-06-07 19:22:20 +06:00
|
|
|
WFlags fl)
|
2005-06-08 16:45:19 +06:00
|
|
|
: QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
|
|
|
|
WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
|
|
|
|
mySMESHGUI( theModule ),
|
|
|
|
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
|
|
|
|
myViewWindow( SMESH::GetViewWindow( theModule ) )
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!name)
|
|
|
|
setName("SMESHGUI_TransparencyDlg");
|
|
|
|
setCaption(tr("SMESH_TRANSPARENCY_TITLE" ));
|
|
|
|
setSizeGripEnabled(TRUE);
|
|
|
|
QGridLayout* SMESHGUI_TransparencyDlgLayout = new QGridLayout(this);
|
|
|
|
SMESHGUI_TransparencyDlgLayout->setSpacing(6);
|
|
|
|
SMESHGUI_TransparencyDlgLayout->setMargin(11);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
|
|
|
/*************************************************************************/
|
2005-06-07 19:22:20 +06:00
|
|
|
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);
|
|
|
|
|
|
|
|
TextLabelTransparent = new QLabel(GroupC1, "TextLabelTransparent");
|
|
|
|
TextLabelTransparent->setText(tr("SMESH_TRANSPARENCY_TRANSPARENT" ));
|
|
|
|
TextLabelTransparent->setAlignment(AlignLeft);
|
|
|
|
GroupC1Layout->addWidget(TextLabelTransparent, 0, 0);
|
|
|
|
|
|
|
|
ValueLab = new QLabel(GroupC1, "ValueLab");
|
|
|
|
ValueLab->setAlignment(AlignCenter);
|
|
|
|
ValueLab->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
|
|
|
QFont fnt = ValueLab->font(); fnt.setBold(true); ValueLab->setFont(fnt);
|
|
|
|
GroupC1Layout->addWidget(ValueLab, 0, 1);
|
|
|
|
|
|
|
|
TextLabelOpaque = new QLabel(GroupC1, "TextLabelOpaque");
|
|
|
|
TextLabelOpaque->setText(tr("SMESH_TRANSPARENCY_OPAQUE" ));
|
|
|
|
TextLabelOpaque->setAlignment(AlignRight);
|
|
|
|
GroupC1Layout->addWidget(TextLabelOpaque, 0, 2);
|
|
|
|
|
|
|
|
Slider1 = new QSlider(0, 10, 1, 5, Horizontal, GroupC1, "Slider1");
|
|
|
|
Slider1->setFocusPolicy(QWidget::NoFocus);
|
|
|
|
Slider1->setMinimumSize(300, 0);
|
|
|
|
Slider1->setTickmarks(QSlider::Above);
|
|
|
|
Slider1->setTickInterval(10);
|
|
|
|
Slider1->setTracking(true);
|
|
|
|
Slider1->setMinValue(0);
|
|
|
|
Slider1->setMaxValue(100);
|
|
|
|
Slider1->setLineStep(1);
|
|
|
|
Slider1->setPageStep(10);
|
|
|
|
GroupC1Layout->addMultiCellWidget(Slider1, 1, 1, 0, 2);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
/*************************************************************************/
|
2005-06-07 19:22:20 +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("SMESH_BUT_CLOSE"));
|
|
|
|
buttonOk->setAutoDefault(TRUE);
|
|
|
|
buttonOk->setDefault(TRUE);
|
2006-05-06 14:51:48 +06:00
|
|
|
buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
|
|
|
|
buttonHelp->setText(tr("SMESH_BUT_HELP"));
|
|
|
|
buttonHelp->setAutoDefault(TRUE);
|
|
|
|
|
|
|
|
//GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0);
|
|
|
|
GroupButtonsLayout->addWidget(buttonOk, 0, 0);
|
|
|
|
GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
|
|
|
|
GroupButtonsLayout->addWidget(buttonHelp, 0, 2);
|
|
|
|
//GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
SMESHGUI_TransparencyDlgLayout->addWidget(GroupC1, 0, 0);
|
|
|
|
SMESHGUI_TransparencyDlgLayout->addWidget(GroupButtons, 1, 0);
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
// Initial state
|
2005-06-07 19:22:20 +06:00
|
|
|
this->onSelectionChanged();
|
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
// signals and slots connections : after ValueHasChanged()
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
2006-05-06 14:51:48 +06:00
|
|
|
connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(Slider1, SIGNAL(valueChanged(int)), this, SLOT(SetTransparency()));
|
|
|
|
connect(Slider1, SIGNAL(sliderMoved(int)), this, SLOT(ValueHasChanged()));
|
2005-06-08 16:45:19 +06:00
|
|
|
connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnOk()));
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged()));
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
myHelpFileName = "transparency.htm";
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
this->show();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~SMESHGUI_TransparencyDlg()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
SMESHGUI_TransparencyDlg::~SMESHGUI_TransparencyDlg()
|
|
|
|
{
|
2004-06-18 14:34:31 +06:00
|
|
|
// no need to delete child widgets, Qt does it all for us
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_TransparencyDlg::ClickOnOk()
|
|
|
|
{
|
2004-06-18 14:34:31 +06:00
|
|
|
close();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnHelp()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_TransparencyDlg::ClickOnHelp()
|
|
|
|
{
|
|
|
|
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
|
|
|
|
if (app)
|
|
|
|
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
|
|
|
|
else {
|
|
|
|
SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
|
|
|
|
QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
|
|
|
|
arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
|
|
|
|
QObject::tr("BUT_OK"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : SetTransparency()
|
|
|
|
// purpose : Called when value of slider change
|
|
|
|
// : or the first time as initilisation
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_TransparencyDlg::SetTransparency()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-08 16:45:19 +06:00
|
|
|
if( myViewWindow ) {
|
2005-06-07 19:22:20 +06:00
|
|
|
SUIT_OverrideCursor wc;
|
|
|
|
float opacity = this->Slider1->value() / 100.;
|
|
|
|
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
mySelectionMgr->selectedObjects(aList);
|
|
|
|
|
|
|
|
SALOME_ListIteratorOfListIO It (aList);
|
|
|
|
for (;It.More(); It.Next()) {
|
2004-06-18 14:34:31 +06:00
|
|
|
Handle(SALOME_InteractiveObject) IOS = It.Value();
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH_Actor* anActor = SMESH::FindActorByEntry(IOS->getEntry());
|
2005-06-07 19:22:20 +06:00
|
|
|
if (anActor)
|
|
|
|
anActor->SetOpacity(opacity);
|
2004-06-18 14:34:31 +06:00
|
|
|
}
|
2005-06-08 16:45:19 +06:00
|
|
|
myViewWindow->Repaint();
|
2004-06-18 14:34:31 +06:00
|
|
|
}
|
|
|
|
ValueHasChanged();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ValueHasChanged()
|
2004-06-18 14:34:31 +06:00
|
|
|
// purpose : Called when user moves a slider
|
2003-05-19 20:07:00 +06:00
|
|
|
//=================================================================================
|
2004-06-18 14:34:31 +06:00
|
|
|
void SMESHGUI_TransparencyDlg::ValueHasChanged()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
ValueLab->setText(QString::number(this->Slider1->value()) + "%");
|
2004-06-18 14:34:31 +06:00
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : onSelectionChanged()
|
|
|
|
// purpose : Called when selection is changed
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_TransparencyDlg::onSelectionChanged()
|
|
|
|
{
|
2005-06-08 16:45:19 +06:00
|
|
|
if( myViewWindow ) {
|
2004-06-18 14:34:31 +06:00
|
|
|
int opacity = 100;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
mySelectionMgr->selectedObjects(aList);
|
|
|
|
|
|
|
|
if (aList.Extent() == 1) {
|
|
|
|
Handle(SALOME_InteractiveObject) FirstIOS = aList.First();
|
|
|
|
if (!FirstIOS.IsNull()) {
|
|
|
|
SMESH_Actor* anActor = SMESH::FindActorByEntry(FirstIOS->getEntry());
|
|
|
|
if (anActor)
|
|
|
|
opacity = int(anActor->GetOpacity() * 100. + 0.5);
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
} else if (aList.Extent() > 1) {
|
|
|
|
SALOME_ListIteratorOfListIO It (aList);
|
2004-06-18 14:34:31 +06:00
|
|
|
int setOp = -1;
|
2005-06-07 19:22:20 +06:00
|
|
|
for (; It.More(); It.Next()) {
|
2004-06-18 14:34:31 +06:00
|
|
|
Handle(SALOME_InteractiveObject) IO = It.Value();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!IO.IsNull()) {
|
|
|
|
SMESH_Actor* anActor = SMESH::FindActorByEntry(IO->getEntry());
|
|
|
|
if (anActor) {
|
|
|
|
int op = int(anActor->GetOpacity() * 100. + 0.5);
|
|
|
|
if (setOp < 0)
|
2004-06-18 14:34:31 +06:00
|
|
|
setOp = op;
|
2005-06-07 19:22:20 +06:00
|
|
|
else if (setOp != op) {
|
2004-06-18 14:34:31 +06:00
|
|
|
setOp = 100;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
if (setOp >= 0)
|
2004-06-18 14:34:31 +06:00
|
|
|
opacity = setOp;
|
2005-06-07 19:22:20 +06:00
|
|
|
} else {
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
Slider1->setValue(opacity);
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2004-06-18 14:34:31 +06:00
|
|
|
ValueHasChanged();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|