mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactor RimPlotWindow and RimPlotInterface
This commit is contained in:
@@ -57,9 +57,6 @@ RimGridCrossPlot::RimGridCrossPlot()
|
||||
CAF_PDM_InitField( &m_showInfoBox, "ShowInfoBox", true, "Show Info Box", "", "", "" );
|
||||
CAF_PDM_InitField( &m_showLegend_OBSOLETE, "ShowLegend", false, "Show Legend", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_rowSpan, "RowSpan", "Row Span", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Col Span", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "Name Config", "", "", "" );
|
||||
m_nameConfig.uiCapability()->setUiTreeHidden( true );
|
||||
m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
@@ -90,22 +87,6 @@ RimGridCrossPlot::~RimGridCrossPlot()
|
||||
cleanupBeforeClose();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridCrossPlot::isChecked() const
|
||||
{
|
||||
return isWindowVisible();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::setChecked( bool checked )
|
||||
{
|
||||
m_showWindow = checked;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -314,14 +295,6 @@ void RimGridCrossPlot::detachAllCurves()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::loadDataAndUpdate()
|
||||
{
|
||||
onLoadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -338,14 +311,6 @@ void RimGridCrossPlot::setAutoScaleYEnabled( bool enabled )
|
||||
m_yAxisProperties->setAutoZoom( enabled );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::createPlotWidget()
|
||||
{
|
||||
createViewWidget( nullptr );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -441,22 +406,6 @@ void RimGridCrossPlot::updateAfterInsertingIntoMultiPlot()
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGridCrossPlot::rowSpan() const
|
||||
{
|
||||
return static_cast<int>( m_rowSpan() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGridCrossPlot::colSpan() const
|
||||
{
|
||||
return static_cast<int>( m_colSpan() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -508,7 +457,7 @@ void RimGridCrossPlot::initAfterRead()
|
||||
{
|
||||
if ( m_showLegend_OBSOLETE() )
|
||||
{
|
||||
m_showPlotLegends = true;
|
||||
setLegendsVisible( true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,14 +469,9 @@ void RimGridCrossPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
|
||||
caf::PdmUiGroup* generalGroup = uiOrdering.addNewGroup( "Plot Options" );
|
||||
generalGroup->add( &m_showInfoBox );
|
||||
|
||||
if ( isStandalonePlot() )
|
||||
if ( isMdiWindow() )
|
||||
{
|
||||
generalGroup->add( &m_showPlotLegends );
|
||||
|
||||
if ( m_showPlotLegends() )
|
||||
{
|
||||
generalGroup->add( &m_legendFontSize );
|
||||
}
|
||||
RimPlotWindow::uiOrderingForLegendSettings( uiConfigName, *generalGroup );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -563,14 +507,10 @@ void RimGridCrossPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
if ( changedField == &m_legendFontSize )
|
||||
RimPlot::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
if ( changedField == &m_colSpan || changedField == &m_rowSpan )
|
||||
{
|
||||
updateLegend();
|
||||
}
|
||||
else if ( changedField == &m_colSpan || changedField == &m_rowSpan )
|
||||
{
|
||||
updatePlotWindowLayout();
|
||||
updateParentLayout();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -578,32 +518,6 @@ void RimGridCrossPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimGridCrossPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( fieldNeedingOptions == &m_legendFontSize )
|
||||
{
|
||||
std::vector<int> fontSizes;
|
||||
fontSizes.push_back( 8 );
|
||||
fontSizes.push_back( 10 );
|
||||
fontSizes.push_back( 12 );
|
||||
fontSizes.push_back( 14 );
|
||||
fontSizes.push_back( 16 );
|
||||
|
||||
for ( int value : fontSizes )
|
||||
{
|
||||
QString text = QString( "%1" ).arg( value );
|
||||
options.push_back( caf::PdmOptionItemInfo( text, value ) );
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -660,7 +574,7 @@ void RimGridCrossPlot::updateCurveNamesAndPlotTitle()
|
||||
m_crossPlotDataSets[i]->updateCurveNames( i, m_crossPlotDataSets.size() );
|
||||
}
|
||||
|
||||
if ( m_plotWidget && isStandalonePlot() )
|
||||
if ( m_plotWidget && isMdiWindow() )
|
||||
{
|
||||
m_plotWidget->setTitle( this->createAutoName() );
|
||||
}
|
||||
@@ -695,6 +609,20 @@ void RimGridCrossPlot::swapAxes()
|
||||
updateAxes();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGridCrossPlot::asciiDataForPlotExport() const
|
||||
{
|
||||
QString fullData;
|
||||
for ( int i = 0; i < (int)m_crossPlotDataSets.size(); ++i )
|
||||
{
|
||||
fullData += asciiTitleForPlotExport( i ) + "\n";
|
||||
fullData += asciiDataForGridCrossPlotExport( i ) + "\n";
|
||||
}
|
||||
return fullData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -758,20 +686,6 @@ void RimGridCrossPlot::setYAxisInverted( bool inverted )
|
||||
m_yAxisProperties->setAxisInverted( inverted );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGridCrossPlot::legendFontSize() const
|
||||
{
|
||||
RimMultiPlot* plotWindow = nullptr;
|
||||
this->firstAncestorOrThisOfType( plotWindow );
|
||||
if ( plotWindow )
|
||||
{
|
||||
return plotWindow->legendFontSize();
|
||||
}
|
||||
return m_legendFontSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -821,8 +735,8 @@ bool RimGridCrossPlot::applyFontSize( RiaDefines::FontSettingType fontSettingTyp
|
||||
|
||||
if ( forceChange || legendFontSize() == oldFontSize )
|
||||
{
|
||||
m_legendFontSize = fontSize;
|
||||
anyChange = true;
|
||||
setLegendFontSize( fontSize );
|
||||
anyChange = true;
|
||||
}
|
||||
|
||||
if ( anyChange ) loadDataAndUpdate();
|
||||
@@ -833,8 +747,9 @@ bool RimGridCrossPlot::applyFontSize( RiaDefines::FontSettingType fontSettingTyp
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::updateLayout()
|
||||
void RimGridCrossPlot::performLayoutUpdate()
|
||||
{
|
||||
updateLegend();
|
||||
updatePlot();
|
||||
}
|
||||
|
||||
@@ -843,8 +758,8 @@ void RimGridCrossPlot::updateLayout()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::updateLegend()
|
||||
{
|
||||
m_plotWidget->setInternalQwtLegendVisible( m_showPlotLegends() && isStandalonePlot() );
|
||||
m_plotWidget->setLegendFontSize( m_legendFontSize() );
|
||||
m_plotWidget->setInternalQwtLegendVisible( legendsVisible() && isMdiWindow() );
|
||||
m_plotWidget->setLegendFontSize( legendFontSize() );
|
||||
for ( auto dataSet : m_crossPlotDataSets )
|
||||
{
|
||||
dataSet->updateLegendIcons();
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RimNameConfig.h"
|
||||
#include "RimPlotInterface.h"
|
||||
#include "RimPlotWindow.h"
|
||||
#include "RimPlot.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
@@ -49,7 +48,7 @@ protected:
|
||||
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
};
|
||||
|
||||
class RimGridCrossPlot : public RimPlotWindow, public RimPlotInterface, public RimNameConfigHolderInterface
|
||||
class RimGridCrossPlot : public RimPlot, public RimNameConfigHolderInterface
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
@@ -57,9 +56,6 @@ public:
|
||||
RimGridCrossPlot();
|
||||
~RimGridCrossPlot();
|
||||
|
||||
bool isChecked() const override;
|
||||
void setChecked( bool checked ) override;
|
||||
|
||||
QString description() const override;
|
||||
|
||||
RimGridCrossPlotDataSet* createDataSet();
|
||||
@@ -83,13 +79,14 @@ public:
|
||||
void performAutoNameUpdate() override;
|
||||
void updateCurveNamesAndPlotTitle();
|
||||
void swapAxes();
|
||||
QString asciiTitleForPlotExport( int dataSetIndex ) const;
|
||||
QString asciiDataForGridCrossPlotExport( int dataSetIndex ) const;
|
||||
|
||||
QString asciiDataForPlotExport() const override;
|
||||
QString asciiTitleForPlotExport( int dataSetIndex ) const;
|
||||
QString asciiDataForGridCrossPlotExport( int dataSetIndex ) const;
|
||||
|
||||
bool isXAxisLogarithmic() const;
|
||||
bool isYAxisLogarithmic() const;
|
||||
void setYAxisInverted( bool inverted );
|
||||
int legendFontSize() const;
|
||||
|
||||
bool hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const override;
|
||||
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
|
||||
@@ -97,17 +94,13 @@ public:
|
||||
int fontSize,
|
||||
bool forceChange = false ) override;
|
||||
|
||||
void updateLayout() override;
|
||||
void updateLegend();
|
||||
|
||||
void updateZoomInQwt() override;
|
||||
void updateZoomFromQwt() override;
|
||||
|
||||
void loadDataAndUpdate() override;
|
||||
|
||||
void setAutoScaleXEnabled( bool enabled ) override;
|
||||
void setAutoScaleYEnabled( bool enabled ) override;
|
||||
void createPlotWidget() override;
|
||||
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override;
|
||||
void onAxisSelected( int axis, bool toggle ) override;
|
||||
|
||||
@@ -117,24 +110,20 @@ public:
|
||||
void removeFromMdiAreaAndCollection() override;
|
||||
void updateAfterInsertingIntoMultiPlot() override;
|
||||
|
||||
int rowSpan() const override;
|
||||
int colSpan() const override;
|
||||
|
||||
protected:
|
||||
QWidget* createViewWidget( QWidget* mainWindowParent ) override;
|
||||
QWidget* createViewWidget( QWidget* mainWindowParent = nullptr ) override;
|
||||
void deleteViewWidget() override;
|
||||
void onLoadDataAndUpdate() override;
|
||||
void initAfterRead() override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly ) override;
|
||||
void updateAxes() override;
|
||||
void updatePlot();
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue ) override;
|
||||
|
||||
void updateAxes() override;
|
||||
void updatePlot();
|
||||
|
||||
virtual QString xAxisParameterString() const;
|
||||
QString yAxisParameterString() const;
|
||||
@@ -152,6 +141,8 @@ protected:
|
||||
std::set<RimPlotAxisPropertiesInterface*> allPlotAxes() const;
|
||||
|
||||
private:
|
||||
void performLayoutUpdate() override;
|
||||
|
||||
void cleanupBeforeClose();
|
||||
|
||||
private:
|
||||
@@ -159,9 +150,6 @@ private:
|
||||
caf::PdmField<bool> m_showLegend_OBSOLETE;
|
||||
caf::PdmChildField<RimGridCrossPlotNameConfig*> m_nameConfig;
|
||||
|
||||
caf::PdmField<RimPlotInterface::RowOrColSpanEnum> m_rowSpan;
|
||||
caf::PdmField<RimPlotInterface::RowOrColSpanEnum> m_colSpan;
|
||||
|
||||
caf::PdmChildField<RimPlotAxisProperties*> m_yAxisProperties;
|
||||
caf::PdmChildField<RimPlotAxisProperties*> m_xAxisProperties;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user