mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add preview mode to multi plots
* Apply margins matching the Page Layout so the plot is a preview of the PDF output * Currently not a user setting, just switched off for plots based on MultiPlotPage and on for plots based on MultiPlotWindow
This commit is contained in:
parent
3d5903b9c4
commit
de68df122d
@ -105,7 +105,9 @@ void RicSnapshotViewToFileFeature::savePlotPDFReportAs( const QString& fileName,
|
|||||||
pdfPrinter.setCreator( QCoreApplication::applicationName() );
|
pdfPrinter.setCreator( QCoreApplication::applicationName() );
|
||||||
pdfPrinter.setResolution( resolution );
|
pdfPrinter.setResolution( resolution );
|
||||||
QRect widgetRect = plot->viewWidget()->contentsRect();
|
QRect widgetRect = plot->viewWidget()->contentsRect();
|
||||||
if ( dynamic_cast<RimMultiPlotWindow*>( plot ) )
|
|
||||||
|
RimMultiPlotWindow* multiPlot = dynamic_cast<RimMultiPlotWindow*>( plot );
|
||||||
|
if ( multiPlot && multiPlot->previewModeEnabled() )
|
||||||
{
|
{
|
||||||
QRect pageRect = pdfPrinter.pageLayout().fullRectPixels( resolution );
|
QRect pageRect = pdfPrinter.pageLayout().fullRectPixels( resolution );
|
||||||
plot->viewWidget()->resize( pageRect.size() );
|
plot->viewWidget()->resize( pageRect.size() );
|
||||||
|
@ -465,6 +465,18 @@ bool RimMultiPlotWindow::acceptDrops() const
|
|||||||
return m_acceptDrops;
|
return m_acceptDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimMultiPlotWindow::previewModeEnabled() const
|
||||||
|
{
|
||||||
|
if ( m_viewer )
|
||||||
|
{
|
||||||
|
return m_viewer->previewModeEnabled();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -103,6 +103,8 @@ public:
|
|||||||
void setAcceptDrops( bool acceptDrops );
|
void setAcceptDrops( bool acceptDrops );
|
||||||
bool acceptDrops() const;
|
bool acceptDrops() const;
|
||||||
|
|
||||||
|
bool previewModeEnabled() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QImage snapshotWindowContent() override;
|
QImage snapshotWindowContent() override;
|
||||||
|
|
||||||
|
@ -50,6 +50,9 @@ public:
|
|||||||
virtual void setFontSize( int fontSize ) = 0;
|
virtual void setFontSize( int fontSize ) = 0;
|
||||||
virtual int fontSize() const = 0;
|
virtual int fontSize() const = 0;
|
||||||
|
|
||||||
|
virtual bool previewModeEnabled() const = 0;
|
||||||
|
virtual void setPreviewModeEnabled( bool previewMode ) = 0;
|
||||||
|
|
||||||
virtual void scheduleUpdate() = 0;
|
virtual void scheduleUpdate() = 0;
|
||||||
virtual void scheduleReplotOfAllPlots() = 0;
|
virtual void scheduleReplotOfAllPlots() = 0;
|
||||||
virtual void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) = 0;
|
virtual void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) = 0;
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
RiuMultiPlotPage::RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget* parent )
|
RiuMultiPlotPage::RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget* parent )
|
||||||
: RiuMultiPlotInterface( parent )
|
: RiuMultiPlotInterface( parent )
|
||||||
, m_plotDefinition( plotDefinition )
|
, m_plotDefinition( plotDefinition )
|
||||||
|
, m_previewMode( false )
|
||||||
{
|
{
|
||||||
Q_ASSERT( plotDefinition );
|
Q_ASSERT( plotDefinition );
|
||||||
m_plotDefinition = plotDefinition;
|
m_plotDefinition = plotDefinition;
|
||||||
@ -288,6 +289,22 @@ int RiuMultiPlotPage::fontSize() const
|
|||||||
return m_plotTitle->font().pointSize() - 2;
|
return m_plotTitle->font().pointSize() - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RiuMultiPlotPage::previewModeEnabled() const
|
||||||
|
{
|
||||||
|
return m_previewMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuMultiPlotPage::setPreviewModeEnabled( bool previewMode )
|
||||||
|
{
|
||||||
|
m_previewMode = previewMode;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -554,10 +571,17 @@ int RiuMultiPlotPage::heightForWidth( int width ) const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuMultiPlotPage::updateMarginsFromPageLayout()
|
void RiuMultiPlotPage::updateMarginsFromPageLayout()
|
||||||
{
|
{
|
||||||
QPageLayout pageLayout = m_plotDefinition->pageLayout();
|
if ( m_previewMode )
|
||||||
const int resolution = RiaGuiApplication::applicationResolution();
|
{
|
||||||
QMargins margins = pageLayout.marginsPixels( resolution );
|
QPageLayout pageLayout = m_plotDefinition->pageLayout();
|
||||||
m_layout->setContentsMargins( margins );
|
const int resolution = RiaGuiApplication::applicationResolution();
|
||||||
|
QMargins margins = pageLayout.marginsPixels( resolution );
|
||||||
|
m_layout->setContentsMargins( margins );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_layout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -74,6 +74,9 @@ public:
|
|||||||
void setFontSize( int fontSize ) override;
|
void setFontSize( int fontSize ) override;
|
||||||
int fontSize() const override;
|
int fontSize() const override;
|
||||||
|
|
||||||
|
bool previewModeEnabled() const override;
|
||||||
|
void setPreviewModeEnabled( bool previewMode ) override;
|
||||||
|
|
||||||
void scheduleUpdate() override;
|
void scheduleUpdate() override;
|
||||||
void scheduleReplotOfAllPlots() override;
|
void scheduleReplotOfAllPlots() override;
|
||||||
void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) override {}
|
void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) override {}
|
||||||
@ -136,6 +139,7 @@ protected:
|
|||||||
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
|
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
|
||||||
caf::PdmPointer<RimMultiPlotWindow> m_plotDefinition;
|
caf::PdmPointer<RimMultiPlotWindow> m_plotDefinition;
|
||||||
QPointer<QLabel> m_dropTargetPlaceHolder;
|
QPointer<QLabel> m_dropTargetPlaceHolder;
|
||||||
|
bool m_previewMode;
|
||||||
|
|
||||||
caf::UiStyleSheet m_dropTargetStyleSheet;
|
caf::UiStyleSheet m_dropTargetStyleSheet;
|
||||||
|
|
||||||
|
@ -103,6 +103,7 @@ RiuMultiPlotWindow::RiuMultiPlotWindow( RimMultiPlotWindow* plotDefinition, QWid
|
|||||||
, m_plotDefinition( plotDefinition )
|
, m_plotDefinition( plotDefinition )
|
||||||
, m_plotTitle( "Multi Plot" )
|
, m_plotTitle( "Multi Plot" )
|
||||||
, m_titleVisible( true )
|
, m_titleVisible( true )
|
||||||
|
, m_previewMode( true )
|
||||||
{
|
{
|
||||||
Q_ASSERT( plotDefinition );
|
Q_ASSERT( plotDefinition );
|
||||||
m_plotDefinition = plotDefinition;
|
m_plotDefinition = plotDefinition;
|
||||||
@ -250,10 +251,13 @@ void RiuMultiPlotWindow::setFontSize( int fontSize )
|
|||||||
|
|
||||||
font.setPixelSize( pixelSize );
|
font.setPixelSize( pixelSize );
|
||||||
this->setFont( font );
|
this->setFont( font );
|
||||||
|
|
||||||
for ( auto page : m_pages )
|
for ( auto page : m_pages )
|
||||||
{
|
{
|
||||||
page->setFontSize( fontSize );
|
page->setFontSize( fontSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scheduleUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -272,6 +276,29 @@ int RiuMultiPlotWindow::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
|
|||||||
return m_plotWidgets.indexOf( plotWidget );
|
return m_plotWidgets.indexOf( plotWidget );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RiuMultiPlotWindow::previewModeEnabled() const
|
||||||
|
{
|
||||||
|
return m_previewMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuMultiPlotWindow::setPreviewModeEnabled( bool previewMode )
|
||||||
|
{
|
||||||
|
m_previewMode = previewMode;
|
||||||
|
|
||||||
|
for ( auto page : m_pages )
|
||||||
|
{
|
||||||
|
page->setPreviewModeEnabled( previewModeEnabled() );
|
||||||
|
}
|
||||||
|
|
||||||
|
scheduleUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -471,9 +498,11 @@ void RiuMultiPlotWindow::createPages()
|
|||||||
page->setVisible( true );
|
page->setVisible( true );
|
||||||
page->performUpdate();
|
page->performUpdate();
|
||||||
}
|
}
|
||||||
// Reapply plot titles
|
// Reapply plot settings
|
||||||
setPlotTitle( m_plotTitle );
|
setPlotTitle( m_plotTitle );
|
||||||
|
setFontSize( fontSize() );
|
||||||
setTitleVisible( m_titleVisible );
|
setTitleVisible( m_titleVisible );
|
||||||
|
setPreviewModeEnabled( m_previewMode );
|
||||||
m_book->adjustSize();
|
m_book->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,9 @@ public:
|
|||||||
|
|
||||||
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );
|
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );
|
||||||
|
|
||||||
|
bool previewModeEnabled() const override;
|
||||||
|
void setPreviewModeEnabled( bool previewMode ) override;
|
||||||
|
|
||||||
void scheduleUpdate();
|
void scheduleUpdate();
|
||||||
void scheduleReplotOfAllPlots();
|
void scheduleReplotOfAllPlots();
|
||||||
void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) override {}
|
void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) override {}
|
||||||
@ -118,4 +121,5 @@ protected:
|
|||||||
caf::PdmPointer<RimMultiPlotWindow> m_plotDefinition;
|
caf::PdmPointer<RimMultiPlotWindow> m_plotDefinition;
|
||||||
QString m_plotTitle;
|
QString m_plotTitle;
|
||||||
bool m_titleVisible;
|
bool m_titleVisible;
|
||||||
|
bool m_previewMode;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user