From f6bde92d81d58ca88537ed598e5d04652a8faf95 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 24 Oct 2022 13:38:45 +0200 Subject: [PATCH] Remove unused space caused by bottom margin --- .../ProjectDataModel/RimPlotWindow.cpp | 18 ++++++++++++++++++ .../ProjectDataModel/RimPlotWindow.h | 5 +++++ .../Summary/RimSummaryMultiPlot.cpp | 2 ++ .../UserInterface/RiuMultiPlotPage.cpp | 14 +++++++++----- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotWindow.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotWindow.cpp index 560245199c..c2e4616bdf 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotWindow.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotWindow.cpp @@ -78,6 +78,8 @@ RimPlotWindow::RimPlotWindow() m_titleFontSize = caf::FontTools::RelativeSize::XXLarge; m_legendFontSize = caf::FontTools::RelativeSize::Large; + + m_bottomMargin = -1; } //-------------------------------------------------------------------------------------------------- @@ -286,6 +288,22 @@ QPageLayout RimPlotWindow::pageLayout() const return defaultPageLayout; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotWindow::setBottomMargin( int bottomMargin ) +{ + m_bottomMargin = bottomMargin; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimPlotWindow::bottomMargin() const +{ + return m_bottomMargin; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotWindow.h b/ApplicationLibCode/ProjectDataModel/RimPlotWindow.h index bc33328620..6f84a47a13 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotWindow.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotWindow.h @@ -86,6 +86,7 @@ public: void renderWindowContent( QPaintDevice* painter ); QPageLayout pageLayout() const; + int bottomMargin() const; virtual bool handleGlobalKeyEvent( QKeyEvent* keyEvent ); virtual bool handleGlobalWheelEvent( QWheelEvent* wheelEvent ); @@ -100,6 +101,7 @@ protected: void uiOrderingForLegendsAndFonts( QString uiConfigName, caf::PdmUiOrdering& uiOrdering, bool showLegendPosition = false ); void updateWindowVisibility(); + void setBottomMargin( int bottomMargin ); private: virtual void doUpdateLayout() {} @@ -122,4 +124,7 @@ protected: caf::PdmField m_titleFontSize; caf::PdmField m_legendFontSize; + +private: + int m_bottomMargin; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp index 4a5dfdf117..cd905ebc97 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp @@ -173,6 +173,8 @@ RimSummaryMultiPlot::RimSummaryMultiPlot() m_defaultStepDimension.uiCapability()->setUiHidden( true ); m_nameHelper = std::make_unique(); + + setBottomMargin( 40 ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp index d98593b23b..ec98d5cb61 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp @@ -25,13 +25,10 @@ #include "RiaPlotWindowRedrawScheduler.h" #include "RiaPreferences.h" -#include "WellLogCommands/RicWellLogPlotTrackFeatureImpl.h" - #include "RimContextCommandBuilder.h" #include "RimMultiPlot.h" #include "RimPlotCurve.h" #include "RimPlotWindow.h" -#include "RimWellLogTrack.h" #include "RiuDraggableOverlayFrame.h" #include "RiuMainWindow.h" @@ -109,7 +106,7 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* pare m_gridLayout = new QGridLayout( m_plotWidgetFrame ); m_gridLayout->setContentsMargins( 0, 0, 0, 0 ); - m_gridLayout->setSpacing( 5 ); + m_gridLayout->setSpacing( 0 ); new RiuPlotObjectPicker( m_plotTitle, m_plotDefinition ); @@ -829,8 +826,15 @@ void RiuMultiPlotPage::adjustHeadingSpacing( RiuPlotWidget* plotWidget ) { // Adjust the space below a graph to make sure the heading of the row below is closest to the // corresponding graph + + if ( !m_plotDefinition ) return; + + int bottomMargin = m_plotDefinition->bottomMargin(); + if ( bottomMargin < 0 ) return; + auto margins = plotWidget->contentsMargins(); - margins.setBottom( 40 ); + + margins.setBottom( bottomMargin ); plotWidget->setContentsMargins( margins ); }