#6008 Add support for optional Page Preview mode for multi plots

This commit is contained in:
Gaute Lindkvist
2020-06-09 13:43:22 +02:00
parent c1847adfac
commit e58b42f537
10 changed files with 148 additions and 45 deletions

View File

@@ -28,6 +28,9 @@
#include "RiuPlotMainWindow.h"
#include "RiuPlotMainWindowTools.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include <QPaintDevice>
#include <QRegularExpression>
@@ -80,6 +83,9 @@ RimMultiPlot::RimMultiPlot()
CAF_PDM_InitFieldNoDefault( &m_subTitleFontSize, "SubTitleFontSize", "Sub Plot Title Font Size", "", "", "" );
CAF_PDM_InitField( &m_pagePreviewMode, "PagePreviewMode", false, "Page Preview Mode", "", "", "" );
m_pagePreviewMode.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_pagePreviewMode.uiCapability()->setUiIconFromResourceString( ":/PagePreview16x16.png" );
m_viewer = nullptr;
setDeletable( true );
@@ -120,6 +126,7 @@ RimMultiPlot& RimMultiPlot::operator=( RimMultiPlot&& rhs )
m_rowsPerPage = rhs.m_rowsPerPage;
m_showIndividualPlotTitles = rhs.m_showIndividualPlotTitles;
m_subTitleFontSize = rhs.m_subTitleFontSize;
m_pagePreviewMode = rhs.m_pagePreviewMode;
return *this;
}
@@ -311,6 +318,7 @@ void RimMultiPlot::doUpdateLayout()
m_viewer->setTitleFontSizes( titleFontSize(), subTitleFontSize() );
m_viewer->setLegendFontSize( legendFontSize() );
m_viewer->setAxisFontSizes( axisTitleFontSize(), axisValueFontSize() );
m_viewer->setPagePreviewModeEnabled( m_pagePreviewMode() );
m_viewer->scheduleUpdate();
m_viewer->adjustSize();
@@ -414,6 +422,14 @@ caf::PdmFieldHandle* RimMultiPlot::rowsPerPageField()
return &m_rowsPerPage;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimMultiPlot::pagePreviewField()
{
return &m_pagePreviewMode;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -470,7 +486,7 @@ bool RimMultiPlot::previewModeEnabled() const
{
if ( m_viewer )
{
return m_viewer->previewModeEnabled();
return m_viewer->pagePreviewModeEnabled();
}
return false;
}
@@ -566,7 +582,7 @@ void RimMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, co
{
updateFonts();
}
else if ( changedField == &m_columnCount || changedField == &m_rowsPerPage )
else if ( changedField == &m_columnCount || changedField == &m_rowsPerPage || changedField == &m_pagePreviewMode )
{
updateLayout();
RiuPlotMainWindowTools::refreshToolbars();
@@ -597,6 +613,23 @@ void RimMultiPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& u
uiOrderingForMultiPlotLayout( uiConfigName, *titleAndLegendsGroup );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultiPlot::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_rowsPerPage || field == &m_columnCount )
{
auto myattr = dynamic_cast<caf::PdmUiComboBoxEditorAttribute*>( attribute );
if ( myattr )
{
myattr->iconSize = QSize( 24, 16 );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -610,6 +643,7 @@ void RimMultiPlot::uiOrderingForMultiPlotLayout( QString uiConfigName, caf::PdmU
uiOrdering.add( &m_columnCount );
uiOrdering.add( &m_rowsPerPage );
uiOrdering.add( &m_majorTickmarkCount );
uiOrdering.add( &m_pagePreviewMode );
}
//--------------------------------------------------------------------------------------------------
@@ -631,7 +665,7 @@ QList<caf::PdmOptionItemInfo> RimMultiPlot::calculateValueOptions( const caf::Pd
options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ),
enumVal,
false,
caf::IconProvider( iconPath ) ) );
caf::IconProvider( iconPath, QSize( 24, 16 ) ) ) );
}
else
{
@@ -639,7 +673,7 @@ QList<caf::PdmOptionItemInfo> RimMultiPlot::calculateValueOptions( const caf::Pd
options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ),
enumVal,
false,
caf::IconProvider( iconPath ) ) );
caf::IconProvider( iconPath, QSize( 24, 16 ) ) ) );
}
}
}

View File

@@ -90,6 +90,7 @@ public:
int rowsPerPage() const;
caf::PdmFieldHandle* columnCountField();
caf::PdmFieldHandle* rowsPerPageField();
caf::PdmFieldHandle* pagePreviewField();
bool showPlotTitles() const;
void zoomAll() override;
@@ -112,7 +113,9 @@ protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void uiOrderingForMultiPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
@@ -142,6 +145,7 @@ protected:
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_subTitleFontSize;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisTitleFontSize;
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisValueFontSize;
caf::PdmField<bool> m_pagePreviewMode;
caf::PdmField<RimPlotAxisPropertiesInterface::LegendTickmarkCountEnum> m_majorTickmarkCount;

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

View File

@@ -95,6 +95,7 @@
<file>ObservedRFTDataFile16x16.png</file>
<file>ObservedRSMDataFile16x16.png</file>
<file>OctaveScriptFile16x16.png</file>
<file>PagePreview16x16.png</file>
<file>PdfSave.png</file>
<file>Parallel24x24.png</file>
<file>PerforationInterval16x16.png</file>

View File

@@ -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 );
}
}

View File

@@ -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();

View File

@@ -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 );
}
}

View File

@@ -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();

View File

@@ -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();

View File

@@ -96,6 +96,7 @@ void RiuPlotMainWindowTools::refreshToolbars()
{
mpw->updateSummaryPlotToolBar();
mpw->updateWellLogPlotToolBar();
mpw->updateMultiPlotToolBar();
}
}
}