2015-04-29 03:50:25 -05:00
# include "RimView.h"
2015-04-29 15:19:49 -05:00
# include "RiaApplication.h"
# include "RiaPreferences.h"
2015-08-25 05:40:55 -05:00
2015-04-29 15:19:49 -05:00
# include "Rim3dOverlayInfoConfig.h"
2015-08-27 06:44:27 -05:00
# include "RimCellRangeFilterCollection.h"
2015-09-03 06:06:00 -05:00
# include "RimEclipseCase.h"
# include "RimEclipseView.h"
2015-11-27 05:17:50 -06:00
# include "RimGridCollection.h"
2016-10-25 02:50:33 -05:00
# include "RimIntersectionCollection.h"
2017-03-29 07:02:32 -05:00
# include "RimMainPlotCollection.h"
2015-08-25 05:40:55 -05:00
# include "RimOilField.h"
# include "RimProject.h"
2015-11-18 02:15:13 -06:00
# include "RimPropertyFilterCollection.h"
2015-10-22 04:41:27 -05:00
# include "RimViewController.h"
2015-09-07 07:29:46 -05:00
# include "RimViewLinker.h"
2015-10-22 04:41:27 -05:00
# include "RimViewLinkerCollection.h"
2015-08-25 05:40:55 -05:00
# include "RimWellPathCollection.h"
2015-04-30 03:34:15 -05:00
# include "RiuMainWindow.h"
2015-08-25 05:40:55 -05:00
# include "RiuViewer.h"
# include "RivWellPathCollectionPartMgr.h"
2016-09-29 04:43:47 -05:00
# include "cafDisplayCoordTransform.h"
2015-08-25 05:40:55 -05:00
# include "cafFrameAnimationControl.h"
# include "cafPdmObjectFactory.h"
2016-09-29 04:43:47 -05:00
2015-04-30 03:34:15 -05:00
# include "cvfCamera.h"
2015-06-11 06:44:21 -05:00
# include "cvfModel.h"
# include "cvfModelBasicList.h"
# include "cvfPart.h"
# include "cvfScene.h"
2015-04-30 03:34:15 -05:00
# include "cvfViewport.h"
2015-04-29 15:19:49 -05:00
2015-05-11 02:48:55 -05:00
# include <limits.h>
2015-05-08 07:13:26 -05:00
namespace caf {
template < >
void caf : : AppEnum < RimView : : MeshModeType > : : setUp ( )
{
addItem ( RimView : : FULL_MESH , " FULL_MESH " , " All " ) ;
2015-11-18 02:15:13 -06:00
addItem ( RimView : : FAULTS_MESH , " FAULTS_MESH " , " Faults only " ) ;
addItem ( RimView : : NO_MESH , " NO_MESH " , " None " ) ;
2015-05-08 07:13:26 -05: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 08:09:19 -05:00
CAF_PDM_XML_ABSTRACT_SOURCE_INIT ( RimView , " GenericView " ) ; // Do not use. Abstract class
2015-04-29 03:50:25 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimView : : RimView ( void )
{
2015-04-29 15:19:49 -05: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 14:51:02 -05:00
cameraPosition . uiCapability ( ) - > setUiHidden ( true ) ;
2015-12-04 17:56:14 -06:00
2016-08-16 07:34:37 -05:00
CAF_PDM_InitField ( & cameraPointOfInterest , " CameraPointOfInterest " , cvf : : Vec3d : : ZERO , " " , " " , " " , " " ) ;
cameraPointOfInterest . uiCapability ( ) - > setUiHidden ( true ) ;
2015-12-04 17:56:14 -06:00
CAF_PDM_InitField ( & isPerspectiveView , " PerspectiveProjection " , true , " Perspective Projection " , " " , " " , " " ) ;
2015-04-29 15:19:49 -05:00
2015-10-26 04:29:57 -05:00
double defaultScaleFactor = preferences - > defaultScaleFactorZ ;
2015-04-29 15:19:49 -05: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 06:27:36 -05:00
maximumFrameRate . uiCapability ( ) - > setUiHidden ( true ) ;
2015-06-09 09:18:11 -05:00
CAF_PDM_InitField ( & hasUserRequestedAnimation , " AnimationMode " , false , " Animation Mode " , " " , " " , " " ) ;
2015-08-05 06:27:36 -05:00
hasUserRequestedAnimation . uiCapability ( ) - > setUiHidden ( true ) ;
2015-04-29 15:19:49 -05:00
CAF_PDM_InitField ( & m_currentTimeStep , " CurrentTimeStep " , 0 , " Current Time Step " , " " , " " , " " ) ;
2015-08-05 06:27:36 -05:00
m_currentTimeStep . uiCapability ( ) - > setUiHidden ( true ) ;
2015-04-29 15:19:49 -05:00
2015-08-27 06:44:27 -05: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 15:19:49 -05:00
2015-05-08 07:13:26 -05: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 03:50:25 -05:00
2015-11-27 03:47:12 -06:00
CAF_PDM_InitField ( & showGridBox , " ShowGridBox " , true , " Show Grid Box " , " " , " " , " " ) ;
2015-11-16 04:44:41 -06:00
2015-06-18 06:20:54 -05:00
CAF_PDM_InitField ( & m_disableLighting , " DisableLighting " , false , " Disable Results Lighting " , " " , " Disable light model for scalar result colors " , " " ) ;
2015-06-17 08:04:55 -05:00
2015-09-01 15:11:39 -05:00
2015-10-19 05:10:18 -05:00
CAF_PDM_InitFieldNoDefault ( & m_rangeFilterCollection , " RangeFilters " , " Range Filters " , " " , " " , " " ) ;
m_rangeFilterCollection . uiCapability ( ) - > setUiHidden ( true ) ;
2015-10-21 05:21:08 -05:00
m_rangeFilterCollection = new RimCellRangeFilterCollection ( ) ;
2015-10-19 05:10:18 -05: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 02:07:35 -06:00
CAF_PDM_InitFieldNoDefault ( & crossSectionCollection , " CrossSections " , " Intersections " , " " , " " , " " ) ;
2015-11-18 08:09:50 -06:00
crossSectionCollection . uiCapability ( ) - > setUiHidden ( true ) ;
2016-09-21 03:52:16 -05:00
crossSectionCollection = new RimIntersectionCollection ( ) ;
2015-11-18 02:15:13 -06:00
2015-11-27 05:17:50 -06:00
CAF_PDM_InitFieldNoDefault ( & m_gridCollection , " GridCollection " , " GridCollection " , " " , " " , " " ) ;
m_gridCollection . uiCapability ( ) - > setUiHidden ( true ) ;
m_gridCollection = new RimGridCollection ( ) ;
2015-05-08 07:13:26 -05:00
m_previousGridModeMeshLinesWasFaults = false ;
2015-11-19 04:41:16 -06:00
2015-11-23 04:21:12 -06:00
m_crossSectionVizModel = new cvf : : ModelBasicList ;
m_crossSectionVizModel - > setName ( " CrossSectionModel " ) ;
2015-11-19 04:41:16 -06:00
2015-11-23 04:21:12 -06:00
m_highlightVizModel = new cvf : : ModelBasicList ;
m_highlightVizModel - > setName ( " HighlightModel " ) ;
m_wellPathPipeVizModel = new cvf : : ModelBasicList ;
m_wellPathPipeVizModel - > setName ( " WellPathPipeModel " ) ;
2017-01-17 06:06:57 -06:00
2017-01-20 04:38:18 -06:00
this - > setAs3DViewMdiWindow ( ) ;
2015-04-29 03:50:25 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimView : : ~ RimView ( void )
{
2015-10-22 04:41:27 -05: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 06:44:27 -05:00
delete this - > m_overlayInfoConfig ( ) ;
2015-04-30 03:34:15 -05:00
2017-01-20 04:38:18 -06:00
removeMdiWindowFromMdiArea ( ) ;
2015-04-30 03:34:15 -05:00
2017-01-17 06:06:57 -06:00
deleteViewWidget ( ) ;
2015-10-19 05:10:18 -05:00
delete m_rangeFilterCollection ;
delete m_overrideRangeFilterCollection ;
2015-12-03 01:26:38 -06:00
delete crossSectionCollection ;
2015-12-09 06:52:25 -06:00
delete m_gridCollection ;
2015-04-29 03:50:25 -05:00
}
2015-04-29 15:19:49 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuViewer * RimView : : viewer ( )
{
return m_viewer ;
}
2015-04-30 03:34:15 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-01-17 06:06:57 -06:00
QWidget * RimView : : createViewWidget ( QWidget * mainWindowParent )
2015-04-30 03:34:15 -05:00
{
2017-01-17 06:06:57 -06:00
QGLFormat glFormat ;
glFormat . setDirectRendering ( RiaApplication : : instance ( ) - > useShaders ( ) ) ;
2015-04-30 03:34:15 -05:00
2017-01-17 06:06:57 -06:00
m_viewer = new RiuViewer ( glFormat , NULL ) ;
m_viewer - > setOwnerReservoirView ( this ) ;
2015-04-30 03:34:15 -05:00
2017-01-17 06:06:57 -06:00
return m_viewer - > layoutWidget ( ) ;
}
2015-04-30 03:34:15 -05:00
2017-01-17 06:06:57 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : updateViewWidgetAfterCreation ( )
{
m_viewer - > setDefaultPerspectiveNearPlaneDistance ( 10 ) ;
2015-04-30 03:34:15 -05:00
2017-01-17 06:06:57 -06:00
this - > resetLegendsInViewer ( ) ;
2015-04-30 03:34:15 -05:00
2017-01-17 06:06:57 -06:00
m_viewer - > updateNavigationPolicy ( ) ;
m_viewer - > enablePerfInfoHud ( RiaApplication : : instance ( ) - > showPerformanceInfo ( ) ) ;
2015-04-30 03:34:15 -05:00
2017-01-17 06:06:57 -06:00
m_viewer - > mainCamera ( ) - > setViewMatrix ( cameraPosition ) ;
m_viewer - > setPointOfInterest ( cameraPointOfInterest ( ) ) ;
m_viewer - > enableParallelProjection ( ! isPerspectiveView ( ) ) ;
2015-11-16 07:08:17 -06:00
2017-01-17 06:06:57 -06:00
m_viewer - > mainCamera ( ) - > viewport ( ) - > setClearColor ( cvf : : Color4f ( backgroundColor ( ) ) ) ;
this - > updateGridBoxData ( ) ;
this - > createHighlightAndGridBoxDisplayModel ( ) ;
m_viewer - > update ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-01-20 04:38:18 -06:00
void RimView : : updateMdiWindowTitle ( )
2017-01-17 06:06:57 -06:00
{
if ( m_viewer )
2015-04-30 03:34:15 -05:00
{
2017-01-17 06:06:57 -06:00
QString windowTitle ;
if ( ownerCase ( ) )
2015-04-30 03:34:15 -05:00
{
2017-01-17 06:06:57 -06:00
windowTitle = QString ( " %1 - %2 " ) . arg ( ownerCase ( ) - > caseUserDescription ( ) ) . arg ( name ) ;
}
else
{
windowTitle = name ;
2015-04-30 03:34:15 -05:00
}
2017-01-17 06:06:57 -06:00
m_viewer - > layoutWidget ( ) - > setWindowTitle ( windowTitle ) ;
}
2015-04-30 03:34:15 -05:00
}
2017-01-17 06:06:57 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : deleteViewWidget ( )
{
if ( m_viewer )
{
m_viewer - > deleteLater ( ) ;
m_viewer = nullptr ;
}
}
2017-04-06 11:37:43 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : defineUiOrdering ( QString uiConfigName , caf : : PdmUiOrdering & uiOrdering )
{
caf : : PdmUiGroup * viewGroup = uiOrdering . addNewGroup ( " Viewer " ) ;
viewGroup - > add ( & name ) ;
viewGroup - > add ( & backgroundColor ) ;
viewGroup - > add ( & showGridBox ) ;
viewGroup - > add ( & isPerspectiveView ) ;
viewGroup - > add ( & m_disableLighting ) ;
caf : : PdmUiGroup * gridGroup = uiOrdering . addNewGroup ( " Grid Appearance " ) ;
gridGroup - > add ( & scaleZ ) ;
gridGroup - > add ( & meshMode ) ;
gridGroup - > add ( & surfaceMode ) ;
}
2016-06-27 14:01:17 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QImage RimView : : snapshotWindowContent ( )
{
if ( m_viewer )
{
2016-12-22 01:44:36 -06:00
// Force update of scheduled display models before snapshotting
RiaApplication : : instance ( ) - > slotUpdateScheduledDisplayModels ( ) ;
2016-06-27 14:01:17 -05:00
m_viewer - > repaint ( ) ;
2016-08-31 10:34:31 -05:00
return m_viewer - > snapshotImage ( ) ;
2016-06-27 14:01:17 -05:00
}
2016-08-31 10:34:31 -05:00
return QImage ( ) ;
2016-06-27 14:01:17 -05:00
}
2015-04-30 03:34:15 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : scheduleCreateDisplayModelAndRedraw ( )
{
RiaApplication : : instance ( ) - > scheduleDisplayModelUpdateAndRedraw ( this ) ;
2015-09-25 04:01:41 -05:00
if ( this - > isMasterView ( ) )
2015-09-13 01:54:32 -05:00
{
2015-09-25 04:01:41 -05:00
RimViewLinker * viewLinker = this - > assosiatedViewLinker ( ) ;
if ( viewLinker )
{
viewLinker - > scheduleCreateDisplayModelAndRedrawForDependentViews ( ) ;
}
2015-09-13 01:54:32 -05:00
}
2015-04-30 03:34:15 -05:00
}
2015-05-08 03:38:10 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-03-02 09:10:18 -06:00
void RimView : : setCurrentTimeStepAndUpdate ( int frameIndex )
2015-05-08 03:38:10 -05:00
{
2017-03-14 10:20:59 -05:00
setCurrentTimeStep ( frameIndex ) ;
2015-08-31 05:31:38 -05:00
2015-05-08 03:38:10 -05:00
this - > updateCurrentTimeStep ( ) ;
2017-03-29 07:02:32 -05:00
RimProject * project ;
firstAncestorOrThisOfTypeAsserted ( project ) ;
project - > mainPlotCollection ( ) - > updateCurrentTimeStepInPlots ( ) ;
2015-05-08 03:38:10 -05:00
}
2017-03-02 09:10:18 -06: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 03:38:10 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : updateCurrentTimeStepAndRedraw ( )
{
this - > updateCurrentTimeStep ( ) ;
2017-03-29 07:02:32 -05:00
RimProject * project ;
firstAncestorOrThisOfTypeAsserted ( project ) ;
project - > mainPlotCollection ( ) - > updateCurrentTimeStepInPlots ( ) ;
2015-09-01 11:04:35 -05:00
if ( m_viewer ) m_viewer - > update ( ) ;
2015-05-08 03:38:10 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : createDisplayModelAndRedraw ( )
{
if ( m_viewer )
{
this - > clampCurrentTimestep ( ) ;
createDisplayModel ( ) ;
2015-11-19 04:41:16 -06:00
createHighlightAndGridBoxDisplayModel ( ) ;
2015-11-16 05:08:53 -06:00
updateDisplayModelVisibility ( ) ;
2015-09-21 10:45:54 -05:00
if ( cameraPosition ( ) . isIdentity ( ) )
{
setDefaultView ( ) ;
2015-09-21 11:01:21 -05:00
cameraPosition = m_viewer - > mainCamera ( ) - > viewMatrix ( ) ;
2016-08-16 07:34:37 -05:00
cameraPointOfInterest = m_viewer - > pointOfInterest ( ) ;
2015-09-21 10:45:54 -05:00
}
2015-05-08 03:38:10 -05:00
}
2015-06-17 08:04:55 -05:00
RiuMainWindow : : instance ( ) - > refreshAnimationActions ( ) ;
2015-05-08 03:38:10 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setDefaultView ( )
{
if ( m_viewer )
{
m_viewer - > setDefaultView ( ) ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : endAnimation ( )
{
2015-06-09 09:18:11 -05:00
this - > hasUserRequestedAnimation = false ;
2015-05-08 03:38:10 -05:00
this - > updateStaticCellColors ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setupBeforeSave ( )
{
if ( m_viewer )
{
2015-06-09 09:18:11 -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...
2015-05-08 03:38:10 -05:00
cameraPosition = m_viewer - > mainCamera ( ) - > viewMatrix ( ) ;
2016-08-16 07:34:37 -05:00
cameraPointOfInterest = m_viewer - > pointOfInterest ( ) ;
2016-05-26 06:17:26 -05:00
}
2015-05-08 03:38:10 -05:00
}
2015-04-30 03:34:15 -05:00
2015-05-08 07:13:26 -05: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 08:30:52 -05:00
meshMode . setValueWithFieldChanged ( FULL_MESH ) ;
2015-05-08 07:13:26 -05:00
}
else
{
2016-10-19 08:30:52 -05:00
meshMode . setValueWithFieldChanged ( FAULTS_MESH ) ;
2015-05-08 07:13:26 -05:00
}
2016-10-19 08:30:52 -05:00
surfaceMode . setValueWithFieldChanged ( NO_SURFACE ) ;
2015-05-08 07:13:26 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setMeshSurfDrawstyle ( )
{
if ( isGridVisualizationMode ( ) )
{
2016-10-19 08:30:52 -05:00
surfaceMode . setValueWithFieldChanged ( SURFACE ) ;
meshMode . setValueWithFieldChanged ( FULL_MESH ) ;
2015-05-08 07:13:26 -05:00
}
else
{
2016-10-19 08:30:52 -05:00
surfaceMode . setValueWithFieldChanged ( FAULTS ) ;
meshMode . setValueWithFieldChanged ( FAULTS_MESH ) ;
2015-05-08 07:13:26 -05: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 08:30:52 -05:00
surfaceMode . setValueWithFieldChanged ( SURFACE ) ;
2015-05-08 07:13:26 -05:00
}
else
{
2016-10-19 08:30:52 -05:00
surfaceMode . setValueWithFieldChanged ( FAULTS ) ;
2015-05-08 07:13:26 -05:00
}
2016-10-19 08:30:52 -05:00
meshMode . setValueWithFieldChanged ( FAULTS_MESH ) ;
2015-05-08 07:13:26 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setSurfOnlyDrawstyle ( )
{
if ( isGridVisualizationMode ( ) )
{
2016-10-19 08:30:52 -05:00
surfaceMode . setValueWithFieldChanged ( SURFACE ) ;
2015-05-08 07:13:26 -05:00
}
else
{
2016-10-19 08:30:52 -05:00
surfaceMode . setValueWithFieldChanged ( FAULTS ) ;
2015-05-08 07:13:26 -05:00
}
2015-07-31 11:58:23 -05:00
2016-10-19 08:30:52 -05:00
meshMode . setValueWithFieldChanged ( NO_MESH ) ;
2015-05-08 07:13:26 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-11-27 06:45:02 -06:00
void RimView : : showGridCells ( bool enableGridCells )
2015-05-08 07:13:26 -05:00
{
2015-11-27 06:45:02 -06:00
if ( ! enableGridCells )
2015-05-08 07:13:26 -05:00
{
m_previousGridModeMeshLinesWasFaults = meshMode ( ) = = FAULTS_MESH ;
2016-10-19 08:30:52 -05:00
if ( surfaceMode ( ) ! = NO_SURFACE ) surfaceMode . setValueWithFieldChanged ( FAULTS ) ;
if ( meshMode ( ) ! = NO_MESH ) meshMode . setValueWithFieldChanged ( FAULTS_MESH ) ;
2015-05-08 07:13:26 -05:00
}
else
{
2016-10-19 08:30:52 -05:00
if ( surfaceMode ( ) ! = NO_SURFACE ) surfaceMode . setValueWithFieldChanged ( SURFACE ) ;
if ( meshMode ( ) ! = NO_MESH ) meshMode . setValueWithFieldChanged ( m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH ) ;
2015-05-08 07:13:26 -05:00
}
2015-11-27 06:45:02 -06:00
m_gridCollection - > isActive = enableGridCells ;
m_gridCollection - > updateConnectedEditors ( ) ;
m_gridCollection - > updateUiIconFromState ( enableGridCells ) ;
2015-05-08 07:13:26 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setSurfaceDrawstyle ( )
{
2016-10-19 08:30:52 -05:00
if ( surfaceMode ( ) ! = NO_SURFACE ) surfaceMode . setValueWithFieldChanged ( SURFACE ) ;
2015-05-08 07:13:26 -05:00
}
2015-06-17 08:04:55 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : disableLighting ( bool disable )
{
m_disableLighting = disable ;
updateCurrentTimeStepAndRedraw ( ) ;
updateConnectedEditors ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimView : : isLightingDisabled ( ) const
{
return m_disableLighting ( ) ;
}
2015-05-08 07:13:26 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : fieldChangedByUi ( const caf : : PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
{
2017-01-20 09:25:05 -06:00
RimViewWindow : : fieldChangedByUi ( changedField , oldValue , newValue ) ;
2015-05-08 07:13:26 -05:00
if ( changedField = = & meshMode )
{
createDisplayModel ( ) ;
updateDisplayModelVisibility ( ) ;
RiuMainWindow : : instance ( ) - > refreshDrawStyleActions ( ) ;
2015-11-27 05:17:50 -06:00
RiuMainWindow : : instance ( ) - > refreshAnimationActions ( ) ;
2015-05-08 07:13:26 -05:00
}
2015-12-04 17:56:14 -06:00
else if ( changedField = = & isPerspectiveView )
{
if ( m_viewer ) m_viewer - > enableParallelProjection ( ! isPerspectiveView ( ) ) ;
}
2015-05-13 15:42:11 -05:00
else if ( changedField = = & scaleZ )
{
if ( scaleZ < 1 ) scaleZ = 1 ;
2015-11-16 00:16:30 -06:00
this - > updateGridBoxData ( ) ;
2015-05-13 15:42:11 -05: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 02:50:33 -05:00
crossSectionCollection - > updateIntersectionBoxGeometry ( ) ;
2015-05-13 15:42:11 -05: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 06:06:00 -05:00
2015-09-23 05:50:06 -05:00
m_viewer - > update ( ) ;
2015-09-25 04:01:41 -05:00
RimViewLinker * viewLinker = this - > assosiatedViewLinker ( ) ;
2015-09-07 07:29:46 -05:00
if ( viewLinker )
2015-09-03 06:06:00 -05:00
{
2015-09-23 04:01:46 -05:00
viewLinker - > updateScaleZ ( this , scaleZ ) ;
2015-09-23 05:50:06 -05:00
viewLinker - > updateCamera ( this ) ;
2015-09-03 06:06:00 -05:00
}
2015-05-13 15:42:11 -05:00
}
RiuMainWindow : : instance ( ) - > updateScaleValue ( ) ;
}
2015-05-08 07:13:26 -05:00
else if ( changedField = = & surfaceMode )
{
createDisplayModel ( ) ;
updateDisplayModelVisibility ( ) ;
RiuMainWindow : : instance ( ) - > refreshDrawStyleActions ( ) ;
2015-11-27 05:17:50 -06:00
RiuMainWindow : : instance ( ) - > refreshAnimationActions ( ) ;
2015-05-08 07:13:26 -05:00
}
2015-11-16 04:44:41 -06:00
else if ( changedField = = & showGridBox )
{
2015-11-19 04:41:16 -06:00
createHighlightAndGridBoxDisplayModelWithRedraw ( ) ;
2015-11-16 04:44:41 -06:00
}
2015-06-17 08:04:55 -05:00
else if ( changedField = = & m_disableLighting )
{
createDisplayModel ( ) ;
RiuMainWindow : : instance ( ) - > refreshDrawStyleActions ( ) ;
2015-11-27 05:17:50 -06:00
RiuMainWindow : : instance ( ) - > refreshAnimationActions ( ) ;
2015-06-17 08:04:55 -05:00
}
2015-05-08 07:13:26 -05:00
else if ( changedField = = & name )
{
2017-01-20 04:38:18 -06:00
updateMdiWindowTitle ( ) ;
2015-09-25 09:39:19 -05:00
if ( viewController ( ) )
{
viewController ( ) - > updateDisplayNameAndIcon ( ) ;
viewController ( ) - > updateConnectedEditors ( ) ;
}
else
{
if ( isMasterView ( ) )
{
assosiatedViewLinker ( ) - > updateUiNameAndIcon ( ) ;
assosiatedViewLinker ( ) - > updateConnectedEditors ( ) ;
}
}
2015-05-08 07:13:26 -05:00
}
else if ( changedField = = & m_currentTimeStep )
{
if ( m_viewer )
{
2015-09-01 11:04:35 -05:00
m_viewer - > update ( ) ;
2015-08-25 05:40:55 -05:00
2015-09-25 04:01:41 -05:00
RimViewLinker * viewLinker = this - > assosiatedViewLinker ( ) ;
2015-09-07 07:29:46 -05:00
if ( viewLinker )
2015-09-01 10:14:22 -05:00
{
2015-09-23 04:01:46 -05:00
viewLinker - > updateTimeStep ( this , m_currentTimeStep ) ;
2015-09-01 10:14:22 -05:00
}
2015-05-08 07:13:26 -05:00
}
}
else if ( changedField = = & backgroundColor )
{
2017-01-17 06:06:57 -06:00
if ( m_viewer ! = nullptr )
2015-05-08 07:13:26 -05:00
{
2017-01-17 06:06:57 -06:00
m_viewer - > mainCamera ( ) - > viewport ( ) - > setClearColor ( cvf : : Color4f ( backgroundColor ( ) ) ) ;
2015-05-08 07:13:26 -05: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 06:44:21 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-22 02:09:33 -05:00
void RimView : : addWellPathsToModel ( cvf : : ModelBasicList * wellPathModelBasicList ,
const cvf : : Vec3d & displayModelOffset ,
double characteristicCellSize ,
const cvf : : BoundingBox & wellPathClipBoundingBox ,
2015-06-12 02:25:09 -05:00
cvf : : Transform * scaleTransform )
2015-06-11 06:44:21 -05: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 02:09:33 -05:00
wellPathCollectionPartMgr - > appendStaticGeometryPartsToModel ( wellPathModelBasicList ,
displayModelOffset ,
scaleTransform ,
characteristicCellSize ,
2017-05-05 05:12:51 -05:00
wellPathClipBoundingBox ,
this - > displayCoordTransform ( ) . p ( ) ) ;
2015-06-11 06:44:21 -05:00
}
wellPathModelBasicList - > updateBoundingBoxesRecursive ( ) ;
}
2015-08-27 06:44:27 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCellRangeFilterCollection * RimView : : rangeFilterCollection ( )
{
2015-10-21 06:27:10 -05:00
if ( this - > viewController ( ) & & this - > viewController ( ) - > isRangeFiltersControlled ( ) & & m_overrideRangeFilterCollection )
2015-08-27 06:44:27 -05:00
{
return m_overrideRangeFilterCollection ;
}
else
{
return m_rangeFilterCollection ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimCellRangeFilterCollection * RimView : : rangeFilterCollection ( ) const
{
2015-10-21 06:27:10 -05:00
if ( this - > viewController ( ) & & this - > viewController ( ) - > isRangeFiltersControlled ( ) & & m_overrideRangeFilterCollection )
2015-08-27 06:44:27 -05:00
{
return m_overrideRangeFilterCollection ;
}
else
{
return m_rangeFilterCollection ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setOverrideRangeFilterCollection ( RimCellRangeFilterCollection * rfc )
{
2015-10-20 04:13:31 -05:00
if ( m_overrideRangeFilterCollection ( ) ) delete m_overrideRangeFilterCollection ( ) ;
2015-08-27 06:44:27 -05:00
m_overrideRangeFilterCollection = rfc ;
2015-09-13 01:54:32 -05:00
this - > scheduleGeometryRegen ( RANGE_FILTERED ) ;
this - > scheduleGeometryRegen ( RANGE_FILTERED_INACTIVE ) ;
this - > scheduleCreateDisplayModelAndRedraw ( ) ;
2015-08-27 06:44:27 -05:00
}
2015-09-01 11:21:20 -05:00
2015-09-03 06:06:00 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : setScaleZAndUpdate ( double scaleZ )
{
this - > scaleZ = scaleZ ;
updateScaleTransform ( ) ;
2016-11-24 07:05:51 -06:00
this - > updateGridBoxData ( ) ;
2015-09-22 14:00:50 -05:00
this - > scheduleCreateDisplayModelAndRedraw ( ) ;
2015-09-03 06:06:00 -05:00
}
2015-09-14 09:14:44 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-09-25 04:01:41 -05: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 09:14:44 -05:00
{
2015-09-25 04:01:41 -05:00
RimViewLinker * viewLinker = this - > viewLinkerIfMasterView ( ) ;
if ( ! viewLinker )
{
RimViewController * viewController = this - > viewController ( ) ;
if ( viewController )
{
viewLinker = viewController - > ownerViewLinker ( ) ;
}
}
return viewLinker ;
2015-09-14 09:14:44 -05: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 04:01:41 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimView : : isMasterView ( ) const
{
RimViewLinker * viewLinker = this - > assosiatedViewLinker ( ) ;
if ( viewLinker & & this = = viewLinker - > masterView ( ) )
{
return true ;
}
return false ;
}
2015-10-19 05:10:18 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-11-12 03:48:13 -06:00
bool RimView : : hasOverridenRangeFilterCollection ( )
2015-10-19 05:10:18 -05:00
{
2015-11-12 03:48:13 -06:00
return m_overrideRangeFilterCollection ( ) ! = NULL ;
2015-10-19 05:10:18 -05:00
}
2015-10-21 05:45:35 -05: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 12:05:00 -06: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 00:16:30 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : updateGridBoxData ( )
{
2015-11-16 07:08:17 -06:00
if ( m_viewer )
2015-11-16 00:16:30 -06:00
{
2015-11-16 07:08:17 -06:00
m_viewer - > updateGridBoxData ( ) ;
2015-11-16 00:16:30 -06:00
}
}
2015-11-16 04:30:03 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-11-19 04:41:16 -06:00
void RimView : : createHighlightAndGridBoxDisplayModelWithRedraw ( )
2015-11-16 04:30:03 -06:00
{
2015-11-19 04:41:16 -06:00
createHighlightAndGridBoxDisplayModel ( ) ;
2015-11-16 04:30:03 -06:00
if ( m_viewer )
{
m_viewer - > update ( ) ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-11-19 04:41:16 -06:00
void RimView : : createHighlightAndGridBoxDisplayModel ( )
2015-11-16 04:30:03 -06:00
{
2015-11-23 04:21:12 -06:00
m_viewer - > removeStaticModel ( m_highlightVizModel . p ( ) ) ;
2015-11-19 04:41:16 -06:00
m_viewer - > removeStaticModel ( m_viewer - > gridBoxModel ( ) ) ;
2015-11-23 04:21:12 -06:00
m_highlightVizModel - > removeAllParts ( ) ;
2015-11-16 04:30:03 -06:00
cvf : : Collection < cvf : : Part > parts ;
createPartCollectionFromSelection ( & parts ) ;
if ( parts . size ( ) > 0 )
{
for ( size_t i = 0 ; i < parts . size ( ) ; i + + )
{
2015-11-23 04:21:12 -06:00
m_highlightVizModel - > addPart ( parts [ i ] . p ( ) ) ;
2015-11-16 04:30:03 -06:00
}
2015-11-23 04:21:12 -06:00
m_highlightVizModel - > updateBoundingBoxesRecursive ( ) ;
m_viewer - > addStaticModelOnce ( m_highlightVizModel . p ( ) ) ;
2015-11-16 04:30:03 -06:00
}
2015-11-16 04:44:41 -06:00
if ( showGridBox )
2015-11-16 04:30:03 -06:00
{
2015-11-23 04:21:12 -06:00
m_viewer - > addStaticModelOnce ( m_viewer - > gridBoxModel ( ) ) ;
2015-11-16 04:30:03 -06:00
}
}
2015-11-16 07:08:17 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimView : : showActiveCellsOnly ( )
{
return false ;
}
2015-12-07 02:59:19 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : selectOverlayInfoConfig ( )
{
2015-12-07 03:07:51 -06:00
RiuMainWindow : : instance ( ) - > selectAsCurrentItem ( m_overlayInfoConfig ) ;
2015-12-07 02:59:19 -06:00
}
2016-07-05 03:47:03 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : zoomAll ( )
{
if ( m_viewer )
{
m_viewer - > zoomAll ( ) ;
}
}
2016-09-29 04:43:47 -05: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 04:03:13 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget * RimView : : viewWidget ( )
{
2017-01-17 06:06:57 -06:00
if ( m_viewer ) return m_viewer - > layoutWidget ( ) ;
else return nullptr ;
2016-10-27 04:03:13 -05:00
}
2017-01-20 09:25:05 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView : : forceShowWindowOn ( )
{
m_showWindow . setValueWithFieldChanged ( true ) ;
}