ResInsight/ApplicationCode/ProjectDataModel/Rim3dView.cpp

1397 lines
49 KiB
C++
Raw Normal View History

2018-01-09 03:11:28 -06:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
2019-09-06 06:17:36 -05:00
//
2018-01-09 03:11:28 -06:00
// ResInsight 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.
2019-09-06 06:17:36 -05:00
//
2018-01-09 03:11:28 -06:00
// ResInsight 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.
2019-09-06 06:17:36 -05:00
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
2018-01-09 03:11:28 -06:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "Rim3dView.h"
#include "RiaFieldHandleTools.h"
2019-09-06 06:17:36 -05:00
#include "RiaGuiApplication.h"
#include "RiaOptionItemFactory.h"
2018-01-09 03:11:28 -06:00
#include "RiaPreferences.h"
#include "RiaViewRedrawScheduler.h"
2018-01-09 03:11:28 -06:00
#include "RicfCommandObject.h"
#include "Rim3dWellLogCurve.h"
#include "RimAnnotationInViewCollection.h"
2019-09-06 06:17:36 -05:00
#include "RimCase.h"
#include "RimGridView.h"
2018-01-09 03:11:28 -06:00
#include "RimMainPlotCollection.h"
2019-09-06 06:17:36 -05:00
#include "RimMeasurement.h"
2018-01-09 03:11:28 -06:00
#include "RimProject.h"
#include "RimTools.h"
2018-01-09 03:11:28 -06:00
#include "RimViewController.h"
#include "RimViewLinker.h"
#include "RimViewManipulator.h"
#include "RimViewNameConfig.h"
2019-09-06 06:17:36 -05:00
#include "RimWellPathCollection.h"
2018-01-09 03:11:28 -06:00
#include "RivAnnotationsPartMgr.h"
#include "RivMeasurementPartMgr.h"
2019-09-06 06:17:36 -05:00
#include "RivWellPathsPartMgr.h"
2018-01-09 03:11:28 -06:00
#include "RiuMainWindow.h"
#include "RiuTimeStepChangedHandler.h"
2019-09-06 06:17:36 -05:00
#include "RiuViewer.h"
2018-01-09 03:11:28 -06:00
#include "cafDisplayCoordTransform.h"
#include "cafFrameAnimationControl.h"
#include "cvfCamera.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfTransform.h"
2018-01-09 03:11:28 -06:00
#include "cvfViewport.h"
#include "cvfScene.h"
2019-09-06 06:17:36 -05:00
#include <climits>
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
namespace caf
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
template <>
void caf::AppEnum<Rim3dView::SurfaceModeType>::setUp()
{
addItem( Rim3dView::SURFACE, "SURFACE", "All" );
addItem( Rim3dView::FAULTS, "FAULTS", "Faults only" );
addItem( Rim3dView::NO_SURFACE, "NO_SURFACE", "None" );
setDefault( Rim3dView::SURFACE );
2018-01-09 03:11:28 -06:00
}
} // End namespace caf
2019-09-06 06:17:36 -05:00
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( Rim3dView, "GenericView" ); // Do not use. Abstract class
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
Rim3dView::Rim3dView( void )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
RiaApplication* app = RiaApplication::instance();
2018-01-09 03:11:28 -06:00
RiaPreferences* preferences = app->preferences();
2019-09-06 06:17:36 -05:00
CVF_ASSERT( preferences );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "", "", "", "" );
m_nameConfig = new RimViewNameConfig();
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
CAF_PDM_InitField( &m_name_OBSOLETE, "UserDescription", QString( "" ), "Name", "", "", "" );
m_name_OBSOLETE.xmlCapability()->setIOWritable( false );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
CAF_PDM_InitField( &m_cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", "" );
m_cameraPosition.uiCapability()->setUiHidden( true );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
CAF_PDM_InitField( &m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", "" );
m_cameraPointOfInterest.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", "" );
2018-01-09 03:11:28 -06:00
double defaultScaleFactor = preferences->defaultScaleFactorZ;
2019-09-06 06:17:36 -05:00
CAF_PDM_InitField( &scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", "" );
2018-01-09 03:11:28 -06:00
cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor();
2019-09-06 06:17:36 -05:00
RICF_InitField( &m_backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", "" );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
CAF_PDM_InitField( &maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", "" );
maximumFrameRate.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", "" );
hasUserRequestedAnimation.uiCapability()->setUiHidden( true );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
CAF_PDM_InitField( &m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", "" );
m_currentTimeStep.uiCapability()->setUiHidden( true );
2018-01-09 03:11:28 -06:00
caf::AppEnum<RiaDefines::MeshModeType> defaultMeshType = preferences->defaultMeshModeType();
2019-09-06 06:17:36 -05:00
CAF_PDM_InitField( &meshMode, "MeshMode", defaultMeshType, "Grid Lines", "", "", "" );
CAF_PDM_InitFieldNoDefault( &surfaceMode, "SurfaceMode", "Grid Surface", "", "", "" );
RICF_InitField( &m_showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", "" );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
CAF_PDM_InitField( &m_disableLighting,
"DisableLighting",
false,
"Disable Results Lighting",
"",
"Disable light model for scalar result colors",
"" );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
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", "", "", "" );
CAF_PDM_InitField( &m_isComparisonViewLinkingTimestep,
"EnableComparisonViewTimestepLinking",
true,
"Link Timestep",
"",
"",
"" );
2018-01-09 03:11:28 -06:00
m_crossSectionVizModel = new cvf::ModelBasicList;
2019-09-06 06:17:36 -05:00
m_crossSectionVizModel->setName( "CrossSectionModel" );
2018-01-09 03:11:28 -06:00
m_highlightVizModel = new cvf::ModelBasicList;
2019-09-06 06:17:36 -05:00
m_highlightVizModel->setName( "HighlightModel" );
2018-01-09 03:11:28 -06:00
m_wellPathPipeVizModel = new cvf::ModelBasicList;
2019-09-06 06:17:36 -05:00
m_wellPathPipeVizModel->setName( "WellPathPipeModel" );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
m_wellPathsPartManager = new RivWellPathsPartMgr( this );
m_annotationsPartManager = new RivAnnotationsPartMgr( this );
2019-09-06 06:17:36 -05:00
m_measurementPartManager = new RivMeasurementPartMgr( this );
2018-01-09 03:11:28 -06:00
this->setAs3DViewMdiWindow();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
Rim3dView::~Rim3dView( void )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
if ( m_viewer )
{
m_viewer->clearRimView();
}
2018-01-09 03:11:28 -06:00
removeMdiWindowFromMdiArea();
deleteViewWidget();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2018-09-12 03:04:15 -05:00
RiuViewer* Rim3dView::viewer() const
2018-01-09 03:11:28 -06:00
{
return m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuViewer* Rim3dView::nativeOrOverrideViewer() const
{
if ( m_overrideViewer ) return m_overrideViewer;
return m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::setOverrideViewer( RiuViewer* overrideViewer )
{
m_overrideViewer = overrideViewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Rim3dView::isUsingOverrideViewer() const
{
return m_overrideViewer != nullptr;
}
2018-09-24 15:15:34 -05:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-09-24 15:15:34 -05:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::setName( const QString& name )
2018-09-24 15:15:34 -05:00
{
2019-09-06 06:17:36 -05:00
m_nameConfig->setCustomName( name );
2018-09-24 15:15:34 -05:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-09-24 15:15:34 -05:00
//--------------------------------------------------------------------------------------------------
QString Rim3dView::name() const
{
return m_nameConfig->customName();
2018-09-24 15:15:34 -05:00
}
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
QWidget* Rim3dView::createViewWidget( QWidget* mainWindowParent )
2018-01-09 03:11:28 -06:00
{
QGLFormat glFormat;
2019-09-06 06:17:36 -05:00
glFormat.setDirectRendering( RiaGuiApplication::instance()->useShaders() );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
m_viewer = new RiuViewer( glFormat, mainWindowParent );
m_viewer->setOwnerReservoirView( this );
2018-01-09 03:11:28 -06:00
cvf::String xLabel;
cvf::String yLabel;
cvf::String zLabel;
2019-09-06 06:17:36 -05:00
this->axisLabels( &xLabel, &yLabel, &zLabel );
m_viewer->setAxisLabels( xLabel, yLabel, zLabel );
updateZScaleLabel();
2018-01-09 03:11:28 -06:00
return m_viewer->layoutWidget();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateViewWidgetAfterCreation()
{
2019-09-06 06:17:36 -05:00
m_viewer->setDefaultPerspectiveNearPlaneDistance( 10 );
2018-01-09 03:11:28 -06:00
this->resetLegendsInViewer();
m_viewer->updateNavigationPolicy();
2019-09-06 06:17:36 -05:00
m_viewer->enablePerfInfoHud( RiaGuiApplication::instance()->showPerformanceInfo() );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
m_viewer->mainCamera()->setViewMatrix( m_cameraPosition );
m_viewer->setPointOfInterest( m_cameraPointOfInterest() );
m_viewer->enableParallelProjection( !isPerspectiveView() );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
m_viewer->mainCamera()->viewport()->setClearColor( cvf::Color4f( backgroundColor() ) );
2018-01-09 03:11:28 -06:00
this->updateGridBoxData();
this->updateAnnotationItems();
this->createHighlightAndGridBoxDisplayModel();
m_viewer->update();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::initAfterRead()
{
RimViewWindow::initAfterRead();
2019-09-06 06:17:36 -05:00
if ( !m_name_OBSOLETE().isEmpty() )
{
2019-09-06 06:17:36 -05:00
nameConfig()->setCustomName( m_name_OBSOLETE() );
nameConfig()->setAddCaseName( false );
nameConfig()->setAddAggregationType( false );
nameConfig()->setAddProperty( false );
nameConfig()->setAddSampleSpacing( false );
}
}
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateMdiWindowTitle()
{
2019-09-06 06:17:36 -05:00
if ( m_viewer )
2018-01-09 03:11:28 -06:00
{
QString windowTitle;
2019-09-06 06:17:36 -05:00
if ( ownerCase() )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
windowTitle = QString( "%1 - %2" ).arg( ownerCase()->caseUserDescription() ).arg( name() );
2018-01-09 03:11:28 -06:00
}
else
{
windowTitle = name();
2018-01-09 03:11:28 -06:00
}
2019-09-06 06:17:36 -05:00
m_viewer->layoutWidget()->setWindowTitle( windowTitle );
2018-01-09 03:11:28 -06:00
}
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::deleteViewWidget()
{
2019-09-06 06:17:36 -05:00
// Earlier implementations has used m_viewer->deleteLater(). This caused issues triggered by 3D editors and
// interaction with the event processing. deleteLater() will not be handeled by processEvents() if we are in the
// state of processing UI events, ie in the process of handling a QAction
delete m_viewer;
m_viewer = nullptr;
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
2018-01-09 03:11:28 -06:00
{
RimViewWindow::defineUiOrdering( uiConfigName, uiOrdering );
2019-07-15 04:43:22 -05:00
2019-09-06 06:17:36 -05:00
caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroupWithKeyword( "Viewer", "ViewGroup" );
2019-09-06 06:17:36 -05:00
viewGroup->add( &m_backgroundColor );
viewGroup->add( &m_showZScaleLabel );
viewGroup->add( &m_showGridBox );
viewGroup->add( &isPerspectiveView );
viewGroup->add( &m_disableLighting );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "Grid Appearance" );
gridGroup->add( &scaleZ );
gridGroup->add( &meshMode );
gridGroup->add( &surfaceMode );
caf::PdmUiGroup* compViewGroup = uiOrdering.addNewGroup( "Comparison View" );
compViewGroup->add( &m_isComparisonViewEnabled );
compViewGroup->add( &m_comparisonView );
compViewGroup->add( &m_isComparisonViewLinkingTimestep );
2019-09-06 06:17:36 -05:00
uiOrdering.skipRemainingFields( true );
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
QImage Rim3dView::snapshotWindowContent()
{
2019-09-06 06:17:36 -05:00
if ( m_viewer )
2018-01-09 03:11:28 -06:00
{
// Force update of scheduled display models before snapshotting
RiaViewRedrawScheduler::instance()->updateAndRedrawScheduledViews();
2018-01-09 03:11:28 -06:00
m_viewer->repaint();
return m_viewer->snapshotImage();
}
return QImage();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::scheduleCreateDisplayModelAndRedraw()
{
2019-09-06 06:17:36 -05:00
RiaViewRedrawScheduler::instance()->scheduleDisplayModelUpdateAndRedraw( this );
if ( this->isMasterView() )
2018-01-09 03:11:28 -06:00
{
RimViewLinker* viewLinker = this->assosiatedViewLinker();
2019-09-06 06:17:36 -05:00
if ( viewLinker )
2018-01-09 03:11:28 -06:00
{
viewLinker->scheduleCreateDisplayModelAndRedrawForDependentViews();
}
}
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::setCurrentTimeStepAndUpdate( int frameIndex )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
setCurrentTimeStep( frameIndex );
2018-01-09 03:11:28 -06:00
this->updateCurrentTimeStep();
if ( Rim3dView* depView = activeComparisonView() )
{
prepareComparisonView();
depView->updateCurrentTimeStep();
depView->appendAnnotationsToModel();
depView->appendMeasurementToModel();
restoreComparisonView();
}
2018-01-09 03:11:28 -06:00
RimProject* project;
2019-09-06 06:17:36 -05:00
firstAncestorOrThisOfTypeAsserted( project );
2018-01-09 03:11:28 -06:00
project->mainPlotCollection()->updateCurrentTimeStepInPlots();
appendAnnotationsToModel();
appendMeasurementToModel();
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Rim3dView::isTimeStepDependentDataVisibleInThisOrComparisonView() const
{
Rim3dView* otherView = activeComparisonView();
if ( !otherView && isUsingOverrideViewer() )
{
otherView = dynamic_cast<Rim3dView*>( nativeOrOverrideViewer()->ownerReservoirView() );
}
return ( isTimeStepDependentDataVisible() || ( otherView && otherView->isTimeStepDependentDataVisible() ) );
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
QString Rim3dView::timeStepName( int frameIdx ) const
{
2019-09-06 06:17:36 -05:00
return this->ownerCase()->timeStepName( frameIdx );
}
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::setCurrentTimeStep( int frameIndex )
2018-01-09 03:11:28 -06:00
{
const int oldTimeStep = m_currentTimeStep;
m_currentTimeStep = frameIndex;
clampCurrentTimestep();
2019-09-06 06:17:36 -05:00
if ( m_currentTimeStep != oldTimeStep )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
RiuTimeStepChangedHandler::instance()->handleTimeStepChanged( this );
this->onTimeStepChanged();
2018-01-09 03:11:28 -06:00
}
this->hasUserRequestedAnimation = true;
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateCurrentTimeStepAndRedraw()
{
this->updateCurrentTimeStep();
if ( Rim3dView* depView = activeComparisonView() )
{
prepareComparisonView();
depView->updateCurrentTimeStep();
restoreComparisonView();
}
2018-01-09 03:11:28 -06:00
RimProject* project;
2019-09-06 06:17:36 -05:00
firstAncestorOrThisOfTypeAsserted( project );
2018-01-09 03:11:28 -06:00
project->mainPlotCollection()->updateCurrentTimeStepInPlots();
if ( nativeOrOverrideViewer() ) nativeOrOverrideViewer()->update();
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::createDisplayModelAndRedraw()
{
if ( nativeOrOverrideViewer() )
2018-01-09 03:11:28 -06:00
{
this->clampCurrentTimestep();
updateScaleTransform();
2018-01-09 03:11:28 -06:00
createDisplayModel();
createHighlightAndGridBoxDisplayModel();
updateDisplayModelVisibility();
2019-09-06 06:17:36 -05:00
if ( m_cameraPosition().isIdentity() )
2018-01-09 03:11:28 -06:00
{
setDefaultView();
m_cameraPosition = nativeOrOverrideViewer()->mainCamera()->viewMatrix();
m_cameraPointOfInterest = nativeOrOverrideViewer()->pointOfInterest();
}
if ( Rim3dView* depView = activeComparisonView() )
{
prepareComparisonView();
depView->createDisplayModelAndRedraw();
if ( isTimeStepDependentDataVisibleInThisOrComparisonView() )
{
// To make the override viewer see the new frame (skeletons) created by createDisplayModelAndRedraw
nativeOrOverrideViewer()->slotSetCurrentFrame( currentTimeStep() );
depView->updateCurrentTimeStep();
}
restoreComparisonView();
}
else if ( viewer() )
{
// Remove the comparison scene data
viewer()->setMainScene( nullptr, true );
viewer()->removeAllFrames( true );
2018-01-09 03:11:28 -06:00
}
}
2019-09-06 06:17:36 -05:00
if ( RiuMainWindow::instance() )
{
RiuMainWindow::instance()->refreshAnimationActions();
}
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::removeModelByName( cvf::Scene* scene, const cvf::String& modelName )
{
std::vector<cvf::Model*> modelsToBeRemoved;
2019-09-06 06:17:36 -05:00
for ( cvf::uint i = 0; i < scene->modelCount(); i++ )
{
2019-09-06 06:17:36 -05:00
if ( scene->model( i )->name() == modelName )
{
2019-09-06 06:17:36 -05:00
modelsToBeRemoved.push_back( scene->model( i ) );
}
}
2019-09-06 06:17:36 -05:00
for ( size_t i = 0; i < modelsToBeRemoved.size(); i++ )
{
2019-09-06 06:17:36 -05:00
scene->removeModel( modelsToBeRemoved[i] );
}
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::setDefaultView()
{
2019-09-06 06:17:36 -05:00
if ( m_viewer )
2018-01-09 03:11:28 -06:00
{
m_viewer->setDefaultView();
}
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::endAnimation()
{
this->hasUserRequestedAnimation = false;
this->updateStaticCellColors();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2018-01-31 08:53:02 -06:00
RimWellPathCollection* Rim3dView::wellPathCollection() const
2018-01-09 03:11:28 -06:00
{
return RimTools::wellPathCollection();
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
bool Rim3dView::hasVisibleTimeStepDependent3dWellLogCurves() const
{
2019-09-06 06:17:36 -05:00
if ( wellPathCollection() )
{
std::vector<Rim3dWellLogCurve*> wellLogCurves;
2019-09-06 06:17:36 -05:00
wellPathCollection()->descendantsIncludingThisOfType( wellLogCurves );
for ( const Rim3dWellLogCurve* curve : wellLogCurves )
{
2019-09-06 06:17:36 -05:00
if ( curve->showInView( this ) && curve->isShowingTimeDependentResult() )
{
return true;
}
}
}
return false;
}
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::setupBeforeSave()
{
2019-09-06 06:17:36 -05:00
if ( m_viewer )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
hasUserRequestedAnimation =
m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go,
// and store the user intentions. But I guess that in practice...
m_cameraPosition = m_viewer->mainCamera()->viewMatrix();
m_cameraPointOfInterest = m_viewer->pointOfInterest();
2018-01-09 03:11:28 -06:00
}
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::setMeshOnlyDrawstyle()
{
2019-09-06 06:17:36 -05:00
meshMode.setValueWithFieldChanged( RiaDefines::FULL_MESH );
surfaceMode.setValueWithFieldChanged( NO_SURFACE );
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::setMeshSurfDrawstyle()
{
2019-09-06 06:17:36 -05:00
surfaceMode.setValueWithFieldChanged( SURFACE );
meshMode.setValueWithFieldChanged( RiaDefines::FULL_MESH );
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::setFaultMeshSurfDrawstyle()
{
2019-09-06 06:17:36 -05:00
surfaceMode.setValueWithFieldChanged( SURFACE );
meshMode.setValueWithFieldChanged( RiaDefines::FAULTS_MESH );
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::setSurfOnlyDrawstyle()
{
2019-09-06 06:17:36 -05:00
surfaceMode.setValueWithFieldChanged( SURFACE );
meshMode.setValueWithFieldChanged( RiaDefines::NO_MESH );
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::setSurfaceDrawstyle()
{
2019-09-06 06:17:36 -05:00
if ( surfaceMode() != NO_SURFACE ) surfaceMode.setValueWithFieldChanged( SURFACE );
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::disableLighting( bool disable )
2018-01-09 03:11:28 -06:00
{
m_disableLighting = disable;
updateCurrentTimeStepAndRedraw();
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
bool Rim3dView::isLightingDisabled() const
{
return m_disableLighting();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* Rim3dView::userDescriptionField()
{
return m_nameConfig->nameField();
}
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
RimViewWindow::fieldChangedByUi( changedField, oldValue, newValue );
2018-01-09 03:11:28 -06:00
2019-09-06 06:17:36 -05:00
if ( changedField == &meshMode )
2018-01-09 03:11:28 -06:00
{
createDisplayModel();
updateDisplayModelVisibility();
RiuMainWindow::instance()->refreshDrawStyleActions();
RiuMainWindow::instance()->refreshAnimationActions();
}
2019-09-06 06:17:36 -05:00
else if ( changedField == &isPerspectiveView )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
if ( m_viewer ) m_viewer->enableParallelProjection( !isPerspectiveView() );
2018-01-09 03:11:28 -06:00
}
2019-09-06 06:17:36 -05:00
else if ( changedField == &scaleZ )
2018-01-09 03:11:28 -06:00
{
updateScaling();
2018-01-09 03:11:28 -06:00
RiuMainWindow::instance()->updateScaleValue();
}
2019-09-06 06:17:36 -05:00
else if ( changedField == &surfaceMode )
2018-01-09 03:11:28 -06:00
{
createDisplayModel();
updateDisplayModelVisibility();
RiuMainWindow::instance()->refreshDrawStyleActions();
RiuMainWindow::instance()->refreshAnimationActions();
}
2019-09-06 06:17:36 -05:00
else if ( changedField == &m_showGridBox )
2018-01-09 03:11:28 -06:00
{
createHighlightAndGridBoxDisplayModelWithRedraw();
}
2019-09-06 06:17:36 -05:00
else if ( changedField == &m_disableLighting )
2018-01-09 03:11:28 -06:00
{
createDisplayModel();
RiuMainWindow::instance()->refreshDrawStyleActions();
RiuMainWindow::instance()->refreshAnimationActions();
}
2019-09-06 06:17:36 -05:00
else if ( changedField == m_nameConfig->nameField() )
2018-01-09 03:11:28 -06:00
{
updateMdiWindowTitle();
2019-09-06 06:17:36 -05:00
if ( viewController() )
2018-01-09 03:11:28 -06:00
{
viewController()->updateDisplayNameAndIcon();
viewController()->updateConnectedEditors();
}
else
{
2019-09-06 06:17:36 -05:00
if ( isMasterView() )
2018-01-09 03:11:28 -06:00
{
assosiatedViewLinker()->updateUiNameAndIcon();
assosiatedViewLinker()->updateConnectedEditors();
}
}
}
2019-09-06 06:17:36 -05:00
else if ( changedField == &m_currentTimeStep )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
if ( m_viewer )
2018-01-09 03:11:28 -06:00
{
m_viewer->update();
}
}
2019-09-06 06:17:36 -05:00
else if ( changedField == &m_backgroundColor )
2018-01-09 03:11:28 -06:00
{
this->applyBackgroundColorAndFontChanges();
2018-01-09 03:11:28 -06:00
}
2019-09-06 06:17:36 -05:00
else if ( changedField == &maximumFrameRate )
2018-01-09 03:11:28 -06:00
{
// !! Use cvf::UNDEFINED_INT or something if we end up with frame rate 0?
// !! Should be able to specify legal range for number properties
2019-09-06 06:17:36 -05:00
if ( m_viewer )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
m_viewer->animationControl()->setTimeout( maximumFrameRate != 0 ? 1000 / maximumFrameRate
: std::numeric_limits<int>::max() );
2018-01-09 03:11:28 -06:00
}
}
2019-09-06 06:17:36 -05:00
else if ( changedField == &m_showZScaleLabel )
{
2019-09-06 06:17:36 -05:00
m_viewer->showZScaleLabel( m_showZScaleLabel() );
m_viewer->update();
}
else if ( changedField == &m_isComparisonViewEnabled )
{
createDisplayModelAndRedraw();
}
else if ( changedField == &m_comparisonView )
{
if ( m_isComparisonViewEnabled() )
{
createDisplayModelAndRedraw();
}
}
else if ( changedField == &m_isComparisonViewLinkingTimestep )
{
if ( m_isComparisonViewEnabled() && m_comparisonView() )
{
createDisplayModelAndRedraw();
}
}
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::addWellPathsToModel( cvf::ModelBasicList* wellPathModelBasicList,
const cvf::BoundingBox& wellPathClipBoundingBox )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
if ( !this->ownerCase() ) return;
2018-01-09 03:11:28 -06:00
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
2019-09-06 06:17:36 -05:00
m_wellPathsPartManager->appendStaticGeometryPartsToModel( wellPathModelBasicList,
transForm.p(),
this->ownerCase()->characteristicCellSize(),
wellPathClipBoundingBox );
2018-01-09 03:11:28 -06:00
wellPathModelBasicList->updateBoundingBoxesRecursive();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::addDynamicWellPathsToModel( cvf::ModelBasicList* wellPathModelBasicList,
const cvf::BoundingBox& wellPathClipBoundingBox )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
if ( !this->ownerCase() ) return;
2018-01-09 03:11:28 -06:00
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
size_t timeStepIndex = currentTimeStep();
2019-09-06 06:17:36 -05:00
m_wellPathsPartManager->appendDynamicGeometryPartsToModel( wellPathModelBasicList,
timeStepIndex,
transForm.p(),
this->ownerCase()->characteristicCellSize(),
wellPathClipBoundingBox );
2018-01-09 03:11:28 -06:00
wellPathModelBasicList->updateBoundingBoxesRecursive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::addAnnotationsToModel( cvf::ModelBasicList* wellPathModelBasicList )
{
2019-09-06 06:17:36 -05:00
if ( !this->ownerCase() ) return;
std::vector<RimAnnotationInViewCollection*> annotationCollections;
2019-09-06 06:17:36 -05:00
descendantsIncludingThisOfType( annotationCollections );
2019-09-06 06:17:36 -05:00
if ( annotationCollections.empty() || !annotationCollections.front()->isActive() )
{
m_annotationsPartManager->clearGeometryCache();
}
else
{
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
2019-09-06 06:17:36 -05:00
m_annotationsPartManager->appendGeometryPartsToModel( wellPathModelBasicList,
transForm.p(),
ownerCase()->allCellsBoundingBox() );
}
wellPathModelBasicList->updateBoundingBoxesRecursive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::addMeasurementToModel( cvf::ModelBasicList* wellPathModelBasicList )
{
2019-09-06 06:17:36 -05:00
if ( !this->ownerCase() ) return;
RimMeasurement* measurement = RiaApplication::instance()->project()->measurement();
2019-09-06 06:17:36 -05:00
if ( !measurement || measurement->pointsInDomainCoords().empty() )
{
m_measurementPartManager->clearGeometryCache();
}
else
{
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
m_measurementPartManager->appendGeometryPartsToModel( nativeOrOverrideViewer()->mainCamera(),
2019-09-06 06:17:36 -05:00
wellPathModelBasicList,
transForm.p(),
ownerCase()->allCellsBoundingBox() );
}
wellPathModelBasicList->updateBoundingBoxesRecursive();
}
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::setScaleZAndUpdate( double scalingFactor )
2018-01-09 03:11:28 -06:00
{
2018-09-24 15:42:13 -05:00
this->scaleZ = scalingFactor;
2018-01-09 03:11:28 -06:00
updateScaleTransform();
this->updateGridBoxData();
this->scheduleCreateDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
bool Rim3dView::isMasterView() const
{
RimViewLinker* viewLinker = this->assosiatedViewLinker();
2019-09-06 06:17:36 -05:00
if ( viewLinker && this == viewLinker->masterView() )
2018-01-09 03:11:28 -06:00
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateGridBoxData()
{
if ( viewer() && ownerCase() )
2018-01-09 03:11:28 -06:00
{
using BBox = cvf::BoundingBox;
BBox masterDomainBBox = showActiveCellsOnly() ? ownerCase()->activeCellsBoundingBox()
: ownerCase()->allCellsBoundingBox();
BBox combinedDomainBBox = masterDomainBBox;
if ( Rim3dView* depView = activeComparisonView() )
{
viewer()->setComparisonViewEyePointOffset(
RimViewManipulator::calculateEquivalentCamPosOffset( this, depView ) );
RimCase* destinationOwnerCase = depView->ownerCase();
if ( destinationOwnerCase )
{
BBox depDomainBBox = depView->showActiveCellsOnly() ? destinationOwnerCase->activeCellsBoundingBox()
: destinationOwnerCase->allCellsBoundingBox();
if ( depDomainBBox.isValid() )
{
combinedDomainBBox.add( depDomainBBox.min() );
combinedDomainBBox.add( depDomainBBox.max() );
}
}
}
viewer()->updateGridBoxData( scaleZ(), ownerCase()->displayModelOffset(), backgroundColor(), combinedDomainBBox );
2018-01-09 03:11:28 -06:00
}
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateAnnotationItems()
{
if ( nativeOrOverrideViewer() )
2018-01-09 03:11:28 -06:00
{
nativeOrOverrideViewer()->updateAnnotationItems();
2018-01-09 03:11:28 -06:00
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateScaling()
{
2019-09-06 06:17:36 -05:00
if ( scaleZ < 1 ) scaleZ = 1;
if ( viewer() )
{
cvf::Vec3d poi = viewer()->pointOfInterest();
cvf::Vec3d eye, dir, up;
eye = viewer()->mainCamera()->position();
dir = viewer()->mainCamera()->direction();
up = viewer()->mainCamera()->up();
2019-09-06 06:17:36 -05:00
eye[2] = poi[2] * scaleZ() / this->scaleTransform()->worldTransform()( 2, 2 ) + ( eye[2] - poi[2] );
poi[2] = poi[2] * scaleZ() / this->scaleTransform()->worldTransform()( 2, 2 );
viewer()->mainCamera()->setFromLookAt( eye, eye + dir, up );
viewer()->setPointOfInterest( poi );
updateScaleTransform();
createDisplayModelAndRedraw();
viewer()->update();
updateZScaleLabel();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateZScaleLabel()
{
// Update Z scale label
2019-09-06 06:17:36 -05:00
int scale = static_cast<int>( scaleZ() );
nativeOrOverrideViewer()->setZScale( scale );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateMeasurement()
{
2019-09-06 06:17:36 -05:00
if ( m_viewer )
{
appendMeasurementToModel();
nativeOrOverrideViewer()->update();
}
}
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::createHighlightAndGridBoxDisplayModelWithRedraw()
{
createHighlightAndGridBoxDisplayModel();
if ( nativeOrOverrideViewer() )
2018-01-09 03:11:28 -06:00
{
nativeOrOverrideViewer()->update();
2018-01-09 03:11:28 -06:00
}
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::createHighlightAndGridBoxDisplayModel()
{
if ( !nativeOrOverrideViewer() ) return;
nativeOrOverrideViewer()->removeStaticModel( m_highlightVizModel.p() );
2018-01-09 03:11:28 -06:00
m_highlightVizModel->removeAllParts();
cvf::Collection<cvf::Part> parts;
2019-09-06 06:17:36 -05:00
createPartCollectionFromSelection( &parts );
if ( parts.size() > 0 )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
for ( size_t i = 0; i < parts.size(); i++ )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
m_highlightVizModel->addPart( parts[i].p() );
2018-01-09 03:11:28 -06:00
}
m_highlightVizModel->updateBoundingBoxesRecursive();
nativeOrOverrideViewer()->addStaticModelOnce( m_highlightVizModel.p(), isUsingOverrideViewer() );
2018-01-09 03:11:28 -06:00
}
this->updateGridBoxData();
if ( viewer() ) viewer()->showGridBox( m_showGridBox() );
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::setBackgroundColor( const cvf::Color3f& newBackgroundColor )
{
2019-09-06 06:17:36 -05:00
m_backgroundColor = newBackgroundColor;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::setShowGridBox( bool showGridBox )
{
m_showGridBox = showGridBox;
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::applyBackgroundColorAndFontChanges()
{
if ( viewer() != nullptr )
{
viewer()->mainCamera()->viewport()->setClearColor( cvf::Color4f( backgroundColor() ) );
viewer()->updateFonts();
}
updateGridBoxData();
updateAnnotationItems();
2018-04-09 04:51:30 -05:00
updateLegends();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
3d Cross Plot: First implementation (#4127) * First cross plot commit * Made cross plot deal with "all time steps" and categorise curves based on time step * Support STATIC vs DYNAMIC plotting * #4115 Avoid updating plots in RimEclipseCase::computeCachedData() * Make sure loading of Cross plot from file works * Show Legend in Cross Plot * Uncheck / Check curves to disable/enable * Axis titles and checkable data set * Name config and setting of common plot look * Fix category indentation in GeoMech results * Support name configuration for Grid Cross Plot * Support adding new curve sets * Improve colors and symbols with better cycling * Moved GridCrossPlot files to sub directory in ProjectDataModel and Commands * #4111 3D calculations : Always show difference options * Whitespace * #4111 Move resultDefinition field to private * Whitespace * #4087 Ensemble : When importing and ensemble, show by default an ensemble plot * #4085 3D view: Improve overlay item colors * #4106 Crash on Linux Temporary workaround to avoid crash * #4106 Stop trying to do recursive setting tab order widget * The double pointer was handled wrongly and shift-tab order isn't working anyway. * #4114 Regression Test : Remove cached pointer to eclipse case * Revert "#4114 Regression Test : Remove cached pointer to eclipse case" This reverts commit f2146c600705280c85391f88a861a070812ae83a. * #4114 Regression Test : Missing data for flow diag property filter * #4085 3D view: Add check box for version info text * Whtespace * Improve labelling of static results * Fix update of result property when changing type
2019-02-21 05:52:23 -06:00
void Rim3dView::performAutoNameUpdate()
{
updateMdiWindowTitle();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateDisplayModelVisibility()
{
if ( viewer() == nullptr || isUsingOverrideViewer() ) return;
2019-09-06 06:17:36 -05:00
const cvf::uint uintSurfaceBit = surfaceBit;
const cvf::uint uintMeshSurfaceBit = meshSurfaceBit;
const cvf::uint uintFaultBit = faultBit;
const cvf::uint uintMeshFaultBit = meshFaultBit;
const cvf::uint uintIntersectionCellFaceBit = intersectionCellFaceBit;
const cvf::uint uintIntersectionCellMeshBit = intersectionCellMeshBit;
const cvf::uint uintIntersectionFaultMeshBit = intersectionFaultMeshBit;
// Initialize the mask to show everything except the the bits controlled here
2019-09-06 06:17:36 -05:00
unsigned int mask = 0xffffffff & ~uintSurfaceBit & ~uintFaultBit & ~uintMeshSurfaceBit & ~uintMeshFaultBit &
~intersectionCellFaceBit & ~intersectionCellMeshBit & ~intersectionFaultMeshBit;
// Then turn the appropriate bits on according to the user settings
2019-09-06 06:17:36 -05:00
if ( surfaceMode == SURFACE )
{
mask |= uintSurfaceBit;
mask |= uintFaultBit;
mask |= intersectionCellFaceBit;
}
2019-09-06 06:17:36 -05:00
else if ( surfaceMode == FAULTS )
{
mask |= uintFaultBit;
mask |= intersectionCellFaceBit;
}
2019-09-06 06:17:36 -05:00
if ( meshMode == RiaDefines::FULL_MESH )
{
mask |= uintMeshSurfaceBit;
mask |= uintMeshFaultBit;
mask |= intersectionCellMeshBit;
mask |= intersectionFaultMeshBit;
}
2019-09-06 06:17:36 -05:00
else if ( meshMode == RiaDefines::FAULTS_MESH )
{
mask |= uintMeshFaultBit;
mask |= intersectionFaultMeshBit;
}
viewer()->setEnableMask( mask, false );
viewer()->setEnableMask( mask, true );
viewer()->update();
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
bool Rim3dView::showActiveCellsOnly()
{
return false;
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::zoomAll()
{
2019-09-06 06:17:36 -05:00
if ( m_viewer )
2018-01-09 03:11:28 -06:00
{
m_viewer->zoomAll();
}
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
cvf::ref<caf::DisplayCoordTransform> Rim3dView::displayCoordTransform() const
{
cvf::ref<caf::DisplayCoordTransform> coordTrans = new caf::DisplayCoordTransform;
2019-09-06 06:17:36 -05:00
cvf::Vec3d scale( 1.0, 1.0, scaleZ );
coordTrans->setScale( scale );
2018-01-09 03:11:28 -06:00
RimCase* rimCase = ownerCase();
2019-09-06 06:17:36 -05:00
if ( rimCase )
2018-01-09 03:11:28 -06:00
{
2019-09-06 06:17:36 -05:00
coordTrans->setTranslation( rimCase->displayModelOffset() );
2018-01-09 03:11:28 -06:00
}
return coordTrans;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
bool Rim3dView::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
bool Rim3dView::applyFontSize( RiaDefines::FontSettingType fontSettingType,
int oldFontSize,
int fontSize,
bool forceChange /*= false*/ )
{
2019-09-06 06:17:36 -05:00
if ( fontSettingType == RiaDefines::SCENE_FONT )
{
applyBackgroundColorAndFontChanges();
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> Rim3dView::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_comparisonView )
{
RimProject* proj;
this->firstAncestorOrThisOfType( proj );
if ( proj )
{
std::vector<Rim3dView*> views;
proj->allViews( views );
for ( auto view : views )
{
if ( view != this ) RiaOptionItemFactory::appendOptionItemFromViewNameAndCaseName( view, &options );
}
if ( !options.empty() )
{
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
cvf::Mat4d Rim3dView::cameraPosition() const
{
return m_cameraPosition();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d Rim3dView::cameraPointOfInterest() const
{
return m_cameraPointOfInterest();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewNameConfig* Rim3dView::nameConfig() const
{
return m_nameConfig();
}
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
QWidget* Rim3dView::viewWidget()
{
2019-09-06 06:17:36 -05:00
if ( m_viewer )
return m_viewer->layoutWidget();
else
return nullptr;
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-01-09 03:11:28 -06:00
//--------------------------------------------------------------------------------------------------
void Rim3dView::forceShowWindowOn()
{
2019-09-06 06:17:36 -05:00
m_showWindow.setValueWithFieldChanged( true );
2018-01-09 03:11:28 -06:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::disableGridBoxField()
{
m_showGridBox = false;
2019-09-06 06:17:36 -05:00
RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_showGridBox );
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::disablePerspectiveProjectionField()
{
isPerspectiveView = false;
2019-09-06 06:17:36 -05:00
RiaFieldhandleTools::disableWriteAndSetFieldHidden( &isPerspectiveView );
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::handleMdiWindowClosed()
{
RimViewWindow::handleMdiWindowClosed();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void Rim3dView::setMdiWindowGeometry( const RimMdiWindowGeometry& windowGeometry )
{
2019-09-06 06:17:36 -05:00
RimViewWindow::setMdiWindowGeometry( windowGeometry );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::appendAnnotationsToModel()
{
if ( !nativeOrOverrideViewer() ) return;
cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() );
2019-09-06 06:17:36 -05:00
if ( frameScene )
{
cvf::String name = "Annotations";
2019-09-06 06:17:36 -05:00
this->removeModelByName( frameScene, name );
cvf::ref<cvf::ModelBasicList> model = new cvf::ModelBasicList;
2019-09-06 06:17:36 -05:00
model->setName( name );
2019-09-06 06:17:36 -05:00
addAnnotationsToModel( model.p() );
2019-09-06 06:17:36 -05:00
frameScene->addModel( model.p() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::appendMeasurementToModel()
{
if ( !nativeOrOverrideViewer() ) return;
cvf::Scene* frameScene = nativeOrOverrideViewer()->frame( m_currentTimeStep, isUsingOverrideViewer() );
2019-09-06 06:17:36 -05:00
if ( frameScene )
{
cvf::String name = "Measurement";
2019-09-06 06:17:36 -05:00
this->removeModelByName( frameScene, name );
cvf::ref<cvf::ModelBasicList> model = new cvf::ModelBasicList;
2019-09-06 06:17:36 -05:00
model->setName( name );
2019-09-06 06:17:36 -05:00
addMeasurementToModel( model.p() );
2019-09-06 06:17:36 -05:00
frameScene->addModel( model.p() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim3dView* Rim3dView::activeComparisonView() const
{
if ( m_isComparisonViewEnabled() )
{
return m_comparisonView();
}
else
{
return nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::prepareComparisonView()
{
Rim3dView* depView = activeComparisonView();
CVF_ASSERT( depView );
// prepareComparisonView
m_comparisonViewOrgTimestep = depView->currentTimeStep();
depView->m_currentTimeStep = currentTimeStep();
depView->clampCurrentTimestep();
m_comparisonViewOrgZScale = depView->scaleZ();
depView->scaleZ = scaleZ();
viewer()->setComparisonViewEyePointOffset( RimViewManipulator::calculateEquivalentCamPosOffset( this, depView ) );
depView->setOverrideViewer( viewer() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::restoreComparisonView()
{
Rim3dView* depView = activeComparisonView();
CVF_ASSERT( depView );
depView->setOverrideViewer( nullptr );
depView->m_currentTimeStep = m_comparisonViewOrgTimestep;
depView->scaleZ = m_comparisonViewOrgZScale;
}