diff --git a/ApplicationCode/Commands/ViewLink/RicCompareTo3dViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicCompareTo3dViewFeature.cpp index c95e2a5c75..70edcd4bf2 100644 --- a/ApplicationCode/Commands/ViewLink/RicCompareTo3dViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicCompareTo3dViewFeature.cpp @@ -19,6 +19,7 @@ #include "RiaApplication.h" +#include "Rim3dOverlayInfoConfig.h" #include "RimGridView.h" #include "RiuViewer.h" @@ -50,6 +51,7 @@ void RicCompareTo3dViewFeature::onActionTriggered( bool isChecked ) { activeView->setComparisonView( view ); activeView->scheduleCreateDisplayModelAndRedraw(); + activeView->overlayInfoConfig()->updateConnectedEditors(); } } diff --git a/ApplicationCode/Commands/ViewLink/RicRemoveComparison3dViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicRemoveComparison3dViewFeature.cpp index 0031f554be..3a59493be7 100644 --- a/ApplicationCode/Commands/ViewLink/RicRemoveComparison3dViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicRemoveComparison3dViewFeature.cpp @@ -19,7 +19,9 @@ #include "RiaApplication.h" +#include "Rim3dOverlayInfoConfig.h" #include "Rim3dView.h" +#include "RimGridView.h" #include "RiuViewer.h" #include "RiuViewerCommands.h" @@ -48,6 +50,9 @@ public: { m_activeView->setComparisonView( nullptr ); m_activeView->scheduleCreateDisplayModelAndRedraw(); + + auto gridView = dynamic_cast( m_activeView ); + if ( gridView ) gridView->overlayInfoConfig()->updateConnectedEditors(); } private: diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 063f1b5c2d..8d098aa6a3 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -425,11 +425,11 @@ bool Rim2dIntersectionView::hasResults() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int Rim2dIntersectionView::timeStepCount() +size_t Rim2dIntersectionView::onTimeStepCountRequested() { if ( isTimeStepDependentDataVisible() ) { - return static_cast( this->ownerCase()->timeStepStrings().size() ); + return this->ownerCase()->timeStepStrings().size(); } return 0; @@ -484,9 +484,9 @@ void Rim2dIntersectionView::onCreateDisplayModel() nativeOrOverrideViewer()->removeAllFrames( isUsingOverrideViewer() ); - int tsCount = this->timeStepCount(); + size_t tsCount = this->timeStepCount(); - for ( int i = 0; i < tsCount; ++i ) + for ( size_t i = 0; i < tsCount; ++i ) { nativeOrOverrideViewer()->addFrame( new cvf::Scene(), isUsingOverrideViewer() ); } diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 9c911b6580..83ceb7c7ad 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -106,7 +106,8 @@ protected: bool* useOptionsOnly ) override; bool hasResults(); - int timeStepCount(); + + virtual size_t onTimeStepCountRequested() override; private: QString createAutoName() const override; diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 686b09d32f..d5fa217c68 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -926,7 +926,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() return; } - m_viewDef->viewer()->showInfoText( m_showCaseInfo() || m_showResultInfo() ); + m_viewDef->viewer()->showInfoText( m_showCaseInfo() || ( m_showResultInfo() && !m_viewDef->activeComparisonView() ) ); m_viewDef->viewer()->showHistogram( false ); m_viewDef->viewer()->showAnimationProgress( m_showAnimProgress() ); m_viewDef->viewer()->showVersionInfo( m_showVersionInfo() ); @@ -1024,6 +1024,12 @@ void Rim3dOverlayInfoConfig::defineUiOrdering( QString uiConfigName, caf::PdmUiO } statGroup->add( &m_statisticsCellRange ); } + + bool isUsingComparisonView = m_viewDef->activeComparisonView(); + m_showResultInfo.uiCapability()->setUiReadOnly( isUsingComparisonView ); + m_showVolumeWeightedMean.uiCapability()->setUiReadOnly( isUsingComparisonView ); + m_showHistogram.uiCapability()->setUiReadOnly( isUsingComparisonView ); + uiOrdering.skipRemainingFields( true ); } diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index f3e62de869..14a0b5ce51 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -453,6 +453,14 @@ bool Rim3dView::isTimeStepDependentDataVisibleInThisOrComparisonView() const return ( isTimeStepDependentDataVisible() || ( otherView && otherView->isTimeStepDependentDataVisible() ) ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t Rim3dView::timeStepCount() +{ + return this->onTimeStepCountRequested(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index 6b3635df5e..f359e658b7 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -142,10 +142,12 @@ public: void forceShowWindowOn(); // Animation - int currentTimeStep() const; - void setCurrentTimeStep( int frameIdx ); - void setCurrentTimeStepAndUpdate( int frameIdx ) override; - bool isTimeStepDependentDataVisibleInThisOrComparisonView() const; + int currentTimeStep() const; + void setCurrentTimeStep( int frameIdx ); + void setCurrentTimeStepAndUpdate( int frameIdx ) override; + bool isTimeStepDependentDataVisibleInThisOrComparisonView() const; + size_t timeStepCount(); + QString timeStepName( int frameIdx ) const override; // Updating void scheduleCreateDisplayModelAndRedraw(); @@ -200,10 +202,12 @@ protected: // Abstract methods to implement in subclasses - virtual void onCreateDisplayModel() = 0; - virtual void onUpdateDisplayModelForCurrentTimeStep() = 0; - virtual void onUpdateDisplayModelVisibility(){}; - virtual void onClampCurrentTimestep() = 0; + virtual void onCreateDisplayModel() = 0; + virtual void onUpdateDisplayModelForCurrentTimeStep() = 0; + virtual void onUpdateDisplayModelVisibility(){}; + virtual void onClampCurrentTimestep() = 0; + virtual size_t onTimeStepCountRequested() = 0; + virtual void onClearReservoirCellVisibilitiesIfNeccessary(){}; virtual bool isTimeStepDependentDataVisible() const = 0; virtual void defineAxisLabels( cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel ) = 0; @@ -258,8 +262,7 @@ private: void setCameraPosition( const cvf::Mat4d& cameraPosition ) override; void setCameraPointOfInterest( const cvf::Vec3d& cameraPointOfInterest ) override; - QString timeStepName( int frameIdx ) const override; - void endAnimation() override; + void endAnimation() override; caf::PdmObjectHandle* implementingPdmObject() override; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 35ad8567d1..5ad2f4597f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -268,6 +268,19 @@ void RimEclipseView::onClampCurrentTimestep() if ( m_currentTimeStep < 0 ) m_currentTimeStep = 0; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimEclipseView::onTimeStepCountRequested() +{ + if ( this->currentGridCellResults() ) + { + return this->currentGridCellResults()->maxTimeStepCount(); + } + + return 0; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 4ad598540c..3330a95173 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -186,7 +186,9 @@ private: void syncronizeWellsWithResults(); - void onClampCurrentTimestep() override; + void onClampCurrentTimestep() override; + size_t onTimeStepCountRequested() override; + void setVisibleGridParts( const std::vector& cellSets ); void setVisibleGridPartsWatertight(); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 79f445317e..1d34ccf335 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -725,6 +725,19 @@ void RimGeoMechView::onClampCurrentTimestep() if ( m_currentTimeStep < 0 ) m_currentTimeStep = 0; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimGeoMechView::onTimeStepCountRequested() +{ + if ( m_geomechCase ) + { + return m_geomechCase->geoMechData()->femPartResults()->frameCount(); + } + + return 0; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index a1c3085ca5..8966f896e0 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -121,7 +121,8 @@ private: void onUpdateScaleTransform() override; - void onClampCurrentTimestep() override; + void onClampCurrentTimestep() override; + size_t onTimeStepCountRequested() override; void onUpdateDisplayModelForCurrentTimeStep() override; void onUpdateStaticCellColors() override; diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index d30d52e9b6..7038d64cdd 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -118,6 +118,20 @@ RiuViewer::RiuViewer( const QGLFormat& format, QWidget* parent ) m_infoLabel->setFont( font ); m_showInfoText = true; + m_shortInfoLabel = new QLabel(); + m_shortInfoLabel->setObjectName( "ShortInfoLabel" ); + m_shortInfoLabel->setFrameShape( QFrame::Box ); + m_shortInfoLabel->setFrameShadow( QFrame::Plain ); + m_shortInfoLabel->setMinimumWidth( 100 ); + m_shortInfoLabel->setFont( font ); + + m_shortInfoLabelCompView = new QLabel(); + m_shortInfoLabelCompView->setObjectName( "ShortInfoLabelCompView" ); + m_shortInfoLabelCompView->setFrameShape( QFrame::Box ); + m_shortInfoLabelCompView->setFrameShadow( QFrame::Plain ); + m_shortInfoLabelCompView->setMinimumWidth( 100 ); + m_shortInfoLabelCompView->setFont( font ); + // Version info label m_versionInfoLabel = new QLabel(); m_versionInfoLabel->setFrameShape( QFrame::NoFrame ); @@ -144,6 +158,13 @@ RiuViewer::RiuViewer( const QGLFormat& format, QWidget* parent ) m_animationProgress->setObjectName( "AnimationProgress" ); m_animationProgress->setFont( font ); + m_animationProgressCompView = new caf::QStyledProgressBar( "AnimationProgress" ); + m_animationProgressCompView->setFormat( "Time Step: %v/%m" ); + m_animationProgressCompView->setTextVisible( true ); + m_animationProgressCompView->setAlignment( Qt::AlignCenter ); + m_animationProgressCompView->setObjectName( "AnimationProgress" ); + m_animationProgressCompView->setFont( font ); + m_showAnimProgress = false; // Histogram @@ -158,6 +179,8 @@ RiuViewer::RiuViewer( const QGLFormat& format, QWidget* parent ) regTestFont.setPixelSize( 11 ); m_infoLabel->setFont( regTestFont ); + m_shortInfoLabel->setFont( regTestFont ); + m_shortInfoLabelCompView->setFont( regTestFont ); m_versionInfoLabel->setFont( regTestFont ); m_animationProgress->setFont( regTestFont ); m_histogramWidget->setFont( regTestFont ); @@ -198,7 +221,10 @@ RiuViewer::~RiuViewer() } delete m_infoLabel; + delete m_shortInfoLabel; + delete m_shortInfoLabelCompView; delete m_animationProgress; + delete m_animationProgressCompView; delete m_histogramWidget; delete m_gridBoxGenerator; delete m_comparisonGridBoxGenerator; @@ -255,9 +281,9 @@ void RiuViewer::mouseReleaseEvent( QMouseEvent* event ) return; } - if ( !m_infoLabelOverlayArea.isNull() ) + if ( !m_infoPickArea.isNull() ) { - if ( m_infoLabelOverlayArea.contains( event->x(), event->y() ) ) + if ( m_infoPickArea.contains( event->x(), event->y() ) ) { m_rimView->selectOverlayInfoConfig(); @@ -265,6 +291,18 @@ void RiuViewer::mouseReleaseEvent( QMouseEvent* event ) } } + if ( !m_infoPickAreaCompView.isNull() ) + { + if ( m_infoPickAreaCompView.contains( event->x(), event->y() ) ) + { + Rim3dView* compView = dynamic_cast( m_rimView.p() )->activeComparisonView(); + + if ( compView ) compView->selectOverlayInfoConfig(); + + return; + } + } + m_viewerCommands->handlePickAction( event->x(), event->y(), event->modifiers() ); return; @@ -366,8 +404,9 @@ void RiuViewer::paintOverlayItems( QPainter* painter ) int edgeAxisFrameBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth() : 0; int edgeAxisFrameBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight() : 0; - int margin = 5; - int yPos = margin + edgeAxisFrameBorderHeight; + int margin = 5; + int startYPos = margin + edgeAxisFrameBorderHeight; + int yPos = startYPos; bool showAnimBar = false; if ( isAnimationActive() && frameCount() > 1 ) showAnimBar = true; @@ -376,37 +415,101 @@ void RiuViewer::paintOverlayItems( QPainter* painter ) int columnPos = this->width() - columnWidth - margin - edgeAxisFrameBorderWidth; + if ( this->isComparisonViewActive() ) + { + Rim3dView* compView = dynamic_cast( m_rimView.p() )->activeComparisonView(); + columnWidth = 200; + + // int sliderPos = this->width() * this->comparisonViewVisibleNormalizedRect().min().x(); + int sliderPos = 0.5 * this->width(); + int compViewItemsXPos = sliderPos + 0.5 * ( this->width() - sliderPos ) - 0.5 * columnWidth; + columnPos = 0.5 * sliderPos - 0.5 * columnWidth; + + if ( m_showInfoText ) + { + { + Rim3dView* view = dynamic_cast( m_rimView.p() ); + m_shortInfoLabel->setText( "
" + view->ownerCase()->caseUserDescription() + "
" ); + + QPoint topLeft = QPoint( columnPos, yPos ); + m_shortInfoLabel->resize( columnWidth, m_shortInfoLabel->sizeHint().height() ); + m_shortInfoLabel->render( painter, topLeft ); + } + + { + m_shortInfoLabelCompView->setText( "
" + compView->ownerCase()->caseUserDescription() + + "
" ); + QPoint topLeft = QPoint( compViewItemsXPos, yPos ); + m_shortInfoLabelCompView->resize( columnWidth, m_shortInfoLabelCompView->sizeHint().height() ); + m_shortInfoLabelCompView->render( painter, topLeft ); + } + + yPos += m_shortInfoLabel->height(); + } + + int pickAreaHeight = yPos - startYPos; + if ( m_showAnimProgress && isAnimationActive( true ) && compView->timeStepCount() > 1 ) + { + QString stepName = compView->timeStepName( compView->currentTimeStep() ); + + m_animationProgressCompView->setFormat( "Time Step: %v/%m " + stepName ); + m_animationProgressCompView->setMinimum( 0 ); + m_animationProgressCompView->setMaximum( static_cast( compView->timeStepCount() ) - 1 ); + m_animationProgressCompView->setValue( compView->currentTimeStep() ); + + m_animationProgressCompView->resize( columnWidth, m_animationProgressCompView->sizeHint().height() ); + + m_animationProgressCompView->render( painter, QPoint( compViewItemsXPos, yPos ) ); + + pickAreaHeight += m_animationProgressCompView->height(); + } + + m_infoPickArea.setLeft( columnPos ); + m_infoPickArea.setWidth( columnWidth ); + m_infoPickArea.setHeight( pickAreaHeight ); + m_infoPickArea.setTop( startYPos ); + + m_infoPickAreaCompView.setLeft( compViewItemsXPos ); + m_infoPickAreaCompView.setWidth( columnWidth ); + m_infoPickAreaCompView.setHeight( pickAreaHeight ); + m_infoPickAreaCompView.setTop( startYPos ); + } + if ( showAnimBar && m_showAnimProgress ) { - QString stepName = m_rimView->timeStepName( currentFrameIndex() ); + Rim3dView* view = dynamic_cast( m_rimView.p() ); + + QString stepName = view->timeStepName( view->currentTimeStep() ); + m_animationProgress->setFormat( "Time Step: %v/%m " + stepName ); m_animationProgress->setMinimum( 0 ); - m_animationProgress->setMaximum( static_cast( frameCount() ) - 1 ); - m_animationProgress->setValue( currentFrameIndex() ); - m_animationProgress->resize( columnWidth, m_animationProgress->sizeHint().height() ); + m_animationProgress->setMaximum( static_cast( view->timeStepCount() ) - 1 ); + m_animationProgress->setValue( view->currentTimeStep() ); + m_animationProgress->resize( columnWidth, m_animationProgress->sizeHint().height() ); m_animationProgress->render( painter, QPoint( columnPos, yPos ) ); + yPos += m_animationProgress->height() + margin; } - if ( m_showInfoText ) + if ( m_showInfoText && !this->isComparisonViewActive() ) { QPoint topLeft = QPoint( columnPos, yPos ); m_infoLabel->resize( columnWidth, m_infoLabel->sizeHint().height() ); m_infoLabel->render( painter, topLeft ); - m_infoLabelOverlayArea.setTopLeft( topLeft ); - m_infoLabelOverlayArea.setBottom( yPos + m_infoLabel->height() ); - m_infoLabelOverlayArea.setRight( columnPos + columnWidth ); + m_infoPickArea.setTopLeft( topLeft ); + m_infoPickArea.setBottom( yPos + m_infoLabel->height() ); + m_infoPickArea.setRight( columnPos + columnWidth ); yPos += m_infoLabel->height() + margin; } - else + else if ( !this->isComparisonViewActive() ) { - m_infoLabelOverlayArea = QRect(); + m_infoPickArea = QRect(); } - if ( m_showHistogram ) + if ( m_showHistogram && !this->isComparisonViewActive() ) { m_histogramWidget->resize( columnWidth, 40 ); m_histogramWidget->render( painter, QPoint( columnPos, yPos ) ); @@ -808,7 +911,7 @@ void RiuViewer::updateLegendLayout() const int xPos = width() - (int)scaleLegendSize.x() - margin - edgeAxisBorderWidth; const int yPos = margin + edgeAxisBorderHeight + margin + otherItemsHeight; - m_scaleLegend->setLayoutFixedPosition( { xPos, yPos } ); + m_scaleLegend->setLayoutFixedPosition( {xPos, yPos} ); } } @@ -1185,9 +1288,9 @@ void RiuViewer::showScaleLegend( bool show ) if ( show ) { if ( m_scaleLegend->orientation() == caf::OverlayScaleLegend::HORIZONTAL ) - m_scaleLegend->setRenderSize( { 280, 45 } ); + m_scaleLegend->setRenderSize( {280, 45} ); else - m_scaleLegend->setRenderSize( { 50, 280 } ); + m_scaleLegend->setRenderSize( {50, 280} ); overlayItemsRendering()->addOverlayItem( m_scaleLegend.p() ); } @@ -1233,7 +1336,10 @@ void RiuViewer::updateFonts() m_zScaleLabel->setFont( font ); m_infoLabel->setFont( font ); + m_shortInfoLabel->setFont( font ); + m_shortInfoLabelCompView->setFont( font ); m_animationProgress->setFont( font ); + m_animationProgressCompView->setFont( font ); m_versionInfoLabel->setFont( font ); } @@ -1337,6 +1443,16 @@ void RiuViewer::updateOverlayItemsStyle() contrastColor, backgroundColor, backgroundFrameColor ) ); + m_shortInfoLabel->setStyleSheet( caf::StyleSheetTools::createFrameStyleSheet( "QLabel", + "ShortInfoLabel", + contrastColor, + backgroundColor, + backgroundFrameColor ) ); + m_shortInfoLabelCompView->setStyleSheet( caf::StyleSheetTools::createFrameStyleSheet( "QLabel", + "ShortInfoLabelCompView", + contrastColor, + backgroundColor, + backgroundFrameColor ) ); m_histogramWidget->setStyleSheet( caf::StyleSheetTools::createFrameStyleSheet( "", "HistogramWidget", contrastColor, @@ -1354,6 +1470,10 @@ void RiuViewer::updateOverlayItemsStyle() backgroundColor, backgroundFrameColor, progressColor ); + m_animationProgressCompView->setTextBackgroundAndProgressColor( contrastColor, + backgroundColor, + backgroundFrameColor, + progressColor ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index c2eac497ea..8f6f76e532 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -166,7 +166,11 @@ private: private: QLabel* m_infoLabel; - QRect m_infoLabelOverlayArea; + QRect m_infoPickArea; + QRect m_infoPickAreaCompView; + + QLabel* m_shortInfoLabel; // Used when in comparison view mode + QLabel* m_shortInfoLabelCompView; QLabel* m_versionInfoLabel; bool m_showInfoText; @@ -178,6 +182,7 @@ private: double m_zScale; caf::QStyledProgressBar* m_animationProgress; + caf::QStyledProgressBar* m_animationProgressCompView; bool m_showAnimProgress; RiuSimpleHistogramWidget* m_histogramWidget; bool m_showHistogram;