Better fix for legend and title in sub plots and summary dialog

This commit is contained in:
Gaute Lindkvist
2020-09-17 10:02:58 +02:00
committed by Magne Sjaastad
parent 377274cdec
commit 9391453c2c
26 changed files with 79 additions and 47 deletions

View File

@@ -1646,7 +1646,7 @@ void RimAnalysisPlot::updatePlotTitle()
{ {
QString plotTitle = description(); QString plotTitle = description();
m_plotWidget->setPlotTitle( plotTitle ); m_plotWidget->setPlotTitle( plotTitle );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
m_plotWidget->scheduleReplot(); m_plotWidget->scheduleReplot();
} }
} }

View File

@@ -192,4 +192,5 @@ void RimAnalysisPlotCollection::insertPlot( RimAnalysisPlot* analysisPlot, size_
void RimAnalysisPlotCollection::removePlot( RimAnalysisPlot* analysisPlot ) void RimAnalysisPlotCollection::removePlot( RimAnalysisPlot* analysisPlot )
{ {
m_analysisPlots.removeChildObject( analysisPlot ); m_analysisPlots.removeChildObject( analysisPlot );
updateAllRequiredEditors();
} }

View File

@@ -176,6 +176,8 @@ RimCorrelationMatrixPlot::RimCorrelationMatrixPlot()
m_legendConfig->setColorLegend( m_legendConfig->setColorLegend(
RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::CORRELATION ) ); RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::CORRELATION ) );
setLegendsVisible( false );
this->uiCapability()->setUiTreeChildrenHidden( true ); this->uiCapability()->setUiTreeChildrenHidden( true );
m_selectMultipleVectors = true; m_selectMultipleVectors = true;
} }
@@ -661,7 +663,7 @@ void RimCorrelationMatrixPlot::updatePlotTitle()
if ( m_plotWidget ) if ( m_plotWidget )
{ {
m_plotWidget->setPlotTitle( m_description ); m_plotWidget->setPlotTitle( m_description );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
if ( isMdiWindow() ) if ( isMdiWindow() )
{ {
m_plotWidget->setPlotTitleFontSize( titleFontSize() ); m_plotWidget->setPlotTitleFontSize( titleFontSize() );

View File

@@ -89,6 +89,7 @@ RimCorrelationPlot::RimCorrelationPlot()
m_selectedParametersList.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); m_selectedParametersList.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
m_selectedParametersList.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); m_selectedParametersList.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
setLegendsVisible( false );
setDeletable( true ); setDeletable( true );
} }
@@ -296,7 +297,7 @@ void RimCorrelationPlot::updatePlotTitle()
.arg( timeStepString() ); .arg( timeStepString() );
} }
m_plotWidget->setPlotTitle( m_description ); m_plotWidget->setPlotTitle( m_description );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
m_plotWidget->setPlotTitleFontSize( titleFontSize() ); m_plotWidget->setPlotTitleFontSize( titleFontSize() );
} }

View File

@@ -192,6 +192,7 @@ void RimCorrelationPlotCollection::insertPlot( RimAbstractCorrelationPlot* plot,
void RimCorrelationPlotCollection::removePlot( RimAbstractCorrelationPlot* plot ) void RimCorrelationPlotCollection::removePlot( RimAbstractCorrelationPlot* plot )
{ {
m_correlationPlots.removeChildObject( plot ); m_correlationPlots.removeChildObject( plot );
updateAllRequiredEditors();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -84,7 +84,7 @@ RimCorrelationReportPlot::RimCorrelationReportPlot()
m_correlationPlot->setLegendsVisible( false ); m_correlationPlot->setLegendsVisible( false );
m_parameterResultCrossPlot = new RimParameterResultCrossPlot; m_parameterResultCrossPlot = new RimParameterResultCrossPlot;
m_parameterResultCrossPlot->setLegendsVisible( false ); m_parameterResultCrossPlot->setLegendsVisible( true );
this->uiCapability()->setUiTreeChildrenHidden( true ); this->uiCapability()->setUiTreeChildrenHidden( true );

View File

@@ -166,10 +166,13 @@ void RimParameterResultCrossPlot::onLoadDataAndUpdate()
if ( m_plotWidget && m_analyserOfSelectedCurveDefs ) if ( m_plotWidget && m_analyserOfSelectedCurveDefs )
{ {
createPoints(); createPoints();
QwtLegend* legend = new QwtLegend( m_plotWidget ); if ( m_showPlotLegends && !isSubPlot() )
m_plotWidget->insertLegend( legend, QwtPlot::RightLegend ); {
m_plotWidget->setLegendFontSize( legendFontSize() ); QwtLegend* legend = new QwtLegend( m_plotWidget );
m_plotWidget->updateLegend(); m_plotWidget->insertLegend( legend, QwtPlot::RightLegend );
m_plotWidget->setLegendFontSize( legendFontSize() );
m_plotWidget->updateLegend();
}
this->updateAxes(); this->updateAxes();
this->updatePlotTitle(); this->updatePlotTitle();
@@ -307,6 +310,6 @@ void RimParameterResultCrossPlot::updatePlotTitle()
.arg( timeStepString() ); .arg( timeStepString() );
} }
m_plotWidget->setPlotTitle( m_description ); m_plotWidget->setPlotTitle( m_description );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
m_plotWidget->setPlotTitleFontSize( titleFontSize() ); m_plotWidget->setPlotTitleFontSize( titleFontSize() );
} }

View File

@@ -634,7 +634,7 @@ void RimGridCrossPlot::updateCurveNamesAndPlotTitle()
{ {
QString plotTitle = this->createAutoName(); QString plotTitle = this->createAutoName();
m_plotWidget->setPlotTitle( plotTitle ); m_plotWidget->setPlotTitle( plotTitle );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
} }
updateMdiWindowTitle(); updateMdiWindowTitle();
} }

