mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Fix Summary Multiplot subplot colspan issue (#8805)
Fix colspan bug for summary multiplots
This commit is contained in:
parent
c41ab07c1a
commit
db3395da44
@ -31,12 +31,12 @@
|
|||||||
#include "RimSummaryCurve.h"
|
#include "RimSummaryCurve.h"
|
||||||
#include "RimSummaryPlotControls.h"
|
#include "RimSummaryPlotControls.h"
|
||||||
|
|
||||||
#include "RimMultiPlot.h"
|
|
||||||
#include "RimSummaryAddress.h"
|
#include "RimSummaryAddress.h"
|
||||||
#include "RimSummaryPlot.h"
|
#include "RimSummaryPlot.h"
|
||||||
#include "RimSummaryPlotNameHelper.h"
|
#include "RimSummaryPlotNameHelper.h"
|
||||||
#include "RimSummaryPlotSourceStepping.h"
|
#include "RimSummaryPlotSourceStepping.h"
|
||||||
|
|
||||||
|
#include "RiuSummaryMultiPlotBook.h"
|
||||||
#include "RiuSummaryVectorSelectionUi.h"
|
#include "RiuSummaryVectorSelectionUi.h"
|
||||||
|
|
||||||
#include "cafPdmUiComboBoxEditor.h"
|
#include "cafPdmUiComboBoxEditor.h"
|
||||||
@ -619,3 +619,17 @@ void RimSummaryMultiPlot::onSubPlotAxisChanged( const caf::SignalEmitter* emitte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QWidget* RimSummaryMultiPlot::createViewWidget( QWidget* mainWindowParent )
|
||||||
|
{
|
||||||
|
if ( m_viewer.isNull() )
|
||||||
|
{
|
||||||
|
m_viewer = new RiuSummaryMultiPlotBook( this, mainWindowParent );
|
||||||
|
}
|
||||||
|
recreatePlotWidgets();
|
||||||
|
|
||||||
|
return m_viewer;
|
||||||
|
}
|
||||||
|
@ -87,6 +87,8 @@ protected:
|
|||||||
|
|
||||||
void initAfterRead() override;
|
void initAfterRead() override;
|
||||||
|
|
||||||
|
QWidget* createViewWidget( QWidget* mainWindowParent ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||||
|
@ -54,9 +54,10 @@ set(SOURCE_GROUP_HEADER_FILES
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotPage.h
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotPage.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotBook.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuPlotWidget.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuPlotWidget.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuPlotAxis.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuPlotAxis.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h
|
||||||
@ -157,6 +158,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotPage.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotPage.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotBook.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuPlotWidget.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiuPlotWidget.cpp
|
||||||
@ -259,6 +261,7 @@ list(
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotBook.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotPage.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuSummaryMultiPlotPage.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h
|
||||||
|
@ -594,8 +594,9 @@ void RiuMultiPlotBook::createPages()
|
|||||||
m_pages[i]->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( pageNumber ).arg( m_pages.size() ) );
|
m_pages[i]->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( pageNumber ).arg( m_pages.size() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_book->adjustSize();
|
adjustBookFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -609,20 +610,24 @@ const QList<QPointer<RiuMultiPlotPage>>& RiuMultiPlotBook::pages() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuMultiPlotPage* RiuMultiPlotBook::createPage()
|
RiuMultiPlotPage* RiuMultiPlotBook::createPage()
|
||||||
{
|
{
|
||||||
RiuMultiPlotPage* page;
|
RiuMultiPlotPage* page = new RiuMultiPlotPage( m_plotDefinition, this );
|
||||||
|
|
||||||
RimSummaryMultiPlot* sumMultPlot = dynamic_cast<RimSummaryMultiPlot*>( m_plotDefinition.p() );
|
applyPageSettings( page );
|
||||||
|
|
||||||
if ( sumMultPlot )
|
m_pages.push_back( page );
|
||||||
{
|
m_bookLayout->addWidget( page );
|
||||||
page = new RiuSummaryMultiPlotPage( sumMultPlot, this );
|
|
||||||
}
|
page->setVisible( true );
|
||||||
else
|
return page;
|
||||||
{
|
|
||||||
page = new RiuMultiPlotPage( m_plotDefinition, this );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reapply plot settings
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuMultiPlotBook::applyPageSettings( RiuMultiPlotPage* page )
|
||||||
|
{
|
||||||
|
if ( !page ) return;
|
||||||
|
|
||||||
page->setPlotTitle( m_plotTitle );
|
page->setPlotTitle( m_plotTitle );
|
||||||
page->setTitleFontSizes( m_plotDefinition->titleFontSize(), m_plotDefinition->subTitleFontSize() );
|
page->setTitleFontSizes( m_plotDefinition->titleFontSize(), m_plotDefinition->subTitleFontSize() );
|
||||||
page->setLegendFontSize( m_plotDefinition->legendFontSize() );
|
page->setLegendFontSize( m_plotDefinition->legendFontSize() );
|
||||||
@ -630,12 +635,6 @@ RiuMultiPlotPage* RiuMultiPlotBook::createPage()
|
|||||||
page->setTitleVisible( m_titleVisible );
|
page->setTitleVisible( m_titleVisible );
|
||||||
page->setSubTitlesVisible( m_subTitlesVisible );
|
page->setSubTitlesVisible( m_subTitlesVisible );
|
||||||
page->setPagePreviewModeEnabled( m_previewMode );
|
page->setPagePreviewModeEnabled( m_previewMode );
|
||||||
|
|
||||||
m_pages.push_back( page );
|
|
||||||
m_bookLayout->addWidget( page );
|
|
||||||
|
|
||||||
page->setVisible( true );
|
|
||||||
return page;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -748,3 +747,11 @@ bool RiuMultiPlotBook::eventFilter( QObject* obj, QEvent* event )
|
|||||||
}
|
}
|
||||||
return QWidget::eventFilter( obj, event );
|
return QWidget::eventFilter( obj, event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuMultiPlotBook::adjustBookFrame()
|
||||||
|
{
|
||||||
|
m_book->adjustSize();
|
||||||
|
}
|
||||||
|
@ -113,11 +113,16 @@ protected:
|
|||||||
|
|
||||||
bool eventFilter( QObject* obj, QEvent* ev ) override;
|
bool eventFilter( QObject* obj, QEvent* ev ) override;
|
||||||
|
|
||||||
private:
|
virtual void createPages();
|
||||||
void deleteAllPages();
|
|
||||||
void createPages();
|
void adjustBookFrame();
|
||||||
|
void applyPageSettings( RiuMultiPlotPage* page );
|
||||||
|
|
||||||
const QList<QPointer<RiuMultiPlotPage>>& pages() const;
|
const QList<QPointer<RiuMultiPlotPage>>& pages() const;
|
||||||
|
|
||||||
|
private:
|
||||||
RiuMultiPlotPage* createPage();
|
RiuMultiPlotPage* createPage();
|
||||||
|
void deleteAllPages();
|
||||||
void applyLook();
|
void applyLook();
|
||||||
|
|
||||||
void changeCurrentPage( int pageNumber );
|
void changeCurrentPage( int pageNumber );
|
||||||
|
@ -90,6 +90,11 @@ public:
|
|||||||
QSize minimumSizeHint() const override;
|
QSize minimumSizeHint() const override;
|
||||||
int heightForWidth( int width ) const override;
|
int heightForWidth( int width ) const override;
|
||||||
|
|
||||||
|
std::pair<int, int> findAvailableRowAndColumn( int startRow, int startColumn, int columnSpan, int columnCount ) const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void performUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void contextMenuEvent( QContextMenuEvent* ) override;
|
void contextMenuEvent( QContextMenuEvent* ) override;
|
||||||
QLabel* createTitleLabel() const;
|
QLabel* createTitleLabel() const;
|
||||||
@ -117,17 +122,12 @@ protected:
|
|||||||
QList<QPointer<RiuQwtPlotLegend>> legendsForVisiblePlots() const;
|
QList<QPointer<RiuQwtPlotLegend>> legendsForVisiblePlots() const;
|
||||||
QList<QPointer<QLabel>> subTitlesForVisiblePlots() const;
|
QList<QPointer<QLabel>> subTitlesForVisiblePlots() const;
|
||||||
|
|
||||||
std::pair<int, int> findAvailableRowAndColumn( int startRow, int startColumn, int columnSpan, int columnCount ) const;
|
|
||||||
|
|
||||||
void applyLook();
|
void applyLook();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
virtual void performUpdate( RiaDefines::MultiPlotPageUpdateType whatToUpdate );
|
|
||||||
void onLegendUpdated();
|
void onLegendUpdated();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class RiuMultiPlotBook;
|
|
||||||
|
|
||||||
QPointer<QVBoxLayout> m_layout;
|
QPointer<QVBoxLayout> m_layout;
|
||||||
QPointer<QHBoxLayout> m_plotLayout;
|
QPointer<QHBoxLayout> m_plotLayout;
|
||||||
QPointer<QFrame> m_plotWidgetFrame;
|
QPointer<QFrame> m_plotWidgetFrame;
|
||||||
|
110
ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.cpp
Normal file
110
ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.cpp
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2022 Equinor ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include "RiuSummaryMultiPlotBook.h"
|
||||||
|
|
||||||
|
#include "RimSummaryMultiPlot.h"
|
||||||
|
|
||||||
|
#include "RiuSummaryMultiPlotPage.h"
|
||||||
|
|
||||||
|
#include "RiuPlotWidget.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RiuSummaryMultiPlotBook::RiuSummaryMultiPlotBook( RimSummaryMultiPlot* plotDefinition, QWidget* parent )
|
||||||
|
: RiuMultiPlotBook( plotDefinition, parent )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RiuSummaryMultiPlotBook::~RiuSummaryMultiPlotBook()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuSummaryMultiPlotBook::createPages()
|
||||||
|
{
|
||||||
|
CAF_ASSERT( m_plotDefinition );
|
||||||
|
|
||||||
|
QList<QPointer<RiuPlotWidget>> plotWidgets = this->visiblePlotWidgets();
|
||||||
|
|
||||||
|
int columns = std::max( 1, m_plotDefinition->columnCount() );
|
||||||
|
int rowsPerPage = m_plotDefinition->rowsPerPage();
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
int col = 0;
|
||||||
|
|
||||||
|
RiuSummaryMultiPlotPage* page = createSummaryPage();
|
||||||
|
|
||||||
|
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
|
||||||
|
{
|
||||||
|
int expectedColSpan = static_cast<int>( plotWidgets[visibleIndex]->colSpan() );
|
||||||
|
int colSpan = std::min( expectedColSpan, columns );
|
||||||
|
|
||||||
|
if ( row >= rowsPerPage )
|
||||||
|
{
|
||||||
|
row = 0;
|
||||||
|
page = createSummaryPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
page->addPlot( plotWidgets[visibleIndex] );
|
||||||
|
page->performUpdate( RiaDefines::MultiPlotPageUpdateType::ALL );
|
||||||
|
|
||||||
|
col += colSpan;
|
||||||
|
if ( col >= columns )
|
||||||
|
{
|
||||||
|
row++;
|
||||||
|
col = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set page numbers in title when there's more than one page
|
||||||
|
if ( m_pages.size() > 1 )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < m_pages.size(); ++i )
|
||||||
|
{
|
||||||
|
int pageNumber = i + 1;
|
||||||
|
m_pages[i]->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( pageNumber ).arg( m_pages.size() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
adjustBookFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RiuSummaryMultiPlotPage* RiuSummaryMultiPlotBook::createSummaryPage()
|
||||||
|
{
|
||||||
|
RimSummaryMultiPlot* sumMultPlot = dynamic_cast<RimSummaryMultiPlot*>( m_plotDefinition.p() );
|
||||||
|
RiuSummaryMultiPlotPage* page = new RiuSummaryMultiPlotPage( sumMultPlot, this );
|
||||||
|
|
||||||
|
applyPageSettings( page );
|
||||||
|
|
||||||
|
m_pages.push_back( page );
|
||||||
|
m_bookLayout->addWidget( page );
|
||||||
|
|
||||||
|
page->setVisible( true );
|
||||||
|
return page;
|
||||||
|
}
|
42
ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.h
Normal file
42
ApplicationLibCode/UserInterface/RiuSummaryMultiPlotBook.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2022 Equinor ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "RiuMultiPlotBook.h"
|
||||||
|
|
||||||
|
class RimSummaryMultiPlot;
|
||||||
|
class RiuSummaryMultiPlotPage;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==================================================================================================
|
||||||
|
class RiuSummaryMultiPlotBook : public RiuMultiPlotBook
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
RiuSummaryMultiPlotBook( RimSummaryMultiPlot* plotDefinition, QWidget* parent = nullptr );
|
||||||
|
~RiuSummaryMultiPlotBook() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void createPages() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
RiuSummaryMultiPlotPage* createSummaryPage();
|
||||||
|
};
|
@ -147,6 +147,7 @@ void RiuSummaryMultiPlotPage::reinsertPlotWidgets()
|
|||||||
}
|
}
|
||||||
|
|
||||||
visibleIndex++;
|
visibleIndex++;
|
||||||
|
col += colSpan - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user