mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-23 23:13:39 -06:00
#1886 Curve creator. Copy curves back to target plot
This commit is contained in:
parent
5eeefc2511
commit
66d08aeb8d
@ -905,6 +905,7 @@ void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* fi
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSummaryPlot)
|
||||
{
|
||||
m_previewPlot->deleteAllSummaryCurves();
|
||||
for (const auto& curve : sourceSummaryPlot.summaryCurves())
|
||||
{
|
||||
// Select case if not already selected
|
||||
@ -927,35 +928,42 @@ void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSu
|
||||
}
|
||||
|
||||
// Copy curve object to the preview plot
|
||||
RimSummaryCurve* curveCopy = dynamic_cast<RimSummaryCurve*>(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(curveCopy);
|
||||
|
||||
m_previewPlot->addCurve(curveCopy);
|
||||
|
||||
// Resolve references after object has been inserted into the project data model
|
||||
curveCopy->resolveReferencesRecursively();
|
||||
|
||||
// The curve creator is not a descendant of the project, and need to be set manually
|
||||
curveCopy->setSummaryCase(curve->summaryCase());
|
||||
curveCopy->initAfterReadRecursively();
|
||||
curveCopy->loadDataAndUpdate();
|
||||
copyCurveAndAddToPlot(curve, m_previewPlot);
|
||||
}
|
||||
m_previewPlot->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Copy curves from
|
||||
/// Copy curves from preview plot to target plot
|
||||
// Todo: Do not copy curves already in target plot (?)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCreator::updateTargetPlot()
|
||||
{
|
||||
// Q: What about hidden curves?
|
||||
|
||||
if (m_targetPlot == nullptr)
|
||||
m_targetPlot = new RimSummaryPlot();
|
||||
|
||||
for (const auto& curve : m_previewPlot->summaryCurves())
|
||||
{
|
||||
m_targetPlot->addCurve(curve);
|
||||
copyCurveAndAddToPlot(curve, m_targetPlot);
|
||||
}
|
||||
m_targetPlot->loadDataAndUpdate();
|
||||
m_targetPlot->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot)
|
||||
{
|
||||
RimSummaryCurve* curveCopy = dynamic_cast<RimSummaryCurve*>(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(curveCopy);
|
||||
|
||||
plot->addCurve(curveCopy);
|
||||
|
||||
// Resolve references after object has been inserted into the project data model
|
||||
curveCopy->resolveReferencesRecursively();
|
||||
|
||||
// The curve creator is not a descendant of the project, and need to be set manually
|
||||
curveCopy->setSummaryCase(curve->summaryCase());
|
||||
curveCopy->initAfterReadRecursively();
|
||||
curveCopy->loadDataAndUpdate();
|
||||
}
|
||||
|
@ -108,6 +108,7 @@ private:
|
||||
|
||||
void populateCurveCreator(const RimSummaryPlot& sourceSummaryPlot);
|
||||
void updateTargetPlot();
|
||||
void copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot);
|
||||
|
||||
private:
|
||||
caf::PdmPtrArrayField<RimSummaryCase*> m_selectedCases;
|
||||
|
@ -201,7 +201,7 @@ void RimSummaryCurve::setSummaryCase(RimSummaryCase* sumCase)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCase* RimSummaryCurve::summaryCase()
|
||||
RimSummaryCase* RimSummaryCurve::summaryCase() const
|
||||
{
|
||||
return m_summaryCase();
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
virtual ~RimSummaryCurve();
|
||||
|
||||
void setSummaryCase(RimSummaryCase* sumCase);
|
||||
RimSummaryCase* summaryCase();
|
||||
RimSummaryCase* summaryCase() const;
|
||||
|
||||
RifEclipseSummaryAddress summaryAddress();
|
||||
void setSummaryAddress(const RifEclipseSummaryAddress& address);
|
||||
|
@ -176,6 +176,14 @@ void RimSummaryCurveCollection::deleteCurvesAssosiatedWithCase(RimSummaryCase* s
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveCollection::deleteAllCurves()
|
||||
{
|
||||
m_curves.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
|
||||
std::vector<RimSummaryCurve*> curves();
|
||||
void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase);
|
||||
|
||||
void deleteAllCurves();
|
||||
void updateCaseNameHasChanged();
|
||||
|
||||
private:
|
||||
|
@ -453,21 +453,15 @@ QString RimSummaryPlot::asciiDataForPlotExport() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCurve*> RimSummaryPlot::summaryCurves() const
|
||||
{
|
||||
std::vector<RimSummaryCurve*> curves;
|
||||
curves.reserve(m_summaryCurves.size());
|
||||
for (const auto& curve : m_summaryCurveCollection->curves())
|
||||
{
|
||||
curves.push_back(curve);
|
||||
}
|
||||
return curves;
|
||||
return m_summaryCurveCollection->curves();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::deleteAllCurves()
|
||||
void RimSummaryPlot::deleteAllSummaryCurves()
|
||||
{
|
||||
m_summaryCurveCollection->curves().clear();
|
||||
m_summaryCurveCollection->deleteAllCurves();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
QString asciiDataForPlotExport() const;
|
||||
|
||||
std::vector<RimSummaryCurve*> summaryCurves() const;
|
||||
void deleteAllCurves();
|
||||
void deleteAllSummaryCurves();
|
||||
|
||||
// RimViewWindow overrides
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user