2019-02-21 05:52:23 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- Equinor ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RimGridCrossPlotCurveSet.h"
|
|
|
|
|
2019-02-22 02:37:59 -06:00
|
|
|
#include "RiaApplication.h"
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "RiaColorTables.h"
|
2019-02-21 06:56:37 -06:00
|
|
|
#include "RiaLogging.h"
|
|
|
|
|
2019-03-11 05:39:23 -05:00
|
|
|
#include "RifEclipseDataTableFormatter.h"
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "RigActiveCellInfo.h"
|
|
|
|
#include "RigActiveCellsResultAccessor.h"
|
|
|
|
#include "RigCaseCellResultCalculator.h"
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "RigEclipseCaseData.h"
|
2019-02-27 03:57:17 -06:00
|
|
|
#include "RigEclipseCrossPlotDataExtractor.h"
|
|
|
|
|
2019-02-26 09:22:01 -06:00
|
|
|
#include "RigFormationNames.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "RigMainGrid.h"
|
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "RiuGridCrossQwtPlot.h"
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "RimCase.h"
|
|
|
|
#include "RimEclipseCase.h"
|
2019-02-27 07:33:27 -06:00
|
|
|
#include "RimEclipseView.h"
|
2019-03-05 05:37:58 -06:00
|
|
|
#include "RimEclipseCellColors.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "RimEclipseResultDefinition.h"
|
|
|
|
#include "RimGridCrossPlot.h"
|
|
|
|
#include "RimGridCrossPlotCurve.h"
|
2019-02-27 07:33:27 -06:00
|
|
|
#include "RimGridView.h"
|
2019-02-22 02:37:59 -06:00
|
|
|
#include "RimProject.h"
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "RimRegularLegendConfig.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "RimTools.h"
|
|
|
|
|
2019-03-11 05:39:23 -05:00
|
|
|
#include "cafCategoryMapper.h"
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "cafColorTable.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "cafPdmUiComboBoxEditor.h"
|
2019-02-27 02:25:08 -06:00
|
|
|
#include "cafPdmUiSliderEditor.h"
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
2019-03-11 05:39:23 -05:00
|
|
|
#include "cafProgressInfo.h"
|
2019-03-04 08:35:48 -06:00
|
|
|
#include "cvfScalarMapper.h"
|
2019-03-11 05:39:23 -05:00
|
|
|
#include "cvfqtUtils.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-02-27 03:57:17 -06:00
|
|
|
#include <QString>
|
2019-02-26 09:22:01 -06:00
|
|
|
|
2019-02-27 03:57:17 -06:00
|
|
|
CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurveSet, "GridCrossPlotCurveSet");
|
2019-02-26 09:22:01 -06:00
|
|
|
|
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template<>
|
2019-03-05 06:26:59 -06:00
|
|
|
void RimGridCrossPlotCurveSet::CurveGroupingEnum::setUp()
|
2019-02-26 09:22:01 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
addItem(RigGridCrossPlotCurveGrouping::NO_GROUPING, "NONE", "Nothing");
|
|
|
|
addItem(RigGridCrossPlotCurveGrouping::GROUP_BY_TIME, "TIME", "Time Step");
|
|
|
|
addItem(RigGridCrossPlotCurveGrouping::GROUP_BY_FORMATION, "FORMATION", "Formations");
|
|
|
|
addItem(RigGridCrossPlotCurveGrouping::GROUP_BY_RESULT, "RESULT", "Result Property");
|
|
|
|
setDefault(RigGridCrossPlotCurveGrouping::GROUP_BY_TIME);
|
2019-02-26 09:22:01 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Cross Plot Data Set", ":/WellLogCurve16x16.png", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_case, "Case", "Case", "", "", "");
|
|
|
|
m_case.uiCapability()->setUiTreeChildrenHidden(true);
|
|
|
|
CAF_PDM_InitField(&m_timeStep, "TimeStep", -1, "Time Step", "", "", "");
|
|
|
|
m_timeStep.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
|
|
|
|
|
2019-03-08 02:59:29 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_cellFilterView, "VisibleCellView", "Filter by 3d View Visibility", "", "", "");
|
2019-02-27 07:33:27 -06:00
|
|
|
|
2019-03-05 06:26:59 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_grouping, "Grouping", "Group Data by", "", "", "");
|
2019-02-26 09:22:01 -06:00
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_xAxisProperty, "XAxisProperty", "X-Axis Property", "", "", "");
|
|
|
|
m_xAxisProperty = new RimEclipseResultDefinition;
|
|
|
|
m_xAxisProperty.uiCapability()->setUiHidden(true);
|
|
|
|
m_xAxisProperty.uiCapability()->setUiTreeChildrenHidden(true);
|
2019-03-08 02:59:29 -06:00
|
|
|
m_xAxisProperty->setLabelsOnTop(true);
|
2019-02-21 05:52:23 -06:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_yAxisProperty, "YAxisProperty", "Y-Axis Property", "", "", "");
|
|
|
|
m_yAxisProperty = new RimEclipseResultDefinition;
|
|
|
|
m_yAxisProperty.uiCapability()->setUiHidden(true);
|
|
|
|
m_yAxisProperty.uiCapability()->setUiTreeChildrenHidden(true);
|
2019-03-08 02:59:29 -06:00
|
|
|
m_yAxisProperty->setLabelsOnTop(true);
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-03-05 06:26:59 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_groupingProperty, "GroupingProperty", "Data Grouping Property", "", "", "");
|
|
|
|
m_groupingProperty = new RimEclipseCellColors;
|
|
|
|
m_groupingProperty.uiCapability()->setUiHidden(true);
|
2019-03-07 12:04:10 -06:00
|
|
|
m_groupingProperty->legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER);
|
2019-02-27 02:25:08 -06:00
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "Name", "", "", "");
|
|
|
|
m_nameConfig = new RimGridCrossPlotCurveSetNameConfig(this);
|
|
|
|
m_nameConfig.uiCapability()->setUiTreeHidden(true);
|
|
|
|
m_nameConfig.uiCapability()->setUiTreeChildrenHidden(true);
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_crossPlotCurves, "CrossPlotCurves", "Curves", "", "", "");
|
|
|
|
m_crossPlotCurves.uiCapability()->setUiTreeHidden(true);
|
|
|
|
|
2019-02-22 02:37:59 -06:00
|
|
|
setDefaults();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-03-01 08:49:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::setCellFilterView(RimGridView* cellFilterView)
|
|
|
|
{
|
|
|
|
m_cellFilterView = cellFilterView;
|
2019-03-08 02:59:29 -06:00
|
|
|
m_groupingProperty->setReservoirView(dynamic_cast<RimEclipseView*>(m_cellFilterView()));
|
2019-03-01 08:49:02 -06:00
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::loadDataAndUpdate(bool updateParentPlot)
|
|
|
|
{
|
|
|
|
onLoadDataAndUpdate(updateParentPlot);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::setParentQwtPlotNoReplot(QwtPlot* parent)
|
|
|
|
{
|
|
|
|
for (auto& curve : m_crossPlotCurves())
|
|
|
|
{
|
|
|
|
curve->setParentQwtPlotNoReplot(m_isChecked() ? parent : nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimGridCrossPlotCurveSet::xAxisName() const
|
|
|
|
{
|
|
|
|
return m_xAxisProperty->resultVariableUiShortName();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimGridCrossPlotCurveSet::yAxisName() const
|
|
|
|
{
|
|
|
|
return m_yAxisProperty->resultVariableUiShortName();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RimGridCrossPlotCurveSet::indexInPlot() const
|
|
|
|
{
|
|
|
|
RimGridCrossPlot* parent;
|
|
|
|
this->firstAncestorOrThisOfTypeAsserted(parent);
|
|
|
|
return parent->indexOfCurveSet(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimGridCrossPlotCurveSet::createAutoName() const
|
|
|
|
{
|
|
|
|
if (m_case() == nullptr)
|
|
|
|
{
|
|
|
|
return "Undefined";
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList nameTags;
|
|
|
|
if (!m_nameConfig->customName().isEmpty())
|
|
|
|
{
|
|
|
|
nameTags += m_nameConfig->customName();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_nameConfig->addCaseName())
|
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
nameTags += caseNameString();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_nameConfig->addAxisVariables())
|
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
nameTags += axisVariableString();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-03-04 03:19:02 -06:00
|
|
|
if (m_nameConfig->addTimestep() && !timeStepString().isEmpty())
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
nameTags += timeStepString();
|
2019-02-27 05:45:02 -06:00
|
|
|
}
|
|
|
|
|
2019-03-07 07:17:12 -06:00
|
|
|
if (m_nameConfig->addGrouping() && groupParameter() != "None")
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
QString catTitle = groupTitle();
|
2019-03-04 08:35:48 -06:00
|
|
|
if (!catTitle.isEmpty()) nameTags += catTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nameTags.join(", ");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-05 06:26:59 -06:00
|
|
|
QString RimGridCrossPlotCurveSet::groupTitle() const
|
2019-03-07 07:17:12 -06:00
|
|
|
{
|
2019-03-11 05:39:23 -05:00
|
|
|
if (m_grouping != NO_GROUPING)
|
|
|
|
{
|
|
|
|
return QString("Grouped by %1").arg(groupParameter());
|
|
|
|
}
|
|
|
|
return "";
|
2019-03-07 07:17:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimGridCrossPlotCurveSet::groupParameter() const
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
if (m_grouping() == GROUP_BY_TIME)
|
2019-02-27 05:45:02 -06:00
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
return QString("Time Steps");
|
|
|
|
}
|
2019-03-05 06:26:59 -06:00
|
|
|
else if (m_grouping() == GROUP_BY_FORMATION)
|
2019-03-05 05:37:58 -06:00
|
|
|
{
|
|
|
|
return QString("Formations");
|
|
|
|
}
|
2019-03-05 06:26:59 -06:00
|
|
|
else if (m_grouping() == GROUP_BY_RESULT && m_groupingProperty->hasResult())
|
2019-03-05 05:37:58 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
return QString("%1").arg(m_groupingProperty->resultVariableUiShortName());
|
2019-02-27 05:45:02 -06:00
|
|
|
}
|
2019-03-07 07:17:12 -06:00
|
|
|
return "None";
|
2019-02-27 05:45:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-04 03:19:02 -06:00
|
|
|
void RimGridCrossPlotCurveSet::detachAllCurves()
|
2019-02-27 05:45:02 -06:00
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
for (auto curve : m_crossPlotCurves())
|
2019-02-27 05:45:02 -06:00
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
curve->detachQwtCurve();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
2019-03-04 03:19:02 -06:00
|
|
|
}
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-03-04 03:19:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::cellFilterViewUpdated()
|
|
|
|
{
|
|
|
|
if (m_cellFilterView())
|
2019-02-27 05:45:02 -06:00
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
loadDataAndUpdate(true);
|
2019-02-27 05:45:02 -06:00
|
|
|
}
|
2019-03-04 03:19:02 -06:00
|
|
|
}
|
2019-02-27 05:45:02 -06:00
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-05 05:37:58 -06:00
|
|
|
RimRegularLegendConfig* RimGridCrossPlotCurveSet::legendConfig() const
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
return m_groupingProperty->legendConfig();
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
|
2019-03-04 03:19:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimGridCrossPlotCurve*> RimGridCrossPlotCurveSet::curves() const
|
|
|
|
{
|
|
|
|
return m_crossPlotCurves.childObjects();
|
|
|
|
}
|
2019-02-27 05:45:02 -06:00
|
|
|
|
2019-03-04 03:19:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimGridCrossPlotCurveSet::caseNameString() const
|
|
|
|
{
|
|
|
|
if (m_case())
|
2019-02-27 05:45:02 -06:00
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
return m_case->caseUserDescription();
|
2019-02-27 05:45:02 -06:00
|
|
|
}
|
2019-03-04 03:19:02 -06:00
|
|
|
return "";
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
2019-02-21 08:42:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-04 03:19:02 -06:00
|
|
|
QString RimGridCrossPlotCurveSet::axisVariableString() const
|
2019-02-21 08:42:02 -06:00
|
|
|
{
|
2019-03-07 07:17:12 -06:00
|
|
|
return QString("%1 x %2").arg(xAxisName(), yAxisName());
|
2019-02-21 08:42:02 -06:00
|
|
|
}
|
|
|
|
|
2019-02-27 07:33:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-04 03:19:02 -06:00
|
|
|
QString RimGridCrossPlotCurveSet::timeStepString() const
|
2019-02-27 07:33:27 -06:00
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
// If using time categorization, the time step will be included as a category, so skip it here.
|
2019-03-05 06:26:59 -06:00
|
|
|
if (m_grouping() != RigGridCrossPlotCurveGrouping::GROUP_BY_TIME)
|
2019-02-27 07:33:27 -06:00
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
if (m_case() && (m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult()))
|
|
|
|
{
|
|
|
|
if (m_timeStep == -1)
|
|
|
|
{
|
|
|
|
return "All Time Steps";
|
|
|
|
}
|
|
|
|
return m_case->timeStepStrings()[m_timeStep];
|
|
|
|
}
|
2019-02-27 07:33:27 -06:00
|
|
|
}
|
2019-03-04 03:19:02 -06:00
|
|
|
return "";
|
2019-02-27 07:33:27 -06:00
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-25 07:54:36 -06:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-05 06:26:59 -06:00
|
|
|
std::vector<QString> RimGridCrossPlotCurveSet::groupStrings() const
|
2019-02-25 07:54:36 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
std::vector<QString> groupStrings;
|
2019-03-04 08:35:48 -06:00
|
|
|
for (auto curve : m_crossPlotCurves())
|
2019-03-04 03:19:02 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
groupStrings.push_back(legendConfig()->categoryNameFromCategoryValue(curve->groupIndex()));
|
2019-03-04 03:19:02 -06:00
|
|
|
}
|
2019-03-05 06:26:59 -06:00
|
|
|
return groupStrings;
|
2019-02-25 07:54:36 -06:00
|
|
|
}
|
|
|
|
|
2019-03-07 07:17:12 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::map<RimGridCrossPlotCurveSet::NameComponents, QString>
|
|
|
|
RimGridCrossPlotCurveSet::nameComponents() const
|
|
|
|
{
|
|
|
|
std::map<RimGridCrossPlotCurveSet::NameComponents, QString> componentNames;
|
|
|
|
if (m_nameConfig->addCaseName())
|
2019-03-12 04:27:20 -05:00
|
|
|
componentNames[GCP_CASE_NAME] = caseNameString();
|
2019-03-07 07:17:12 -06:00
|
|
|
if (m_nameConfig->addAxisVariables())
|
2019-03-12 04:27:20 -05:00
|
|
|
componentNames[GCP_AXIS_VARIABLES] = axisVariableString();
|
2019-03-07 07:17:12 -06:00
|
|
|
if (m_nameConfig->addTimestep())
|
2019-03-12 04:27:20 -05:00
|
|
|
componentNames[GCP_TIME_STEP] = timeStepString();
|
2019-03-07 07:17:12 -06:00
|
|
|
if (m_nameConfig->addGrouping())
|
2019-03-12 04:27:20 -05:00
|
|
|
componentNames[GCP_GROUP_NAME] = groupTitle();
|
2019-03-07 07:17:12 -06:00
|
|
|
|
|
|
|
return componentNames;
|
|
|
|
}
|
|
|
|
|
2019-02-25 07:54:36 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-21 05:52:23 -06:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::initAfterRead()
|
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case());
|
|
|
|
if (eclipseCase)
|
|
|
|
{
|
|
|
|
m_xAxisProperty->setEclipseCase(eclipseCase);
|
|
|
|
m_yAxisProperty->setEclipseCase(eclipseCase);
|
2019-03-05 06:26:59 -06:00
|
|
|
m_groupingProperty->setEclipseCase(eclipseCase);
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-27 03:57:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
2019-02-27 02:25:08 -06:00
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
updateDataSetName();
|
2019-02-27 03:57:17 -06:00
|
|
|
|
|
|
|
detachAllCurves();
|
|
|
|
m_crossPlotCurves.deleteAllChildObjects();
|
2019-02-27 02:25:08 -06:00
|
|
|
|
2019-02-27 03:57:17 -06:00
|
|
|
if (m_case() == nullptr)
|
2019-02-27 02:25:08 -06:00
|
|
|
{
|
2019-02-27 03:57:17 -06:00
|
|
|
return;
|
2019-02-27 02:25:08 -06:00
|
|
|
}
|
2019-02-27 03:57:17 -06:00
|
|
|
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
|
2019-02-27 02:25:08 -06:00
|
|
|
|
2019-02-27 03:57:17 -06:00
|
|
|
if (eclipseCase == nullptr)
|
2019-02-27 02:25:08 -06:00
|
|
|
{
|
2019-02-27 03:57:17 -06:00
|
|
|
return;
|
2019-02-27 02:25:08 -06:00
|
|
|
}
|
|
|
|
|
2019-02-27 03:57:17 -06:00
|
|
|
if (!eclipseCase->ensureReservoirCaseIsOpen())
|
2019-02-27 02:25:08 -06:00
|
|
|
{
|
2019-02-27 03:57:17 -06:00
|
|
|
RiaLogging::warning(QString("Failed to open eclipse grid file %1").arg(eclipseCase->gridFileName()));
|
2019-02-27 02:25:08 -06:00
|
|
|
|
2019-02-27 03:57:17 -06:00
|
|
|
return;
|
2019-02-27 02:25:08 -06:00
|
|
|
}
|
|
|
|
|
2019-02-27 03:57:17 -06:00
|
|
|
RigEclipseResultAddress xAddress(m_xAxisProperty->resultType(), m_xAxisProperty->resultVariable());
|
|
|
|
RigEclipseResultAddress yAddress(m_yAxisProperty->resultType(), m_yAxisProperty->resultVariable());
|
2019-03-05 06:26:59 -06:00
|
|
|
RigEclipseResultAddress groupAddress(m_groupingProperty->resultType(), m_groupingProperty->resultVariable());
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-02-27 07:33:27 -06:00
|
|
|
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap = calculateCellVisibility(eclipseCase);
|
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
updateLegend();
|
|
|
|
|
2019-02-27 03:57:17 -06:00
|
|
|
RigEclipseCrossPlotResult result = RigEclipseCrossPlotDataExtractor::extract(
|
2019-03-05 06:26:59 -06:00
|
|
|
eclipseCase->eclipseCaseData(), m_timeStep(), xAddress, yAddress, m_grouping(), groupAddress, timeStepCellVisibilityMap);
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-03-13 04:16:46 -05:00
|
|
|
if (isXAxisLogarithmic() || isYAxisLogarithmic())
|
|
|
|
{
|
|
|
|
filterInvalidCurveValues(&result);
|
|
|
|
}
|
2019-03-04 08:35:48 -06:00
|
|
|
createCurves(result);
|
|
|
|
|
|
|
|
if (updateParentPlot)
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-03-04 08:35:48 -06:00
|
|
|
triggerPlotNameUpdateAndReplot();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& result)
|
|
|
|
{
|
2019-03-11 05:39:23 -05:00
|
|
|
m_groupedResults.clear();
|
2019-03-05 06:26:59 -06:00
|
|
|
if (!groupingEnabled())
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
|
|
|
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
|
|
|
|
int colorIndex = indexInPlot();
|
|
|
|
|
|
|
|
RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve();
|
|
|
|
curve->setColor(colors.cycledColor3f(colorIndex));
|
2019-03-05 06:26:59 -06:00
|
|
|
curve->setGroupingInformation(indexInPlot(), 0);
|
2019-03-04 08:35:48 -06:00
|
|
|
curve->setSamples(result.xValues, result.yValues);
|
2019-02-27 03:57:17 -06:00
|
|
|
curve->updateCurveAppearance();
|
|
|
|
curve->updateUiIconFromPlotSymbol();
|
|
|
|
m_crossPlotCurves.push_back(curve);
|
2019-03-11 05:39:23 -05:00
|
|
|
m_groupedResults[0] = result;
|
2019-02-27 03:57:17 -06:00
|
|
|
}
|
2019-03-04 08:35:48 -06:00
|
|
|
else
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-03-04 08:35:48 -06:00
|
|
|
std::vector<double> tickValues;
|
|
|
|
|
2019-03-05 06:26:59 -06:00
|
|
|
if (groupingByCategoryResult())
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
|
|
|
for (size_t i = 0; i < result.xValues.size(); ++i)
|
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
int categoryNum =
|
2019-03-05 06:26:59 -06:00
|
|
|
m_grouping == GROUP_BY_RESULT
|
|
|
|
? static_cast<int>(result.groupValuesContinuous[i])
|
|
|
|
: result.groupValuesDiscrete[i];
|
2019-03-05 05:37:58 -06:00
|
|
|
|
2019-03-11 05:39:23 -05:00
|
|
|
m_groupedResults[categoryNum].xValues.push_back(result.xValues[i]);
|
|
|
|
m_groupedResults[categoryNum].yValues.push_back(result.yValues[i]);
|
|
|
|
if (!result.groupValuesContinuous.empty())
|
|
|
|
m_groupedResults[categoryNum].groupValuesContinuous.push_back(result.groupValuesContinuous[i]);
|
|
|
|
if (!result.groupValuesDiscrete.empty())
|
|
|
|
m_groupedResults[categoryNum].groupValuesDiscrete.push_back(result.groupValuesDiscrete[i]);
|
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
legendConfig()->scalarMapper()->majorTickValues(&tickValues);
|
2019-03-04 08:35:48 -06:00
|
|
|
|
|
|
|
for (size_t i = 0; i < result.xValues.size(); ++i)
|
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
auto upperBoundIt = std::lower_bound(tickValues.begin(), tickValues.end(), result.groupValuesContinuous[i]);
|
2019-03-04 08:35:48 -06:00
|
|
|
int upperBoundIndex = static_cast<int>(upperBoundIt - tickValues.begin());
|
2019-03-11 05:39:23 -05:00
|
|
|
int categoryNum = std::min((int) tickValues.size() - 2, std::max(0, upperBoundIndex - 1));
|
|
|
|
m_groupedResults[categoryNum].xValues.push_back(result.xValues[i]);
|
|
|
|
m_groupedResults[categoryNum].yValues.push_back(result.yValues[i]);
|
|
|
|
if (!result.groupValuesContinuous.empty())
|
|
|
|
m_groupedResults[categoryNum].groupValuesContinuous.push_back(result.groupValuesContinuous[i]);
|
|
|
|
if (!result.groupValuesDiscrete.empty())
|
|
|
|
m_groupedResults[categoryNum].groupValuesDiscrete.push_back(result.groupValuesDiscrete[i]);
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-11 05:39:23 -05:00
|
|
|
for (auto it = m_groupedResults.rbegin(); it != m_groupedResults.rend(); ++it)
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
|
|
|
RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve();
|
2019-03-05 06:26:59 -06:00
|
|
|
curve->setGroupingInformation(indexInPlot(), it->first);
|
|
|
|
if (groupingByCategoryResult())
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
curve->setColor(cvf::Color3f(legendConfig()->scalarMapper()->mapToColor(it->first)));
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
curve->setColor(cvf::Color3f(legendConfig()->scalarMapper()->mapToColor(tickValues[it->first])));
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
2019-03-11 05:39:23 -05:00
|
|
|
curve->setSamples(it->second.xValues, it->second.yValues);
|
2019-03-04 08:35:48 -06:00
|
|
|
curve->showLegend(m_crossPlotCurves.empty());
|
2019-03-11 05:39:23 -05:00
|
|
|
curve->setLegendEntryText(createAutoName());
|
2019-03-04 08:35:48 -06:00
|
|
|
curve->updateCurveAppearance();
|
|
|
|
curve->updateUiIconFromPlotSymbol();
|
|
|
|
m_crossPlotCurves.push_back(curve);
|
|
|
|
}
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-11 05:39:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimGridCrossPlotCurveSet::createGroupName(size_t groupIndex) const
|
|
|
|
{
|
|
|
|
if (groupingByCategoryResult())
|
|
|
|
{
|
|
|
|
return legendConfig()->categoryNameFromCategoryValue(groupIndex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<double> tickValues;
|
|
|
|
legendConfig()->scalarMapper()->majorTickValues(&tickValues);
|
|
|
|
double lowerLimit = tickValues[groupIndex];
|
|
|
|
double upperLimit =
|
|
|
|
groupIndex + 1u < tickValues.size() ? tickValues[groupIndex + 1u] : std::numeric_limits<double>::infinity();
|
|
|
|
return QString("%1 [%2, %3]").arg(groupParameter()).arg(lowerLimit).arg(upperLimit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-27 07:33:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::map<int, cvf::UByteArray> RimGridCrossPlotCurveSet::calculateCellVisibility(RimEclipseCase* eclipseCase) const
|
|
|
|
{
|
|
|
|
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap;
|
|
|
|
if (m_cellFilterView)
|
|
|
|
{
|
|
|
|
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_cellFilterView());
|
|
|
|
if (eclipseView)
|
|
|
|
{
|
|
|
|
std::set<int> timeSteps;
|
|
|
|
if (m_timeStep() == -1)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < (int)eclipseCase->timeStepDates().size(); ++i)
|
|
|
|
{
|
|
|
|
timeSteps.insert(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
timeSteps.insert(m_timeStep());
|
|
|
|
}
|
|
|
|
for (int i : timeSteps)
|
|
|
|
{
|
|
|
|
eclipseView->calculateCurrentTotalCellVisibility(&timeStepCellVisibilityMap[i], i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return timeStepCellVisibilityMap;
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
|
|
|
uiOrdering.add(&m_case);
|
|
|
|
if (m_case)
|
|
|
|
{
|
|
|
|
uiOrdering.add(&m_timeStep);
|
2019-02-27 07:33:27 -06:00
|
|
|
uiOrdering.add(&m_cellFilterView);
|
2019-03-05 06:26:59 -06:00
|
|
|
uiOrdering.add(&m_grouping);
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-03-05 06:26:59 -06:00
|
|
|
if (m_grouping() == GROUP_BY_TIME &&
|
2019-03-04 03:19:02 -06:00
|
|
|
!(m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult()))
|
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
m_grouping = NO_GROUPING;
|
2019-03-04 03:19:02 -06:00
|
|
|
}
|
|
|
|
|
2019-03-05 06:26:59 -06:00
|
|
|
if (m_grouping() == GROUP_BY_RESULT)
|
2019-02-27 02:25:08 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
caf::PdmUiGroup* dataGroupingGroup = uiOrdering.addNewGroup("Data Grouping Property");
|
|
|
|
m_groupingProperty->uiOrdering(uiConfigName, *dataGroupingGroup);
|
2019-02-27 02:25:08 -06:00
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
caf::PdmUiGroup* xAxisGroup = uiOrdering.addNewGroup("X-Axis Property");
|
|
|
|
m_xAxisProperty->uiOrdering(uiConfigName, *xAxisGroup);
|
|
|
|
|
2019-03-08 02:59:29 -06:00
|
|
|
caf::PdmUiGroup* yAxisGroup = uiOrdering.addNewGroup("Y-Axis Property", false);
|
2019-02-21 05:52:23 -06:00
|
|
|
m_yAxisProperty->uiOrdering(uiConfigName, *yAxisGroup);
|
|
|
|
}
|
2019-02-27 02:25:08 -06:00
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Name Configuration");
|
|
|
|
m_nameConfig->uiOrdering(uiConfigName, *nameGroup);
|
|
|
|
|
|
|
|
uiOrdering.skipRemainingFields(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue)
|
|
|
|
{
|
|
|
|
if (changedField == &m_case)
|
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
|
|
|
|
if (eclipseCase)
|
|
|
|
{
|
|
|
|
m_xAxisProperty->setEclipseCase(eclipseCase);
|
|
|
|
m_yAxisProperty->setEclipseCase(eclipseCase);
|
2019-03-05 06:26:59 -06:00
|
|
|
m_groupingProperty->setEclipseCase(eclipseCase);
|
2019-02-27 02:25:08 -06:00
|
|
|
// TODO: Do we need all these??
|
2019-02-21 05:52:23 -06:00
|
|
|
m_xAxisProperty->updateConnectedEditors();
|
|
|
|
m_yAxisProperty->updateConnectedEditors();
|
2019-03-05 06:26:59 -06:00
|
|
|
m_groupingProperty->updateConnectedEditors();
|
2019-02-27 02:25:08 -06:00
|
|
|
|
2019-02-22 03:15:07 -06:00
|
|
|
loadDataAndUpdate(true);
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (changedField == &m_timeStep)
|
|
|
|
{
|
2019-03-07 07:17:12 -06:00
|
|
|
if (m_timeStep != -1 && m_grouping == GROUP_BY_TIME)
|
|
|
|
{
|
|
|
|
m_grouping = NO_GROUPING;
|
|
|
|
}
|
|
|
|
|
2019-02-22 03:15:07 -06:00
|
|
|
loadDataAndUpdate(true);
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
2019-03-05 06:26:59 -06:00
|
|
|
else if (changedField == &m_grouping)
|
2019-02-26 09:22:01 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
if (m_grouping == GROUP_BY_TIME)
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
legendConfig()->setColorRange(RimRegularLegendConfig::NORMAL);
|
|
|
|
legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER);
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
2019-03-05 06:26:59 -06:00
|
|
|
else if (groupingByCategoryResult())
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
legendConfig()->setColorRange(RimRegularLegendConfig::CATEGORY);
|
|
|
|
legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER);
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-05 05:37:58 -06:00
|
|
|
legendConfig()->setColorRange(RimRegularLegendConfig::NORMAL);
|
|
|
|
legendConfig()->setMappingMode(RimRegularLegendConfig::LINEAR_DISCRETE);
|
2019-03-04 08:35:48 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-02-26 09:22:01 -06:00
|
|
|
loadDataAndUpdate(true);
|
|
|
|
}
|
2019-02-27 07:33:27 -06:00
|
|
|
else if (changedField == &m_cellFilterView)
|
|
|
|
{
|
2019-03-08 02:59:29 -06:00
|
|
|
m_groupingProperty->setReservoirView(dynamic_cast<RimEclipseView*>(m_cellFilterView()));
|
2019-02-27 07:33:27 -06:00
|
|
|
loadDataAndUpdate(true);
|
|
|
|
}
|
2019-02-21 05:52:23 -06:00
|
|
|
else if (changedField == &m_isChecked)
|
|
|
|
{
|
2019-03-04 08:35:48 -06:00
|
|
|
updateLegend();
|
2019-03-04 03:19:02 -06:00
|
|
|
triggerPlotNameUpdateAndReplot();
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimGridCrossPlotCurveSet::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
|
|
|
bool* useOptionsOnly)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
|
|
|
if (fieldNeedingOptions == &m_case)
|
|
|
|
{
|
2019-02-27 06:47:10 -06:00
|
|
|
RimTools::eclipseCaseOptionItems(&options);
|
2019-02-22 02:37:59 -06:00
|
|
|
if (options.empty())
|
|
|
|
{
|
|
|
|
options.push_front(caf::PdmOptionItemInfo("None", nullptr));
|
|
|
|
}
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
else if (fieldNeedingOptions == &m_timeStep)
|
|
|
|
{
|
|
|
|
QStringList timeStepNames;
|
|
|
|
|
|
|
|
if (m_case)
|
|
|
|
{
|
|
|
|
timeStepNames = m_case->timeStepStrings();
|
|
|
|
}
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("All Time Steps", -1));
|
|
|
|
for (int i = 0; i < timeStepNames.size(); i++)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
|
|
|
|
}
|
|
|
|
}
|
2019-02-27 07:33:27 -06:00
|
|
|
else if (fieldNeedingOptions == &m_cellFilterView)
|
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case());
|
|
|
|
if (eclipseCase)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("Disabled", nullptr));
|
|
|
|
for (RimEclipseView* view : eclipseCase->reservoirViews.childObjects())
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(view->name(), view, false, view->uiIcon()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-05 06:26:59 -06:00
|
|
|
else if (fieldNeedingOptions == &m_grouping)
|
2019-03-04 03:19:02 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
std::set<RigGridCrossPlotCurveGrouping> validOptions = { NO_GROUPING, GROUP_BY_TIME, GROUP_BY_FORMATION, GROUP_BY_RESULT };
|
2019-03-07 12:00:38 -06:00
|
|
|
if (!hasMultipleTimeSteps())
|
2019-03-04 03:19:02 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
validOptions.erase(GROUP_BY_TIME);
|
2019-03-04 03:19:02 -06:00
|
|
|
}
|
2019-03-07 07:17:12 -06:00
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case());
|
|
|
|
if (!eclipseCase || !eclipseCase->eclipseCaseData()->activeFormationNames())
|
|
|
|
{
|
|
|
|
validOptions.erase(GROUP_BY_FORMATION);
|
|
|
|
}
|
|
|
|
}
|
2019-03-04 03:19:02 -06:00
|
|
|
for (auto optionItem : validOptions)
|
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
options.push_back(caf::PdmOptionItemInfo(CurveGroupingEnum::uiText(optionItem), optionItem));
|
2019-03-04 03:19:02 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
2019-03-04 08:35:48 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::updateLegend()
|
|
|
|
{
|
2019-03-07 07:17:12 -06:00
|
|
|
legendConfig()->setTitle(groupParameter());
|
2019-03-07 12:00:38 -06:00
|
|
|
legendConfig()->disableAllTimeStepsRange(!hasMultipleTimeSteps());
|
2019-03-04 08:35:48 -06:00
|
|
|
|
|
|
|
RimGridCrossPlot* parent;
|
|
|
|
this->firstAncestorOrThisOfTypeAsserted(parent);
|
|
|
|
if (parent->qwtPlot())
|
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
if (groupingEnabled() && m_case() && isChecked() && legendConfig()->showLegend())
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
if (m_grouping() == GROUP_BY_FORMATION)
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case());
|
2019-03-07 07:17:12 -06:00
|
|
|
if (eclipseCase)
|
|
|
|
{
|
|
|
|
RigFormationNames* formationNames = eclipseCase->eclipseCaseData()->activeFormationNames();
|
|
|
|
if (formationNames)
|
|
|
|
{
|
|
|
|
const std::vector<QString>& categoryNames = formationNames->formationNames();
|
|
|
|
if (!categoryNames.empty())
|
|
|
|
{
|
|
|
|
legendConfig()->setNamedCategories(categoryNames);
|
|
|
|
legendConfig()->setAutomaticRanges(0, categoryNames.size() - 1, 0, categoryNames.size() - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
2019-03-05 06:26:59 -06:00
|
|
|
else if (m_grouping() == GROUP_BY_TIME)
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
|
|
|
QStringList timeStepNames = m_case->timeStepStrings();
|
|
|
|
std::vector<QString> categoryNames;
|
|
|
|
for (auto name : timeStepNames)
|
|
|
|
{
|
|
|
|
categoryNames.push_back(name);
|
|
|
|
}
|
2019-03-07 07:17:12 -06:00
|
|
|
if (!categoryNames.empty())
|
|
|
|
{
|
|
|
|
legendConfig()->setNamedCategories(categoryNames);
|
|
|
|
legendConfig()->setAutomaticRanges(0, categoryNames.size() - 1, 0, categoryNames.size() - 1);
|
|
|
|
}
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
2019-03-05 06:26:59 -06:00
|
|
|
else if (m_groupingProperty->eclipseResultAddress().isValid())
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case());
|
2019-03-05 05:37:58 -06:00
|
|
|
if (eclipseCase)
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
m_groupingProperty->updateLegendData(eclipseCase, m_timeStep());
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
parent->qwtPlot()->addOrUpdateCurveSetLegend(this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parent->qwtPlot()->removeCurveSetLegend(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-05 06:26:59 -06:00
|
|
|
bool RimGridCrossPlotCurveSet::groupingByCategoryResult() const
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
if (m_grouping == GROUP_BY_FORMATION || m_grouping == GROUP_BY_TIME)
|
2019-03-05 05:37:58 -06:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2019-03-05 06:26:59 -06:00
|
|
|
else if (m_grouping == GROUP_BY_RESULT)
|
2019-03-05 05:37:58 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
return m_groupingProperty->hasCategoryResult();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimGridCrossPlotCurveSet::groupingEnabled() const
|
|
|
|
{
|
|
|
|
if (m_grouping != NO_GROUPING)
|
|
|
|
{
|
|
|
|
if (m_grouping == GROUP_BY_RESULT && !m_groupingProperty->eclipseResultAddress().isValid())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2019-03-05 05:37:58 -06:00
|
|
|
}
|
|
|
|
return false;
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
|
2019-03-08 02:59:29 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::swapAxisProperties(bool updatePlot)
|
|
|
|
{
|
|
|
|
RimEclipseResultDefinition* xAxisProperties = m_xAxisProperty();
|
|
|
|
RimEclipseResultDefinition* yAxisProperties = m_yAxisProperty();
|
|
|
|
|
|
|
|
m_xAxisProperty.removeChildObject(xAxisProperties);
|
|
|
|
m_yAxisProperty.removeChildObject(yAxisProperties);
|
|
|
|
m_yAxisProperty = xAxisProperties;
|
|
|
|
m_xAxisProperty = yAxisProperties;
|
2019-03-12 07:48:51 -05:00
|
|
|
|
|
|
|
updateConnectedEditors();
|
2019-03-08 02:59:29 -06:00
|
|
|
loadDataAndUpdate(updatePlot);
|
|
|
|
}
|
|
|
|
|
2019-03-11 05:39:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::exportFormattedData(RifEclipseDataTableFormatter& formatter) const
|
|
|
|
{
|
|
|
|
if (m_groupedResults.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (m_grouping != NO_GROUPING)
|
|
|
|
{
|
|
|
|
std::vector<RifEclipseOutputTableColumn> header = {RifEclipseOutputTableColumn("X"),
|
|
|
|
RifEclipseOutputTableColumn("Y"),
|
|
|
|
RifEclipseOutputTableColumn("Group Index"),
|
|
|
|
RifEclipseOutputTableColumn("Group Description")};
|
|
|
|
|
|
|
|
formatter.header(header);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<RifEclipseOutputTableColumn> header = {RifEclipseOutputTableColumn("X"), RifEclipseOutputTableColumn("Y")};
|
|
|
|
formatter.header(header);
|
|
|
|
}
|
|
|
|
|
|
|
|
caf::ProgressInfo progress(m_groupedResults.size(), "Gathering Data Points");
|
|
|
|
for (auto it = m_groupedResults.begin(); it != m_groupedResults.end(); ++it)
|
|
|
|
{
|
2019-03-12 05:02:06 -05:00
|
|
|
auto task = progress.task(QString("Exporting Group %1").arg(it->first));
|
|
|
|
|
|
|
|
RigEclipseCrossPlotResult res = it->second;
|
2019-03-11 05:39:23 -05:00
|
|
|
|
|
|
|
for (size_t i = 0; i < it->second.xValues.size(); ++i)
|
|
|
|
{
|
|
|
|
if (m_grouping() == NO_GROUPING)
|
|
|
|
{
|
|
|
|
formatter.add(res.xValues[i]);
|
|
|
|
formatter.add(res.yValues[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-12 05:02:06 -05:00
|
|
|
int groupIndex = it->first;
|
2019-03-11 05:39:23 -05:00
|
|
|
QString groupName = createGroupName(groupIndex);
|
|
|
|
formatter.add(res.xValues[i]);
|
|
|
|
formatter.add(res.yValues[i]);
|
|
|
|
formatter.add(groupIndex);
|
|
|
|
formatter.add(groupName);
|
|
|
|
}
|
|
|
|
formatter.rowCompleted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-13 04:16:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimGridCrossPlotCurveSet::isXAxisLogarithmic() const
|
|
|
|
{
|
|
|
|
RimGridCrossPlot* parent = nullptr;
|
|
|
|
firstAncestorOrThisOfTypeAsserted(parent);
|
|
|
|
return parent->isXAxisLogarithmic();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimGridCrossPlotCurveSet::isYAxisLogarithmic() const
|
|
|
|
{
|
|
|
|
RimGridCrossPlot* parent = nullptr;
|
|
|
|
firstAncestorOrThisOfTypeAsserted(parent);
|
|
|
|
return parent->isYAxisLogarithmic();
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-04 03:19:02 -06:00
|
|
|
void RimGridCrossPlotCurveSet::triggerPlotNameUpdateAndReplot()
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
|
|
|
RimGridCrossPlot* parent;
|
2019-03-12 08:31:26 -05:00
|
|
|
this->firstAncestorOrThisOfType(parent);
|
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
parent->updateCurveNamesAndPlotTitle();
|
|
|
|
parent->reattachCurvesToQwtAndReplot();
|
|
|
|
parent->updateConnectedEditors();
|
|
|
|
}
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-07 07:17:12 -06:00
|
|
|
void RimGridCrossPlotCurveSet::updateCurveNames(size_t curveSetIndex, size_t curveSetCount)
|
2019-02-28 11:30:07 -06:00
|
|
|
{
|
2019-03-07 07:17:12 -06:00
|
|
|
for (size_t i = 0; i < m_crossPlotCurves.size(); ++i)
|
2019-02-28 11:30:07 -06:00
|
|
|
{
|
2019-03-07 07:17:12 -06:00
|
|
|
QString curveSetName = createAutoName();
|
|
|
|
if (curveSetName.isEmpty())
|
2019-03-04 03:19:02 -06:00
|
|
|
{
|
2019-03-07 07:17:12 -06:00
|
|
|
if (curveSetCount > 1u)
|
2019-03-11 05:39:23 -05:00
|
|
|
curveSetName = QString("Curve Set #%1").arg(curveSetIndex + 1);
|
2019-03-07 07:17:12 -06:00
|
|
|
else
|
2019-03-11 05:39:23 -05:00
|
|
|
curveSetName = "Curve Set";
|
2019-03-04 03:19:02 -06:00
|
|
|
}
|
|
|
|
|
2019-03-07 07:17:12 -06:00
|
|
|
auto curve = m_crossPlotCurves[i];
|
|
|
|
if (groupingEnabled())
|
2019-02-28 11:30:07 -06:00
|
|
|
{
|
2019-03-11 05:39:23 -05:00
|
|
|
QString curveGroupName = createGroupName(curve->groupIndex());
|
|
|
|
curve->setCustomName(curveGroupName);
|
|
|
|
curve->setLegendEntryText(curveSetName);
|
2019-02-28 11:30:07 -06:00
|
|
|
}
|
2019-03-07 07:17:12 -06:00
|
|
|
else
|
2019-03-04 08:35:48 -06:00
|
|
|
{
|
2019-03-07 07:17:12 -06:00
|
|
|
curve->setCustomName(curveSetName);
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
2019-02-28 11:30:07 -06:00
|
|
|
curve->updateCurveNameAndUpdatePlotLegendAndTitle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-04 03:19:02 -06:00
|
|
|
void RimGridCrossPlotCurveSet::updateDataSetName()
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
|
|
|
this->setName(createAutoName());
|
|
|
|
}
|
|
|
|
|
2019-02-22 02:37:59 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-28 11:30:07 -06:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::performAutoNameUpdate()
|
|
|
|
{
|
2019-03-04 03:19:02 -06:00
|
|
|
updateDataSetName();
|
|
|
|
triggerPlotNameUpdateAndReplot();
|
2019-02-28 11:30:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-22 02:37:59 -06:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::setDefaults()
|
|
|
|
{
|
|
|
|
RimProject* project = RiaApplication::instance()->project();
|
|
|
|
if (project)
|
|
|
|
{
|
|
|
|
if (!project->eclipseCases().empty())
|
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase = project->eclipseCases().front();
|
|
|
|
m_case = eclipseCase;
|
|
|
|
m_xAxisProperty->setEclipseCase(eclipseCase);
|
|
|
|
m_yAxisProperty->setEclipseCase(eclipseCase);
|
2019-03-05 06:26:59 -06:00
|
|
|
m_groupingProperty->setEclipseCase(eclipseCase);
|
2019-02-22 02:37:59 -06:00
|
|
|
|
|
|
|
m_xAxisProperty->setResultType(RiaDefines::DYNAMIC_NATIVE);
|
|
|
|
m_xAxisProperty->setResultVariable("SOIL");
|
|
|
|
|
|
|
|
m_yAxisProperty->setResultType(RiaDefines::DYNAMIC_NATIVE);
|
|
|
|
m_yAxisProperty->setResultVariable("PRESSURE");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-27 02:25:08 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::defineEditorAttribute(const caf::PdmFieldHandle* field,
|
|
|
|
QString uiConfigName,
|
|
|
|
caf::PdmUiEditorAttribute* attribute)
|
|
|
|
{
|
2019-03-04 08:35:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
if (groupingEnabled())
|
2019-02-27 02:25:08 -06:00
|
|
|
{
|
2019-03-05 06:26:59 -06:00
|
|
|
m_groupingProperty->uiTreeOrdering(uiTreeOrdering, uiConfigName);
|
2019-02-27 02:25:08 -06:00
|
|
|
}
|
2019-03-04 08:35:48 -06:00
|
|
|
|
|
|
|
for (auto curve : m_crossPlotCurves())
|
|
|
|
{
|
|
|
|
uiTreeOrdering.add(curve);
|
|
|
|
}
|
|
|
|
|
|
|
|
uiTreeOrdering.skipRemainingChildren(true);
|
2019-02-27 02:25:08 -06:00
|
|
|
}
|
|
|
|
|
2019-03-07 12:00:38 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimGridCrossPlotCurveSet::hasMultipleTimeSteps() const
|
|
|
|
{
|
|
|
|
return m_timeStep() == -1 && (m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-03-13 04:16:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSet::filterInvalidCurveValues(RigEclipseCrossPlotResult* result)
|
|
|
|
{
|
|
|
|
bool xLog = isXAxisLogarithmic();
|
|
|
|
bool yLog = isYAxisLogarithmic();
|
|
|
|
|
|
|
|
if (xLog || yLog)
|
|
|
|
{
|
|
|
|
|
|
|
|
RigEclipseCrossPlotResult validResult;
|
|
|
|
for (size_t i = 0; i < result->xValues.size(); ++i)
|
|
|
|
{
|
|
|
|
double xValue = result->xValues[i];
|
|
|
|
double yValue = result->yValues[i];
|
|
|
|
bool invalid = (xLog && xValue <= 0.0) || (yLog && yValue <= 0.0);
|
|
|
|
if (!invalid)
|
|
|
|
{
|
|
|
|
validResult.xValues.push_back(xValue);
|
|
|
|
validResult.yValues.push_back(yValue);
|
|
|
|
if (i < result->groupValuesContinuous.size())
|
|
|
|
{
|
|
|
|
validResult.groupValuesContinuous.push_back(result->groupValuesContinuous[i]);
|
|
|
|
}
|
|
|
|
if (i < result->groupValuesDiscrete.size())
|
|
|
|
{
|
|
|
|
validResult.groupValuesDiscrete.push_back(result->groupValuesDiscrete[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*result = validResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurveSetNameConfig, "RimGridCrossPlotCurveSetNameConfig");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGridCrossPlotCurveSetNameConfig::RimGridCrossPlotCurveSetNameConfig(RimNameConfigHolderInterface* parent)
|
|
|
|
: RimNameConfig(parent)
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Cross Plot Curve Set NameGenerator", "", "", "");
|
|
|
|
|
2019-03-07 07:17:12 -06:00
|
|
|
CAF_PDM_InitField(&addCaseName, "AddCaseName", true, "Add Case Name", "", "", "");
|
2019-02-21 05:52:23 -06:00
|
|
|
CAF_PDM_InitField(&addAxisVariables, "AddAxisVariables", true, "Add Axis Variables", "", "", "");
|
2019-03-07 07:17:12 -06:00
|
|
|
CAF_PDM_InitField(&addTimestep, "AddTimeStep", true, "Add Time Step", "", "", "");
|
2019-03-05 06:26:59 -06:00
|
|
|
CAF_PDM_InitField(&addGrouping, "AddGrouping", true, "Add Data Group", "", "", "");
|
2019-02-21 05:52:23 -06:00
|
|
|
|
|
|
|
setCustomName("");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimGridCrossPlotCurveSetNameConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
|
|
|
uiOrdering.add(&addCaseName);
|
|
|
|
uiOrdering.add(&addAxisVariables);
|
|
|
|
uiOrdering.add(&addTimestep);
|
2019-03-05 06:26:59 -06:00
|
|
|
uiOrdering.add(&addGrouping);
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|