#777 Create default curve filter when creating a summary plot

This commit is contained in:
Magne Sjaastad 2016-06-30 10:06:15 +02:00
parent e730e5bf9f
commit bfc58f3201
6 changed files with 140 additions and 63 deletions

View File

@ -18,17 +18,19 @@
#include "RicNewSummaryPlotFeature.h"
#include "RimProject.h"
#include "RimSummaryPlot.h"
#include "RiaApplication.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryCurveFilter.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RiuMainPlotWindow.h"
#include <QAction>
#include "cvfAssert.h"
#include "RimSummaryPlotCollection.h"
#include "RimMainPlotCollection.h"
#include "RiuMainWindow.h"
CAF_CMD_SOURCE_INIT(RicNewSummaryPlotFeature, "RicNewSummaryPlotFeature");
@ -60,10 +62,14 @@ void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked)
plot->setDescription(QString("Summary Plot %1").arg(summaryPlotColl->m_summaryPlots.size()));
RimSummaryCurveFilter* newCurveFilter = new RimSummaryCurveFilter();
newCurveFilter->createCurves("*F*P*");
plot->addCurveFilter(newCurveFilter);
summaryPlotColl->updateConnectedEditors();
plot->loadDataAndUpdate();
RiuMainWindow::instance()->selectAsCurrentItem(plot);
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurveFilter);
}
//--------------------------------------------------------------------------------------------------

View File

