mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -05:00
#14362 Allow arbitrary Z-scale factor
Make the Z-scale combo boxes in the toolbar and property editor editable, so any positive scale value can be entered as text. Invalid input is rejected and the previous value is restored. Add keyboard shortcuts Ctrl+Shift+Up and Ctrl+Shift+Down to step the Z-scale of the active view through the predefined scale values.
This commit is contained in:
1 parent
9ccca3e20a
commit
1aa95936fc
12 files changed
+267
-14
No files matched your search
@@ -73,6 +73,7 @@
|
||||
#include "cvfTransform.h"
|
||||
#include "cvfViewport.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
|
||||
namespace caf
|
||||
@@ -577,7 +578,7 @@ void Rim3dView::scheduleCreateDisplayModelAndRedraw()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<Rim3dView*> Rim3dView::viewsUsingThisAsComparisonView()
|
||||
std::set<Rim3dView*> Rim3dView::viewsUsingThisAsComparisonView() const
|
||||
{
|
||||
std::set<Rim3dView*> containingViews;
|
||||
std::vector<caf::PdmFieldHandle*> fieldsReferringToMe = referringPtrFields();
|
||||
@@ -627,7 +628,7 @@ std::vector<Rim3dView*> Rim3dView::validComparisonViews() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool Rim3dView::isScaleZEditable()
|
||||
bool Rim3dView::isScaleZEditable() const
|
||||
{
|
||||
return ( this->viewsUsingThisAsComparisonView().empty() || ( this->viewController() && this->viewController()->isCameraLinked() ) );
|
||||
}
|
||||
@@ -1007,6 +1008,14 @@ void Rim3dView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const
|
||||
}
|
||||
else if ( changedField == &m_scaleZ )
|
||||
{
|
||||
// Invalid text entered in the combo box is converted to 0.0, and a negative scale is not supported
|
||||
if ( m_scaleZ() <= 0.0 )
|
||||
{
|
||||
double fallbackValue = oldValue.toDouble() > 0.0 ? oldValue.toDouble() : 1.0;
|
||||
m_scaleZ.setValueWithFieldChanged( fallbackValue );
|
||||
return;
|
||||
}
|
||||
|
||||
updateScaling();
|
||||
|
||||
RiuMainWindow::instance()->updateScaleValue();
|
||||
@@ -1602,7 +1611,15 @@ QList<caf::PdmOptionItemInfo> Rim3dView::calculateValueOptions( const caf::PdmFi
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_scaleZ )
|
||||
{
|
||||
for ( auto scale : RiaDefines::viewScaleOptions() )
|
||||
// Include the current scale value in the options, as any value can be entered as text in the combo box
|
||||
auto scaleOptions = RiaDefines::viewScaleOptions();
|
||||
if ( std::find( scaleOptions.begin(), scaleOptions.end(), m_scaleZ() ) == scaleOptions.end() )
|
||||
{
|
||||
scaleOptions.push_back( m_scaleZ() );
|
||||
std::sort( scaleOptions.begin(), scaleOptions.end() );
|
||||
}
|
||||
|
||||
for ( auto scale : scaleOptions )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( QString::number( scale ), scale ) );
|
||||
}
|
||||
@@ -1982,3 +1999,18 @@ void Rim3dView::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEdi
|
||||
treeItemAttribute->tags.push_back( std::move( iconTag ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
if ( field == &m_scaleZ )
|
||||
{
|
||||
if ( auto attr = dynamic_cast<caf::PdmUiComboBoxEditorAttribute*>( attribute ) )
|
||||
{
|
||||
attr->enableEditableContent = true;
|
||||
attr->enableAutoComplete = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user