mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1886 Curve creator. Implemented editor apply button behavior
This commit is contained in:
parent
d94eddc1ef
commit
65692eddab
@ -790,7 +790,7 @@ void RicSummaryCurveCreator::syncCurvesFromUiSelection()
|
|||||||
for (const auto& curve : currentCurvesInPlot)
|
for (const auto& curve : currentCurvesInPlot)
|
||||||
{
|
{
|
||||||
std::pair<RimSummaryCase*, RifEclipseSummaryAddress> curveDef = std::make_pair(curve->summaryCase(), curve->summaryAddress());
|
std::pair<RimSummaryCase*, RifEclipseSummaryAddress> curveDef = std::make_pair(curve->summaryCase(), curve->summaryAddress());
|
||||||
if (deleteCurveDefs.count(curveDef))
|
if (deleteCurveDefs.count(curveDef) > 0)
|
||||||
deleteCurves.insert(curve);
|
deleteCurves.insert(curve);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -999,23 +999,72 @@ void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy curve object to the preview plot
|
// Copy curve object to the preview plot
|
||||||
copyCurveAndAddToPlot(curve, m_previewPlot);
|
copyCurveAndAddToPlot(curve, m_previewPlot, true);
|
||||||
}
|
}
|
||||||
m_previewPlot->updateConnectedEditors();
|
m_previewPlot->updateConnectedEditors();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Copy curves from preview plot to target plot
|
/// Copy curves from preview plot to target plot
|
||||||
// Todo: Do not copy curves already in target plot (?)
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicSummaryCurveCreator::updateTargetPlot()
|
void RicSummaryCurveCreator::updateTargetPlot()
|
||||||
{
|
{
|
||||||
if (m_targetPlot == nullptr)
|
if (m_targetPlot == nullptr)
|
||||||
m_targetPlot = new RimSummaryPlot();
|
m_targetPlot = new RimSummaryPlot();
|
||||||
|
|
||||||
|
std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress>> targetCurveDefs;
|
||||||
|
std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress>> editedCurveDefs;
|
||||||
|
for (const auto& curve : m_targetPlot->summaryCurves())
|
||||||
|
{
|
||||||
|
targetCurveDefs.insert(std::make_pair(curve->summaryCase(), curve->summaryAddress()));
|
||||||
|
}
|
||||||
for (const auto& curve : m_previewPlot->summaryCurves())
|
for (const auto& curve : m_previewPlot->summaryCurves())
|
||||||
{
|
{
|
||||||
copyCurveAndAddToPlot(curve, m_targetPlot);
|
if (curve->isCurveVisible())
|
||||||
|
{
|
||||||
|
editedCurveDefs.insert(std::make_pair(curve->summaryCase(), curve->summaryAddress()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// First delete target plot curves that have been deleted or unchecked in the preview plot
|
||||||
|
std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress>> deleteCurveDefs;
|
||||||
|
std::set_difference(targetCurveDefs.begin(), targetCurveDefs.end(),
|
||||||
|
editedCurveDefs.begin(), editedCurveDefs.end(),
|
||||||
|
std::inserter(deleteCurveDefs, deleteCurveDefs.end()));
|
||||||
|
|
||||||
|
if (deleteCurveDefs.size() > 0)
|
||||||
|
{
|
||||||
|
for (const auto& curve : m_targetPlot->summaryCurves())
|
||||||
|
{
|
||||||
|
std::pair<RimSummaryCase*, RifEclipseSummaryAddress> curveDef = std::make_pair(curve->summaryCase(), curve->summaryAddress());
|
||||||
|
if (deleteCurveDefs.count(curveDef) > 0)
|
||||||
|
m_targetPlot->deleteCurve(curve);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add edited curves to target plot, skipping curves that already exists in the plot
|
||||||
|
for (const auto& editedCurve : m_previewPlot->summaryCurves())
|
||||||
|
{
|
||||||
|
if (!editedCurve->isCurveVisible())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Avoid duplicate curves in target plot
|
||||||
|
bool curveExistsInTargetPlot = false;
|
||||||
|
for (const auto& existingCurve : m_targetPlot->summaryCurves())
|
||||||
|
{
|
||||||
|
if (existingCurve->summaryCase() == editedCurve->summaryCase() &&
|
||||||
|
existingCurve->summaryAddress() == editedCurve->summaryAddress())
|
||||||
|
{
|
||||||
|
curveExistsInTargetPlot = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!curveExistsInTargetPlot)
|
||||||
|
{
|
||||||
|
copyCurveAndAddToPlot(editedCurve, m_targetPlot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_targetPlot->updateConnectedEditors();
|
m_targetPlot->updateConnectedEditors();
|
||||||
}
|
}
|
||||||
@ -1023,11 +1072,13 @@ void RicSummaryCurveCreator::updateTargetPlot()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot)
|
void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot, bool forceVisible)
|
||||||
{
|
{
|
||||||
RimSummaryCurve* curveCopy = dynamic_cast<RimSummaryCurve*>(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
RimSummaryCurve* curveCopy = dynamic_cast<RimSummaryCurve*>(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||||
CVF_ASSERT(curveCopy);
|
CVF_ASSERT(curveCopy);
|
||||||
|
|
||||||
|
if (forceVisible)
|
||||||
|
curveCopy->setCurveVisiblity(true);
|
||||||
plot->addCurve(curveCopy);
|
plot->addCurve(curveCopy);
|
||||||
|
|
||||||
// Resolve references after object has been inserted into the project data model
|
// Resolve references after object has been inserted into the project data model
|
||||||
|
@ -111,7 +111,7 @@ private:
|
|||||||
|
|
||||||
void populateCurveCreator(const RimSummaryPlot& sourceSummaryPlot);
|
void populateCurveCreator(const RimSummaryPlot& sourceSummaryPlot);
|
||||||
void updateTargetPlot();
|
void updateTargetPlot();
|
||||||
void copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot);
|
void copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot, bool forceVisible = false);
|
||||||
|
|
||||||
void resetAllFields();
|
void resetAllFields();
|
||||||
|
|
||||||
|
@ -191,6 +191,9 @@ std::string RifEclipseSummaryAddress::uiText(RifEclipseSummaryAddress::SummaryId
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
std::string RifEclipseSummaryAddress::formatUiTextIJK() const
|
std::string RifEclipseSummaryAddress::formatUiTextIJK() const
|
||||||
{
|
{
|
||||||
return std::to_string(this->cellI()) + ", "
|
return std::to_string(this->cellI()) + ", "
|
||||||
@ -198,7 +201,9 @@ std::string RifEclipseSummaryAddress::formatUiTextIJK() const
|
|||||||
+ std::to_string(this->cellK());
|
+ std::to_string(this->cellK());
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: Make class member
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
std::tuple<int, int, int> RifEclipseSummaryAddress::ijkTupleFromUiText(const std::string &s)
|
std::tuple<int, int, int> RifEclipseSummaryAddress::ijkTupleFromUiText(const std::string &s)
|
||||||
{
|
{
|
||||||
auto firstSep = s.find(',');
|
auto firstSep = s.find(',');
|
||||||
|
@ -272,6 +272,14 @@ bool RimPlotCurve::isCurveVisible() const
|
|||||||
return m_showCurve;
|
return m_showCurve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimPlotCurve::setCurveVisiblity(bool visible)
|
||||||
|
{
|
||||||
|
m_showCurve = visible;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -82,7 +82,8 @@ public:
|
|||||||
void setLineThickness(int thickness);
|
void setLineThickness(int thickness);
|
||||||
|
|
||||||
bool isCurveVisible() const;
|
bool isCurveVisible() const;
|
||||||
|
void setCurveVisiblity(bool visible);
|
||||||
|
|
||||||
void updateCurveName();
|
void updateCurveName();
|
||||||
QString curveName() const { return m_curveName; }
|
QString curveName() const { return m_curveName; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user