mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6008 Add support for optional Page Preview mode for multi plots
This commit is contained in:
@@ -108,7 +108,6 @@ RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* paren
|
||||
{
|
||||
const int spacing = 8;
|
||||
|
||||
this->setBackgroundRole( QPalette::Dark );
|
||||
this->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_layout = new QVBoxLayout( this );
|
||||
m_layout->setContentsMargins( 0, 0, 0, 0 );
|
||||
@@ -121,7 +120,6 @@ RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* paren
|
||||
m_book->setFrameStyle( QFrame::NoFrame );
|
||||
m_scrollArea->setWidget( m_book );
|
||||
m_scrollArea->setWidgetResizable( true );
|
||||
m_book->setBackgroundRole( QPalette::Dark );
|
||||
m_bookLayout = new QVBoxLayout( m_book );
|
||||
m_bookLayout->setSpacing( spacing );
|
||||
m_scrollArea->setVisible( true );
|
||||
@@ -134,8 +132,10 @@ RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* paren
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
|
||||
QSize pageSize = m_plotDefinition->pageLayout().fullRectPixels( RiaGuiApplication::applicationResolution() ).size();
|
||||
setBookSize( pageSize.width() );
|
||||
applyPagePreviewBookSize( pageSize.width() );
|
||||
this->setObjectName( QString( "%1" ).arg( reinterpret_cast<uint64_t>( this ) ) );
|
||||
|
||||
applyLook();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -266,7 +266,7 @@ int RiuMultiPlotBook::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuMultiPlotBook::previewModeEnabled() const
|
||||
bool RiuMultiPlotBook::pagePreviewModeEnabled() const
|
||||
{
|
||||
return m_previewMode;
|
||||
}
|
||||
@@ -274,13 +274,13 @@ bool RiuMultiPlotBook::previewModeEnabled() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::setPreviewModeEnabled( bool previewMode )
|
||||
void RiuMultiPlotBook::setPagePreviewModeEnabled( bool previewMode )
|
||||
{
|
||||
m_previewMode = previewMode;
|
||||
|
||||
for ( auto page : m_pages )
|
||||
{
|
||||
page->setPreviewModeEnabled( previewModeEnabled() );
|
||||
page->setPagePreviewModeEnabled( pagePreviewModeEnabled() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,14 @@ void RiuMultiPlotBook::showEvent( QShowEvent* event )
|
||||
{
|
||||
QWidget::showEvent( event );
|
||||
performUpdate();
|
||||
setBookSize( width() );
|
||||
if ( m_previewMode )
|
||||
{
|
||||
applyPagePreviewBookSize( width() );
|
||||
}
|
||||
else
|
||||
{
|
||||
applyBookSize( width(), height() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -374,14 +381,21 @@ void RiuMultiPlotBook::showEvent( QShowEvent* event )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::resizeEvent( QResizeEvent* event )
|
||||
{
|
||||
setBookSize( event->size().width() );
|
||||
if ( m_previewMode )
|
||||
{
|
||||
applyPagePreviewBookSize( event->size().width() );
|
||||
}
|
||||
else
|
||||
{
|
||||
applyBookSize( event->size().width(), event->size().height() );
|
||||
}
|
||||
QWidget::resizeEvent( event );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::setBookSize( int frameWidth )
|
||||
void RiuMultiPlotBook::applyPagePreviewBookSize( int frameWidth )
|
||||
{
|
||||
for ( auto page : m_pages )
|
||||
{
|
||||
@@ -392,6 +406,20 @@ void RiuMultiPlotBook::setBookSize( int frameWidth )
|
||||
m_book->setFixedSize( m_book->calculateSize( frameWidth ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::applyBookSize( int frameWidth, int frameHeight )
|
||||
{
|
||||
int totalHeight = 0;
|
||||
for ( auto page : m_pages )
|
||||
{
|
||||
page->resize( frameWidth, frameHeight );
|
||||
totalHeight += frameHeight;
|
||||
}
|
||||
m_book->setFixedSize( QSize( frameWidth, totalHeight ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -420,6 +448,7 @@ bool RiuMultiPlotBook::showYAxis( int row, int column ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::performUpdate()
|
||||
{
|
||||
applyLook();
|
||||
deleteAllPages();
|
||||
createPages();
|
||||
updateGeometry();
|
||||
@@ -521,7 +550,7 @@ RiuMultiPlotPage* RiuMultiPlotBook::createPage()
|
||||
page->setAxisFontSizes( m_plotDefinition->axisTitleFontSize(), m_plotDefinition->axisValueFontSize() );
|
||||
page->setTitleVisible( m_titleVisible );
|
||||
page->setSubTitlesVisible( m_subTitlesVisible );
|
||||
page->setPreviewModeEnabled( m_previewMode );
|
||||
page->setPagePreviewModeEnabled( m_previewMode );
|
||||
|
||||
m_pages.push_back( page );
|
||||
m_bookLayout->addWidget( page );
|
||||
@@ -529,3 +558,25 @@ RiuMultiPlotPage* RiuMultiPlotBook::createPage()
|
||||
page->setVisible( true );
|
||||
return page;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::applyLook()
|
||||
{
|
||||
if ( m_previewMode )
|
||||
{
|
||||
this->setBackgroundRole( QPalette::Dark );
|
||||
m_book->setBackgroundRole( QPalette::Dark );
|
||||
}
|
||||
else
|
||||
{
|
||||
QPalette newPalette( palette() );
|
||||
newPalette.setColor( QPalette::Window, Qt::white );
|
||||
setPalette( newPalette );
|
||||
|
||||
this->setBackgroundRole( QPalette::Window );
|
||||
m_book->setBackgroundRole( QPalette::Window );
|
||||
m_book->setPalette( newPalette );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ public:
|
||||
|
||||
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );
|
||||
|
||||
bool previewModeEnabled() const;
|
||||
void setPreviewModeEnabled( bool previewMode );
|
||||
bool pagePreviewModeEnabled() const;
|
||||
void setPagePreviewModeEnabled( bool previewMode );
|
||||
|
||||
void scheduleUpdate();
|
||||
void scheduleReplotOfAllPlots();
|
||||
@@ -93,7 +93,8 @@ protected:
|
||||
void showEvent( QShowEvent* event ) override;
|
||||
void resizeEvent( QResizeEvent* event ) override;
|
||||
|
||||
void setBookSize( int frameWidth );
|
||||
void applyPagePreviewBookSize( int frameWidth );
|
||||
void applyBookSize( int frameWidth, int frameHeight );
|
||||
|
||||
std::pair<int, int> rowAndColumnCount( int plotWidgetCount ) const;
|
||||
|
||||
@@ -106,7 +107,7 @@ private:
|
||||
void createPages();
|
||||
const QList<QPointer<RiuMultiPlotPage>>& pages() const;
|
||||
RiuMultiPlotPage* createPage();
|
||||
|
||||
void applyLook();
|
||||
private slots:
|
||||
virtual void performUpdate();
|
||||
|
||||
|
||||
@@ -96,34 +96,13 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* pare
|
||||
m_gridLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_gridLayout->setSpacing( 1 );
|
||||
|
||||
QPalette newPalette( palette() );
|
||||
newPalette.setColor( QPalette::Window, Qt::white );
|
||||
setPalette( newPalette );
|
||||
|
||||
setAutoFillBackground( true );
|
||||
|
||||
new RiuPlotObjectPicker( m_plotTitle, m_plotDefinition );
|
||||
|
||||
if ( m_previewMode )
|
||||
{
|
||||
this->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
||||
}
|
||||
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
|
||||
this->setObjectName( QString( "%1" ).arg( reinterpret_cast<uint64_t>( this ) ) );
|
||||
|
||||
this->setBackgroundRole( QPalette::Window );
|
||||
|
||||
QGraphicsDropShadowEffect* dropShadowEffect = new QGraphicsDropShadowEffect( this );
|
||||
dropShadowEffect->setOffset( 4.0, 4.0 );
|
||||
dropShadowEffect->setBlurRadius( 4.0 );
|
||||
dropShadowEffect->setColor( QColor( 40, 40, 40, 40 ) );
|
||||
this->setGraphicsEffect( dropShadowEffect );
|
||||
applyLook();
|
||||
|
||||
updateMarginsFromPageLayout();
|
||||
}
|
||||
@@ -309,7 +288,7 @@ bool RiuMultiPlotPage::previewModeEnabled() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::setPreviewModeEnabled( bool previewMode )
|
||||
void RiuMultiPlotPage::setPagePreviewModeEnabled( bool previewMode )
|
||||
{
|
||||
m_previewMode = previewMode;
|
||||
}
|
||||
@@ -576,6 +555,7 @@ bool RiuMultiPlotPage::showYAxis( int row, int column ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::performUpdate()
|
||||
{
|
||||
applyLook();
|
||||
updateMarginsFromPageLayout();
|
||||
reinsertPlotWidgets();
|
||||
alignCanvasTops();
|
||||
@@ -860,3 +840,32 @@ void RiuMultiPlotPage::restoreWidgetStates()
|
||||
plotWidget->restoreWidgetStates();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::applyLook()
|
||||
{
|
||||
QPalette newPalette( palette() );
|
||||
newPalette.setColor( QPalette::Window, Qt::white );
|
||||
setPalette( newPalette );
|
||||
|
||||
setAutoFillBackground( true );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
|
||||
if ( m_previewMode )
|
||||
{
|
||||
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
|
||||
|
||||
QGraphicsDropShadowEffect* dropShadowEffect = new QGraphicsDropShadowEffect( this );
|
||||
dropShadowEffect->setOffset( 4.0, 4.0 );
|
||||
dropShadowEffect->setBlurRadius( 4.0 );
|
||||
dropShadowEffect->setColor( QColor( 40, 40, 40, 40 ) );
|
||||
setGraphicsEffect( dropShadowEffect );
|
||||
}
|
||||
else
|
||||
{
|
||||
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
||||
setGraphicsEffect( nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
void setSubTitlesVisible( bool visible );
|
||||
|
||||
bool previewModeEnabled() const;
|
||||
void setPreviewModeEnabled( bool previewMode );
|
||||
void setPagePreviewModeEnabled( bool previewMode );
|
||||
|
||||
void scheduleUpdate();
|
||||
void scheduleReplotOfAllPlots();
|
||||
@@ -126,7 +126,7 @@ protected:
|
||||
|
||||
void stashWidgetStates();
|
||||
void restoreWidgetStates();
|
||||
|
||||
void applyLook();
|
||||
private slots:
|
||||
virtual void performUpdate();
|
||||
void onLegendUpdated();
|
||||
|
||||
@@ -596,7 +596,9 @@ void RiuPlotMainWindow::updateMultiPlotToolBar()
|
||||
RimMultiPlot* plotWindow = dynamic_cast<RimMultiPlot*>( m_activePlotViewWindow.p() );
|
||||
if ( plotWindow )
|
||||
{
|
||||
std::vector<caf::PdmFieldHandle*> toolBarFields = {plotWindow->columnCountField()};
|
||||
std::vector<caf::PdmFieldHandle*> toolBarFields = {plotWindow->pagePreviewField(),
|
||||
plotWindow->columnCountField(),
|
||||
plotWindow->rowsPerPageField()};
|
||||
m_multiPlotToolBarEditor->setFields( toolBarFields );
|
||||
m_multiPlotToolBarEditor->updateUi();
|
||||
m_multiPlotToolBarEditor->show();
|
||||
|
||||
@@ -96,6 +96,7 @@ void RiuPlotMainWindowTools::refreshToolbars()
|
||||
{
|
||||
mpw->updateSummaryPlotToolBar();
|
||||
mpw->updateWellLogPlotToolBar();
|
||||
mpw->updateMultiPlotToolBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user