X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_TransparencyWidget.cpp;h=a9283cad61155dba720f308accb30722060d22b8;hb=63ba1dd6387b76f8d2710955f8aebf9cf613058c;hp=76ec83d8247ec5b7d6838cc1b811f5b4c043e70c;hpb=2714903267d23cd0c81166c506fb3edd1e069d40;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_TransparencyWidget.cpp b/src/XGUI/XGUI_TransparencyWidget.cpp index 76ec83d82..a9283cad6 100644 --- a/src/XGUI/XGUI_TransparencyWidget.cpp +++ b/src/XGUI/XGUI_TransparencyWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,16 +12,16 @@ // // 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "XGUI_TransparencyWidget.h" #include #include +#include #include #include #include @@ -29,59 +29,45 @@ XGUI_TransparencyWidget::XGUI_TransparencyWidget(QWidget* theParent, const QString& theLabelText) : QWidget(theParent) { - QHBoxLayout* aLay = new QHBoxLayout(this); + QVBoxLayout* aLay = new QVBoxLayout(this); aLay->setContentsMargins(0, 0, 0, 0); - mySpinValue = new QDoubleSpinBox(this); - mySpinValue->setRange(0, 1); - mySpinValue->setSingleStep(0.1); - mySliderValue = new QSlider(Qt::Horizontal, this); - mySliderValue->setRange(0, 100); + QWidget* aInfoWgt = new QWidget(this); + QHBoxLayout* aInfoLay = new QHBoxLayout(aInfoWgt); + aInfoLay->setContentsMargins(0, 0, 0, 0); + + aInfoLay->addWidget(new QLabel(tr("Opaque"))); + + myValLbl = new QLabel("0%", aInfoWgt); + myValLbl->setAlignment(Qt::AlignCenter); + aInfoLay->addWidget(myValLbl, 1); - myPreview = new QCheckBox("Preview", this); - myPreview->setChecked(true); + aInfoLay->addWidget(new QLabel(tr("Transparent"))); + aLay->addWidget(aInfoWgt); - if (!theLabelText.isEmpty()) - aLay->addWidget(new QLabel(theLabelText, this)); - aLay->addWidget(mySpinValue); + mySliderValue = new QSlider(Qt::Horizontal, this); + mySliderValue->setRange(0, 100); aLay->addWidget(mySliderValue); - aLay->addWidget(myPreview); - connect(mySpinValue, SIGNAL(valueChanged(double)), this, SLOT(onSpinValueChanged(double))); connect(mySliderValue, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int))); - connect(myPreview, SIGNAL(toggled(bool)), this, SIGNAL(previewStateChanged())); } void XGUI_TransparencyWidget::setValue(double theValue) { - bool isSpinBlocked = mySpinValue->blockSignals(true); bool isSliderBlocked = mySliderValue->blockSignals(true); - - mySpinValue->setValue(theValue); - mySliderValue->setValue(theValue * 100); - - mySpinValue->blockSignals(isSpinBlocked); + int aVal = theValue * 100; + mySliderValue->setValue(aVal); + myValLbl->setText(QString("%1%").arg(aVal)); mySliderValue->blockSignals(isSliderBlocked); } double XGUI_TransparencyWidget::getValue() const { - return mySpinValue->value(); -} - -bool XGUI_TransparencyWidget::isPreviewNeeded() const -{ - return myPreview->isChecked(); -} - -void XGUI_TransparencyWidget::onSpinValueChanged(double theValue) -{ - setValue(theValue); - emit transparencyValueChanged(); + return mySliderValue->value() / 100.; } void XGUI_TransparencyWidget::onSliderValueChanged(int theValue) { - setValue((double)theValue / 100); + myValLbl->setText(QString("%1%").arg(theValue)); emit transparencyValueChanged(); }