Allow using scale values less than 1.0 (#9108)

* Change view scale into list of predefined double values in both toolbar and property editor. Add values less than 1.0
This commit is contained in:
jonjenssen 2022-07-04 15:48:52 +02:00 committed by GitHub
parent 55eefbd53e
commit 6105813d28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 83 additions and 42 deletions

View File

@ -345,3 +345,11 @@ QString RiaDefines::stringListSeparator()
{ {
return "|"; return "|";
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiaDefines::viewScaleOptions()
{
return { 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0 };
}

View File

@ -225,4 +225,6 @@ constexpr enum MultiPlotPageUpdateType operator&( const enum MultiPlotPageUpdate
return ( enum MultiPlotPageUpdateType )( uint32_t( selfValue ) & uint32_t( inValue ) ); return ( enum MultiPlotPageUpdateType )( uint32_t( selfValue ) & uint32_t( inValue ) );
} }
std::vector<double> viewScaleOptions();
}; // namespace RiaDefines }; // namespace RiaDefines

View File

@ -1476,10 +1476,11 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences*
rim3dView->applyBackgroundColorAndFontChanges(); rim3dView->applyBackgroundColorAndFontChanges();
} }
if ( oldPreferences && ( applySettingsToAllViews || if ( oldPreferences &&
rim3dView->scaleZ == static_cast<double>( oldPreferences->defaultScaleFactorZ() ) ) ) ( applySettingsToAllViews ||
rim3dView->scaleZ() == static_cast<double>( oldPreferences->defaultScaleFactorZ() ) ) )
{ {
rim3dView->scaleZ = static_cast<double>( m_preferences->defaultScaleFactorZ() ); rim3dView->setScaleZ( static_cast<double>( m_preferences->defaultScaleFactorZ() ) );
rim3dView->updateScaling(); rim3dView->updateScaling();
if ( rim3dView == activeViewWindow() ) if ( rim3dView == activeViewWindow() )
{ {

View File

@ -57,6 +57,7 @@
#include "cafFrameAnimationControl.h" #include "cafFrameAnimationControl.h"
#include "cafPdmFieldScriptingCapability.h" #include "cafPdmFieldScriptingCapability.h"
#include "cafPdmFieldScriptingCapabilityCvfColor3.h" #include "cafPdmFieldScriptingCapabilityCvfColor3.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cvfCamera.h" #include "cvfCamera.h"
#include "cvfModelBasicList.h" #include "cvfModelBasicList.h"
@ -115,13 +116,14 @@ Rim3dView::Rim3dView()
CAF_PDM_InitScriptableField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection" ); CAF_PDM_InitScriptableField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection" );
double defaultScaleFactor = preferences->defaultScaleFactorZ(); double defaultScaleFactor = preferences->defaultScaleFactorZ();
CAF_PDM_InitScriptableField( &scaleZ, CAF_PDM_InitScriptableField( &m_scaleZ,
"GridZScale", "GridZScale",
defaultScaleFactor, defaultScaleFactor,
"Z Scale", "Z Scale",
"", "",
"Scales the scene in the Z direction", "Scales the scene in the Z direction",
"" ); "" );
m_scaleZ.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor(); cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor();
CAF_PDM_InitScriptableField( &m_backgroundColor, "BackgroundColor", defBackgColor, "Background" ); CAF_PDM_InitScriptableField( &m_backgroundColor, "BackgroundColor", defBackgColor, "Background" );
@ -411,8 +413,8 @@ void Rim3dView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOr
viewGroup->add( &m_comparisonView ); viewGroup->add( &m_comparisonView );
caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "Grid Appearance" ); caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "Grid Appearance" );
gridGroup->add( &scaleZ ); gridGroup->add( &m_scaleZ );
scaleZ.uiCapability()->setUiReadOnly( !this->isScaleZEditable() ); m_scaleZ.uiCapability()->setUiReadOnly( !this->isScaleZEditable() );
gridGroup->add( &meshMode ); gridGroup->add( &meshMode );
gridGroup->add( &surfaceMode ); gridGroup->add( &surfaceMode );
@ -846,7 +848,7 @@ void Rim3dView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const
{ {
if ( m_viewer ) m_viewer->enableParallelProjection( !isPerspectiveView() ); if ( m_viewer ) m_viewer->enableParallelProjection( !isPerspectiveView() );
} }
else if ( changedField == &scaleZ ) else if ( changedField == &m_scaleZ )
{ {
updateScaling(); updateScaling();
@ -1081,7 +1083,7 @@ void Rim3dView::updateGridBoxData()
} }
} }
viewer()->updateGridBoxData( scaleZ(), viewer()->updateGridBoxData( m_scaleZ(),
ownerCase()->displayModelOffset(), ownerCase()->displayModelOffset(),
backgroundColor(), backgroundColor(),
combinedDomainBBox, combinedDomainBBox,
@ -1113,21 +1115,33 @@ void Rim3dView::resetLegends()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void Rim3dView::setScaleZAndUpdate( double scalingFactor ) void Rim3dView::setScaleZAndUpdate( double scalingFactor )
{ {
if ( this->scaleZ != scalingFactor ) if ( scaleZ() != scalingFactor )
{ {
this->scaleZ = scalingFactor; this->m_scaleZ.setValueWithFieldChanged( scalingFactor );
updateScaling();
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::setScaleZ( double scalingFactor )
{
m_scaleZ = scalingFactor;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Rim3dView::scaleZ() const
{
return m_scaleZ();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void Rim3dView::updateScaling() void Rim3dView::updateScaling()
{ {
if ( scaleZ < 1 ) scaleZ = 1;
if ( viewer() ) if ( viewer() )
{ {
cvf::Vec3d poi = viewer()->pointOfInterest(); cvf::Vec3d poi = viewer()->pointOfInterest();
@ -1136,8 +1150,8 @@ void Rim3dView::updateScaling()
dir = viewer()->mainCamera()->direction(); dir = viewer()->mainCamera()->direction();
up = viewer()->mainCamera()->up(); up = viewer()->mainCamera()->up();
eye[2] = poi[2] * scaleZ() / this->scaleTransform()->worldTransform()( 2, 2 ) + ( eye[2] - poi[2] ); eye[2] = poi[2] * m_scaleZ() / this->scaleTransform()->worldTransform()( 2, 2 ) + ( eye[2] - poi[2] );
poi[2] = poi[2] * scaleZ() / this->scaleTransform()->worldTransform()( 2, 2 ); poi[2] = poi[2] * m_scaleZ() / this->scaleTransform()->worldTransform()( 2, 2 );
viewer()->mainCamera()->setFromLookAt( eye, eye + dir, up ); viewer()->mainCamera()->setFromLookAt( eye, eye + dir, up );
viewer()->setPointOfInterest( poi ); viewer()->setPointOfInterest( poi );
@ -1145,7 +1159,7 @@ void Rim3dView::updateScaling()
if ( activeComparisonView() ) if ( activeComparisonView() )
{ {
activeComparisonView()->setScaleZAndUpdate( scaleZ ); activeComparisonView()->setScaleZAndUpdate( m_scaleZ );
} }
onUpdateScaleTransform(); onUpdateScaleTransform();
@ -1160,10 +1174,7 @@ void Rim3dView::updateScaling()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void Rim3dView::updateZScaleLabel() void Rim3dView::updateZScaleLabel()
{ {
// Update Z scale label if ( viewer() ) viewer()->setZScale( m_scaleZ() );
int scale = static_cast<int>( scaleZ() );
if ( viewer() ) viewer()->setZScale( scale );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1371,7 +1382,7 @@ cvf::ref<caf::DisplayCoordTransform> Rim3dView::displayCoordTransform() const
{ {
cvf::ref<caf::DisplayCoordTransform> coordTrans = new caf::DisplayCoordTransform; cvf::ref<caf::DisplayCoordTransform> coordTrans = new caf::DisplayCoordTransform;
cvf::Vec3d scale( 1.0, 1.0, scaleZ ); cvf::Vec3d scale( 1.0, 1.0, m_scaleZ );
coordTrans->setScale( scale ); coordTrans->setScale( scale );
RimCase* rimCase = ownerCase(); RimCase* rimCase = ownerCase();
@ -1416,6 +1427,13 @@ QList<caf::PdmOptionItemInfo> Rim3dView::calculateValueOptions( const caf::PdmFi
{ {
options = caf::FontTools::relativeSizeValueOptions( RiaPreferences::current()->defaultSceneFontSize() ); options = caf::FontTools::relativeSizeValueOptions( RiaPreferences::current()->defaultSceneFontSize() );
} }
else if ( fieldNeedingOptions == &m_scaleZ )
{
for ( auto scale : RiaDefines::viewScaleOptions() )
{
options.push_back( caf::PdmOptionItemInfo( QString::number( scale ), scale ) );
}
}
return options; return options;
} }

View File

@ -93,7 +93,6 @@ public:
// Public fields: // Public fields:
caf::PdmField<double> scaleZ;
caf::PdmField<bool> isPerspectiveView; caf::PdmField<bool> isPerspectiveView;
caf::PdmField<int> maximumFrameRate; caf::PdmField<int> maximumFrameRate;
@ -168,10 +167,12 @@ public:
void updateAnnotationItems(); void updateAnnotationItems();
void resetLegends(); void resetLegends();
void setScaleZ( double scaleZ );
void setScaleZAndUpdate( double scaleZ ); void setScaleZAndUpdate( double scaleZ );
void updateScaling(); void updateScaling();
void updateZScaleLabel(); void updateZScaleLabel();
bool isScaleZEditable(); bool isScaleZEditable();
double scaleZ() const;
bool isMasterView() const; bool isMasterView() const;
Rim3dView* activeComparisonView() const; Rim3dView* activeComparisonView() const;
@ -253,6 +254,9 @@ protected:
cvf::ref<cvf::ModelBasicList> m_intersectionVizModel; cvf::ref<cvf::ModelBasicList> m_intersectionVizModel;
cvf::ref<RivWellPathsPartMgr> m_wellPathsPartManager; cvf::ref<RivWellPathsPartMgr> m_wellPathsPartManager;
caf::PdmField<double> m_scaleZ;
caf::PdmField<double> m_customScaleZ;
private: private:
friend class RimProject; friend class RimProject;

View File

@ -466,19 +466,19 @@ void RimGridView::onClearReservoirCellVisibilitiesIfNecessary()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGridView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) void RimGridView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{ {
if ( changedField == &scaleZ ) if ( changedField == &m_scaleZ )
{ {
m_intersectionCollection->updateIntersectionBoxGeometry(); m_intersectionCollection->updateIntersectionBoxGeometry();
} }
Rim3dView::fieldChangedByUi( changedField, oldValue, newValue ); Rim3dView::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &scaleZ ) if ( changedField == &m_scaleZ )
{ {
RimViewLinker* viewLinker = this->assosiatedViewLinker(); RimViewLinker* viewLinker = this->assosiatedViewLinker();
if ( viewLinker ) if ( viewLinker )
{ {
viewLinker->updateScaleZ( this, scaleZ ); viewLinker->updateScaleZ( this, scaleZ() );
viewLinker->updateCamera( this ); viewLinker->updateCamera( this );
} }
} }

View File

@ -84,6 +84,7 @@
#include <QAction> #include <QAction>
#include <QCloseEvent> #include <QCloseEvent>
#include <QComboBox>
#include <QDir> #include <QDir>
#include <QDockWidget> #include <QDockWidget>
#include <QLabel> #include <QLabel>
@ -665,10 +666,14 @@ void RiuMainWindow::createToolBars()
scaleLabel->setText( "Scale" ); scaleLabel->setText( "Scale" );
toolbar->addWidget( scaleLabel ); toolbar->addWidget( scaleLabel );
m_scaleFactor = new QSpinBox( toolbar ); m_scaleFactor = new QComboBox( toolbar );
m_scaleFactor->setValue( 0 ); QStringList scaleItems;
for ( auto d : RiaDefines::viewScaleOptions() )
{
m_scaleFactor->addItem( QString::number( d ), QVariant( d ) );
}
toolbar->addWidget( m_scaleFactor ); toolbar->addWidget( m_scaleFactor );
connect( m_scaleFactor, SIGNAL( valueChanged( int ) ), SLOT( slotScaleChanged( int ) ) ); connect( m_scaleFactor, SIGNAL( currentIndexChanged( int ) ), SLOT( slotScaleChanged( int ) ) );
} }
{ {
@ -1867,11 +1872,13 @@ void RiuMainWindow::applyFontSizesToDockedPlots()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMainWindow::slotScaleChanged( int scaleValue ) void RiuMainWindow::slotScaleChanged( int index )
{ {
if ( RiaApplication::instance()->activeReservoirView() ) if ( RiaApplication::instance()->activeReservoirView() )
{ {
RiaApplication::instance()->activeReservoirView()->scaleZ.setValueWithFieldChanged( scaleValue ); double scaleValue = m_scaleFactor->currentData().toDouble();
RiaApplication::instance()->activeReservoirView()->setScaleZAndUpdate( scaleValue );
} }
} }
@ -1885,10 +1892,11 @@ void RiuMainWindow::updateScaleValue()
if ( isRegularReservoirView && view->isScaleZEditable() ) if ( isRegularReservoirView && view->isScaleZEditable() )
{ {
m_scaleFactor->setEnabled( true ); m_scaleFactor->setEnabled( true );
int scaleValue = static_cast<int>( view->scaleZ() ); // Round down is probably ok.
m_scaleFactor->blockSignals( true ); m_scaleFactor->blockSignals( true );
m_scaleFactor->setValue( scaleValue );
int index = m_scaleFactor->findData( QVariant( view->scaleZ() ) );
m_scaleFactor->setCurrentIndex( index );
m_scaleFactor->blockSignals( false ); m_scaleFactor->blockSignals( false );
} }
else else

View File

@ -35,7 +35,7 @@
class QActionGroup; class QActionGroup;
class QMdiSubWindow; class QMdiSubWindow;
class QToolButton; class QToolButton;
class QSpinBox; class QComboBox;
class QTimer; class QTimer;
class QUndoView; class QUndoView;
@ -255,7 +255,7 @@ private:
caf::PdmObject* m_pdmRoot; caf::PdmObject* m_pdmRoot;
caf::PdmUiPropertyView* m_pdmUiPropertyView; caf::PdmUiPropertyView* m_pdmUiPropertyView;
QSpinBox* m_scaleFactor; QComboBox* m_scaleFactor;
QActionGroup* m_dsActionGroup; QActionGroup* m_dsActionGroup;
QAction* m_enableLightingAction; QAction* m_enableLightingAction;