1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "ATOMSOLVGUI_TransparencyDlg.h"
23 #include "ATOMSOLVGUI_Displayer.h"
27 #include <qpushbutton.h>
32 #include <qwhatsthis.h>
33 #include <qapplication.h>
34 #include <qgroupbox.h>
37 ATOMSOLVGUI_TransparencyDlg::ATOMSOLVGUI_TransparencyDlg( QWidget* parent, const QStringList& entries )
38 :QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
43 setWindowTitle(tr("TRANSPARENCY_DLG_TITLE"));
44 setSizeGripEnabled(TRUE);
45 QGridLayout* lay = new QGridLayout(this);
49 /*************************************************************************/
50 QGroupBox* GroupButtons = new QGroupBox( this );
51 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
52 GroupButtonsLayout->setAlignment( Qt::AlignTop );
53 GroupButtonsLayout->setSpacing( 6 );
54 GroupButtonsLayout->setMargin( 11 );
56 QPushButton* buttonOk = new QPushButton( GroupButtons );
57 buttonOk->setText( tr( "BUT_OK" ) );
58 buttonOk->setAutoDefault( TRUE );
59 buttonOk->setDefault( TRUE );
61 QPushButton* buttonHelp = new QPushButton( GroupButtons );
62 buttonHelp->setText( tr( "BUT_HELP" ) );
63 buttonHelp->setAutoDefault( TRUE );
64 buttonHelp->setDefault( TRUE );
66 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
67 GroupButtonsLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 );
68 GroupButtonsLayout->addWidget( buttonHelp, 0, 2 );
70 /*************************************************************************/
71 QGroupBox* GroupC1 = new QGroupBox( this );
72 QGridLayout* GroupC1Layout = new QGridLayout( GroupC1 );
73 GroupC1Layout->setAlignment( Qt::AlignTop );
74 GroupC1Layout->setSpacing( 6 );
75 GroupC1Layout->setMargin( 11 );
76 GroupC1Layout->setColumnMinimumWidth(1, 100);
78 QLabel* TextLabelOpaque = new QLabel( GroupC1 );
79 TextLabelOpaque->setText( tr( "TRANSPARENCY_TRANSPARENT" ) );
80 TextLabelOpaque->setAlignment( Qt::AlignLeft );
81 GroupC1Layout->addWidget( TextLabelOpaque, 0, 0 );
82 GroupC1Layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
84 QLabel* TextLabelTransparent = new QLabel( GroupC1 );
85 TextLabelTransparent->setText( tr( "TRANSPARENCY_OPAQUE" ) );
86 TextLabelTransparent->setAlignment( Qt::AlignRight );
87 GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 );
89 mySlider = new QSlider( Qt::Horizontal, GroupC1 );
90 mySlider->setMinimum( 0 );
91 mySlider->setMaximum( 10 );
92 GroupC1Layout->addWidget( mySlider, 0, 1 );
93 /*************************************************************************/
95 lay->addWidget(GroupC1, 0, 0);
96 lay->addWidget(GroupButtons, 1, 0);
98 if ( myEntries.count() == 1 ) {
99 int value = (int)(ATOMSOLVGUI_Displayer().getTransparency( myEntries[ 0 ] ) * 10.);
101 mySlider->setValue( value );
103 ValueHasChanged(mySlider->value());
105 // signals and slots connections : after ValueHasChanged()
106 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
107 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
108 connect(mySlider, SIGNAL(valueChanged(int)), this, SLOT(ValueHasChanged(int)));
111 //=================================================================================
112 // function : ClickOnHelp()
114 //=================================================================================
115 void ATOMSOLVGUI_TransparencyDlg::ClickOnHelp()
117 // display a help in browser for example..
118 // not implemented yet..
121 //=================================================================================
122 // function : ValueHasChanged()
123 // purpose : Called when value of slider change
124 // : or the first time as initilisation
125 //=================================================================================
126 void ATOMSOLVGUI_TransparencyDlg::ValueHasChanged( int newValue )
128 ATOMSOLVGUI_Displayer().setTransparency( myEntries, (float)mySlider->value() * .1 );