mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5288 Fix update issues
This commit is contained in:
parent
0692ea28ad
commit
a0cac2fefa
@ -84,22 +84,22 @@ void RicSnapshotViewToFileFeature::savePlotPDFReportAs( const QString& fileName,
|
||||
QFile pdfFile( fileName );
|
||||
if ( pdfFile.open( QIODevice::WriteOnly ) )
|
||||
{
|
||||
int resolution = RiaGuiApplication::applicationResolution();
|
||||
int pageWidth = plot->pageLayout().fullRectPixels( resolution ).width();
|
||||
int widgetWidth = plot->viewWidget()->width();
|
||||
int deltaWidth = widgetWidth - pageWidth;
|
||||
int resolution = RiaGuiApplication::applicationResolution();
|
||||
/* int pageWidth = plot->pageLayout().fullRectPixels( resolution ).width();
|
||||
int widgetWidth = plot->viewWidget()->width();
|
||||
int deltaWidth = widgetWidth - pageWidth;
|
||||
|
||||
while ( std::abs( deltaWidth ) > 1 )
|
||||
{
|
||||
int newResolution = resolution + deltaWidth / std::abs( deltaWidth );
|
||||
pageWidth = plot->pageLayout().fullRectPixels( resolution ).width();
|
||||
int newDeltaWidth = widgetWidth - pageWidth;
|
||||
if ( std::abs( newDeltaWidth ) > std::abs( deltaWidth ) ) break;
|
||||
|
||||
resolution = newResolution;
|
||||
deltaWidth = newDeltaWidth;
|
||||
}
|
||||
while ( std::abs( deltaWidth ) > 1 )
|
||||
{
|
||||
int newResolution = resolution + deltaWidth / std::abs( deltaWidth );
|
||||
pageWidth = plot->pageLayout().fullRectPixels( resolution ).width();
|
||||
int newDeltaWidth = widgetWidth - pageWidth;
|
||||
if ( std::abs( newDeltaWidth ) > std::abs( deltaWidth ) ) break;
|
||||
|
||||
resolution = newResolution;
|
||||
deltaWidth = newDeltaWidth;
|
||||
}
|
||||
*/
|
||||
QPdfWriter pdfPrinter( fileName );
|
||||
pdfPrinter.setPageLayout( plot->pageLayout() );
|
||||
pdfPrinter.setCreator( QCoreApplication::applicationName() );
|
||||
|
@ -178,13 +178,13 @@ void RimMultiPlotWindow::insertPlot( RimPlot* plot, size_t index )
|
||||
if ( plot )
|
||||
{
|
||||
m_plots.insert( index, plot );
|
||||
plot->setShowWindow( true );
|
||||
|
||||
if ( m_viewer )
|
||||
{
|
||||
plot->createPlotWidget();
|
||||
m_viewer->insertPlot( plot->viewer(), index );
|
||||
}
|
||||
plot->setShowWindow( true );
|
||||
plot->setLegendsVisible( false );
|
||||
|
||||
onPlotAdditionOrRemoval();
|
||||
|
@ -76,13 +76,14 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget*
|
||||
|
||||
m_plotTitle = createTitleLabel();
|
||||
m_layout->addWidget( m_plotTitle );
|
||||
m_plotTitle->setVisible( m_plotDefinition->isMultiPlotTitleVisible() );
|
||||
|
||||
m_plotLayout = new QHBoxLayout;
|
||||
m_layout->addLayout( m_plotLayout );
|
||||
|
||||
m_plotWidgetFrame = new QFrame;
|
||||
m_plotWidgetFrame->setVisible( true );
|
||||
m_plotLayout->addWidget( m_plotWidgetFrame, 1 );
|
||||
m_plotWidgetFrame->setVisible( true );
|
||||
|
||||
m_gridLayout = new QGridLayout( m_plotWidgetFrame );
|
||||
m_gridLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||
@ -308,14 +309,17 @@ void RiuMultiPlotPage::scheduleReplotOfAllPlots()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::renderTo( QPaintDevice* paintDevice )
|
||||
{
|
||||
int resolution = paintDevice->logicalDpiX();
|
||||
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
|
||||
|
||||
QPainter painter( paintDevice );
|
||||
renderTo( &painter );
|
||||
renderTo( &painter, scaling );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::renderTo( QPainter* painter )
|
||||
void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor )
|
||||
{
|
||||
setSelectionsVisible( false );
|
||||
m_plotTitle->render( painter );
|
||||
@ -345,7 +349,7 @@ void RiuMultiPlotPage::renderTo( QPainter* painter )
|
||||
QPoint plotWidgetFrameTopLeft = m_plotWidgetFrame->frameGeometry().topLeft();
|
||||
plotWidgetGeometry.moveTo( plotWidgetTopLeft + plotWidgetFrameTopLeft - marginOffset );
|
||||
|
||||
plotWidget->renderTo( painter, plotWidgetGeometry );
|
||||
plotWidget->renderTo( painter, plotWidgetGeometry, scalingFactor );
|
||||
}
|
||||
|
||||
setSelectionsVisible( true );
|
||||
@ -378,7 +382,6 @@ void RiuMultiPlotPage::contextMenuEvent( QContextMenuEvent* event )
|
||||
QLabel* RiuMultiPlotPage::createTitleLabel() const
|
||||
{
|
||||
QLabel* plotTitle = new QLabel( "PLOT TITLE HERE", nullptr );
|
||||
plotTitle->setVisible( m_plotDefinition->isMultiPlotTitleVisible() );
|
||||
plotTitle->setAlignment( Qt::AlignHCenter );
|
||||
plotTitle->setWordWrap( true );
|
||||
plotTitle->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
||||
|
@ -15,7 +15,6 @@
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiuMultiPlotInterface.h"
|
||||
@ -80,7 +79,7 @@ public:
|
||||
void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) override {}
|
||||
|
||||
void renderTo( QPaintDevice* paintDevice ) override;
|
||||
void renderTo( QPainter* painter );
|
||||
void renderTo( QPainter* painter, double scalingFactor );
|
||||
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
|
@ -15,7 +15,6 @@
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuMultiPlotWindow.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
@ -292,6 +291,9 @@ void RiuMultiPlotWindow::renderTo( QPaintDevice* paintDevice )
|
||||
{
|
||||
setSelectionsVisible( false );
|
||||
|
||||
int resolution = paintDevice->logicalDpiX();
|
||||
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
|
||||
|
||||
bool firstPage = true;
|
||||
QPainter painter( paintDevice );
|
||||
for ( RiuMultiPlotPage* page : m_pages )
|
||||
@ -304,7 +306,7 @@ void RiuMultiPlotWindow::renderTo( QPaintDevice* paintDevice )
|
||||
pagedDevice->newPage();
|
||||
}
|
||||
}
|
||||
page->renderTo( &painter );
|
||||
page->renderTo( &painter, scaling );
|
||||
firstPage = false;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiuInterfaceToViewWindow.h"
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
#include "RiuQwtPlotWidget.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTools.h"
|
||||
#include "RiaFontCache.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaPlotWindowRedrawScheduler.h"
|
||||
|
||||
#include "RimPlot.h"
|
||||
@ -609,10 +609,21 @@ void RiuQwtPlotWidget::endZoomOperations() {}
|
||||
//--------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect )
|
||||
void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect, double scaling )
|
||||
{
|
||||
static_cast<QwtPlotCanvas*>( this->canvas() )->setPaintAttribute( QwtPlotCanvas::BackingStore, false );
|
||||
|
||||
QPoint plotTopLeftInWindowCoords = targetRect.topLeft();
|
||||
|
||||
QRectF canvasRect = this->plotLayout()->canvasRect();
|
||||
QPoint canvasTopLeftInPlotCoords( canvasRect.topLeft().x() * scaling, canvasRect.topLeft().y() * scaling );
|
||||
QPoint canvasBottomRightInPlotCoords( canvasRect.bottomRight().x() * scaling, canvasRect.bottomRight().y() * scaling );
|
||||
|
||||
QPoint canvasTopLeftInWindowCoords = canvasTopLeftInPlotCoords + plotTopLeftInWindowCoords;
|
||||
QPoint canvasBottomRightInWindowCoords = canvasBottomRightInPlotCoords + plotTopLeftInWindowCoords;
|
||||
|
||||
QwtPlotRenderer renderer( this );
|
||||
renderer.setDiscardFlag( QwtPlotRenderer::DiscardBackground, true );
|
||||
renderer.render( this, painter, targetRect );
|
||||
static_cast<QwtPlotCanvas*>( this->canvas() )->setPaintAttribute( QwtPlotCanvas::BackingStore, true );
|
||||
|
||||
@ -621,11 +632,8 @@ void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect )
|
||||
if ( overlayFrame->isVisible() )
|
||||
{
|
||||
QPoint overlayTopLeftInCanvasCoords = overlayFrame->frameGeometry().topLeft();
|
||||
QPoint canvasTopLeftInPlotCoords = this->canvas()->frameGeometry().topLeft();
|
||||
QPoint plotTopLeftInWindowCoords = targetRect.topLeft();
|
||||
|
||||
QPoint overlayTopLeftInWindowCoords = plotTopLeftInWindowCoords + canvasTopLeftInPlotCoords +
|
||||
overlayTopLeftInCanvasCoords;
|
||||
QPoint overlayTopLeftInWindowCoords = overlayTopLeftInCanvasCoords + canvasTopLeftInWindowCoords;
|
||||
{
|
||||
QRect overlayRect = overlayFrame->frameGeometry();
|
||||
QSize desiredSize = overlayRect.size();
|
||||
@ -633,6 +641,14 @@ void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect )
|
||||
QSize actualSize = desiredSize.expandedTo( minimumSize );
|
||||
overlayRect.moveTo( overlayTopLeftInWindowCoords );
|
||||
overlayRect.setSize( actualSize );
|
||||
/* QPoint overlayBottomRightInWindowCoords = overlayRect.bottomRight();
|
||||
overlayBottomRightInWindowCoords.setX(
|
||||
std::min( overlayBottomRightInWindowCoords.x(),
|
||||
canvasBottomRightInPlotCoords.x() - (int)scaling * m_overlayMargins ) );
|
||||
overlayBottomRightInWindowCoords.setY(
|
||||
std::min( overlayBottomRightInWindowCoords.y(),
|
||||
canvasBottomRightInPlotCoords.y() - (int)scaling * m_overlayMargins ) );
|
||||
overlayRect.setBottomRight( overlayBottomRightInWindowCoords ); */
|
||||
overlayFrame->renderTo( painter, overlayRect );
|
||||
}
|
||||
}
|
||||
@ -644,8 +660,10 @@ void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::renderTo( QPaintDevice* paintDevice, const QRect& targetRect )
|
||||
{
|
||||
int resolution = paintDevice->logicalDpiX();
|
||||
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
|
||||
QPainter painter( paintDevice );
|
||||
renderTo( &painter, targetRect );
|
||||
renderTo( &painter, targetRect, scaling );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -766,6 +784,29 @@ void RiuQwtPlotWidget::updateOverlayFrameLayout()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::scaleFonts( double scalingFactor )
|
||||
{
|
||||
for ( int axisId = static_cast<int>( QwtPlot::yLeft ); axisId < static_cast<int>( axisCnt ); ++axisId )
|
||||
{
|
||||
QFont axisFont = this->axisFont( axisId );
|
||||
axisFont.setPointSize( axisFont.pointSize() * scalingFactor );
|
||||
this->setAxisFont( axisId, axisFont );
|
||||
|
||||
// Axis title font
|
||||
QwtText axisTitle = this->axisTitle( axisId );
|
||||
QFont axisTitleFont = axisTitle.font();
|
||||
axisTitleFont.setPointSize( axisTitleFont.pointSize() * scalingFactor );
|
||||
axisTitle.setFont( axisTitleFont );
|
||||
this->setAxisTitle( axisId, axisTitle );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::selectPlotOwner( bool toggleItemInSelection )
|
||||
{
|
||||
if ( toggleItemInSelection )
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
void removeOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
|
||||
void updateLayout() override;
|
||||
|
||||
void renderTo( QPainter* painter, const QRect& targetRect );
|
||||
void renderTo( QPainter* painter, const QRect& targetRect, double scaling );
|
||||
void renderTo( QPaintDevice* painter, const QRect& targetRect );
|
||||
int overlayMargins() const;
|
||||
|
||||
@ -139,6 +139,8 @@ private:
|
||||
|
||||
void updateOverlayFrameLayout();
|
||||
|
||||
void scaleFonts( double scalingFactor );
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimPlot> m_plotDefinition;
|
||||
QPoint m_clickPosition;
|
||||
|
@ -59,7 +59,6 @@ void RiuWellLogPlot::updateVerticalScrollBar( double minVisible, double maxVisib
|
||||
m_trackScrollBar->setRange( (int)minAvailable, (int)( ( maxAvailable - visibleRange ) ) );
|
||||
m_trackScrollBar->setPageStep( (int)visibleRange );
|
||||
m_trackScrollBar->setValue( (int)minVisible );
|
||||
m_trackScrollBar->setVisible( true );
|
||||
}
|
||||
m_trackScrollBar->blockSignals( false );
|
||||
}
|
||||
@ -108,9 +107,8 @@ void RiuWellLogPlot::reinsertScrollbar()
|
||||
int rowCount = this->m_gridLayout->rowCount();
|
||||
int colCount = this->m_gridLayout->columnCount();
|
||||
|
||||
m_trackScrollBar->setVisible( !plotWidgets.empty() );
|
||||
|
||||
m_gridLayout->addLayout( m_trackScrollBarLayout, 2, colCount, rowCount * 2 - 1, 1 );
|
||||
m_trackScrollBar->setVisible( !plotWidgets.empty() );
|
||||
m_gridLayout->setColumnStretch( colCount, 0 );
|
||||
}
|
||||
|
||||
@ -141,6 +139,7 @@ void RiuWellLogPlot::slotSetMinDepth( int value )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::performUpdate()
|
||||
{
|
||||
m_trackScrollBar->setVisible( false );
|
||||
reinsertPlotWidgets();
|
||||
reinsertScrollbar();
|
||||
int axisShift = alignCanvasTops();
|
||||
|
Loading…
Reference in New Issue
Block a user