Refactor RimPlotWindow and RimPlotInterface

This commit is contained in:
Gaute Lindkvist
2019-11-15 10:12:19 +01:00
parent 4dd0651dae
commit d9043db5e0
40 changed files with 697 additions and 765 deletions

View File

@@ -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();