mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Fix crashes when dropping analysis plots into Multiplots
This commit is contained in:
committed by
Magne Sjaastad
parent
ab3e43d8fb
commit
93baf776a1
@@ -48,7 +48,7 @@ RimSummaryCrossPlotCollection::~RimSummaryCrossPlotCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCrossPlotCollection::deleteAllChildObjects()
|
||||
void RimSummaryCrossPlotCollection::deleteAllPlots()
|
||||
{
|
||||
m_summaryCrossPlots.deleteAllChildObjects();
|
||||
}
|
||||
@@ -56,11 +56,19 @@ void RimSummaryCrossPlotCollection::deleteAllChildObjects()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryPlot*> RimSummaryCrossPlotCollection::summaryPlots() const
|
||||
std::vector<RimSummaryPlot*> RimSummaryCrossPlotCollection::plots() const
|
||||
{
|
||||
return m_summaryCrossPlots.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RimSummaryCrossPlotCollection::plotCount() const
|
||||
{
|
||||
return m_summaryCrossPlots.size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -86,6 +94,22 @@ void RimSummaryCrossPlotCollection::summaryPlotItemInfos( QList<caf::PdmOptionIt
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCrossPlotCollection::insertPlot( RimSummaryPlot* plot, size_t index )
|
||||
{
|
||||
m_summaryCrossPlots.insert( index, plot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCrossPlotCollection::removePlot( RimSummaryPlot* plot )
|
||||
{
|
||||
m_summaryCrossPlots.removeChildObject( plot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -98,11 +122,3 @@ RimSummaryPlot* RimSummaryCrossPlotCollection::createSummaryPlot()
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCrossPlotCollection::addSummaryPlot( RimSummaryPlot* plot )
|
||||
{
|
||||
m_summaryCrossPlots().push_back( plot );
|
||||
}
|
||||
|
||||
@@ -18,16 +18,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimAbstractPlotCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
class RimSummaryPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimSummaryCrossPlotCollection : public caf::PdmObject
|
||||
class RimSummaryCrossPlotCollection : public caf::PdmObject, public RimTypedPlotCollection<RimSummaryPlot>
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
@@ -35,11 +36,14 @@ public:
|
||||
RimSummaryCrossPlotCollection();
|
||||
~RimSummaryCrossPlotCollection() override;
|
||||
|
||||
void deleteAllChildObjects();
|
||||
void deleteAllPlots() final;
|
||||
|
||||
std::vector<RimSummaryPlot*> summaryPlots() const;
|
||||
RimSummaryPlot* createSummaryPlot();
|
||||
void addSummaryPlot( RimSummaryPlot* plot );
|
||||
std::vector<RimSummaryPlot*> plots() const final;
|
||||
size_t plotCount() const final;
|
||||
void insertPlot( RimSummaryPlot* plot, size_t index ) final;
|
||||
void removePlot( RimSummaryPlot* plot ) final;
|
||||
|
||||
RimSummaryPlot* createSummaryPlot();
|
||||
|
||||
void updateSummaryNameHasChanged();
|
||||
void summaryPlotItemInfos( QList<caf::PdmOptionItemInfo>* optionInfos ) const;
|
||||
|
||||
@@ -106,7 +106,7 @@ protected:
|
||||
void updateLegendsInPlot() override;
|
||||
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||
void initAfterRead();
|
||||
void initAfterRead() override;
|
||||
|
||||
private:
|
||||
RifSummaryReaderInterface* valuesSummaryReaderX() const;
|
||||
|
||||
@@ -1735,20 +1735,6 @@ void RimSummaryPlot::axisLogarithmicChanged( const caf::SignalEmitter* emitter,
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::doRemoveFromCollection()
|
||||
{
|
||||
RimSummaryPlotCollection* summaryCollection = nullptr;
|
||||
this->firstAncestorOrThisOfType( summaryCollection );
|
||||
if ( summaryCollection )
|
||||
{
|
||||
summaryCollection->removeSummaryPlot( this );
|
||||
summaryCollection->updateAllRequiredEditors();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -190,7 +190,6 @@ private:
|
||||
|
||||
void detachAllPlotItems();
|
||||
|
||||
void doRemoveFromCollection() override;
|
||||
void handleKeyPressEvent( QKeyEvent* keyEvent ) override;
|
||||
|
||||
void onCurvesReordered( const SignalEmitter* emitter );
|
||||
|
||||
@@ -39,9 +39,9 @@ RimSummaryPlotCollection::RimSummaryPlotCollection()
|
||||
{
|
||||
CAF_PDM_InitScriptableObject( "Summary Plots", ":/SummaryPlotsLight16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &summaryPlots, "SummaryPlots", "Summary Plots", "", "", "" );
|
||||
summaryPlots.uiCapability()->setUiHidden( true );
|
||||
caf::PdmFieldReorderCapability::addToField( &summaryPlots );
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryPlots, "SummaryPlots", "Summary Plots", "", "", "" );
|
||||
m_summaryPlots.uiCapability()->setUiHidden( true );
|
||||
caf::PdmFieldReorderCapability::addToField( &m_summaryPlots );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -49,7 +49,6 @@ RimSummaryPlotCollection::RimSummaryPlotCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlotCollection::~RimSummaryPlotCollection()
|
||||
{
|
||||
summaryPlots.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -61,7 +60,8 @@ RimSummaryPlot* RimSummaryPlotCollection::createSummaryPlotWithAutoTitle()
|
||||
plot->setAsPlotMdiWindow();
|
||||
|
||||
plot->enableAutoPlotTitle( true );
|
||||
summaryPlots.push_back( plot );
|
||||
|
||||
addPlot( plot );
|
||||
|
||||
return plot;
|
||||
}
|
||||
@@ -74,7 +74,8 @@ RimSummaryPlot* RimSummaryPlotCollection::createNamedSummaryPlot( const QString&
|
||||
RimSummaryPlot* plot = new RimSummaryPlot();
|
||||
plot->setAsPlotMdiWindow();
|
||||
|
||||
summaryPlots.push_back( plot );
|
||||
addPlot( plot );
|
||||
|
||||
plot->setDescription( name );
|
||||
|
||||
return plot;
|
||||
@@ -85,7 +86,7 @@ RimSummaryPlot* RimSummaryPlotCollection::createNamedSummaryPlot( const QString&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotCollection::updateSummaryNameHasChanged()
|
||||
{
|
||||
for ( RimSummaryPlot* plot : summaryPlots )
|
||||
for ( RimSummaryPlot* plot : plots() )
|
||||
{
|
||||
plot->updateCaseNameHasChanged();
|
||||
}
|
||||
@@ -96,21 +97,13 @@ void RimSummaryPlotCollection::updateSummaryNameHasChanged()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotCollection::summaryPlotItemInfos( QList<caf::PdmOptionItemInfo>* optionInfos ) const
|
||||
{
|
||||
for ( RimSummaryPlot* plot : summaryPlots() )
|
||||
for ( RimSummaryPlot* plot : plots() )
|
||||
{
|
||||
QString displayName = plot->description();
|
||||
optionInfos->push_back( caf::PdmOptionItemInfo( displayName, plot, false, plot->uiCapability()->uiIconProvider() ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotCollection::removeSummaryPlot( RimSummaryPlot* summaryPlot )
|
||||
{
|
||||
summaryPlots.removeChildObject( summaryPlot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -121,3 +114,35 @@ void RimSummaryPlotCollection::onChildDeleted( caf::PdmChildArrayFieldHandle*
|
||||
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
mainPlotWindow->updateSummaryPlotToolBar();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryPlot*> RimSummaryPlotCollection::plots() const
|
||||
{
|
||||
return m_summaryPlots.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RimSummaryPlotCollection::plotCount() const
|
||||
{
|
||||
return m_summaryPlots.size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotCollection::insertPlot( RimSummaryPlot* summaryPlot, size_t index )
|
||||
{
|
||||
m_summaryPlots.insert( index, summaryPlot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotCollection::removePlot( RimSummaryPlot* summaryPlot )
|
||||
{
|
||||
m_summaryPlots.removeChildObject( summaryPlot );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimAbstractPlotCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
@@ -28,7 +31,7 @@ class RimSummaryPlot;
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimSummaryPlotCollection : public caf::PdmObject
|
||||
class RimSummaryPlotCollection : public caf::PdmObject, public RimTypedPlotCollection<RimSummaryPlot>
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
@@ -36,16 +39,19 @@ public:
|
||||
RimSummaryPlotCollection();
|
||||
~RimSummaryPlotCollection() override;
|
||||
|
||||
caf::PdmChildArrayField<RimSummaryPlot*> summaryPlots;
|
||||
|
||||
RimSummaryPlot* createSummaryPlotWithAutoTitle();
|
||||
RimSummaryPlot* createNamedSummaryPlot( const QString& name );
|
||||
|
||||
void updateSummaryNameHasChanged();
|
||||
void summaryPlotItemInfos( QList<caf::PdmOptionItemInfo>* optionInfos ) const;
|
||||
|
||||
void removeSummaryPlot( RimSummaryPlot* summaryPlot );
|
||||
|
||||
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
||||
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
|
||||
|
||||
std::vector<RimSummaryPlot*> plots() const final;
|
||||
size_t plotCount() const final;
|
||||
void insertPlot( RimSummaryPlot* summaryPlot, size_t index ) final;
|
||||
void removePlot( RimSummaryPlot* summaryPlot ) final;
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimSummaryPlot*> m_summaryPlots;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user