mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4994 Make ComparisonView mode for InfoBox and animation progress
This commit is contained in:
@@ -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<Rim3dView*>( 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<Rim3dView*>( 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<Rim3dView*>( m_rimView.p() );
|
||||
m_shortInfoLabel->setText( "<center>" + view->ownerCase()->caseUserDescription() + "</center>" );
|
||||
|
||||
QPoint topLeft = QPoint( columnPos, yPos );
|
||||
m_shortInfoLabel->resize( columnWidth, m_shortInfoLabel->sizeHint().height() );
|
||||
m_shortInfoLabel->render( painter, topLeft );
|
||||
}
|
||||
|
||||
{
|
||||
m_shortInfoLabelCompView->setText( "<center>" + compView->ownerCase()->caseUserDescription() +
|
||||
"</center>" );
|
||||
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<int>( 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<Rim3dView*>( 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<int>( frameCount() ) - 1 );
|
||||
m_animationProgress->setValue( currentFrameIndex() );
|
||||
m_animationProgress->resize( columnWidth, m_animationProgress->sizeHint().height() );
|
||||
m_animationProgress->setMaximum( static_cast<int>( 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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user