1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "ATOMSOLVGUI_TransparencyDlg.h"
21 #include "ATOMSOLVGUI_Displayer.h"
25 #include <qpushbutton.h>
30 #include <qwhatsthis.h>
31 #include <qapplication.h>
32 #include <qgroupbox.h>
35 ATOMSOLVGUI_TransparencyDlg::ATOMSOLVGUI_TransparencyDlg( QWidget* parent, const QStringList& entries )
36 :QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
41 setWindowTitle(tr("TRANSPARENCY_DLG_TITLE"));
42 setSizeGripEnabled(true);
43 QGridLayout* lay = new QGridLayout(this);
47 /*************************************************************************/
48 QGroupBox* GroupButtons = new QGroupBox( this );
49 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
50 GroupButtonsLayout->setAlignment( Qt::AlignTop );
51 GroupButtonsLayout->setSpacing( 6 );
52 GroupButtonsLayout->setMargin( 11 );
54 QPushButton* buttonOk = new QPushButton( GroupButtons );
55 buttonOk->setText( tr( "BUT_OK" ) );
56 buttonOk->setAutoDefault( true );
57 buttonOk->setDefault( true );
59 QPushButton* buttonHelp = new QPushButton( GroupButtons );
60 buttonHelp->setText( tr( "BUT_HELP" ) );
61 buttonHelp->setAutoDefault( true );
62 buttonHelp->setDefault( true );
64 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
65 GroupButtonsLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 );
66 GroupButtonsLayout->addWidget( buttonHelp, 0, 2 );
68 /*************************************************************************/
69 QGroupBox* GroupC1 = new QGroupBox( this );
70 QGridLayout* GroupC1Layout = new QGridLayout( GroupC1 );
71 GroupC1Layout->setAlignment( Qt::AlignTop );
72 GroupC1Layout->setSpacing( 6 );
73 GroupC1Layout->setMargin( 11 );
74 GroupC1Layout->setColumnMinimumWidth(1, 100);
76 QLabel* TextLabelOpaque = new QLabel( GroupC1 );
77 TextLabelOpaque->setText( tr( "TRANSPARENCY_TRANSPARENT" ) );
78 TextLabelOpaque->setAlignment( Qt::AlignLeft );
79 GroupC1Layout->addWidget( TextLabelOpaque, 0, 0 );
80 GroupC1Layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
82 QLabel* TextLabelTransparent = new QLabel( GroupC1 );
83 TextLabelTransparent->setText( tr( "TRANSPARENCY_OPAQUE" ) );
84 TextLabelTransparent->setAlignment( Qt::AlignRight );
85 GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 );
87 mySlider = new QSlider( Qt::Horizontal, GroupC1 );
88 mySlider->setMinimum( 0 );
89 mySlider->setMaximum( 10 );
90 GroupC1Layout->addWidget( mySlider, 0, 1 );
91 /*************************************************************************/
93 lay->addWidget(GroupC1, 0, 0);
94 lay->addWidget(GroupButtons, 1, 0);
96 if ( myEntries.count() == 1 ) {
97 int value = (int)(ATOMSOLVGUI_Displayer().getTransparency( myEntries[ 0 ] ) * 10.);
99 mySlider->setValue( value );
101 ValueHasChanged(mySlider->value());
103 // signals and slots connections : after ValueHasChanged()
104 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
105 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
106 connect(mySlider, SIGNAL(valueChanged(int)), this, SLOT(ValueHasChanged(int)));
109 //=================================================================================
110 // function : ClickOnHelp()
112 //=================================================================================
113 void ATOMSOLVGUI_TransparencyDlg::ClickOnHelp()
115 // display a help in browser for example..
116 // not implemented yet..
119 //=================================================================================
120 // function : ValueHasChanged()
121 // purpose : Called when value of slider change
122 // : or the first time as initilisation
123 //=================================================================================
124 void ATOMSOLVGUI_TransparencyDlg::ValueHasChanged( int newValue )
126 ATOMSOLVGUI_Displayer().setTransparency( myEntries, (float)mySlider->value() * .1 );