mirror of
https://github.com/OPM/ResInsight.git
synced 2024-12-29 10:21:54 -06:00
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:
parent
55eefbd53e
commit
6105813d28
@ -345,3 +345,11 @@ QString RiaDefines::stringListSeparator()
|
||||
{
|
||||
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 };
|
||||
}
|
||||
|
@ -225,4 +225,6 @@ constexpr enum MultiPlotPageUpdateType operator&( const enum MultiPlotPageUpdate
|
||||
return ( enum MultiPlotPageUpdateType )( uint32_t( selfValue ) & uint32_t( inValue ) );
|
||||
}
|
||||
|
||||
std::vector<double> viewScaleOptions();
|
||||
|
||||
}; // namespace RiaDefines
|
||||
|
@ -1476,10 +1476,11 @@ void RiaGuiApplication::applyGuiPreferences( const RiaPreferences*
|
||||
rim3dView->applyBackgroundColorAndFontChanges();
|
||||
}
|
||||
|
||||
if ( oldPreferences && ( applySettingsToAllViews ||
|
||||
rim3dView->scaleZ == static_cast<double>( oldPreferences->defaultScaleFactorZ() ) ) )
|
||||
if ( oldPreferences &&
|
||||
( 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();
|
||||
if ( rim3dView == activeViewWindow() )
|
||||
{
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "cafFrameAnimationControl.h"
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafPdmFieldScriptingCapabilityCvfColor3.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
|
||||
#include "cvfCamera.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
@ -115,13 +116,14 @@ Rim3dView::Rim3dView()
|
||||
CAF_PDM_InitScriptableField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection" );
|
||||
|
||||
double defaultScaleFactor = preferences->defaultScaleFactorZ();
|
||||
CAF_PDM_InitScriptableField( &scaleZ,
|
||||
CAF_PDM_InitScriptableField( &m_scaleZ,
|
||||
"GridZScale",
|
||||
defaultScaleFactor,
|
||||
"Z Scale",
|
||||
"",
|
||||
"Scales the scene in the Z direction",
|
||||
"" );
|
||||
m_scaleZ.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
|
||||
cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor();
|
||||
CAF_PDM_InitScriptableField( &m_backgroundColor, "BackgroundColor", defBackgColor, "Background" );
|
||||
@ -411,8 +413,8 @@ void Rim3dView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOr
|
||||
viewGroup->add( &m_comparisonView );
|
||||
|
||||
caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "Grid Appearance" );
|
||||
gridGroup->add( &scaleZ );
|
||||
scaleZ.uiCapability()->setUiReadOnly( !this->isScaleZEditable() );
|
||||
gridGroup->add( &m_scaleZ );
|
||||
m_scaleZ.uiCapability()->setUiReadOnly( !this->isScaleZEditable() );
|
||||
gridGroup->add( &meshMode );
|
||||
gridGroup->add( &surfaceMode );
|
||||
|
||||
@ -846,7 +848,7 @@ void Rim3dView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const
|
||||
{
|
||||
if ( m_viewer ) m_viewer->enableParallelProjection( !isPerspectiveView() );
|
||||
}
|
||||
else if ( changedField == &scaleZ )
|
||||
else if ( changedField == &m_scaleZ )
|
||||
{
|
||||
updateScaling();
|
||||
|
||||
@ -1081,7 +1083,7 @@ void Rim3dView::updateGridBoxData()
|
||||
}
|
||||
}
|
||||
|
||||
viewer()->updateGridBoxData( scaleZ(),
|
||||
viewer()->updateGridBoxData( m_scaleZ(),
|
||||
ownerCase()->displayModelOffset(),
|
||||
backgroundColor(),
|
||||
combinedDomainBBox,
|
||||
@ -1113,21 +1115,33 @@ void Rim3dView::resetLegends()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::setScaleZAndUpdate( double scalingFactor )
|
||||
{
|
||||
if ( this->scaleZ != scalingFactor )
|
||||
if ( scaleZ() != scalingFactor )
|
||||
{
|
||||
this->scaleZ = scalingFactor;
|
||||
|
||||
updateScaling();
|
||||
this->m_scaleZ.setValueWithFieldChanged( scalingFactor );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::setScaleZ( double scalingFactor )
|
||||
{
|
||||
m_scaleZ = scalingFactor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double Rim3dView::scaleZ() const
|
||||
{
|
||||
return m_scaleZ();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::updateScaling()
|
||||
{
|
||||
if ( scaleZ < 1 ) scaleZ = 1;
|
||||
|
||||
if ( viewer() )
|
||||
{
|
||||
cvf::Vec3d poi = viewer()->pointOfInterest();
|
||||
@ -1136,8 +1150,8 @@ void Rim3dView::updateScaling()
|
||||
dir = viewer()->mainCamera()->direction();
|
||||
up = viewer()->mainCamera()->up();
|
||||
|
||||
eye[2] = poi[2] * scaleZ() / this->scaleTransform()->worldTransform()( 2, 2 ) + ( eye[2] - poi[2] );
|
||||
poi[2] = poi[2] * scaleZ() / this->scaleTransform()->worldTransform()( 2, 2 );
|
||||
eye[2] = poi[2] * m_scaleZ() / this->scaleTransform()->worldTransform()( 2, 2 ) + ( eye[2] - poi[2] );
|
||||
poi[2] = poi[2] * m_scaleZ() / this->scaleTransform()->worldTransform()( 2, 2 );
|
||||
|
||||
viewer()->mainCamera()->setFromLookAt( eye, eye + dir, up );
|
||||
viewer()->setPointOfInterest( poi );
|
||||
@ -1145,7 +1159,7 @@ void Rim3dView::updateScaling()
|
||||
|
||||
if ( activeComparisonView() )
|
||||
{
|
||||
activeComparisonView()->setScaleZAndUpdate( scaleZ );
|
||||
activeComparisonView()->setScaleZAndUpdate( m_scaleZ );
|
||||
}
|
||||
|
||||
onUpdateScaleTransform();
|
||||
@ -1160,10 +1174,7 @@ void Rim3dView::updateScaling()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::updateZScaleLabel()
|
||||
{
|
||||
// Update Z scale label
|
||||
int scale = static_cast<int>( scaleZ() );
|
||||
|
||||
if ( viewer() ) viewer()->setZScale( scale );
|
||||
if ( viewer() ) viewer()->setZScale( m_scaleZ() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1371,7 +1382,7 @@ cvf::ref<caf::DisplayCoordTransform> Rim3dView::displayCoordTransform() const
|
||||
{
|
||||
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 );
|
||||
|
||||
RimCase* rimCase = ownerCase();
|
||||
@ -1416,6 +1427,13 @@ QList<caf::PdmOptionItemInfo> Rim3dView::calculateValueOptions( const caf::PdmFi
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -93,9 +93,8 @@ public:
|
||||
|
||||
// Public fields:
|
||||
|
||||
caf::PdmField<double> scaleZ;
|
||||
caf::PdmField<bool> isPerspectiveView;
|
||||
caf::PdmField<int> maximumFrameRate;
|
||||
caf::PdmField<bool> isPerspectiveView;
|
||||
caf::PdmField<int> maximumFrameRate;
|
||||
|
||||
// Draw style
|
||||
|
||||
@ -168,10 +167,12 @@ public:
|
||||
void updateAnnotationItems();
|
||||
void resetLegends();
|
||||
|
||||
void setScaleZAndUpdate( double scaleZ );
|
||||
void updateScaling();
|
||||
void updateZScaleLabel();
|
||||
bool isScaleZEditable();
|
||||
void setScaleZ( double scaleZ );
|
||||
void setScaleZAndUpdate( double scaleZ );
|
||||
void updateScaling();
|
||||
void updateZScaleLabel();
|
||||
bool isScaleZEditable();
|
||||
double scaleZ() const;
|
||||
|
||||
bool isMasterView() const;
|
||||
Rim3dView* activeComparisonView() const;
|
||||
@ -253,6 +254,9 @@ protected:
|
||||
cvf::ref<cvf::ModelBasicList> m_intersectionVizModel;
|
||||
cvf::ref<RivWellPathsPartMgr> m_wellPathsPartManager;
|
||||
|
||||
caf::PdmField<double> m_scaleZ;
|
||||
caf::PdmField<double> m_customScaleZ;
|
||||
|
||||
private:
|
||||
friend class RimProject;
|
||||
|
||||
|
@ -466,19 +466,19 @@ void RimGridView::onClearReservoirCellVisibilitiesIfNecessary()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &scaleZ )
|
||||
if ( changedField == &m_scaleZ )
|
||||
{
|
||||
m_intersectionCollection->updateIntersectionBoxGeometry();
|
||||
}
|
||||
|
||||
Rim3dView::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
|
||||
if ( changedField == &scaleZ )
|
||||
if ( changedField == &m_scaleZ )
|
||||
{
|
||||
RimViewLinker* viewLinker = this->assosiatedViewLinker();
|
||||
if ( viewLinker )
|
||||
{
|
||||
viewLinker->updateScaleZ( this, scaleZ );
|
||||
viewLinker->updateScaleZ( this, scaleZ() );
|
||||
viewLinker->updateCamera( this );
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,7 @@
|
||||
|
||||
#include <QAction>
|
||||
#include <QCloseEvent>
|
||||
#include <QComboBox>
|
||||
#include <QDir>
|
||||
#include <QDockWidget>
|
||||
#include <QLabel>
|
||||
@ -665,10 +666,14 @@ void RiuMainWindow::createToolBars()
|
||||
scaleLabel->setText( "Scale" );
|
||||
toolbar->addWidget( scaleLabel );
|
||||
|
||||
m_scaleFactor = new QSpinBox( toolbar );
|
||||
m_scaleFactor->setValue( 0 );
|
||||
m_scaleFactor = new QComboBox( toolbar );
|
||||
QStringList scaleItems;
|
||||
for ( auto d : RiaDefines::viewScaleOptions() )
|
||||
{
|
||||
m_scaleFactor->addItem( QString::number( d ), QVariant( d ) );
|
||||
}
|
||||
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() )
|
||||
{
|
||||
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() )
|
||||
{
|
||||
m_scaleFactor->setEnabled( true );
|
||||
|
||||
int scaleValue = static_cast<int>( view->scaleZ() ); // Round down is probably ok.
|
||||
m_scaleFactor->blockSignals( true );
|
||||
m_scaleFactor->setValue( scaleValue );
|
||||
|
||||
int index = m_scaleFactor->findData( QVariant( view->scaleZ() ) );
|
||||
m_scaleFactor->setCurrentIndex( index );
|
||||
|
||||
m_scaleFactor->blockSignals( false );
|
||||
}
|
||||
else
|
||||
|
@ -35,7 +35,7 @@
|
||||
class QActionGroup;
|
||||
class QMdiSubWindow;
|
||||
class QToolButton;
|
||||
class QSpinBox;
|
||||
class QComboBox;
|
||||
class QTimer;
|
||||
class QUndoView;
|
||||
|
||||
@ -255,7 +255,7 @@ private:
|
||||
caf::PdmObject* m_pdmRoot;
|
||||
caf::PdmUiPropertyView* m_pdmUiPropertyView;
|
||||
|
||||
QSpinBox* m_scaleFactor;
|
||||
QComboBox* m_scaleFactor;
|
||||
|
||||
QActionGroup* m_dsActionGroup;
|
||||
QAction* m_enableLightingAction;
|
||||
|
Loading…
Reference in New Issue
Block a user