View File

@@ -83,4 +83,5 @@ void RimGridCrossPlotCollection::insertPlot( RimGridCrossPlot* plot, size_t inde
void RimGridCrossPlotCollection::removePlot( RimGridCrossPlot* plot ) void RimGridCrossPlotCollection::removePlot( RimGridCrossPlot* plot )
{ {
m_gridCrossPlots.removeChildObject( plot ); m_gridCrossPlots.removeChildObject( plot );
updateAllRequiredEditors();
} }

View File

@@ -672,7 +672,7 @@ void RimDepthTrackPlot::onPlotAdditionOrRemoval()
calculateAvailableDepthRange(); calculateAvailableDepthRange();
updateZoom(); updateZoom();
updateSubPlotNames(); updateSubPlotNames();
updateConnectedEditors(); updateAllRequiredEditors();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -183,14 +183,6 @@ void RimMultiPlot::setMultiPlotTitle( const QString& title )
m_plotWindowTitle = title; m_plotWindowTitle = title;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultiPlot::addPlot( RimPlot* plot )
{
insertPlot( plot, m_plots.size() );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -206,8 +198,6 @@ void RimMultiPlot::insertPlot( RimPlot* plot, size_t index )
m_viewer->insertPlot( plot->viewer(), index ); m_viewer->insertPlot( plot->viewer(), index );
} }
plot->setShowWindow( true ); plot->setShowWindow( true );
plot->setLegendsVisible( false );
plot->setPlotTitleVisible( false );
plot->updateAfterInsertingIntoMultiPlot(); plot->updateAfterInsertingIntoMultiPlot();
onPlotAdditionOrRemoval(); onPlotAdditionOrRemoval();
@@ -484,7 +474,7 @@ void RimMultiPlot::onPlotAdditionOrRemoval()
updateSubPlotNames(); updateSubPlotNames();
updatePlotWindowTitle(); updatePlotWindowTitle();
applyPlotWindowTitleToWidgets(); applyPlotWindowTitleToWidgets();
updateConnectedEditors(); updateAllRequiredEditors();
updateLayout(); updateLayout();
RiuPlotMainWindowTools::refreshToolbars(); RiuPlotMainWindowTools::refreshToolbars();
} }
@@ -499,6 +489,17 @@ void RimMultiPlot::onPlotsReordered( const caf::SignalEmitter* emitter )
loadDataAndUpdate(); loadDataAndUpdate();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultiPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects )
{
updateSubPlotNames();
recreatePlotWidgets();
loadDataAndUpdate();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -18,6 +18,7 @@
#pragma once #pragma once
#include "RimAbstractPlotCollection.h"
#include "RimPlotAxisPropertiesInterface.h" #include "RimPlotAxisPropertiesInterface.h"
#include "RimPlotWindow.h" #include "RimPlotWindow.h"
@@ -37,7 +38,7 @@
class RimPlot; class RimPlot;
class RimMultiPlot : public RimPlotWindow class RimMultiPlot : public RimPlotWindow, public RimTypedPlotCollection<RimPlot>
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
@@ -69,16 +70,15 @@ public:
QString multiPlotTitle() const; QString multiPlotTitle() const;
void setMultiPlotTitle( const QString& title ); void setMultiPlotTitle( const QString& title );
void addPlot( RimPlot* plot ); void insertPlot( RimPlot* plot, size_t index ) override;
void insertPlot( RimPlot* plot, size_t index ); void removePlot( RimPlot* plot ) override;
void removePlot( RimPlot* plot );
void movePlotsToThis( const std::vector<RimPlot*>& plots, int insertAtPosition ); void movePlotsToThis( const std::vector<RimPlot*>& plots, int insertAtPosition );
size_t plotCount() const; size_t plotCount() const override;
size_t plotIndex( const RimPlot* plot ) const; size_t plotIndex( const RimPlot* plot ) const;
RimPlot* plotByIndex( size_t index ) const; RimPlot* plotByIndex( size_t index ) const;
std::vector<RimPlot*> plots() const; std::vector<RimPlot*> plots() const override;
std::vector<RimPlot*> visiblePlots() const; std::vector<RimPlot*> visiblePlots() const;
void updatePlotOrderFromGridWidget(); void updatePlotOrderFromGridWidget();
@@ -136,6 +136,8 @@ private:
void doRenderWindowContent( QPaintDevice* paintDevice ) override; void doRenderWindowContent( QPaintDevice* paintDevice ) override;
void onPlotAdditionOrRemoval(); void onPlotAdditionOrRemoval();
void onPlotsReordered( const caf::SignalEmitter* emitter ); void onPlotsReordered( const caf::SignalEmitter* emitter );
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
protected: protected:
caf::PdmField<bool> m_showPlotWindowTitle; caf::PdmField<bool> m_showPlotWindowTitle;

View File

@@ -140,9 +140,10 @@ void RimPlot::removeFromMdiAreaAndCollection()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimPlot::updateAfterInsertingIntoMultiPlot() void RimPlot::updateAfterInsertingIntoMultiPlot()
{ {
updateLegend(); loadDataAndUpdate();
updateAxes(); /* updateLegend();
updateLayout(); updateAxes();
updateLayout(); */
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -281,3 +282,13 @@ void RimPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
{ {
loadDataAndUpdate(); loadDataAndUpdate();
} }
//--------------------------------------------------------------------------------------------------
/// Is this inside another plot window?
//--------------------------------------------------------------------------------------------------
bool RimPlot::isSubPlot() const
{
RimPlotWindow* parentPlotWindow = nullptr;
firstAncestorOfType( parentPlotWindow );
return parentPlotWindow != nullptr;
}

View File

@@ -91,6 +91,8 @@ public:
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override; std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
bool isSubPlot() const;
protected: protected:
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;

View File

@@ -223,8 +223,8 @@ void RimPltPlotCollection::addPlot( RimWellPltPlot* newPlot )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimPltPlotCollection::removePlot( RimWellPltPlot* plot ) void RimPltPlotCollection::removePlot( RimWellPltPlot* plot )
{ {
size_t index = m_pltPlots.index( plot ); m_pltPlots.removeChildObject( plot );
if ( index < m_pltPlots.size() ) m_pltPlots.erase( index ); updateAllRequiredEditors();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -223,8 +223,8 @@ void RimRftPlotCollection::addPlot( RimWellRftPlot* newPlot )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimRftPlotCollection::removePlot( RimWellRftPlot* plot ) void RimRftPlotCollection::removePlot( RimWellRftPlot* plot )
{ {
size_t index = m_rftPlots.index( plot ); m_rftPlots.removeChildObject( plot );
if ( index < m_rftPlots.size() ) m_rftPlots.erase( index ); updateAllRequiredEditors();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -93,6 +93,7 @@ void RimViewWindow::loadDataAndUpdate()
{ {
assignIdIfNecessary(); assignIdIfNecessary();
onLoadDataAndUpdate(); onLoadDataAndUpdate();
updateUiIconFromToggleField();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -108,6 +108,7 @@ void RimSummaryCrossPlotCollection::insertPlot( RimSummaryPlot* plot, size_t ind
void RimSummaryCrossPlotCollection::removePlot( RimSummaryPlot* plot ) void RimSummaryCrossPlotCollection::removePlot( RimSummaryPlot* plot )
{ {
m_summaryCrossPlots.removeChildObject( plot ); m_summaryCrossPlots.removeChildObject( plot );
updateAllRequiredEditors();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -588,7 +588,7 @@ void RimSummaryPlot::updatePlotTitle()
{ {
QString plotTitle = description(); QString plotTitle = description();
m_plotWidget->setPlotTitle( plotTitle ); m_plotWidget->setPlotTitle( plotTitle );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle ); m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && !isSubPlot() );
m_plotWidget->scheduleReplot(); m_plotWidget->scheduleReplot();
} }
} }
@@ -656,7 +656,7 @@ void RimSummaryPlot::updateLegend()
{ {
if ( m_plotWidget ) if ( m_plotWidget )
{ {
m_plotWidget->setLegendVisible( m_showPlotLegends ); m_plotWidget->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
} }
reattachAllCurves(); reattachAllCurves();
@@ -1559,7 +1559,7 @@ void RimSummaryPlot::onLoadDataAndUpdate()
if ( m_plotWidget ) if ( m_plotWidget )
{ {
m_plotWidget->setLegendVisible( m_showPlotLegends ); m_plotWidget->setInternalLegendVisible( m_showPlotLegends && !isSubPlot() );
m_plotWidget->setLegendFontSize( legendFontSize() ); m_plotWidget->setLegendFontSize( legendFontSize() );
m_plotWidget->updateLegend(); m_plotWidget->updateLegend();
} }

View File

@@ -145,4 +145,5 @@ void RimSummaryPlotCollection::insertPlot( RimSummaryPlot* summaryPlot, size_t i
void RimSummaryPlotCollection::removePlot( RimSummaryPlot* summaryPlot ) void RimSummaryPlotCollection::removePlot( RimSummaryPlot* summaryPlot )
{ {
m_summaryPlots.removeChildObject( summaryPlot ); m_summaryPlots.removeChildObject( summaryPlot );
updateAllRequiredEditors();
} }

View File

@@ -199,6 +199,10 @@ Qt::DropActions RiuDragDrop::supportedDropActions() const
{ {
return Qt::CopyAction; return Qt::CopyAction;
} }
else if ( RiuTypedPdmObjects<RimPlot>::containsTypedObjects( m_dragItems ) )
{
// return Qt::CopyAction;
}
return Qt::MoveAction; return Qt::MoveAction;
} }

View File

@@ -191,11 +191,9 @@ void RiuMultiPlotBook::removePlot( RiuQwtPlotWidget* plotWidget )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::removeAllPlots() void RiuMultiPlotBook::removeAllPlots()
{ {
auto plotWidgets = m_plotWidgets; deleteAllPages();
for ( RiuQwtPlotWidget* plotWidget : plotWidgets ) m_plotWidgets.clear();
{ scheduleUpdate();
removePlot( plotWidget );
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -483,6 +481,7 @@ QList<QPointer<RiuQwtPlotWidget>> RiuMultiPlotBook::visiblePlotWidgets() const
QList<QPointer<RiuQwtPlotWidget>> plotWidgets; QList<QPointer<RiuQwtPlotWidget>> plotWidgets;
for ( QPointer<RiuQwtPlotWidget> plotWidget : m_plotWidgets ) for ( QPointer<RiuQwtPlotWidget> plotWidget : m_plotWidgets )
{ {
CAF_ASSERT( plotWidget );
if ( plotWidget->isChecked() ) if ( plotWidget->isChecked() )
{ {
plotWidgets.push_back( plotWidget ); plotWidgets.push_back( plotWidget );
@@ -534,6 +533,7 @@ void RiuMultiPlotBook::createPages()
row = 0; row = 0;
column = 0; column = 0;
} }
CAF_ASSERT( plotWidgets[visibleIndex] );
page->addPlot( plotWidgets[visibleIndex] ); page->addPlot( plotWidgets[visibleIndex] );
page->performUpdate(); page->performUpdate();
} }

View File

@@ -155,7 +155,7 @@ void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
m_subTitles.insert( static_cast<int>( index ), subTitle ); m_subTitles.insert( static_cast<int>( index ), subTitle );
RiuQwtPlotLegend* legend = nullptr; RiuQwtPlotLegend* legend = nullptr;
if ( m_plotDefinition->legendsVisible() ) if ( m_plotDefinition->legendsVisible() && plotWidget->plotDefinition()->legendsVisible() )
{ {
legend = new RiuQwtPlotLegend( this ); legend = new RiuQwtPlotLegend( this );
int legendColumns = 1; int legendColumns = 1;

View File

@@ -290,7 +290,7 @@ void RiuQwtPlotWidget::setLegendFontSize( int fontSize )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setLegendVisible( bool visible ) void RiuQwtPlotWidget::setInternalLegendVisible( bool visible )
{ {
if ( visible ) if ( visible )
{ {

View File

@@ -91,7 +91,7 @@ public:
void setPlotTitleFontSize( int titleFontSize ); void setPlotTitleFontSize( int titleFontSize );
void setLegendFontSize( int fontSize ); void setLegendFontSize( int fontSize );
void setLegendVisible( bool visible ); void setInternalLegendVisible( bool visible );
QwtInterval axisRange( QwtPlot::Axis axis ) const; QwtInterval axisRange( QwtPlot::Axis axis ) const;
void setAxisRange( QwtPlot::Axis axis, double min, double max ); void setAxisRange( QwtPlot::Axis axis, double min, double max );

View File

@@ -131,7 +131,7 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*=
RiuQwtPlotTools::setCommonPlotBehaviour( this ); RiuQwtPlotTools::setCommonPlotBehaviour( this );
RiuQwtPlotTools::setDefaultAxes( this ); RiuQwtPlotTools::setDefaultAxes( this );
setLegendVisible( true ); setInternalLegendVisible( true );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------