mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4892 Add Comparison view drop-down to linked view master.
Works as shadow of the views comparison view setting. Make it follow the dependent viewcontrollers managed view. Comparison view dropdown moved to "Viewer" group in view panel. Avoid infinite recursion loops when comparison views are set up in circle
This commit is contained in:
parent
27d65af027
commit
6af4356f36
@ -80,6 +80,7 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT( Rim3dView, "GenericView" ); // Do not use. Abs
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Rim3dView::Rim3dView( void )
|
||||
: m_isCallingUpdateTimestepAndRedraw( false )
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
RiaPreferences* preferences = app->preferences();
|
||||
@ -129,7 +130,6 @@ Rim3dView::Rim3dView( void )
|
||||
|
||||
CAF_PDM_InitField( &m_showZScaleLabel, "ShowZScale", true, "Show Z Scale Label", "", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_isComparisonViewEnabled, "EnableComparisonView", false, "Enable", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_comparisonView, "ComparisonView", "Comparison View", "", "", "" );
|
||||
|
||||
m_crossSectionVizModel = new cvf::ModelBasicList;
|
||||
@ -322,6 +322,7 @@ void Rim3dView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOr
|
||||
viewGroup->add( &m_showGridBox );
|
||||
viewGroup->add( &isPerspectiveView );
|
||||
viewGroup->add( &m_disableLighting );
|
||||
viewGroup->add( &m_comparisonView );
|
||||
|
||||
caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "Grid Appearance" );
|
||||
gridGroup->add( &scaleZ );
|
||||
@ -329,10 +330,6 @@ void Rim3dView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOr
|
||||
gridGroup->add( &meshMode );
|
||||
gridGroup->add( &surfaceMode );
|
||||
|
||||
caf::PdmUiGroup* compViewGroup = uiOrdering.addNewGroup( "Comparison View" );
|
||||
compViewGroup->add( &m_isComparisonViewEnabled );
|
||||
compViewGroup->add( &m_comparisonView );
|
||||
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
@ -412,6 +409,15 @@ bool Rim3dView::isScaleZEditable()
|
||||
( this->viewController() && this->viewController()->isCameraLinked() ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::setComparisonView( Rim3dView* compView )
|
||||
{
|
||||
m_comparisonView = compView;
|
||||
m_comparisonView.uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -484,6 +490,8 @@ void Rim3dView::setCurrentTimeStep( int frameIndex )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::updateCurrentTimeStepAndRedraw()
|
||||
{
|
||||
if ( m_isCallingUpdateTimestepAndRedraw ) return;
|
||||
|
||||
if ( nativeOrOverrideViewer() )
|
||||
{
|
||||
this->updateCurrentTimeStep();
|
||||
@ -498,6 +506,8 @@ void Rim3dView::updateCurrentTimeStepAndRedraw()
|
||||
nativeOrOverrideViewer()->update();
|
||||
}
|
||||
|
||||
m_isCallingUpdateTimestepAndRedraw = true;
|
||||
|
||||
std::set<Rim3dView*> containerViews = this->viewsUsingThisAsComparisonView();
|
||||
if ( !containerViews.empty() && !isUsingOverrideViewer() )
|
||||
{
|
||||
@ -506,6 +516,7 @@ void Rim3dView::updateCurrentTimeStepAndRedraw()
|
||||
view->updateCurrentTimeStepAndRedraw();
|
||||
}
|
||||
}
|
||||
m_isCallingUpdateTimestepAndRedraw = false;
|
||||
|
||||
RimProject* project;
|
||||
firstAncestorOrThisOfTypeAsserted( project );
|
||||
@ -806,18 +817,10 @@ void Rim3dView::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
m_viewer->showZScaleLabel( m_showZScaleLabel() );
|
||||
m_viewer->update();
|
||||
}
|
||||
else if ( changedField == &m_isComparisonViewEnabled )
|
||||
else if ( changedField == &m_comparisonView )
|
||||
{
|
||||
createDisplayModelAndRedraw();
|
||||
}
|
||||
else if ( changedField == &m_comparisonView )
|
||||
{
|
||||
if ( m_isComparisonViewEnabled() )
|
||||
{
|
||||
createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -974,9 +977,12 @@ void Rim3dView::updateAnnotationItems()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::setScaleZAndUpdate( double scalingFactor )
|
||||
{
|
||||
this->scaleZ = scalingFactor;
|
||||
if ( this->scaleZ != scalingFactor )
|
||||
{
|
||||
this->scaleZ = scalingFactor;
|
||||
|
||||
updateScaling();
|
||||
updateScaling();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1001,9 +1007,9 @@ void Rim3dView::updateScaling()
|
||||
viewer()->setPointOfInterest( poi );
|
||||
}
|
||||
|
||||
if (activeComparisonView())
|
||||
if ( activeComparisonView() )
|
||||
{
|
||||
activeComparisonView()->setScaleZAndUpdate(scaleZ);
|
||||
activeComparisonView()->setScaleZAndUpdate( scaleZ );
|
||||
}
|
||||
|
||||
updateScaleTransform();
|
||||
@ -1403,14 +1409,7 @@ void Rim3dView::appendMeasurementToModel()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Rim3dView* Rim3dView::activeComparisonView() const
|
||||
{
|
||||
if ( m_isComparisonViewEnabled() )
|
||||
{
|
||||
return m_comparisonView();
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return m_comparisonView();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1430,7 +1429,6 @@ Rim3dView* Rim3dView::prepareComparisonView()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
if ( depView->scaleZ() != scaleZ() )
|
||||
{
|
||||
depView->setScaleZAndUpdate( scaleZ() );
|
||||
@ -1452,6 +1450,5 @@ void Rim3dView::restoreComparisonView()
|
||||
CVF_ASSERT( depView );
|
||||
|
||||
depView->setOverrideViewer( nullptr );
|
||||
viewer()->setCurrentComparisonFrame(depView->currentTimeStep());
|
||||
|
||||
viewer()->setCurrentComparisonFrame( depView->currentTimeStep() );
|
||||
}
|
||||
|
@ -166,6 +166,7 @@ public:
|
||||
bool isMasterView() const;
|
||||
Rim3dView* activeComparisonView() const;
|
||||
bool isScaleZEditable();
|
||||
void setComparisonView(Rim3dView* compView);
|
||||
|
||||
std::set<Rim3dView*> viewsUsingThisAsComparisonView();
|
||||
|
||||
@ -310,6 +311,7 @@ private:
|
||||
QPointer<RiuViewer> m_overrideViewer;
|
||||
int m_comparisonViewOrgTimestep;
|
||||
double m_comparisonViewOrgZScale;
|
||||
bool m_isCallingUpdateTimestepAndRedraw; // To avoid infinite recursion if comparison views are pointing to each other.
|
||||
|
||||
caf::PdmField<QString> m_name_OBSOLETE;
|
||||
caf::PdmChildField<RimViewNameConfig*> m_nameConfig;
|
||||
@ -319,6 +321,5 @@ private:
|
||||
caf::PdmField<cvf::Color3f> m_backgroundColor;
|
||||
caf::PdmField<bool> m_showGridBox;
|
||||
caf::PdmField<bool> m_showZScaleLabel;
|
||||
caf::PdmField<bool> m_isComparisonViewEnabled;
|
||||
caf::PdmPtrField<Rim3dView*> m_comparisonView;
|
||||
};
|
||||
|
@ -216,6 +216,8 @@ void RimViewController::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel
|
||||
RimGridView* previousManagedView = dynamic_cast<RimGridView*>( prevValue );
|
||||
RimViewController::removeOverrides( previousManagedView );
|
||||
|
||||
ownerViewLinker()->notifyManagedViewChange(previousManagedView, m_managedView());
|
||||
|
||||
setManagedView( m_managedView() );
|
||||
|
||||
m_name.uiCapability()->updateConnectedEditors();
|
||||
@ -469,6 +471,11 @@ RimGridView* RimViewController::managedView() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewController::setManagedView( RimGridView* view )
|
||||
{
|
||||
if (m_managedView != view)
|
||||
{
|
||||
ownerViewLinker()->notifyManagedViewChange(m_managedView(), view);
|
||||
}
|
||||
|
||||
m_managedView = view;
|
||||
|
||||
updateOptionSensitivity();
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "RiaOptionItemFactory.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafQIconProvider.h"
|
||||
#include "cvfCamera.h"
|
||||
@ -70,6 +71,10 @@ RimViewLinker::RimViewLinker()
|
||||
CAF_PDM_InitFieldNoDefault(&m_viewControllers, "ManagedViews", "Managed Views", "", "", "");
|
||||
m_viewControllers.uiCapability()->setUiHidden(true);
|
||||
m_viewControllers.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_comparisonView, "LinkedComparisonView", "Comparison View", "", "", "");
|
||||
m_comparisonView.xmlCapability()->disableIO();
|
||||
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
@ -343,6 +348,10 @@ void RimViewLinker::allViews( std::vector<RimGridView*>& views ) const
|
||||
void RimViewLinker::initAfterRead()
|
||||
{
|
||||
updateUiNameAndIcon();
|
||||
if ( m_masterView() )
|
||||
{
|
||||
m_comparisonView = dynamic_cast<RimGridView*>( m_masterView->activeComparisonView() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -476,6 +485,94 @@ void RimViewLinker::updateCursorPosition( const RimGridView* sourceView, const c
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::notifyManagedViewChange( RimGridView* oldManagedView, RimGridView* newManagedView )
|
||||
{
|
||||
if ( oldManagedView == m_comparisonView )
|
||||
{
|
||||
m_comparisonView = newManagedView;
|
||||
m_comparisonView.uiCapability()->updateConnectedEditors();
|
||||
|
||||
if ( masterView() )
|
||||
{
|
||||
masterView()->setComparisonView( m_comparisonView() );
|
||||
masterView()->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimViewLinker::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
RimGridView* actualComparisonView = nullptr;
|
||||
if ( m_masterView() )
|
||||
{
|
||||
actualComparisonView = dynamic_cast<RimGridView*>( m_masterView->activeComparisonView() );
|
||||
}
|
||||
|
||||
bool isActiveCompViewInList = false;
|
||||
for ( const auto& viewController : m_viewControllers )
|
||||
{
|
||||
if ( viewController->managedView() )
|
||||
{
|
||||
RiaOptionItemFactory::appendOptionItemFromViewNameAndCaseName( viewController->managedView(), &options );
|
||||
if ( viewController->managedView() == actualComparisonView )
|
||||
{
|
||||
isActiveCompViewInList = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isActiveCompViewInList )
|
||||
{
|
||||
// Add the actually used comparison view to the option list, even though it is not one of the linked views
|
||||
options.push_front( caf::PdmOptionItemInfo( actualComparisonView->autoName(),
|
||||
actualComparisonView,
|
||||
false,
|
||||
actualComparisonView->uiCapability()->uiIconProvider() ) );
|
||||
}
|
||||
|
||||
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
// Update the comparison view from the master view
|
||||
if ( m_masterView() )
|
||||
{
|
||||
m_comparisonView = dynamic_cast<RimGridView*>( m_masterView->activeComparisonView() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_comparisonView )
|
||||
{
|
||||
if ( masterView() )
|
||||
{
|
||||
masterView()->setComparisonView( m_comparisonView() );
|
||||
masterView()->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -91,12 +91,24 @@ public:
|
||||
|
||||
void updateCursorPosition( const RimGridView* sourceView, const cvf::Vec3d& domainCoord );
|
||||
|
||||
void notifyManagedViewChange(RimGridView* oldManagedView, RimGridView* newManagedView);
|
||||
|
||||
protected:
|
||||
caf::PdmFieldHandle* userDescriptionField() override
|
||||
{
|
||||
return &m_name;
|
||||
}
|
||||
|
||||
void initAfterRead() override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue ) override;
|
||||
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly ) override;
|
||||
|
||||
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
private:
|
||||
static QString displayNameForView( RimGridView* view );
|
||||
@ -109,4 +121,5 @@ private:
|
||||
caf::PdmChildArrayField<RimViewController*> m_viewControllers;
|
||||
caf::PdmPtrField<RimGridView*> m_masterView;
|
||||
caf::PdmField<QString> m_name;
|
||||
caf::PdmPtrField<RimGridView*> m_comparisonView;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user