@ -185,7 +185,7 @@ void RimPlotCurve::updateCurvePresentation()
void RimPlotCurve::setParentQwtPlot(QwtPlot* plot)
{
m_parentQwtPlot = plot;
if (m_showCurve)
if (m_showCurve && m_parentQwtPlot)
{
m_qwtPlotCurve->attach(m_parentQwtPlot);
m_parentQwtPlot->replot();

View File

@ -19,24 +19,28 @@
#include "RimSummaryCurveFilter.h"
#include "RiaApplication.h"
#include "RifReaderEclipseSummary.h"
#include "RigSummaryCaseData.h"
#include "RimDefines.h"
#include "RimEclipseResultCase.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RiuLineSegmentQwtPlotCurve.h"
#include "RiuSummaryQwtPlot.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiListEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include "RiuLineSegmentQwtPlotCurve.h"
#include "qwt_date.h"
#include "RimSummaryCase.h"
#include "RigSummaryCaseData.h"
#include "RimSummaryCurve.h"
#include "cafPdmUiPushButtonEditor.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "cafPdmUiTreeOrdering.h"
QTextStream& operator << (QTextStream& str, const std::vector<RifEclipseSummaryAddress>& sobj)
@ -97,7 +101,6 @@ RimSummaryCurveFilter::RimSummaryCurveFilter()
m_applyButtonField = false;
m_applyButtonField.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
m_applyButtonField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
}
//--------------------------------------------------------------------------------------------------
@ -109,6 +112,30 @@ RimSummaryCurveFilter::~RimSummaryCurveFilter()
m_curves.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveFilter::createCurves(const QString& stringFilter)
{
RimProject* proj = RiaApplication::instance()->project();
std::vector<RimSummaryCase*> cases;
proj->allSummaryCases(cases);
if (cases.size() > 0)
{
std::vector<RimSummaryCase*> selectedCases;
selectedCases.push_back(cases[0]);
m_summaryFilter->setCompleteVarStringFilter(stringFilter);
std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress> > newCurveDefinitions;
createSetOfCasesAndResultAdresses(selectedCases, *m_summaryFilter, &newCurveDefinitions);
createCurvesFromCurveDefinitions(newCurveDefinitions);
}
}
//--------------------------------------------------------------------------------------------------
///
@ -165,10 +192,8 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurveFilter::calculateValueOptions(const
if(useOptionsOnly) *useOptionsOnly = true;
return optionList;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -185,10 +210,8 @@ void RimSummaryCurveFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd
curveVarSelectionGroup->add(&m_uiFilterResultMultiSelection);
uiOrdering.add(&m_applyButtonField);
uiOrdering.setForgetRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -210,7 +233,6 @@ void RimSummaryCurveFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedF
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -234,7 +256,6 @@ void RimSummaryCurveFilter::detachQwtCurves()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -329,45 +350,7 @@ void RimSummaryCurveFilter::syncCurvesFromUiSelection()
m_curves.deleteAllChildObjects();
#endif
// Create all new curves that is missing
int colorIndex = 2;
int lineStyleIdx = -1;
RimSummaryCase* prevCase = nullptr;
RimPlotCurve::LineStyleEnum lineStyle = RimPlotCurve::STYLE_SOLID;
for (auto& caseAddrPair: newCurveDefinitions)
{
RimSummaryCase* currentCase = caseAddrPair.first;
RimSummaryCurve* curve = new RimSummaryCurve();
curve->setParentQwtPlot(m_parentQwtPlot);
curve->setSummaryCase(currentCase);
curve->setSummaryAddress(caseAddrPair.second);
if(currentCase != prevCase)
{
prevCase = currentCase;
colorIndex = 2;
lineStyleIdx ++;
lineStyle = caf::AppEnum<RimPlotCurve::LineStyleEnum>::fromIndex(lineStyleIdx%caf::AppEnum<RimPlotCurve::LineStyleEnum>::size());
if(lineStyle == RimPlotCurve::STYLE_NONE)
{
lineStyle = RimPlotCurve::STYLE_SOLID;
lineStyleIdx++;
}
}
cvf::Color3f curveColor = curveColorFromTable(colorIndex);
colorIndex++;
curve->setColor(curveColor);
curve->setLineStyle(lineStyle);
m_curves.push_back(curve);
}
createCurvesFromCurveDefinitions(newCurveDefinitions);
}
//--------------------------------------------------------------------------------------------------
@ -438,3 +421,71 @@ std::set<std::string> RimSummaryCurveFilter::unitNames()
}
return unitNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveFilter::createSetOfCasesAndResultAdresses(
const std::vector<RimSummaryCase*>& cases,
const RimSummaryFilter& filter,
std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress> >* curveDefinitions) const
{
for (RimSummaryCase* currentCase : cases)
{
if (!currentCase || !currentCase->caseData() || !currentCase->caseData()->summaryReader()) continue;
RifReaderEclipseSummary* reader = currentCase->caseData()->summaryReader();
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
int addressCount = static_cast<int>(allAddresses.size());
for (int i = 0; i < addressCount; i++)
{
if (!filter.isIncludedByFilter(allAddresses[i])) continue;
curveDefinitions->insert(std::make_pair(currentCase, allAddresses[i]));
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveFilter::createCurvesFromCurveDefinitions(const std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress> >& curveDefinitions)
{
int colorIndex = 2;
int lineStyleIdx = -1;
RimSummaryCase* prevCase = nullptr;
RimPlotCurve::LineStyleEnum lineStyle = RimPlotCurve::STYLE_SOLID;
for (auto& caseAddrPair : curveDefinitions)
{
RimSummaryCase* currentCase = caseAddrPair.first;
RimSummaryCurve* curve = new RimSummaryCurve();
curve->setParentQwtPlot(m_parentQwtPlot);
curve->setSummaryCase(currentCase);
curve->setSummaryAddress(caseAddrPair.second);
if (currentCase != prevCase)
{
prevCase = currentCase;
colorIndex = 2;
lineStyleIdx++;
lineStyle = caf::AppEnum<RimPlotCurve::LineStyleEnum>::fromIndex(lineStyleIdx%caf::AppEnum<RimPlotCurve::LineStyleEnum>::size());
if (lineStyle == RimPlotCurve::STYLE_NONE)
{
lineStyle = RimPlotCurve::STYLE_SOLID;
lineStyleIdx++;
}
}
cvf::Color3f curveColor = curveColorFromTable(colorIndex);
colorIndex++;
curve->setColor(curveColor);
curve->setLineStyle(lineStyle);
m_curves.push_back(curve);
}
}

View File

@ -51,6 +51,8 @@ public:
RimSummaryCurveFilter();
virtual ~RimSummaryCurveFilter();
void createCurves(const QString& stringFilter);
void loadDataAndUpdate();
void setParentQwtPlot(QwtPlot* plot);
void detachQwtCurves();
@ -60,8 +62,16 @@ public:
private:
void syncCurvesFromUiSelection();
void createCurvesFromCurveDefinitions(const std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress> >& curveDefinitions);
void syncUiSelectionFromCurves();
void createSetOfCasesAndResultAdresses(
const std::vector<RimSummaryCase*>& cases,
const RimSummaryFilter& filter,
std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress> >* curveDefinitions) const;
// Overridden PDM methods
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly);

View File

@ -132,7 +132,7 @@ bool isIJKMatch(QString filterString, int cellI, int cellJ, int cellK)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryFilter::isIncludedByFilter(const RifEclipseSummaryAddress& addr)
bool RimSummaryFilter::isIncludedByFilter(const RifEclipseSummaryAddress& addr) const
{
if(!isSumVarTypeMatchingFilterType(m_filterType(), addr.category())) return false;
@ -361,3 +361,12 @@ void RimSummaryFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryFilter::setCompleteVarStringFilter(const QString& stringFilter)
{
m_filterType = SUM_FILTER_VAR_STRING;
m_completeVarStringFilter = stringFilter;
}

View File

@ -49,8 +49,9 @@ public:
RimSummaryFilter();
virtual ~RimSummaryFilter();
bool isIncludedByFilter(const RifEclipseSummaryAddress& addr);
bool isIncludedByFilter(const RifEclipseSummaryAddress& addr) const;
void setCompleteVarStringFilter(const QString& stringFilter);
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;