1 // Copyright (C) 2014-2020 CEA/DEN, EDF R&D
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 "XGUI_TransparencyWidget.h"
23 #include <QDoubleSpinBox>
24 #include <QVBoxLayout>
25 #include <QHBoxLayout>
29 XGUI_TransparencyWidget::XGUI_TransparencyWidget(QWidget* theParent,
30 const QString& /*theLabelText*/)
33 QVBoxLayout* aLay = new QVBoxLayout(this);
34 aLay->setContentsMargins(0, 0, 0, 0);
36 QWidget* aInfoWgt = new QWidget(this);
37 QHBoxLayout* aInfoLay = new QHBoxLayout(aInfoWgt);
38 aInfoLay->setContentsMargins(0, 0, 0, 0);
40 aInfoLay->addWidget(new QLabel(tr("Opaque")));
42 myValLbl = new QLabel("0%", aInfoWgt);
43 myValLbl->setAlignment(Qt::AlignCenter);
44 aInfoLay->addWidget(myValLbl, 1);
46 aInfoLay->addWidget(new QLabel(tr("Transparent")));
47 aLay->addWidget(aInfoWgt);
49 mySliderValue = new QSlider(Qt::Horizontal, this);
50 mySliderValue->setRange(0, 100);
51 aLay->addWidget(mySliderValue);
53 connect(mySliderValue, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
56 void XGUI_TransparencyWidget::setValue(double theValue)
58 bool isSliderBlocked = mySliderValue->blockSignals(true);
59 int aVal = theValue * 100;
60 mySliderValue->setValue(aVal);
61 myValLbl->setText(QString("%1%").arg(aVal));
62 mySliderValue->blockSignals(isSliderBlocked);
65 double XGUI_TransparencyWidget::getValue() const
67 return mySliderValue->value() / 100.;
70 void XGUI_TransparencyWidget::onSliderValueChanged(int theValue)
72 myValLbl->setText(QString("%1%").arg(theValue));
73 emit transparencyValueChanged();