From 31a0429345dbe2b262f4693f6883fb10c3cfdfa8 Mon Sep 17 00:00:00 2001 From: mgn Date: Mon, 24 Feb 2014 15:30:05 +0400 Subject: [PATCH] Additional fix for the "0021793: [CEA 625] Clipping : from coordinates or from bounding box" issue. --- src/OCCViewer/OCCViewer_ClippingDlg.cxx | 159 +++++++----------------- src/OCCViewer/OCCViewer_ClippingDlg.h | 15 +-- src/Qtx/CMakeLists.txt | 6 + src/Qtx/QtxDoubleSpinSlider.cxx | 148 ++++++++++++++++++++++ src/Qtx/QtxDoubleSpinSlider.h | 67 ++++++++++ src/Qtx/QtxIntSpinSlider.cxx | 121 ++++++++++++++++++ src/Qtx/QtxIntSpinSlider.h | 63 ++++++++++ src/Qtx/QtxSlider.cxx | 117 +++++++++++++++++ src/Qtx/QtxSlider.h | 63 ++++++++++ 9 files changed, 634 insertions(+), 125 deletions(-) create mode 100644 src/Qtx/QtxDoubleSpinSlider.cxx create mode 100644 src/Qtx/QtxDoubleSpinSlider.h create mode 100644 src/Qtx/QtxIntSpinSlider.cxx create mode 100644 src/Qtx/QtxIntSpinSlider.h create mode 100644 src/Qtx/QtxSlider.cxx create mode 100644 src/Qtx/QtxSlider.h diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.cxx b/src/OCCViewer/OCCViewer_ClippingDlg.cxx index e1c46998e..593792d32 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.cxx +++ b/src/OCCViewer/OCCViewer_ClippingDlg.cxx @@ -23,6 +23,8 @@ #include "OCCViewer_ClippingDlg.h" #include +#include +#include #include #include "SUIT_Session.h" @@ -624,72 +626,38 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg(OCCViewer_ViewWindow* parent , OCCV CBRelativeOrientation->addItem( tr("ALONG_ZX") ); GroupParametersLayout->addWidget( CBRelativeOrientation, 0, 1 ); - TLValueDistance = new QLabel( GroupParameters ); - TLValueDistance->setObjectName( "TLValueDistance" ); - TLValueDistance->setAlignment( Qt::AlignCenter ); - TLValueDistance->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - QFont fnt = TLValueDistance->font(); fnt.setBold( true ); TLValueDistance->setFont( fnt ); - GroupParametersLayout->addWidget( TLValueDistance, 1, 1 ); - TextLabelDistance = new QLabel( tr("DISTANCE"), GroupParameters ); TextLabelDistance->setObjectName( "TextLabelDistance" ); - GroupParametersLayout->addWidget( TextLabelDistance, 2, 0 ); - - SliderDistance = new QSlider( Qt::Horizontal, GroupParameters ); - SliderDistance->setObjectName( "SliderDistance" ); - SliderDistance->setFocusPolicy( Qt::NoFocus ); - SliderDistance->setMinimumSize( 300, 0 ); - SliderDistance->setMinimum( 0 ); - SliderDistance->setMaximum( 100 ); - SliderDistance->setSingleStep( 1 ); - SliderDistance->setPageStep( 10 ); - SliderDistance->setTracking( false ); - GroupParametersLayout->addWidget( SliderDistance, 2, 1 ); - - TLValueRotation1 = new QLabel( GroupParameters ); - TLValueRotation1->setObjectName( "TLValueRotation1" ); - TLValueRotation1->setAlignment( Qt::AlignCenter ); - TLValueRotation1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TLValueRotation1->setFont( fnt ); - GroupParametersLayout->addWidget( TLValueRotation1, 3, 1 ); + GroupParametersLayout->addWidget( TextLabelDistance, 1, 0 ); + + SpinSliderDistance = new QtxDoubleSpinSlider( 0., 1., 0.01, GroupParameters ); + SpinSliderDistance->setObjectName( "SpinSliderDistance" ); + SpinSliderDistance->setPrecision( precision ); + QFont fnt = SpinSliderDistance->font(); fnt.setBold( true ); SpinSliderDistance->setFont( fnt ); + GroupParametersLayout->addWidget( SpinSliderDistance, 1, 1 ); + + QString aUnitRot = "\xB0"; TextLabelRotation1 = new QLabel( tr("ROTATION_AROUND_X_Y2Z"), GroupParameters ); TextLabelRotation1->setObjectName( "TextLabelRotation1" ); - GroupParametersLayout->addWidget( TextLabelRotation1, 4, 0 ); - - SliderRotation1 = new QSlider( Qt::Horizontal, GroupParameters ); - SliderRotation1->setObjectName( "SliderRotation1" ); - SliderRotation1->setFocusPolicy( Qt::NoFocus ); - SliderRotation1->setMinimumSize( 300, 0 ); - SliderRotation1->setMinimum( -180 ); - SliderRotation1->setMaximum( 180 ); - SliderRotation1->setSingleStep( 1 ); - SliderRotation1->setPageStep( 10 ); - SliderRotation1->setTracking(false); - GroupParametersLayout->addWidget( SliderRotation1, 4, 1 ); - - TLValueRotation2 = new QLabel( GroupParameters ); - TLValueRotation2->setObjectName( "TLValueRotation2" ); - TLValueRotation2->setAlignment( Qt::AlignCenter ); - TLValueRotation2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TLValueRotation2->setFont( fnt ); - GroupParametersLayout->addWidget( TLValueRotation2, 5, 1 ); + GroupParametersLayout->addWidget( TextLabelRotation1, 2, 0 ); + + SpinSliderRotation1 = new QtxIntSpinSlider( -180, 180, 1, GroupParameters ); + SpinSliderRotation1->setObjectName( "SpinSliderRotation1" ); + SpinSliderRotation1->setUnit( aUnitRot ); + SpinSliderRotation1->setFont( fnt ); + GroupParametersLayout->addWidget( SpinSliderRotation1, 2, 1 ); TextLabelRotation2 = new QLabel(tr("ROTATION_AROUND_Y_X2Z"), GroupParameters); TextLabelRotation2->setObjectName( "TextLabelRotation2" ); TextLabelRotation2->setObjectName( "TextLabelRotation2" ); - GroupParametersLayout->addWidget( TextLabelRotation2, 6, 0 ); - - SliderRotation2 = new QSlider( Qt::Horizontal, GroupParameters ); - SliderRotation2->setObjectName( "SliderRotation2" ); - SliderRotation2->setFocusPolicy( Qt::NoFocus ); - SliderRotation2->setMinimumSize( 300, 0 ); - SliderRotation2->setMinimum( -180 ); - SliderRotation2->setMaximum( 180 ); - SliderRotation2->setSingleStep( 1 ); - SliderRotation2->setPageStep( 10 ); - SliderRotation2->setTracking(false); - GroupParametersLayout->addWidget( SliderRotation2, 6, 1 ); + GroupParametersLayout->addWidget( TextLabelRotation2, 3, 0 ); + + SpinSliderRotation2 = new QtxIntSpinSlider( -180, 180, 1, GroupParameters ); + SpinSliderRotation2->setObjectName( "SpinSliderRotation2" ); + SpinSliderRotation2->setUnit( aUnitRot ); + SpinSliderRotation2->setFont( fnt ); + GroupParametersLayout->addWidget( SpinSliderRotation2, 3, 1 ); /***************************************************************/ QGroupBox* CheckBoxWidget = new QGroupBox( this ); @@ -768,12 +736,9 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg(OCCViewer_ViewWindow* parent , OCCV connect( CBAbsoluteOrientation, SIGNAL ( activated ( int ) ), this, SLOT( onOrientationAbsoluteChanged( int ) ) ) ; connect( CBRelativeOrientation, SIGNAL( activated( int ) ), this, SLOT( onOrientationRelativeChanged( int ) ) ); - connect( SliderDistance, SIGNAL( sliderMoved( int ) ), this, SLOT( SliderDistanceHasMoved( int ) ) ); - connect( SliderDistance, SIGNAL( valueChanged( int ) ), this, SLOT( SliderDistanceHasMoved( int ) ) ); - connect( SliderRotation1, SIGNAL( sliderMoved( int ) ), this, SLOT( SliderRotation1HasMoved( int ) ) ); - connect( SliderRotation1, SIGNAL( valueChanged( int ) ), this, SLOT( SliderRotation1HasMoved( int ) ) ); - connect( SliderRotation2, SIGNAL( sliderMoved( int ) ), this, SLOT( SliderRotation2HasMoved( int ) ) ); - connect( SliderRotation2, SIGNAL( valueChanged( int ) ), this, SLOT( SliderRotation2HasMoved( int ) ) ); + connect( SpinSliderDistance, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) ); + connect( SpinSliderRotation1, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) ); + connect( SpinSliderRotation2, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) ); connect( PreviewCheckBox, SIGNAL ( toggled ( bool ) ), this, SLOT( onPreview( bool ) ) ) ; connect( AutoApplyCheckBox, SIGNAL ( toggled( bool ) ), this, SLOT( onAutoApply( bool ) ) ); @@ -858,13 +823,10 @@ void OCCViewer_ClippingDlg::initParam() CBAbsoluteOrientation->setCurrentIndex(0); - TLValueDistance->setText( "0.5" ); - TLValueRotation1->setText( "0\xB0" ); - TLValueRotation2->setText( "0\xB0" ); + SpinSliderDistance->setValue( 0.5 ); + SpinSliderRotation1->setValue( 0 ); + SpinSliderRotation2->setValue( 0 ); CBRelativeOrientation->setCurrentIndex( 0 ); - SliderDistance->setValue( 50 ); - SliderRotation1->setValue( 0 ); - SliderRotation2->setValue( 0 ); } /*! @@ -905,9 +867,9 @@ void OCCViewer_ClippingDlg::synchronize() } else if( myCurrentClipPlaneMode == Relative ) { CBRelativeOrientation->setEnabled( anIsControlsEnable ); - SliderDistance->setEnabled( anIsControlsEnable ); - SliderRotation1->setEnabled( anIsControlsEnable ); - SliderRotation2->setEnabled( anIsControlsEnable ); + SpinSliderDistance->setEnabled( anIsControlsEnable ); + SpinSliderRotation1->setEnabled( anIsControlsEnable ); + SpinSliderRotation2->setEnabled( anIsControlsEnable ); isActivePlane->setEnabled( anIsControlsEnable ); } isActivePlane->setEnabled( anIsControlsEnable ); @@ -1121,18 +1083,13 @@ void OCCViewer_ClippingDlg::updateControls() int anOrientation = aPlane.RelativeMode.Orientation; // Set plane parameters in the dialog - QString aFmtDistance = QString::number( aPlane.RelativeMode.Distance, '.', 2 ); - QString aFmtRotation1 = QString::number( floor( aPlane.RelativeMode.Rotation1 ) ); - QString aFmtRotation2 = QString::number( floor( aPlane.RelativeMode.Rotation2 ) ); - aFmtRotation1 = QString( "%1\xB0" ).arg( aFmtRotation1 ); - aFmtRotation2 = QString( "%1\xB0" ).arg( aFmtRotation2 ); - - SliderDistance->setValue( aPlane.RelativeMode.Distance * 100 ); - TLValueDistance->setText( aFmtDistance ); - SliderRotation1->setValue( floor( aPlane.RelativeMode.Rotation1 ) ); - TLValueRotation1->setText( aFmtRotation1 ); - SliderRotation2->setValue( floor( aPlane.RelativeMode.Rotation2 ) ); - TLValueRotation2->setText( aFmtRotation2 ); + double aFmtDistance = double(aPlane.RelativeMode.Distance); + int aFmtRotation1 = int(aPlane.RelativeMode.Rotation1); + int aFmtRotation2 = int(aPlane.RelativeMode.Rotation2); + + SpinSliderDistance->setValue( aFmtDistance ); + SpinSliderRotation1->setValue( aFmtRotation1 ); + SpinSliderRotation2->setValue( aFmtRotation2 ); CBRelativeOrientation->setCurrentIndex( anOrientation ); onOrientationRelativeChanged( anOrientation ); } @@ -1333,9 +1290,9 @@ void OCCViewer_ClippingDlg::SetCurrentPlaneParam() else if( aPlane.PlaneMode == Relative ) { aPlane.RelativeMode.Orientation = CBRelativeOrientation->currentIndex(); - aPlane.RelativeMode.Distance = TLValueDistance->text().toDouble(); - aPlane.RelativeMode.Rotation1 = TLValueRotation1->text().remove("\xB0").toInt(); - aPlane.RelativeMode.Rotation2 = TLValueRotation2->text().remove("\xB0").toInt(); + aPlane.RelativeMode.Distance = SpinSliderDistance->value(); + aPlane.RelativeMode.Rotation1 = SpinSliderRotation1->value(); + aPlane.RelativeMode.Rotation2 = SpinSliderRotation2->value(); relativePlaneToAbsolute( aPlane, myModel->getAISContext(),myModel->trihedronSize() ); } aPlane.IsOn = isActivePlane->isChecked(); @@ -1578,34 +1535,6 @@ void OCCViewer_ClippingDlg::onPlaneDragged( const Handle(AIS_Plane)& thePlane ) } } -/*! - SLOT: Called when value of slider distance change -*/ -void OCCViewer_ClippingDlg::SliderDistanceHasMoved( int value ) -{ - double new_value = value/100.; - TLValueDistance->setText( QString("%1").arg( new_value ) ); - onValueChanged(); -} - -/*! - SLOT: Called when value of slider rotation1 change -*/ -void OCCViewer_ClippingDlg::SliderRotation1HasMoved( int value ) -{ - TLValueRotation1->setText( QString("%1\xB0").arg( value ) ); - onValueChanged(); -} - -/*! - SLOT: Called when value of slider rotation2 change -*/ -void OCCViewer_ClippingDlg::SliderRotation2HasMoved( int value ) -{ - TLValueRotation2->setText( QString("%1\xB0").arg( value ) ); - onValueChanged(); -} - OCCViewer_ClipPlane& OCCViewer_ClippingDlg::getClipPlane( int theIdx ) { return myLocalPlanes[theIdx]; diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.h b/src/OCCViewer/OCCViewer_ClippingDlg.h index 4a6aced36..23ee3d24c 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.h +++ b/src/OCCViewer/OCCViewer_ClippingDlg.h @@ -37,6 +37,8 @@ class QPushButton; class QComboBox; class QCheckBox; class QtxDoubleSpinBox; +class QtxDoubleSpinSlider; +class QtxIntSpinSlider; class QStackedLayout; class QSlider; class QMenu; @@ -109,12 +111,9 @@ private : QLabel* TextLabelDistance; QLabel* TextLabelRotation1; QLabel* TextLabelRotation2; - QLabel* TLValueDistance; - QLabel* TLValueRotation1; - QLabel* TLValueRotation2; - QSlider* SliderDistance; - QSlider* SliderRotation1; - QSlider* SliderRotation2; + QtxDoubleSpinSlider* SpinSliderDistance; + QtxIntSpinSlider* SpinSliderRotation1; + QtxIntSpinSlider* SpinSliderRotation2; QComboBox* CBRelativeOrientation; QCheckBox* PreviewCheckBox; @@ -166,10 +165,6 @@ private slots: void onPreview( bool on ); void onAutoApply(bool); - void SliderDistanceHasMoved(int); - void SliderRotation1HasMoved(int); - void SliderRotation2HasMoved(int); - void onPlaneClicked( const Handle_AIS_Plane& thePlane ); void onPlaneDragged( const Handle_AIS_Plane& thePlane ); }; diff --git a/src/Qtx/CMakeLists.txt b/src/Qtx/CMakeLists.txt index 404a54941..b1a89f82b 100755 --- a/src/Qtx/CMakeLists.txt +++ b/src/Qtx/CMakeLists.txt @@ -49,10 +49,12 @@ SET(_moc_HEADERS QtxDockAction.h QtxDockWidget.h QtxDoubleSpinBox.h + QtxDoubleSpinSlider.h QtxFontEdit.h QtxGridBox.h QtxGroupBox.h QtxIntSpinBox.h + QtxIntSpinSlider.h QtxListAction.h QtxLogoMgr.h QtxMRUAction.h @@ -67,6 +69,7 @@ SET(_moc_HEADERS QtxRubberBand.h QtxSearchTool.h QtxShortcutEdit.h + QtxSlider.h QtxSplash.h QtxToolBar.h QtxToolTip.h @@ -130,11 +133,13 @@ SET(_other_SOURCES QtxDockAction.cxx QtxDockWidget.cxx QtxDoubleSpinBox.cxx + QtxDoubleSpinSlider.cxx QtxEvalExpr.cxx QtxFontEdit.cxx QtxGridBox.cxx QtxGroupBox.cxx QtxIntSpinBox.cxx + QtxIntSpinSlider.cxx QtxListAction.cxx QtxLogoMgr.cxx QtxMRUAction.cxx @@ -151,6 +156,7 @@ SET(_other_SOURCES QtxRubberBand.cxx QtxSearchTool.cxx QtxShortcutEdit.cxx + QtxSlider.cxx QtxSplash.cxx QtxToolBar.cxx QtxToolTip.cxx diff --git a/src/Qtx/QtxDoubleSpinSlider.cxx b/src/Qtx/QtxDoubleSpinSlider.cxx new file mode 100644 index 000000000..de0f2369a --- /dev/null +++ b/src/Qtx/QtxDoubleSpinSlider.cxx @@ -0,0 +1,148 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : QtxDoubleSpinSlider.cxx +// Author : Maxim GLIBIN, OpenCASCADE S.A.S. (maxim.glibin@opencascade.com) + +#include "QtxDoubleSpinSlider.h" + +/*! + * CONSTRUCTOR of double spin box + */ +QtxDoubleSpinSlider::QtxDoubleSpinSlider( QWidget* theParent ) : QtxSlider( theParent ) +{ + // Get default value of slider + double aMin = mySlider->minimum() / 100.; + double aMax = mySlider->maximum() / 100.; + double aStep = mySlider->singleStep() / 100.; + + // Create double spin box + myDoubleSpinBox = new QtxDoubleSpinBox( aMin, aMax, aStep, theParent ); + myDoubleSpinBox->setFixedWidth( 100 ); + + // Add widget in main layout + mainLayout->addWidget( myDoubleSpinBox ); + + // Signals and slots connections + connect( myDoubleSpinBox, SIGNAL(valueChanged( double )), this, SLOT(DoubleSpinHasChanged( double )) ); + connect( this, SIGNAL(valueUpdated( int )), this, SLOT(setValue( int )) ); +} + +QtxDoubleSpinSlider::QtxDoubleSpinSlider( double theMin, double theMax, double theStep, QWidget* theParent ) : QtxSlider( theParent ) +{ + // Set value of slider + mySlider->setRange( int(theMin*100), int(theMax*100) ); + mySlider->setSingleStep( int(theStep*100) ); + + // Create double spin box + myDoubleSpinBox = new QtxDoubleSpinBox( theMin, theMax, theStep, theParent ); + myDoubleSpinBox->setFixedWidth( 100 ); + + // Add widget in main layout + mainLayout->addWidget( myDoubleSpinBox ); + + // Signals and slots connections + connect( myDoubleSpinBox, SIGNAL(valueChanged( double )), this, SLOT(DoubleSpinHasChanged( double )) ); + connect( this, SIGNAL(valueUpdated( int )), this, SLOT(setValue( int )) ); +} + +/*! + * DESTRUCTOR of double spin box + */ +QtxDoubleSpinSlider::~QtxDoubleSpinSlider() +{ + // Empty +} + +/*! + SLOT: Called when the value of double spin box +*/ +void QtxDoubleSpinSlider::DoubleSpinHasChanged( double theValue ) +{ + + int aNewValue = int( theValue * 100 ); + mySlider->blockSignals( true ); + mySlider->setValue( aNewValue ); + mySlider->blockSignals( false ); + emit valueChanged( theValue ); +} + +/*! + * Get font currently set for the double spin box +*/ +QFont QtxDoubleSpinSlider::font() +{ + return myDoubleSpinBox->font(); +} + +/*! + * Set font currently set for the double spin box +*/ +void QtxDoubleSpinSlider::setFont( QFont& theFont ) +{ + myDoubleSpinBox->setFont( theFont ); +} + +/*! + * Get value in double spin box +*/ +double QtxDoubleSpinSlider::value() +{ + return myDoubleSpinBox->value(); +} + +/*! + * Set value in double spin box +*/ +void QtxDoubleSpinSlider::setValue( double theValue ) +{ + myDoubleSpinBox->setValue( theValue ); +} + +/*! + * Set value in double spin box +*/ +void QtxDoubleSpinSlider::setValue( int theValue ) +{ + double aNewValue = theValue / 100.; + this->setValue( aNewValue ); +} + +/*! + * Set precision of double spin box +*/ +void QtxDoubleSpinSlider::setPrecision( int thePrecision ) +{ + myDoubleSpinBox->setPrecision( thePrecision ); +} + +/*! + * Get precision of double spin box +*/ +int QtxDoubleSpinSlider::precision() +{ + myDoubleSpinBox->getPrecision(); +} + +void QtxDoubleSpinSlider::setUnit( QString& theUnit ) +{ + myDoubleSpinBox->setSuffix( theUnit ); +} diff --git a/src/Qtx/QtxDoubleSpinSlider.h b/src/Qtx/QtxDoubleSpinSlider.h new file mode 100644 index 000000000..8718fffc8 --- /dev/null +++ b/src/Qtx/QtxDoubleSpinSlider.h @@ -0,0 +1,67 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : QtxDoubleSpinSlider.h +// Author : Maxim GLIBIN, OpenCASCADE S.A.S. (maxim.glibin@opencascade.com) + + +#ifndef QTXDOUBLESPINSLIDER_H +#define QTXDOUBLESPINSLIDER_H + +#include "Qtx.h" +#include "QtxDoubleSpinBox.h" +#include "QtxSlider.h" + + +class QTX_EXPORT QtxDoubleSpinSlider : public QtxSlider +{ + Q_OBJECT +public: + QtxDoubleSpinSlider( QWidget* = 0 ); + QtxDoubleSpinSlider( double, double, double, QWidget* = 0 ); + virtual ~QtxDoubleSpinSlider(); + + QFont font(); + void setFont( QFont& ); + + double value(); + void setValue( double ); + + void setPrecision( int ); + int precision(); + + void setUnit( QString& ); + +public slots: + void setValue( int ); + +private slots: + void DoubleSpinHasChanged( double ); + +signals: + void valueChanged( double ); + +private: + QtxDoubleSpinBox* myDoubleSpinBox; +}; + +#endif /* QTXDOUBLESPINSLIDER_H */ + diff --git a/src/Qtx/QtxIntSpinSlider.cxx b/src/Qtx/QtxIntSpinSlider.cxx new file mode 100644 index 000000000..60713a2c9 --- /dev/null +++ b/src/Qtx/QtxIntSpinSlider.cxx @@ -0,0 +1,121 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : QtxIntSpinSlider.cxx +// Author : Maxim GLIBIN, OpenCASCADE S.A.S. (maxim.glibin@opencascade.com) + +#include "QtxIntSpinSlider.h" + +/*! + * CONSTRUCTOR of spin box + */ +QtxIntSpinSlider::QtxIntSpinSlider( QWidget* theParent ) : QtxSlider( theParent ) +{ + // Get default value of slider + int aMin = mySlider->minimum(); + int aMax = mySlider->maximum(); + int aStep = mySlider->singleStep(); + + // Create spin box + myIntSpinBox = new QtxIntSpinBox( aMin, aMax, aStep, theParent ); + myIntSpinBox->setFixedWidth( 100 ); + + // Add widget in main layout + mainLayout->addWidget( myIntSpinBox ); + + // Signals and slots connections + connect( myIntSpinBox, SIGNAL(valueChanged( int )), this, SLOT(IntSpinHasChanged( int )) ); + connect( this, SIGNAL(valueUpdated( int )), this, SLOT(setValue( int )) ); +} + +QtxIntSpinSlider::QtxIntSpinSlider( int theMin, int theMax, int theStep, QWidget* theParent ) +{ + // Set value of slider + mySlider->setRange( theMin, theMax ); + mySlider->setSingleStep( theStep ); + + // Create spin box + myIntSpinBox = new QtxIntSpinBox( theMin, theMax, theStep, theParent ); + myIntSpinBox->setFixedWidth( 100 ); + + // Add widgets in main layout + mainLayout->addWidget( myIntSpinBox ); + + // Signals and slots connections + connect( myIntSpinBox, SIGNAL(valueChanged( int )), this, SLOT(IntSpinHasChanged( int )) ); + connect( this, SIGNAL(valueUpdated( int )), this, SLOT(setValue( int )) ); +} + +/*! + * DESTRUCTOR of spin box + */ +QtxIntSpinSlider::~QtxIntSpinSlider() +{ + // Empty +} + +/*! + SLOT: Called when the value of spin box change +*/ +void QtxIntSpinSlider::IntSpinHasChanged( int theValue ) +{ + mySlider->blockSignals( true ); + mySlider->setValue( theValue ); + mySlider->blockSignals( false ); + emit valueChanged( theValue ); +} + +/*! + * Get font of spin box +*/ +QFont QtxIntSpinSlider::font() +{ + return myIntSpinBox->font(); +} + +/*! + * Set font of spin box +*/ +void QtxIntSpinSlider::setFont( QFont& theFont ) +{ + myIntSpinBox->setFont( theFont ); +} + +/*! + * Get value of spin box +*/ +int QtxIntSpinSlider::value() +{ + return myIntSpinBox->value(); +} + +/*! + * Set value of spin box +*/ +void QtxIntSpinSlider::setValue( int theValue ) +{ + myIntSpinBox->setValue( theValue ); +} + +void QtxIntSpinSlider::setUnit( QString& theUnit ) +{ + myIntSpinBox->setSuffix( theUnit ); +} diff --git a/src/Qtx/QtxIntSpinSlider.h b/src/Qtx/QtxIntSpinSlider.h new file mode 100644 index 000000000..48663e582 --- /dev/null +++ b/src/Qtx/QtxIntSpinSlider.h @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : QtxIntSpinSlider.h +// Author : Maxim GLIBIN, OpenCASCADE S.A.S. (maxim.glibin@opencascade.com) + + +#ifndef QTXINTSPINSLIDER_H +#define QTXINTSPINSLIDER_H + +#include "Qtx.h" +#include "QtxIntSpinBox.h" +#include "QtxSlider.h" + + +class QTX_EXPORT QtxIntSpinSlider : public QtxSlider +{ + Q_OBJECT +public: + QtxIntSpinSlider( QWidget* = 0 ); + QtxIntSpinSlider( int, int, int, QWidget* = 0 ); + virtual ~QtxIntSpinSlider(); + + QFont font(); + void setFont( QFont& ); + + int value(); + + void setUnit( QString& ); + +public slots: + void setValue( int ); + +signals: + void valueChanged( int ); + +private slots: + void IntSpinHasChanged( int ); + +private: + QtxIntSpinBox* myIntSpinBox; +}; + +#endif /* QTXINTSPINSLIDER_H */ + diff --git a/src/Qtx/QtxSlider.cxx b/src/Qtx/QtxSlider.cxx new file mode 100644 index 000000000..006fc576c --- /dev/null +++ b/src/Qtx/QtxSlider.cxx @@ -0,0 +1,117 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : QtxSlider.cxx +// Author : Maxim GLIBIN, OpenCASCADE S.A.S. (maxim.glibin@opencascade.com) + +#include "QtxSlider.h" + +/*! + * CONSTRUCTOR of slider + */ +QtxSlider::QtxSlider( QWidget* theParent ) : QWidget( theParent ) +{ + // Create slider + mySlider = new QSlider( Qt::Horizontal, theParent ); + mySlider->setFocusPolicy( Qt::NoFocus ); + mySlider->setMinimumSize( 250, 0 ); + mySlider->setTracking( false ); + + // Add widgets in main layout + mainLayout = new QHBoxLayout(); + mainLayout->addWidget( mySlider ); + mainLayout->setContentsMargins( 0, 0, 0, 0 ); + this->setLayout( mainLayout ); + + // Signals and slots connections + connect( mySlider, SIGNAL(sliderMoved( int )), this, SLOT(SliderHasMoved( int )) ); + connect( mySlider, SIGNAL(valueChanged( int )), this, SLOT(SliderHasMoved( int )) ); +} + +QtxSlider::QtxSlider( int theMin, int theMax, int theStep, QWidget* theParent ) : QWidget( theParent ) +{ + // Create slider + mySlider = new QSlider( Qt::Horizontal, theParent ); + mySlider->setFocusPolicy( Qt::NoFocus ); + mySlider->setMinimumSize( 200, 0 ); + mySlider->setRange( theMin, theMax ); + mySlider->setSingleStep( theStep ); + mySlider->setPageStep( 10 ); + mySlider->setTracking( false ); + + // Add widgets in main layout + mainLayout = new QHBoxLayout(); + mainLayout->addWidget( mySlider ); + mainLayout->setContentsMargins( 0, 0, 0, 0 ); + this->setLayout( mainLayout ); + + // Signals and slots connections + connect( mySlider, SIGNAL(sliderMoved( int )), this, SLOT(SliderHasMoved( int )) ); + connect( mySlider, SIGNAL(valueChanged( int )), this, SLOT(SliderHasMoved( int )) ); +} + +/*! + * DESTRUCTOR of slider + */ +QtxSlider::~QtxSlider() +{ + // Empty +} + +/*! + SLOT: Called when the value of slider change +*/ +void QtxSlider::SliderHasMoved( int theValue ) +{ + emit valueUpdated( theValue ); +} + +/*! + * Get value of slider +*/ +int QtxSlider::value() +{ + return mySlider->value(); +} + +/*! + * Set value of slider +*/ +void QtxSlider::setValue( int theValue ) +{ + mySlider->setValue( theValue ); +} + +/*! + * Set range of slider +*/ +void QtxSlider::setRange( int theMin, int theMax ) +{ + mySlider->setRange( theMin, theMax ); +} + +/*! + * Set single step of slider +*/ +void QtxSlider::setSingleStep( int theStep ) +{ + mySlider->setSingleStep( theStep ); +} diff --git a/src/Qtx/QtxSlider.h b/src/Qtx/QtxSlider.h new file mode 100644 index 000000000..fea077223 --- /dev/null +++ b/src/Qtx/QtxSlider.h @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : QtxSlider.h +// Author : Maxim GLIBIN, OpenCASCADE S.A.S. (maxim.glibin@opencascade.com) + + +#ifndef QTXSLIDER_H +#define QTXSLIDER_H + +#include +#include +#include + +#include "Qtx.h" + + +class QTX_EXPORT QtxSlider : public QWidget +{ + Q_OBJECT +public: + QtxSlider( QWidget* = 0 ); + QtxSlider( int, int, int, QWidget* = 0 ); + virtual ~QtxSlider(); + + void setValue( int ); + int value(); + + void setRange( int, int ); + + void setSingleStep( int ); + +private slots: + void SliderHasMoved( int ); + +signals: + void valueUpdated( int ); + +protected: + QHBoxLayout* mainLayout; + QSlider* mySlider; +}; + +#endif /* QTXSLIDER_H */ + -- 2.39.2