mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add Value Range editor backed by std::pair<double, double>
This commit is contained in:
parent
6f845f0d42
commit
a0d696e596
@ -41,6 +41,7 @@
|
|||||||
#include "cafPdmUiTextEditor.h"
|
#include "cafPdmUiTextEditor.h"
|
||||||
#include "cafPdmUiTreeSelectionEditor.h"
|
#include "cafPdmUiTreeSelectionEditor.h"
|
||||||
#include "cafPdmUiTreeView.h"
|
#include "cafPdmUiTreeView.h"
|
||||||
|
#include "cafPdmUiValueRangeEditor.h"
|
||||||
#include "cafSelectionManager.h"
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@ -956,6 +957,9 @@ public:
|
|||||||
CAF_PDM_InitField( &m_filePath, "FilePath", QString( "" ), "Filename", "", "", "" );
|
CAF_PDM_InitField( &m_filePath, "FilePath", QString( "" ), "Filename", "", "", "" );
|
||||||
CAF_PDM_InitField( &m_longText, "LongText", QString( "Test text" ), "Long Text", "", "", "" );
|
CAF_PDM_InitField( &m_longText, "LongText", QString( "Test text" ), "Long Text", "", "", "" );
|
||||||
|
|
||||||
|
CAF_PDM_InitField( &m_minMaxSlider, "MinMaxSlider", std::make_pair( 2.5, 10.1 ), "Min max slider", "", "", "" );
|
||||||
|
m_minMaxSlider.uiCapability()->setUiEditorTypeName( caf::PdmUiValueRangeEditor::uiEditorTypeName() );
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault( &m_multiSelectList, "MultiSelect", "Selection List", "", "List", "This is a multi selection list" );
|
CAF_PDM_InitFieldNoDefault( &m_multiSelectList, "MultiSelect", "Selection List", "", "List", "This is a multi selection list" );
|
||||||
CAF_PDM_InitFieldNoDefault( &m_objectList, "ObjectList", "Objects list Field", "", "List", "This is a list of PdmObjects" );
|
CAF_PDM_InitFieldNoDefault( &m_objectList, "ObjectList", "Objects list Field", "", "List", "This is a list of PdmObjects" );
|
||||||
CAF_PDM_InitFieldNoDefault( &m_objectListOfSameType,
|
CAF_PDM_InitFieldNoDefault( &m_objectListOfSameType,
|
||||||
@ -984,6 +988,8 @@ public:
|
|||||||
uiOrdering.add( &m_applyAutoOnChildObjectFields );
|
uiOrdering.add( &m_applyAutoOnChildObjectFields );
|
||||||
uiOrdering.add( &m_updateAutoValues );
|
uiOrdering.add( &m_updateAutoValues );
|
||||||
|
|
||||||
|
uiOrdering.add( &m_minMaxSlider );
|
||||||
|
|
||||||
uiOrdering.add( &m_objectListOfSameType );
|
uiOrdering.add( &m_objectListOfSameType );
|
||||||
uiOrdering.add( &m_ptrField );
|
uiOrdering.add( &m_ptrField );
|
||||||
uiOrdering.add( &m_boolField );
|
uiOrdering.add( &m_boolField );
|
||||||
@ -1041,6 +1047,8 @@ public:
|
|||||||
|
|
||||||
caf::PdmField<QString> m_filePath;
|
caf::PdmField<QString> m_filePath;
|
||||||
|
|
||||||
|
caf::PdmField<std::pair<double, double>> m_minMaxSlider;
|
||||||
|
|
||||||
caf::PdmField<QString> m_longText;
|
caf::PdmField<QString> m_longText;
|
||||||
caf::PdmField<std::vector<QString>> m_multiSelectList;
|
caf::PdmField<std::vector<QString>> m_multiSelectList;
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ set(MOC_HEADER_FILES
|
|||||||
cafPdmUiPickableLineEditor.h
|
cafPdmUiPickableLineEditor.h
|
||||||
cafPdmUiLabelEditor.h
|
cafPdmUiLabelEditor.h
|
||||||
cafPdmUiCheckBoxAndTextEditor.h
|
cafPdmUiCheckBoxAndTextEditor.h
|
||||||
|
cafPdmUiValueRangeEditor.h
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(
|
find_package(
|
||||||
@ -108,6 +109,8 @@ set(PROJECT_FILES
|
|||||||
cafPdmUiLabelEditor.cpp
|
cafPdmUiLabelEditor.cpp
|
||||||
cafPdmUiCheckBoxAndTextEditor.h
|
cafPdmUiCheckBoxAndTextEditor.h
|
||||||
cafPdmUiCheckBoxAndTextEditor.cpp
|
cafPdmUiCheckBoxAndTextEditor.cpp
|
||||||
|
cafPdmUiValueRangeEditor.h
|
||||||
|
cafPdmUiValueRangeEditor.cpp
|
||||||
# object editors
|
# object editors
|
||||||
cafPdmUiDefaultObjectEditor.cpp
|
cafPdmUiDefaultObjectEditor.cpp
|
||||||
cafPdmUiDefaultObjectEditor.h
|
cafPdmUiDefaultObjectEditor.h
|
||||||
@ -171,6 +174,8 @@ set(PROJECT_FILES
|
|||||||
cafPdmUiTreeAttributes.h
|
cafPdmUiTreeAttributes.h
|
||||||
cafUiAppearanceSettings.cpp
|
cafUiAppearanceSettings.cpp
|
||||||
cafUiIconFactory.cpp
|
cafUiIconFactory.cpp
|
||||||
|
cafPdmUiSliderTools.h
|
||||||
|
cafPdmUiSliderTools.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include "cafPdmUiListEditor.h"
|
#include "cafPdmUiListEditor.h"
|
||||||
#include "cafPdmUiTimeEditor.h"
|
#include "cafPdmUiTimeEditor.h"
|
||||||
#include "cafPdmUiTreeSelectionEditor.h"
|
#include "cafPdmUiTreeSelectionEditor.h"
|
||||||
|
#include "cafPdmUiValueRangeEditor.h"
|
||||||
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
|
||||||
@ -75,15 +76,22 @@ CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR( PdmUiTreeSelectionEditor, std::vector<
|
|||||||
|
|
||||||
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR( PdmUiFilePathEditor, FilePath );
|
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR( PdmUiFilePathEditor, FilePath );
|
||||||
|
|
||||||
// As the macro CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR() is not working correctly for std::pair<bool, double> the
|
// As the macro CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR() is not working correctly for std::pair<> the
|
||||||
// registration of this type in the factory has to be written directly
|
// registration of this type in the factory has to be written directly
|
||||||
static bool myPdmUiCheckBoxAndTextEditor73 =
|
static bool myPdmUiCheckBoxAndTextEditor =
|
||||||
caf::Factory<caf::PdmUiFieldEditorHandle, QString>::instance()->registerCreator<PdmUiCheckBoxAndTextEditor>(
|
caf::Factory<caf::PdmUiFieldEditorHandle, QString>::instance()->registerCreator<PdmUiCheckBoxAndTextEditor>(
|
||||||
QString( typeid( caf::PdmField<std::pair<bool, double>> ).name() ) );
|
QString( typeid( caf::PdmField<std::pair<bool, double>> ).name() ) );
|
||||||
static bool my2PdmUiCheckBoxAndTextEditor73 =
|
static bool myPdmUiCheckBoxAndTextEditor_proxy =
|
||||||
caf::Factory<caf::PdmUiFieldEditorHandle, QString>::instance()->registerCreator<PdmUiCheckBoxAndTextEditor>(
|
caf::Factory<caf::PdmUiFieldEditorHandle, QString>::instance()->registerCreator<PdmUiCheckBoxAndTextEditor>(
|
||||||
QString( typeid( caf::PdmProxyValueField<std::pair<bool, double>> ).name() ) );
|
QString( typeid( caf::PdmProxyValueField<std::pair<bool, double>> ).name() ) );
|
||||||
|
|
||||||
|
static bool myPdmUiValueRangeEditor =
|
||||||
|
caf::Factory<caf::PdmUiFieldEditorHandle, QString>::instance()->registerCreator<PdmUiValueRangeEditor>(
|
||||||
|
QString( typeid( caf::PdmField<std::pair<double, double>> ).name() ) );
|
||||||
|
static bool myPdmUiValueRangeEditor_proxy =
|
||||||
|
caf::Factory<caf::PdmUiFieldEditorHandle, QString>::instance()->registerCreator<PdmUiValueRangeEditor>(
|
||||||
|
QString( typeid( caf::PdmProxyValueField<std::pair<double, double>> ).name() ) );
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -44,40 +44,25 @@
|
|||||||
#include <QDoubleValidator>
|
#include <QDoubleValidator>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
class PdmDoubleValidator : public QDoubleValidator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit PdmDoubleValidator( QObject* parent = nullptr )
|
|
||||||
: QDoubleValidator( parent )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PdmDoubleValidator( double bottom, double top, int decimals, QObject* parent )
|
|
||||||
: QDoubleValidator( bottom, top, decimals, parent )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~PdmDoubleValidator() override {}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void fixup( QString& stringValue ) const override
|
|
||||||
{
|
|
||||||
double doubleValue = stringValue.toDouble();
|
|
||||||
doubleValue = qBound( bottom(), doubleValue, top() );
|
|
||||||
|
|
||||||
stringValue = QString::number( doubleValue, 'g', decimals() );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT( PdmUiDoubleSliderEditor );
|
CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT( PdmUiDoubleSliderEditor );
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
PdmUiDoubleSliderEditor::PdmUiDoubleSliderEditor()
|
||||||
|
: m_sliderValue( 0.0 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
PdmUiDoubleSliderEditor::~PdmUiDoubleSliderEditor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -111,7 +96,7 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi( const QString& uiConfigName
|
|||||||
m_lineEdit->setText( textValue );
|
m_lineEdit->setText( textValue );
|
||||||
|
|
||||||
m_sliderValue = doubleValue;
|
m_sliderValue = doubleValue;
|
||||||
updateSliderPosition( doubleValue );
|
PdmUiSliderTools::updateSliderPosition( m_slider, doubleValue, m_attributes );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -167,7 +152,7 @@ void PdmUiDoubleSliderEditor::slotEditingFinished()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void PdmUiDoubleSliderEditor::slotSliderValueChanged( int value )
|
void PdmUiDoubleSliderEditor::slotSliderValueChanged( int value )
|
||||||
{
|
{
|
||||||
double newDoubleValue = convertFromSliderValue( value );
|
double newDoubleValue = PdmUiSliderTools::convertFromSliderValue( m_slider, value, m_attributes );
|
||||||
m_sliderValue = newDoubleValue;
|
m_sliderValue = newDoubleValue;
|
||||||
|
|
||||||
if ( m_attributes.m_delaySliderUpdateUntilRelease )
|
if ( m_attributes.m_delaySliderUpdateUntilRelease )
|
||||||
@ -188,20 +173,6 @@ void PdmUiDoubleSliderEditor::slotSliderReleased()
|
|||||||
writeValueToField( m_sliderValue );
|
writeValueToField( m_sliderValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void PdmUiDoubleSliderEditor::updateSliderPosition( double value )
|
|
||||||
{
|
|
||||||
int newSliderPosition = convertToSliderValue( value );
|
|
||||||
if ( m_slider->value() != newSliderPosition )
|
|
||||||
{
|
|
||||||
m_slider->blockSignals( true );
|
|
||||||
m_slider->setValue( newSliderPosition );
|
|
||||||
m_slider->blockSignals( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -211,30 +182,4 @@ void PdmUiDoubleSliderEditor::writeValueToField( double value )
|
|||||||
this->setValueToField( v );
|
this->setValueToField( v );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
int PdmUiDoubleSliderEditor::convertToSliderValue( double value )
|
|
||||||
{
|
|
||||||
double exactSliderValue =
|
|
||||||
m_slider->maximum() * ( value - m_attributes.m_minimum ) / ( m_attributes.m_maximum - m_attributes.m_minimum );
|
|
||||||
|
|
||||||
int sliderValue = static_cast<int>( exactSliderValue + 0.5 );
|
|
||||||
sliderValue = qBound( m_slider->minimum(), sliderValue, m_slider->maximum() );
|
|
||||||
|
|
||||||
return sliderValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
double PdmUiDoubleSliderEditor::convertFromSliderValue( int sliderValue )
|
|
||||||
{
|
|
||||||
double newDoubleValue = m_attributes.m_minimum +
|
|
||||||
sliderValue * ( m_attributes.m_maximum - m_attributes.m_minimum ) / m_slider->maximum();
|
|
||||||
newDoubleValue = qBound( m_attributes.m_minimum, newDoubleValue, m_attributes.m_maximum );
|
|
||||||
|
|
||||||
return newDoubleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace caf
|
} // end namespace caf
|
||||||
|
@ -35,39 +35,20 @@
|
|||||||
//##################################################################################################
|
//##################################################################################################
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cafPdmUiFieldEditorHandle.h"
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
#include "cafPdmUiSliderTools.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
//==================================================================================================
|
|
||||||
///
|
|
||||||
//==================================================================================================
|
|
||||||
class PdmUiDoubleSliderEditorAttribute : public PdmUiEditorAttribute
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PdmUiDoubleSliderEditorAttribute()
|
|
||||||
{
|
|
||||||
m_minimum = 0;
|
|
||||||
m_maximum = 10;
|
|
||||||
m_decimals = 6;
|
|
||||||
m_sliderTickCount = 2000;
|
|
||||||
m_delaySliderUpdateUntilRelease = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
double m_minimum;
|
|
||||||
double m_maximum;
|
|
||||||
int m_decimals;
|
|
||||||
int m_sliderTickCount;
|
|
||||||
bool m_delaySliderUpdateUntilRelease;
|
|
||||||
};
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@ -78,8 +59,8 @@ class PdmUiDoubleSliderEditor : public PdmUiFieldEditorHandle
|
|||||||
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
|
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PdmUiDoubleSliderEditor() {}
|
PdmUiDoubleSliderEditor();
|
||||||
~PdmUiDoubleSliderEditor() override {}
|
~PdmUiDoubleSliderEditor() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||||
@ -92,12 +73,8 @@ protected slots:
|
|||||||
void slotSliderReleased();
|
void slotSliderReleased();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateSliderPosition( double value );
|
|
||||||
void writeValueToField( double value );
|
void writeValueToField( double value );
|
||||||
|
|
||||||
int convertToSliderValue( double value );
|
|
||||||
double convertFromSliderValue( int sliderValue );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QLineEdit> m_lineEdit;
|
QPointer<QLineEdit> m_lineEdit;
|
||||||
QPointer<QSlider> m_slider;
|
QPointer<QSlider> m_slider;
|
||||||
|
115
Fwk/AppFwk/cafUserInterface/cafPdmUiSliderTools.cpp
Normal file
115
Fwk/AppFwk/cafUserInterface/cafPdmUiSliderTools.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// Custom Visualization Core library
|
||||||
|
// Copyright (C) 2011-2013 Ceetron AS
|
||||||
|
//
|
||||||
|
// This library may be used under the terms of either the GNU General Public License or
|
||||||
|
// the GNU Lesser General Public License as follows:
|
||||||
|
//
|
||||||
|
// GNU General Public License Usage
|
||||||
|
// This library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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 General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
// GNU Lesser General Public License Usage
|
||||||
|
// 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, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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 at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
#include "cafPdmUiSliderTools.h"
|
||||||
|
|
||||||
|
#include <QSlider>
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
PdmDoubleValidator::PdmDoubleValidator( QObject* parent /*= nullptr */ )
|
||||||
|
: QDoubleValidator( parent )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
PdmDoubleValidator::PdmDoubleValidator( double bottom, double top, int decimals, QObject* parent )
|
||||||
|
: QDoubleValidator( bottom, top, decimals, parent )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmDoubleValidator::fixup( QString& stringValue ) const
|
||||||
|
{
|
||||||
|
double doubleValue = stringValue.toDouble();
|
||||||
|
doubleValue = qBound( bottom(), doubleValue, top() );
|
||||||
|
|
||||||
|
stringValue = QString::number( doubleValue, 'g', decimals() );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiSliderTools::updateSliderPosition( QSlider* slider, double value, const PdmUiDoubleSliderEditorAttribute& attributes )
|
||||||
|
{
|
||||||
|
if ( !slider ) return;
|
||||||
|
|
||||||
|
int newSliderPosition = convertToSliderValue( slider, value, attributes );
|
||||||
|
if ( slider->value() != newSliderPosition )
|
||||||
|
{
|
||||||
|
slider->blockSignals( true );
|
||||||
|
slider->setValue( newSliderPosition );
|
||||||
|
slider->blockSignals( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
int PdmUiSliderTools::convertToSliderValue( QSlider* slider, double value, const PdmUiDoubleSliderEditorAttribute& attributes )
|
||||||
|
{
|
||||||
|
double exactSliderValue =
|
||||||
|
slider->maximum() * ( value - attributes.m_minimum ) / ( attributes.m_maximum - attributes.m_minimum );
|
||||||
|
|
||||||
|
int sliderValue = static_cast<int>( exactSliderValue + 0.5 );
|
||||||
|
sliderValue = qBound( slider->minimum(), sliderValue, slider->maximum() );
|
||||||
|
|
||||||
|
return sliderValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
double PdmUiSliderTools::convertFromSliderValue( QSlider* slider,
|
||||||
|
int sliderValue,
|
||||||
|
const PdmUiDoubleSliderEditorAttribute& attributes )
|
||||||
|
{
|
||||||
|
double clampedValue = attributes.m_minimum +
|
||||||
|
sliderValue * ( attributes.m_maximum - attributes.m_minimum ) / slider->maximum();
|
||||||
|
clampedValue = qBound( attributes.m_minimum, clampedValue, attributes.m_maximum );
|
||||||
|
|
||||||
|
return clampedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //namespace caf
|
91
Fwk/AppFwk/cafUserInterface/cafPdmUiSliderTools.h
Normal file
91
Fwk/AppFwk/cafUserInterface/cafPdmUiSliderTools.h
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// Custom Visualization Core library
|
||||||
|
// Copyright (C) 2011-2013 Ceetron AS
|
||||||
|
//
|
||||||
|
// This library may be used under the terms of either the GNU General Public License or
|
||||||
|
// the GNU Lesser General Public License as follows:
|
||||||
|
//
|
||||||
|
// GNU General Public License Usage
|
||||||
|
// This library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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 General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
// GNU Lesser General Public License Usage
|
||||||
|
// 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, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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 at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
|
||||||
|
#include <QValidator>
|
||||||
|
|
||||||
|
class QSlider;
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
class PdmDoubleValidator : public QDoubleValidator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit PdmDoubleValidator( QObject* parent = nullptr );
|
||||||
|
explicit PdmDoubleValidator( double bottom, double top, int decimals, QObject* parent );
|
||||||
|
|
||||||
|
void fixup( QString& stringValue ) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class PdmUiDoubleSliderEditorAttribute : public PdmUiEditorAttribute
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PdmUiDoubleSliderEditorAttribute()
|
||||||
|
{
|
||||||
|
m_minimum = 0;
|
||||||
|
m_maximum = 10;
|
||||||
|
m_decimals = 6;
|
||||||
|
m_sliderTickCount = 2000;
|
||||||
|
m_delaySliderUpdateUntilRelease = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
double m_minimum;
|
||||||
|
double m_maximum;
|
||||||
|
int m_decimals;
|
||||||
|
int m_sliderTickCount;
|
||||||
|
bool m_delaySliderUpdateUntilRelease;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PdmUiSliderTools
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void updateSliderPosition( QSlider* slider, double value, const PdmUiDoubleSliderEditorAttribute& attributes );
|
||||||
|
static int convertToSliderValue( QSlider* slider, double value, const PdmUiDoubleSliderEditorAttribute& attributes );
|
||||||
|
static double
|
||||||
|
convertFromSliderValue( QSlider* slider, int sliderValue, const PdmUiDoubleSliderEditorAttribute& attributes );
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace caf
|
301
Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp
Normal file
301
Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.cpp
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// Custom Visualization Core library
|
||||||
|
// Copyright (C) 2023 Ceetron Solutions AS
|
||||||
|
//
|
||||||
|
// This library may be used under the terms of either the GNU General Public License or
|
||||||
|
// the GNU Lesser General Public License as follows:
|
||||||
|
//
|
||||||
|
// GNU General Public License Usage
|
||||||
|
// This library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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 General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
// GNU Lesser General Public License Usage
|
||||||
|
// 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, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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 at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
#include "cafPdmUiValueRangeEditor.h"
|
||||||
|
|
||||||
|
#include "cafPdmField.h"
|
||||||
|
#include "cafPdmObject.h"
|
||||||
|
#include "cafPdmUiDefaultObjectEditor.h"
|
||||||
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
#include "cafPdmUiLineEditor.h"
|
||||||
|
#include "cafPdmUiOrdering.h"
|
||||||
|
#include "cafQShortenedLabel.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QSlider>
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT( PdmUiValueRangeEditor );
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiValueRangeEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||||
|
{
|
||||||
|
PdmUiFieldEditorHandle::updateLabelFromField( m_label, uiConfigName );
|
||||||
|
|
||||||
|
m_lineEditMin->setEnabled( !uiField()->isUiReadOnly( uiConfigName ) );
|
||||||
|
m_sliderMin->setEnabled( !uiField()->isUiReadOnly( uiConfigName ) );
|
||||||
|
m_lineEditMax->setEnabled( !uiField()->isUiReadOnly( uiConfigName ) );
|
||||||
|
m_sliderMax->setEnabled( !uiField()->isUiReadOnly( uiConfigName ) );
|
||||||
|
|
||||||
|
caf::PdmUiObjectHandle* uiObject = uiObj( uiField()->fieldHandle()->ownerObject() );
|
||||||
|
if ( uiObject )
|
||||||
|
{
|
||||||
|
uiObject->editorAttribute( uiField()->fieldHandle(), uiConfigName, &m_attributes );
|
||||||
|
}
|
||||||
|
|
||||||
|
// A pair is represented as a list of QVariant in PdmValueFieldSpecialization<std::pair<T, U>>
|
||||||
|
auto getTwoDoublesFromVariant = [this]() -> std::pair<double, double>
|
||||||
|
{
|
||||||
|
double firstValue = 0.0;
|
||||||
|
double secondValue = 0.0;
|
||||||
|
|
||||||
|
auto variantValue = uiField()->uiValue();
|
||||||
|
if ( variantValue.canConvert<QList<QVariant>>() )
|
||||||
|
{
|
||||||
|
QList<QVariant> lst = variantValue.toList();
|
||||||
|
if ( lst.size() == 2 )
|
||||||
|
{
|
||||||
|
firstValue = lst[0].toDouble();
|
||||||
|
secondValue = lst[1].toDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_pair( firstValue, secondValue );
|
||||||
|
};
|
||||||
|
|
||||||
|
auto [minimum, maximum] = getTwoDoublesFromVariant();
|
||||||
|
|
||||||
|
m_sliderMin->blockSignals( true );
|
||||||
|
m_sliderMin->setMaximum( m_attributes.m_sliderTickCount );
|
||||||
|
m_sliderMin->blockSignals( false );
|
||||||
|
|
||||||
|
QString textValueMin = QString( "%1" ).arg( minimum );
|
||||||
|
|
||||||
|
PdmDoubleValidator* pdmValidator =
|
||||||
|
new PdmDoubleValidator( m_attributes.m_minimum, m_attributes.m_maximum, m_attributes.m_decimals, this );
|
||||||
|
pdmValidator->fixup( textValueMin );
|
||||||
|
|
||||||
|
m_lineEditMin->setValidator( pdmValidator );
|
||||||
|
m_lineEditMin->setText( textValueMin );
|
||||||
|
|
||||||
|
m_sliderValueMin = minimum;
|
||||||
|
PdmUiSliderTools::updateSliderPosition( m_sliderMin, minimum, m_attributes );
|
||||||
|
|
||||||
|
m_sliderMax->blockSignals( true );
|
||||||
|
m_sliderMax->setMaximum( m_attributes.m_sliderTickCount );
|
||||||
|
m_sliderMax->blockSignals( false );
|
||||||
|
|
||||||
|
QString textValueMax = QString( "%1" ).arg( maximum );
|
||||||
|
|
||||||
|
pdmValidator->fixup( textValueMax );
|
||||||
|
|
||||||
|
m_lineEditMax->setValidator( pdmValidator );
|
||||||
|
m_lineEditMax->setText( textValueMax );
|
||||||
|
|
||||||
|
m_sliderValueMax = maximum;
|
||||||
|
PdmUiSliderTools::updateSliderPosition( m_sliderMax, maximum, m_attributes );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiValueRangeEditor::slotMinEditingFinished()
|
||||||
|
{
|
||||||
|
QString minText = m_lineEditMin->text();
|
||||||
|
QString maxText = m_lineEditMax->text();
|
||||||
|
|
||||||
|
double minValue = minText.toDouble();
|
||||||
|
double maxValue = maxText.toDouble();
|
||||||
|
|
||||||
|
clampAndWriteValues( minValue, maxValue, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiValueRangeEditor::slotMaxEditingFinished()
|
||||||
|
{
|
||||||
|
QString minText = m_lineEditMin->text();
|
||||||
|
QString maxText = m_lineEditMax->text();
|
||||||
|
|
||||||
|
double minValue = minText.toDouble();
|
||||||
|
double maxValue = maxText.toDouble();
|
||||||
|
|
||||||
|
clampAndWriteValues( minValue, maxValue, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiValueRangeEditor::slotMinSliderValueChanged( int value )
|
||||||
|
{
|
||||||
|
double newDoubleValue = PdmUiSliderTools::convertFromSliderValue( m_sliderMin, value, m_attributes );
|
||||||
|
m_sliderValueMin = newDoubleValue;
|
||||||
|
|
||||||
|
if ( m_attributes.m_delaySliderUpdateUntilRelease )
|
||||||
|
{
|
||||||
|
m_lineEditMin->setText( QString( "%1" ).arg( m_sliderValueMin ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
clampAndWriteValues( m_sliderValueMin, m_sliderValueMax, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiValueRangeEditor::slotMaxSliderValueChanged( int value )
|
||||||
|
{
|
||||||
|
double newDoubleValue = PdmUiSliderTools::convertFromSliderValue( m_sliderMax, value, m_attributes );
|
||||||
|
m_sliderValueMax = newDoubleValue;
|
||||||
|
|
||||||
|
if ( m_attributes.m_delaySliderUpdateUntilRelease )
|
||||||
|
{
|
||||||
|
m_lineEditMax->setText( QString( "%1" ).arg( m_sliderValueMax ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
clampAndWriteValues( m_sliderValueMin, m_sliderValueMax, false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiValueRangeEditor::slotMinSliderReleased()
|
||||||
|
{
|
||||||
|
clampAndWriteValues( m_sliderValueMin, m_sliderValueMax, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiValueRangeEditor::slotMaxSliderReleased()
|
||||||
|
{
|
||||||
|
clampAndWriteValues( m_sliderValueMin, m_sliderValueMax, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiValueRangeEditor::clampAndWriteValues( double valueMin, double valueMax, bool isMinChanged )
|
||||||
|
{
|
||||||
|
if ( isMinChanged && valueMin > valueMax )
|
||||||
|
{
|
||||||
|
valueMax = valueMin;
|
||||||
|
}
|
||||||
|
else if ( valueMax < valueMin )
|
||||||
|
{
|
||||||
|
valueMin = valueMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
valueMin = qBound( m_attributes.m_minimum, valueMin, m_attributes.m_maximum );
|
||||||
|
valueMax = qBound( m_attributes.m_minimum, valueMax, m_attributes.m_maximum );
|
||||||
|
m_sliderValueMin = valueMin;
|
||||||
|
m_sliderValueMax = valueMax;
|
||||||
|
|
||||||
|
writeValues( valueMin, valueMax );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiValueRangeEditor::writeValues( double valueMin, double valueMax )
|
||||||
|
{
|
||||||
|
auto pairValue = std::make_pair( valueMin, valueMax );
|
||||||
|
|
||||||
|
QVariant v = caf::PdmValueFieldSpecialization<std::pair<double, double>>::convert( pairValue );
|
||||||
|
setValueToField( v );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
PdmUiValueRangeEditor::PdmUiValueRangeEditor()
|
||||||
|
: m_sliderValueMin( 0.0 )
|
||||||
|
, m_sliderValueMax( 0.0 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
PdmUiValueRangeEditor::~PdmUiValueRangeEditor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QWidget* PdmUiValueRangeEditor::createEditorWidget( QWidget* parent )
|
||||||
|
{
|
||||||
|
auto containerWidget = new QWidget( parent );
|
||||||
|
|
||||||
|
auto layout = new QGridLayout();
|
||||||
|
layout->setMargin( 0 );
|
||||||
|
containerWidget->setLayout( layout );
|
||||||
|
|
||||||
|
m_lineEditMin = new QLineEdit( containerWidget );
|
||||||
|
m_lineEditMin->setMaximumWidth( 100 );
|
||||||
|
connect( m_lineEditMin, SIGNAL( editingFinished() ), this, SLOT( slotMinEditingFinished() ) );
|
||||||
|
|
||||||
|
m_sliderMin = new QSlider( Qt::Horizontal, containerWidget );
|
||||||
|
|
||||||
|
layout->addWidget( m_lineEditMin, 0, 0 );
|
||||||
|
layout->addWidget( m_sliderMin, 0, 1 );
|
||||||
|
|
||||||
|
connect( m_sliderMin, SIGNAL( valueChanged( int ) ), this, SLOT( slotMinSliderValueChanged( int ) ) );
|
||||||
|
connect( m_sliderMin, SIGNAL( sliderReleased() ), this, SLOT( slotMinSliderReleased() ) );
|
||||||
|
|
||||||
|
m_lineEditMax = new QLineEdit( containerWidget );
|
||||||
|
m_lineEditMax->setMaximumWidth( 100 );
|
||||||
|
connect( m_lineEditMax, SIGNAL( editingFinished() ), this, SLOT( slotMaxEditingFinished() ) );
|
||||||
|
|
||||||
|
m_sliderMax = new QSlider( Qt::Horizontal, containerWidget );
|
||||||
|
|
||||||
|
layout->addWidget( m_lineEditMax, 1, 0 );
|
||||||
|
layout->addWidget( m_sliderMax, 1, 1 );
|
||||||
|
|
||||||
|
connect( m_sliderMax, SIGNAL( valueChanged( int ) ), this, SLOT( slotMaxSliderValueChanged( int ) ) );
|
||||||
|
connect( m_sliderMax, SIGNAL( sliderReleased() ), this, SLOT( slotMaxSliderReleased() ) );
|
||||||
|
|
||||||
|
return containerWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QWidget* PdmUiValueRangeEditor::createLabelWidget( QWidget* parent )
|
||||||
|
{
|
||||||
|
m_label = new QShortenedLabel( parent );
|
||||||
|
return m_label;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace caf
|
88
Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.h
Normal file
88
Fwk/AppFwk/cafUserInterface/cafPdmUiValueRangeEditor.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// Custom Visualization Core library
|
||||||
|
// Copyright (C) 2023 Ceetron Solutions AS
|
||||||
|
//
|
||||||
|
// This library may be used under the terms of either the GNU General Public License or
|
||||||
|
// the GNU Lesser General Public License as follows:
|
||||||
|
//
|
||||||
|
// GNU General Public License Usage
|
||||||
|
// This library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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 General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
// GNU Lesser General Public License Usage
|
||||||
|
// 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, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// 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 at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
#include "cafPdmUiSliderTools.h"
|
||||||
|
|
||||||
|
class QLineEdit;
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class PdmUiValueRangeEditor : public PdmUiFieldEditorHandle
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PdmUiValueRangeEditor();
|
||||||
|
~PdmUiValueRangeEditor() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QWidget* createEditorWidget( QWidget* parent ) override;
|
||||||
|
QWidget* createLabelWidget( QWidget* parent ) override;
|
||||||
|
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotMinEditingFinished();
|
||||||
|
void slotMaxEditingFinished();
|
||||||
|
void slotMinSliderValueChanged( int value );
|
||||||
|
void slotMaxSliderValueChanged( int value );
|
||||||
|
void slotMinSliderReleased();
|
||||||
|
void slotMaxSliderReleased();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void clampAndWriteValues( double valueMin, double valueMax, bool isMinChanged );
|
||||||
|
void writeValues( double valueMin, double valueMax );
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<QLineEdit> m_lineEditMin;
|
||||||
|
QPointer<QSlider> m_sliderMin;
|
||||||
|
QPointer<QLineEdit> m_lineEditMax;
|
||||||
|
QPointer<QSlider> m_sliderMax;
|
||||||
|
|
||||||
|
QPointer<QShortenedLabel> m_label;
|
||||||
|
double m_sliderValueMin;
|
||||||
|
double m_sliderValueMax;
|
||||||
|
|
||||||
|
PdmUiDoubleSliderEditorAttribute m_attributes;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace caf
|
Loading…
Reference in New Issue
Block a user