2015-04-29 10:50:25 +02:00
# include "RimView.h"
2015-04-29 22:19:49 +02:00
# include "RiaApplication.h"
# include "RiaPreferences.h"
2015-08-25 12:40:55 +02:00
2015-04-29 22:19:49 +02:00
# include "Rim3dOverlayInfoConfig.h"
2015-08-27 13:44:27 +02:00
# include "RimCellRangeFilterCollection.h"
2015-09-03 13:06:00 +02:00
# include "RimEclipseCase.h"
# include "RimEclipseView.h"
2015-11-27 12:17:50 +01:00
# include "RimGridCollection.h"
2016-10-25 09:50:33 +02:00
# include "RimIntersectionCollection.h"
2015-08-25 12:40:55 +02:00
# include "RimOilField.h"
# include "RimProject.h"
2015-11-18 09:15:13 +01:00
# include "RimPropertyFilterCollection.h"
2015-10-22 11:41:27 +02:00
# include "RimViewController.h"
2015-09-07 14:29:46 +02:00
# include "RimViewLinker.h"
2015-10-22 11:41:27 +02:00
# include "RimViewLinkerCollection.h"
2015-08-25 12:40:55 +02:00
# include "RimWellPathCollection.h"
2015-04-30 10:34:15 +02:00
# include "RiuMainWindow.h"
2015-08-25 12:40:55 +02:00
# include "RiuViewer.h"
# include "RivWellPathCollectionPartMgr.h"
2016-09-29 11:43:47 +02:00
# include "cafDisplayCoordTransform.h"
2015-08-25 12:40:55 +02:00
# include "cafFrameAnimationControl.h"
# include "cafPdmObjectFactory.h"
2016-09-29 11:43:47 +02:00
2015-04-30 10:34:15 +02:00
# include "cvfCamera.h"
2015-06-11 13:44:21 +02:00
# include "cvfModel.h"
# include "cvfModelBasicList.h"
# include "cvfPart.h"
# include "cvfScene.h"
2015-04-30 10:34:15 +02:00
# include "cvfViewport.h"
2015-04-29 22:19:49 +02:00
2015-05-11 09:48:55 +02:00
# include <limits.h>
2015-05-08 14:13:26 +02:00
namespace caf {
template < >
void caf : : AppEnum < RimView : : MeshModeType > : : setUp ( )
{
addItem ( RimView : : FULL_MESH , " FULL_MESH " , " All " ) ;
2015-11-18 09:15:13 +01:00
addItem ( RimView : : FAULTS_MESH , " FAULTS_MESH " , " Faults only " ) ;
addItem ( RimView : : NO_MESH , " NO_MESH " , " None " ) ;
2015-05-08 14:13:26 +02:00
setDefault ( RimView : : FULL_MESH ) ;
}
template < >
void caf : : AppEnum < RimView : : SurfaceModeType > : : setUp ( )
{
addItem ( RimView : : SURFACE , " SURFACE " , " All " ) ;
addItem ( RimView : : FAULTS , " FAULTS " , " Faults only " ) ;
addItem ( RimView : : NO_SURFACE , " NO_SURFACE " , " None " ) ;
setDefault ( RimView : : SURFACE ) ;
}
} // End namespace caf
2015-09-25 15:09:19 +02:00
CAF_PDM_XML_ABSTRACT_SOURCE_INIT ( RimView , " GenericView " ) ; // Do not use. Abstract class
2015-04-29 10:50:25 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimView : : RimView ( void )
{
2015-04-29 22:19:49 +02:00
RiaApplication * app = RiaApplication : : instance ( ) ;
RiaPreferences * preferences = app - > preferences ( ) ;
CVF_ASSERT ( preferences ) ;
CAF_PDM_InitField ( & name , " UserDescription " , QString ( " " ) , " Name " , " " , " " , " " ) ;
CAF_PDM_InitField ( & cameraPosition , " CameraPosition " , cvf : : Mat4d : : IDENTITY , " " , " " , " " , " " ) ;
2015-08-12 21:51:02 +02:00
cameraPosition . uiCapability ( ) - > setUiHidden ( true ) ;
2015-12-05 00:56:14 +01:00
2016-08-16 14:34:37 +02:00
CAF_PDM_InitField ( & cameraPointOfInterest , " CameraPointOfInterest " , cvf : : Vec3d : : ZERO , " " , " " , " " , " " ) ;
cameraPointOfInterest . uiCapability ( ) - > setUiHidden ( true ) ;
2015-12-05 00:56:14 +01:00
CAF_PDM_InitField ( & isPerspectiveView , " PerspectiveProjection " , true , " Perspective Projection " , " " , " " , " " ) ;
2015-04-29 22:19:49 +02:00
2015-10-26 10:29:57 +01:00
double defaultScaleFactor = preferences - > defaultScaleFactorZ ;
2015-04-29 22:19:49 +02:00
CAF_PDM_InitField ( & scaleZ , " GridZScale " , defaultScaleFactor , " Z Scale " , " " , " Scales the scene in the Z direction " , " " ) ;
cvf : : Color3f defBackgColor = preferences - > defaultViewerBackgroundColor ( ) ;
CAF_PDM_InitField ( & backgroundColor , " ViewBackgroundColor " , defBackgColor , " Background " , " " , " " , " " ) ;
CAF_PDM_InitField ( & maximumFrameRate , " MaximumFrameRate " , 10 , " Maximum frame rate " , " " , " " , " " ) ;
2015-08-05 13:27:36 +02:00
maximumFrameRate . uiCapability ( ) - > setUiHidden ( true ) ;
2015-06-09 16:18:11 +02:00
CAF_PDM_InitField ( & hasUserRequestedAnimation , " AnimationMode " , false , " Animation Mode " , " " , " " , " " ) ;
2015-08-05 13:27:36 +02:00
hasUserRequestedAnimation . uiCapability ( ) - > setUiHidden ( true ) ;
2015-04-29 22:19:49 +02:00
CAF_PDM_InitField ( & m_currentTimeStep , " CurrentTimeStep " , 0 , " Current Time Step " , " " , " " , " " ) ;
2015-08-05 13:27:36 +02:00
m_currentTimeStep . uiCapability ( ) - > setUiHidden ( true ) ;
2015-04-29 22:19:49 +02:00
2015-08-27 13:44:27 +02:00
CAF_PDM_InitFieldNoDefault ( & m_overlayInfoConfig , " OverlayInfoConfig " , " Info Box " , " " , " " , " " ) ;
m_overlayInfoConfig = new Rim3dOverlayInfoConfig ( ) ;
m_overlayInfoConfig - > setReservoirView ( this ) ;
m_overlayInfoConfig . uiCapability ( ) - > setUiHidden ( true ) ;
2015-04-29 22:19:49 +02:00
2015-05-08 14:13:26 +02:00
caf : : AppEnum < RimView : : MeshModeType > defaultMeshType = NO_MESH ;
if ( preferences - > defaultGridLines ) defaultMeshType = FULL_MESH ;
CAF_PDM_InitField ( & meshMode , " MeshMode " , defaultMeshType , " Grid lines " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( & surfaceMode , " SurfaceMode " , " Grid surface " , " " , " " , " " ) ;
2015-04-29 10:50:25 +02:00
2015-11-27 10:47:12 +01:00
CAF_PDM_InitField ( & showGridBox , " ShowGridBox " , true , " Show Grid Box " , " " , " " , " " ) ;
2015-11-16 11:44:41 +01:00
2015-06-18 13:20:54 +02:00
CAF_PDM_InitField ( & m_disableLighting , " DisableLighting " , false , " Disable Results Lighting " , " " , " Disable light model for scalar result colors " , " " ) ;
2015-06-17 15:04:55 +02:00
2015-09-01 22:11:39 +02:00
2015-10-19 12:10:18 +02:00
CAF_PDM_InitFieldNoDefault ( & m_rangeFilterCollection , " RangeFilters " , " Range Filters " , " " , " " , " " ) ;
m_rangeFilterCollection . uiCapability ( ) - > setUiHidden ( true ) ;
2015-10-21 12:21:08 +02:00
m_rangeFilterCollection = new RimCellRangeFilterCollection ( ) ;
2015-10-19 12:10:18 +02:00
CAF_PDM_InitFieldNoDefault ( & m_overrideRangeFilterCollection , " RangeFiltersControlled " , " Range Filters (controlled) " , " " , " " , " " ) ;
m_overrideRangeFilterCollection . uiCapability ( ) - > setUiHidden ( true ) ;
m_overrideRangeFilterCollection . xmlCapability ( ) - > setIOWritable ( false ) ;
m_overrideRangeFilterCollection . xmlCapability ( ) - > setIOReadable ( false ) ;
2015-11-23 09:07:35 +01:00
CAF_PDM_InitFieldNoDefault ( & crossSectionCollection , " CrossSections " , " Intersections " , " " , " " , " " ) ;
2015-11-18 15:09:50 +01:00
crossSectionCollection . uiCapability ( ) - > setUiHidden ( true ) ;
2016-09-21 10:52:16 +02:00
crossSectionCollection = new RimIntersectionCollection ( ) ;
2015-11-18 09:15:13 +01:00
2015-11-27 12:17:50 +01:00
CAF_PDM_InitFieldNoDefault ( & m_gridCollection , " GridCollection " , " GridCollection " , " " , " " , " " ) ;
m_gridCollection . uiCapability ( ) - > setUiHidden ( true ) ;
m_gridCollection = new RimGridCollection ( ) ;
2015-05-08 14:13:26 +02:00
m_previousGridModeMeshLinesWasFaults = false ;
2015-11-19 11:41:16 +01:00
2015-11-23 11:21:12 +01:00
m_crossSectionVizModel = new cvf : : ModelBasicList ;
m_crossSectionVizModel - > setName ( " CrossSectionModel " ) ;
2015-11-19 11:41:16 +01:00
2015-11-23 11:21:12 +01:00
m_highlightVizModel = new cvf : : ModelBasicList ;
m_highlightVizModel - > setName ( " HighlightModel " ) ;
m_wellPathPipeVizModel = new cvf : : ModelBasicList ;
m_wellPathPipeVizModel - > setName ( " WellPathPipeModel " ) ;
2017-01-17 13:06:57 +01:00
2017-01-20 11:38:18 +01:00
this - > setAs3DViewMdiWindow ( ) ;
2015-04-29 10:50:25 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimView : : ~ RimView ( void )
{
2015-10-22 11:41:27 +02:00
RimProject * proj = RiaApplication : : instance ( ) - > project ( ) ;
if ( proj & & this - > isMasterView ( ) )
{
delete proj - > viewLinkerCollection - > viewLinker ( ) ;
proj - > viewLinkerCollection - > viewLinker = NULL ;
proj - > uiCapability ( ) - > updateConnectedEditors ( ) ;
}
RimViewController * vController = this - > viewController ( ) ;
if ( proj & & vController )
{
vController - > setManagedView ( NULL ) ;
vController - > ownerViewLinker ( ) - > removeViewController ( vController ) ;
delete vController ;
proj - > uiCapability ( ) - > updateConnectedEditors ( ) ;
}
2015-08-27 13:44:27 +02:00
delete this - > m_overlayInfoConfig ( ) ;
2015-04-30 10:34:15 +02:00
2017-01-20 11:38:18 +01:00
removeMdiWindowFromMdiArea ( ) ;
2015-04-30 10:34:15 +02:00
2017-01-17 13:06:57 +01:00
deleteViewWidget ( ) ;
2015-10-19 12:10:18 +02:00
delete m_rangeFilterCollection ;
delete m_overrideRangeFilterCollection ;
2015-12-03 08:26:38 +01:00
delete crossSectionCollection ;
2015-12-09 13:52:25 +01:00
delete m_gridCollection ;
2015-04-29 10:50:25 +02:00
}
2015-04-29 22:19:49 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuViewer * RimView : : viewer ( )
{
return m_viewer ;
}
2015-04-30 10:34:15 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-01-17 13:06:57 +01:00
QWidget * RimView : : createViewWidget ( QWidget * mainWindowParent )
2015-04-30 10:34:15 +02:00
{
2017-01-17 13:06:57 +01:00
QGLFormat glFormat ;
glFormat . setDirectRendering ( RiaApplication : : instance ( ) - > useShaders ( ) ) ;
2015-04-30 10:34:15 +02:00
2017-01-17 13:06:57 +01:00
m_viewer = new RiuViewer ( glFormat , NULL ) ;
m_viewer - > setOwnerReservoirView ( this ) ;
2015-04-30 10:34:15 +02:00
2017-01-17 13:06:57 +01:00
return m_viewer - > layoutWidget ( ) ;
}
2015-04-30 10:34:15 +02:00
2017-01-17 13:06:57 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : updateViewWidgetAfterCreation ( )
{
m_viewer - > setDefaultPerspectiveNearPlaneDistance ( 10 ) ;
2015-04-30 10:34:15 +02:00
2017-01-17 13:06:57 +01:00
this - > resetLegendsInViewer ( ) ;
2015-04-30 10:34:15 +02:00
2017-01-17 13:06:57 +01:00
m_viewer - > updateNavigationPolicy ( ) ;
m_viewer - > enablePerfInfoHud ( RiaApplication : : instance ( ) - > showPerformanceInfo ( ) ) ;
2015-04-30 10:34:15 +02:00
2017-01-17 13:06:57 +01:00
m_viewer - > mainCamera ( ) - > setViewMatrix ( cameraPosition ) ;
m_viewer - > setPointOfInterest ( cameraPointOfInterest ( ) ) ;
m_viewer - > enableParallelProjection ( ! isPerspectiveView ( ) ) ;
2015-11-16 14:08:17 +01:00
2017-01-17 13:06:57 +01:00
m_viewer - > mainCamera ( ) - > viewport ( ) - > setClearColor ( cvf : : Color4f ( backgroundColor ( ) ) ) ;
this - > updateGridBoxData ( ) ;
this - > createHighlightAndGridBoxDisplayModel ( ) ;
m_viewer - > update ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-01-20 11:38:18 +01:00
void RimView : : updateMdiWindowTitle ( )
2017-01-17 13:06:57 +01:00
{
if ( m_viewer )
2015-04-30 10:34:15 +02:00
{
2017-01-17 13:06:57 +01:00
QString windowTitle ;
if ( ownerCase ( ) )
2015-04-30 10:34:15 +02:00
{
2017-01-17 13:06:57 +01:00
windowTitle = QString ( " %1 - %2 " ) . arg ( ownerCase ( ) - > caseUserDescription ( ) ) . arg ( name ) ;
}
else
{
windowTitle = name ;
2015-04-30 10:34:15 +02:00
}
2017-01-17 13:06:57 +01:00
m_viewer - > layoutWidget ( ) - > setWindowTitle ( windowTitle ) ;
}
2015-04-30 10:34:15 +02:00
}
2017-01-17 13:06:57 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : deleteViewWidget ( )
{
if ( m_viewer )
{
m_viewer - > deleteLater ( ) ;
m_viewer = nullptr ;
}
}
2016-06-27 21:01:17 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QImage RimView : : snapshotWindowContent ( )
{
if ( m_viewer )
{
2016-12-22 08:44:36 +01:00
// Force update of scheduled display models before snapshotting
RiaApplication : : instance ( ) - > slotUpdateScheduledDisplayModels ( ) ;
2016-06-27 21:01:17 +02:00
m_viewer - > repaint ( ) ;
2016-08-31 17:34:31 +02:00
return m_viewer - > snapshotImage ( ) ;
2016-06-27 21:01:17 +02:00
}
2016-08-31 17:34:31 +02:00
return QImage ( ) ;
2016-06-27 21:01:17 +02:00
}
2015-04-30 10:34:15 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : scheduleCreateDisplayModelAndRedraw ( )
{
RiaApplication : : instance ( ) - > scheduleDisplayModelUpdateAndRedraw ( this ) ;
2015-09-25 11:01:41 +02:00
if ( this - > isMasterView ( ) )
2015-09-13 08:54:32 +02:00
{
2015-09-25 11:01:41 +02:00
RimViewLinker * viewLinker = this - > assosiatedViewLinker ( ) ;
if ( viewLinker )
{
viewLinker - > scheduleCreateDisplayModelAndRedrawForDependentViews ( ) ;
}
2015-09-13 08:54:32 +02:00
}
2015-04-30 10:34:15 +02:00
}
2015-05-08 10:38:10 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-03-02 16:10:18 +01:00
void RimView : : setCurrentTimeStepAndUpdate ( int frameIndex )
2015-05-08 10:38:10 +02:00
{
m_currentTimeStep = frameIndex ;
2015-08-31 12:31:38 +02:00
clampCurrentTimestep ( ) ;
2015-06-09 16:18:11 +02:00
this - > hasUserRequestedAnimation = true ;
2015-11-12 12:24:05 +01:00
if ( this - > propertyFilterCollection ( ) & & this - > propertyFilterCollection ( ) - > hasActiveDynamicFilters ( ) )
{
m_currentReservoirCellVisibility = NULL ;
}
2015-05-08 10:38:10 +02:00
this - > updateCurrentTimeStep ( ) ;
}
2017-03-02 16:10:18 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setCurrentTimeStep ( int frameIndex )
{
m_currentTimeStep = frameIndex ;
clampCurrentTimestep ( ) ;
this - > hasUserRequestedAnimation = true ;
if ( this - > propertyFilterCollection ( ) & & this - > propertyFilterCollection ( ) - > hasActiveDynamicFilters ( ) )
{
m_currentReservoirCellVisibility = NULL ;
}
}
2015-05-08 10:38:10 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : updateCurrentTimeStepAndRedraw ( )
{
this - > updateCurrentTimeStep ( ) ;
2015-09-01 18:04:35 +02:00
if ( m_viewer ) m_viewer - > update ( ) ;
2015-05-08 10:38:10 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : createDisplayModelAndRedraw ( )
{
if ( m_viewer )
{
this - > clampCurrentTimestep ( ) ;
createDisplayModel ( ) ;
2015-11-19 11:41:16 +01:00
createHighlightAndGridBoxDisplayModel ( ) ;
2015-11-16 12:08:53 +01:00
updateDisplayModelVisibility ( ) ;
2015-09-21 17:45:54 +02:00
if ( cameraPosition ( ) . isIdentity ( ) )
{
setDefaultView ( ) ;
2015-09-21 18:01:21 +02:00
cameraPosition = m_viewer - > mainCamera ( ) - > viewMatrix ( ) ;
2016-08-16 14:34:37 +02:00
cameraPointOfInterest = m_viewer - > pointOfInterest ( ) ;
2015-09-21 17:45:54 +02:00
}
2015-05-08 10:38:10 +02:00
}
2015-06-17 15:04:55 +02:00
RiuMainWindow : : instance ( ) - > refreshAnimationActions ( ) ;
2015-05-08 10:38:10 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setDefaultView ( )
{
if ( m_viewer )
{
m_viewer - > setDefaultView ( ) ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : endAnimation ( )
{
2015-06-09 16:18:11 +02:00
this - > hasUserRequestedAnimation = false ;
2015-05-08 10:38:10 +02:00
this - > updateStaticCellColors ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setupBeforeSave ( )
{
if ( m_viewer )
{
2015-06-09 16:18:11 +02: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...
2015-05-08 10:38:10 +02:00
cameraPosition = m_viewer - > mainCamera ( ) - > viewMatrix ( ) ;
2016-08-16 14:34:37 +02:00
cameraPointOfInterest = m_viewer - > pointOfInterest ( ) ;
2016-05-26 13:17:26 +02:00
}
2015-05-08 10:38:10 +02:00
}
2015-04-30 10:34:15 +02:00
2015-05-08 14:13:26 +02:00
//--------------------------------------------------------------------------------------------------
///
// Surf: No Fault Surf
// Mesh -------------
// No F F G
// Fault F F G
// Mesh G G G
//
//--------------------------------------------------------------------------------------------------
bool RimView : : isGridVisualizationMode ( ) const
{
return ( this - > surfaceMode ( ) = = SURFACE
| | this - > meshMode ( ) = = FULL_MESH ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setMeshOnlyDrawstyle ( )
{
if ( isGridVisualizationMode ( ) )
{
2016-10-19 15:30:52 +02:00
meshMode . setValueWithFieldChanged ( FULL_MESH ) ;
2015-05-08 14:13:26 +02:00
}
else
{
2016-10-19 15:30:52 +02:00
meshMode . setValueWithFieldChanged ( FAULTS_MESH ) ;
2015-05-08 14:13:26 +02:00
}
2016-10-19 15:30:52 +02:00
surfaceMode . setValueWithFieldChanged ( NO_SURFACE ) ;
2015-05-08 14:13:26 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setMeshSurfDrawstyle ( )
{
if ( isGridVisualizationMode ( ) )
{
2016-10-19 15:30:52 +02:00
surfaceMode . setValueWithFieldChanged ( SURFACE ) ;
meshMode . setValueWithFieldChanged ( FULL_MESH ) ;
2015-05-08 14:13:26 +02:00
}
else
{
2016-10-19 15:30:52 +02:00
surfaceMode . setValueWithFieldChanged ( FAULTS ) ;
meshMode . setValueWithFieldChanged ( FAULTS_MESH ) ;
2015-05-08 14:13:26 +02:00
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setFaultMeshSurfDrawstyle ( )
{
// Surf: No Fault Surf
// Mesh -------------
// No FF FF SF
// Fault FF FF SF
// Mesh SF SF SF
if ( this - > isGridVisualizationMode ( ) )
{
2016-10-19 15:30:52 +02:00
surfaceMode . setValueWithFieldChanged ( SURFACE ) ;
2015-05-08 14:13:26 +02:00
}
else
{
2016-10-19 15:30:52 +02:00
surfaceMode . setValueWithFieldChanged ( FAULTS ) ;
2015-05-08 14:13:26 +02:00
}
2016-10-19 15:30:52 +02:00
meshMode . setValueWithFieldChanged ( FAULTS_MESH ) ;
2015-05-08 14:13:26 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setSurfOnlyDrawstyle ( )
{
if ( isGridVisualizationMode ( ) )
{
2016-10-19 15:30:52 +02:00
surfaceMode . setValueWithFieldChanged ( SURFACE ) ;
2015-05-08 14:13:26 +02:00
}
else
{
2016-10-19 15:30:52 +02:00
surfaceMode . setValueWithFieldChanged ( FAULTS ) ;
2015-05-08 14:13:26 +02:00
}
2015-07-31 18:58:23 +02:00
2016-10-19 15:30:52 +02:00
meshMode . setValueWithFieldChanged ( NO_MESH ) ;
2015-05-08 14:13:26 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-11-27 13:45:02 +01:00
void RimView : : showGridCells ( bool enableGridCells )
2015-05-08 14:13:26 +02:00
{
2015-11-27 13:45:02 +01:00
if ( ! enableGridCells )
2015-05-08 14:13:26 +02:00
{
m_previousGridModeMeshLinesWasFaults = meshMode ( ) = = FAULTS_MESH ;
2016-10-19 15:30:52 +02:00
if ( surfaceMode ( ) ! = NO_SURFACE ) surfaceMode . setValueWithFieldChanged ( FAULTS ) ;
if ( meshMode ( ) ! = NO_MESH ) meshMode . setValueWithFieldChanged ( FAULTS_MESH ) ;
2015-05-08 14:13:26 +02:00
}
else
{
2016-10-19 15:30:52 +02:00
if ( surfaceMode ( ) ! = NO_SURFACE ) surfaceMode . setValueWithFieldChanged ( SURFACE ) ;
if ( meshMode ( ) ! = NO_MESH ) meshMode . setValueWithFieldChanged ( m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH ) ;
2015-05-08 14:13:26 +02:00
}
2015-11-27 13:45:02 +01:00
m_gridCollection - > isActive = enableGridCells ;
m_gridCollection - > updateConnectedEditors ( ) ;
m_gridCollection - > updateUiIconFromState ( enableGridCells ) ;
2015-05-08 14:13:26 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setSurfaceDrawstyle ( )
{
2016-10-19 15:30:52 +02:00
if ( surfaceMode ( ) ! = NO_SURFACE ) surfaceMode . setValueWithFieldChanged ( SURFACE ) ;
2015-05-08 14:13:26 +02:00
}
2015-06-17 15:04:55 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : disableLighting ( bool disable )
{
m_disableLighting = disable ;
updateCurrentTimeStepAndRedraw ( ) ;
updateConnectedEditors ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimView : : isLightingDisabled ( ) const
{
return m_disableLighting ( ) ;
}
2015-05-08 14:13:26 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : fieldChangedByUi ( const caf : : PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
{
2017-01-20 16:25:05 +01:00
RimViewWindow : : fieldChangedByUi ( changedField , oldValue , newValue ) ;
2015-05-08 14:13:26 +02:00
if ( changedField = = & meshMode )
{
createDisplayModel ( ) ;
updateDisplayModelVisibility ( ) ;
RiuMainWindow : : instance ( ) - > refreshDrawStyleActions ( ) ;
2015-11-27 12:17:50 +01:00
RiuMainWindow : : instance ( ) - > refreshAnimationActions ( ) ;
2015-05-08 14:13:26 +02:00
}
2015-12-05 00:56:14 +01:00
else if ( changedField = = & isPerspectiveView )
{
if ( m_viewer ) m_viewer - > enableParallelProjection ( ! isPerspectiveView ( ) ) ;
}
2015-05-13 22:42:11 +02:00
else if ( changedField = = & scaleZ )
{
if ( scaleZ < 1 ) scaleZ = 1 ;
2015-11-16 07:16:30 +01:00
this - > updateGridBoxData ( ) ;
2015-05-13 22:42:11 +02:00
// Regenerate well paths
RimOilField * oilFields = RiaApplication : : instance ( ) - > project ( ) ? RiaApplication : : instance ( ) - > project ( ) - > activeOilField ( ) : NULL ;
RimWellPathCollection * wellPathCollection = ( oilFields ) ? oilFields - > wellPathCollection ( ) : NULL ;
if ( wellPathCollection ) wellPathCollection - > wellPathCollectionPartMgr ( ) - > scheduleGeometryRegen ( ) ;
2016-10-25 09:50:33 +02:00
crossSectionCollection - > updateIntersectionBoxGeometry ( ) ;
2015-05-13 22:42:11 +02:00
if ( m_viewer )
{
cvf : : Vec3d poi = m_viewer - > pointOfInterest ( ) ;
cvf : : Vec3d eye , dir , up ;
eye = m_viewer - > mainCamera ( ) - > position ( ) ;
dir = m_viewer - > mainCamera ( ) - > direction ( ) ;
up = m_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 ) ;
m_viewer - > mainCamera ( ) - > setFromLookAt ( eye , eye + dir , up ) ;
m_viewer - > setPointOfInterest ( poi ) ;
updateScaleTransform ( ) ;
createDisplayModelAndRedraw ( ) ;
2015-09-03 13:06:00 +02:00
2015-09-23 12:50:06 +02:00
m_viewer - > update ( ) ;
2015-09-25 11:01:41 +02:00
RimViewLinker * viewLinker = this - > assosiatedViewLinker ( ) ;
2015-09-07 14:29:46 +02:00
if ( viewLinker )
2015-09-03 13:06:00 +02:00
{
2015-09-23 11:01:46 +02:00
viewLinker - > updateScaleZ ( this , scaleZ ) ;
2015-09-23 12:50:06 +02:00
viewLinker - > updateCamera ( this ) ;
2015-09-03 13:06:00 +02:00
}
2015-05-13 22:42:11 +02:00
}
RiuMainWindow : : instance ( ) - > updateScaleValue ( ) ;
}
2015-05-08 14:13:26 +02:00
else if ( changedField = = & surfaceMode )
{
createDisplayModel ( ) ;
updateDisplayModelVisibility ( ) ;
RiuMainWindow : : instance ( ) - > refreshDrawStyleActions ( ) ;
2015-11-27 12:17:50 +01:00
RiuMainWindow : : instance ( ) - > refreshAnimationActions ( ) ;
2015-05-08 14:13:26 +02:00
}
2015-11-16 11:44:41 +01:00
else if ( changedField = = & showGridBox )
{
2015-11-19 11:41:16 +01:00
createHighlightAndGridBoxDisplayModelWithRedraw ( ) ;
2015-11-16 11:44:41 +01:00
}
2015-06-17 15:04:55 +02:00
else if ( changedField = = & m_disableLighting )
{
createDisplayModel ( ) ;
RiuMainWindow : : instance ( ) - > refreshDrawStyleActions ( ) ;
2015-11-27 12:17:50 +01:00
RiuMainWindow : : instance ( ) - > refreshAnimationActions ( ) ;
2015-06-17 15:04:55 +02:00
}
2015-05-08 14:13:26 +02:00
else if ( changedField = = & name )
{
2017-01-20 11:38:18 +01:00
updateMdiWindowTitle ( ) ;
2015-09-25 16:39:19 +02:00
if ( viewController ( ) )
{
viewController ( ) - > updateDisplayNameAndIcon ( ) ;
viewController ( ) - > updateConnectedEditors ( ) ;
}
else
{
if ( isMasterView ( ) )
{
assosiatedViewLinker ( ) - > updateUiNameAndIcon ( ) ;
assosiatedViewLinker ( ) - > updateConnectedEditors ( ) ;
}
}
2015-05-08 14:13:26 +02:00
}
else if ( changedField = = & m_currentTimeStep )
{
if ( m_viewer )
{
2015-09-01 18:04:35 +02:00
m_viewer - > update ( ) ;
2015-08-25 12:40:55 +02:00
2015-09-25 11:01:41 +02:00
RimViewLinker * viewLinker = this - > assosiatedViewLinker ( ) ;
2015-09-07 14:29:46 +02:00
if ( viewLinker )
2015-09-01 17:14:22 +02:00
{
2015-09-23 11:01:46 +02:00
viewLinker - > updateTimeStep ( this , m_currentTimeStep ) ;
2015-09-01 17:14:22 +02:00
}
2015-05-08 14:13:26 +02:00
}
}
else if ( changedField = = & backgroundColor )
{
2017-01-17 13:06:57 +01:00
if ( m_viewer ! = nullptr )
2015-05-08 14:13:26 +02:00
{
2017-01-17 13:06:57 +01:00
m_viewer - > mainCamera ( ) - > viewport ( ) - > setClearColor ( cvf : : Color4f ( backgroundColor ( ) ) ) ;
2015-05-08 14:13:26 +02:00
}
}
else if ( changedField = = & maximumFrameRate )
{
// !! Use cvf::UNDEFINED_INT or something if we end up with frame rate 0?
// !! Should be able to specify legal range for number properties
if ( m_viewer )
{
m_viewer - > animationControl ( ) - > setTimeout ( maximumFrameRate ! = 0 ? 1000 / maximumFrameRate : INT_MAX ) ;
}
}
}
2015-06-11 13:44:21 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-22 09:09:33 +02:00
void RimView : : addWellPathsToModel ( cvf : : ModelBasicList * wellPathModelBasicList ,
const cvf : : Vec3d & displayModelOffset ,
double characteristicCellSize ,
const cvf : : BoundingBox & wellPathClipBoundingBox ,
2015-06-12 09:25:09 +02:00
cvf : : Transform * scaleTransform )
2015-06-11 13:44:21 +02:00
{
RimOilField * oilFields = RiaApplication : : instance ( ) - > project ( ) ? RiaApplication : : instance ( ) - > project ( ) - > activeOilField ( ) : NULL ;
RimWellPathCollection * wellPathCollection = oilFields ? oilFields - > wellPathCollection ( ) : NULL ;
RivWellPathCollectionPartMgr * wellPathCollectionPartMgr = wellPathCollection ? wellPathCollection - > wellPathCollectionPartMgr ( ) : NULL ;
if ( wellPathCollectionPartMgr )
{
2015-06-22 09:09:33 +02:00
wellPathCollectionPartMgr - > appendStaticGeometryPartsToModel ( wellPathModelBasicList ,
displayModelOffset ,
scaleTransform ,
characteristicCellSize ,
wellPathClipBoundingBox ) ;
2015-06-11 13:44:21 +02:00
}
wellPathModelBasicList - > updateBoundingBoxesRecursive ( ) ;
}
2015-08-27 13:44:27 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCellRangeFilterCollection * RimView : : rangeFilterCollection ( )
{
2015-10-21 13:27:10 +02:00
if ( this - > viewController ( ) & & this - > viewController ( ) - > isRangeFiltersControlled ( ) & & m_overrideRangeFilterCollection )
2015-08-27 13:44:27 +02:00
{
return m_overrideRangeFilterCollection ;
}
else
{
return m_rangeFilterCollection ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimCellRangeFilterCollection * RimView : : rangeFilterCollection ( ) const
{
2015-10-21 13:27:10 +02:00
if ( this - > viewController ( ) & & this - > viewController ( ) - > isRangeFiltersControlled ( ) & & m_overrideRangeFilterCollection )
2015-08-27 13:44:27 +02:00
{
return m_overrideRangeFilterCollection ;
}
else
{
return m_rangeFilterCollection ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setOverrideRangeFilterCollection ( RimCellRangeFilterCollection * rfc )
{
2015-10-20 11:13:31 +02:00
if ( m_overrideRangeFilterCollection ( ) ) delete m_overrideRangeFilterCollection ( ) ;
2015-08-27 13:44:27 +02:00
m_overrideRangeFilterCollection = rfc ;
2015-09-13 08:54:32 +02:00
this - > scheduleGeometryRegen ( RANGE_FILTERED ) ;
this - > scheduleGeometryRegen ( RANGE_FILTERED_INACTIVE ) ;
this - > scheduleCreateDisplayModelAndRedraw ( ) ;
2015-08-27 13:44:27 +02:00
}
2015-09-01 18:21:20 +02:00
2015-09-03 13:06:00 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setScaleZAndUpdate ( double scaleZ )
{
this - > scaleZ = scaleZ ;
updateScaleTransform ( ) ;
2016-11-24 14:05:51 +01:00
this - > updateGridBoxData ( ) ;
2015-09-22 21:00:50 +02:00
this - > scheduleCreateDisplayModelAndRedraw ( ) ;
2015-09-03 13:06:00 +02:00
}
2015-09-14 16:14:44 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-09-25 11:01:41 +02:00
RimViewController * RimView : : viewController ( ) const
{
RimViewController * viewController = NULL ;
std : : vector < caf : : PdmObjectHandle * > reffingObjs ;
this - > objectsWithReferringPtrFields ( reffingObjs ) ;
for ( size_t i = 0 ; i < reffingObjs . size ( ) ; + + i )
{
viewController = dynamic_cast < RimViewController * > ( reffingObjs [ i ] ) ;
if ( viewController ) break ;
}
return viewController ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewLinker * RimView : : viewLinkerIfMasterView ( ) const
{
RimViewLinker * viewLinker = NULL ;
std : : vector < caf : : PdmObjectHandle * > reffingObjs ;
this - > objectsWithReferringPtrFields ( reffingObjs ) ;
for ( size_t i = 0 ; i < reffingObjs . size ( ) ; + + i )
{
viewLinker = dynamic_cast < RimViewLinker * > ( reffingObjs [ i ] ) ;
if ( viewLinker ) break ;
}
return viewLinker ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewLinker * RimView : : assosiatedViewLinker ( ) const
2015-09-14 16:14:44 +02:00
{
2015-09-25 11:01:41 +02:00
RimViewLinker * viewLinker = this - > viewLinkerIfMasterView ( ) ;
if ( ! viewLinker )
{
RimViewController * viewController = this - > viewController ( ) ;
if ( viewController )
{
viewLinker = viewController - > ownerViewLinker ( ) ;
}
}
return viewLinker ;
2015-09-14 16:14:44 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf : : ref < cvf : : UByteArray > RimView : : currentTotalCellVisibility ( )
{
if ( m_currentReservoirCellVisibility . isNull ( ) )
{
m_currentReservoirCellVisibility = new cvf : : UByteArray ;
this - > calculateCurrentTotalCellVisibility ( m_currentReservoirCellVisibility . p ( ) ) ;
}
return m_currentReservoirCellVisibility ;
}
2015-09-25 11:01:41 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimView : : isMasterView ( ) const
{
RimViewLinker * viewLinker = this - > assosiatedViewLinker ( ) ;
if ( viewLinker & & this = = viewLinker - > masterView ( ) )
{
return true ;
}
return false ;
}
2015-10-19 12:10:18 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-11-12 10:48:13 +01:00
bool RimView : : hasOverridenRangeFilterCollection ( )
2015-10-19 12:10:18 +02:00
{
2015-11-12 10:48:13 +01:00
return m_overrideRangeFilterCollection ( ) ! = NULL ;
2015-10-19 12:10:18 +02:00
}
2015-10-21 12:45:35 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : replaceRangeFilterCollectionWithOverride ( )
{
RimCellRangeFilterCollection * overrideRfc = m_overrideRangeFilterCollection ;
CVF_ASSERT ( overrideRfc ) ;
RimCellRangeFilterCollection * currentRfc = m_rangeFilterCollection ;
if ( currentRfc )
{
delete currentRfc ;
}
// Must call removeChildObject() to make sure the object has no parent
// No parent is required when assigning a object into a field
m_overrideRangeFilterCollection . removeChildObject ( overrideRfc ) ;
m_rangeFilterCollection = overrideRfc ;
this - > uiCapability ( ) - > updateConnectedEditors ( ) ;
}
2015-11-09 19:05:00 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : removeModelByName ( cvf : : Scene * scene , const cvf : : String & modelName )
{
std : : vector < cvf : : Model * > modelsToBeRemoved ;
for ( cvf : : uint i = 0 ; i < scene - > modelCount ( ) ; i + + )
{
if ( scene - > model ( i ) - > name ( ) = = modelName )
{
modelsToBeRemoved . push_back ( scene - > model ( i ) ) ;
}
}
for ( size_t i = 0 ; i < modelsToBeRemoved . size ( ) ; i + + )
{
scene - > removeModel ( modelsToBeRemoved [ i ] ) ;
}
}
2015-11-16 07:16:30 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : updateGridBoxData ( )
{
2015-11-16 14:08:17 +01:00
if ( m_viewer )
2015-11-16 07:16:30 +01:00
{
2015-11-16 14:08:17 +01:00
m_viewer - > updateGridBoxData ( ) ;
2015-11-16 07:16:30 +01:00
}
}
2015-11-16 11:30:03 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-11-19 11:41:16 +01:00
void RimView : : createHighlightAndGridBoxDisplayModelWithRedraw ( )
2015-11-16 11:30:03 +01:00
{
2015-11-19 11:41:16 +01:00
createHighlightAndGridBoxDisplayModel ( ) ;
2015-11-16 11:30:03 +01:00
if ( m_viewer )
{
m_viewer - > update ( ) ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-11-19 11:41:16 +01:00
void RimView : : createHighlightAndGridBoxDisplayModel ( )
2015-11-16 11:30:03 +01:00
{
2015-11-23 11:21:12 +01:00
m_viewer - > removeStaticModel ( m_highlightVizModel . p ( ) ) ;
2015-11-19 11:41:16 +01:00
m_viewer - > removeStaticModel ( m_viewer - > gridBoxModel ( ) ) ;
2015-11-23 11:21:12 +01:00
m_highlightVizModel - > removeAllParts ( ) ;
2015-11-16 11:30:03 +01:00
cvf : : Collection < cvf : : Part > parts ;
createPartCollectionFromSelection ( & parts ) ;
if ( parts . size ( ) > 0 )
{
for ( size_t i = 0 ; i < parts . size ( ) ; i + + )
{
2015-11-23 11:21:12 +01:00
m_highlightVizModel - > addPart ( parts [ i ] . p ( ) ) ;
2015-11-16 11:30:03 +01:00
}
2015-11-23 11:21:12 +01:00
m_highlightVizModel - > updateBoundingBoxesRecursive ( ) ;
m_viewer - > addStaticModelOnce ( m_highlightVizModel . p ( ) ) ;
2015-11-16 11:30:03 +01:00
}
2015-11-16 11:44:41 +01:00
if ( showGridBox )
2015-11-16 11:30:03 +01:00
{
2015-11-23 11:21:12 +01:00
m_viewer - > addStaticModelOnce ( m_viewer - > gridBoxModel ( ) ) ;
2015-11-16 11:30:03 +01:00
}
}
2015-11-16 14:08:17 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimView : : showActiveCellsOnly ( )
{
return false ;
}
2015-12-07 09:59:19 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : selectOverlayInfoConfig ( )
{
2015-12-07 10:07:51 +01:00
RiuMainWindow : : instance ( ) - > selectAsCurrentItem ( m_overlayInfoConfig ) ;
2015-12-07 09:59:19 +01:00
}
2016-07-05 10:47:03 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : zoomAll ( )
{
if ( m_viewer )
{
m_viewer - > zoomAll ( ) ;
}
}
2016-09-29 11:43:47 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf : : ref < caf : : DisplayCoordTransform > RimView : : displayCoordTransform ( )
{
cvf : : ref < caf : : DisplayCoordTransform > coordTrans = new caf : : DisplayCoordTransform ;
cvf : : Vec3d scale ( 1.0 , 1.0 , scaleZ ) ;
coordTrans - > setScale ( scale ) ;
RimCase * rimCase = ownerCase ( ) ;
if ( rimCase )
{
coordTrans - > setTranslation ( rimCase - > displayModelOffset ( ) ) ;
}
return coordTrans ;
}
2016-10-27 11:03:13 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget * RimView : : viewWidget ( )
{
2017-01-17 13:06:57 +01:00
if ( m_viewer ) return m_viewer - > layoutWidget ( ) ;
else return nullptr ;
2016-10-27 11:03:13 +02:00
}
2017-01-20 16:25:05 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : forceShowWindowOn ( )
{
m_showWindow . setValueWithFieldChanged ( true ) ;
}