#4216 Support saving curve appearance

This commit is contained in:
Gaute Lindkvist 2019-03-22 10:49:52 +01:00
parent 646d79ce57
commit bf3f505dc1
5 changed files with 139 additions and 42 deletions

View File

@ -97,17 +97,20 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet()
m_xAxisProperty.uiCapability()->setUiHidden(true);
m_xAxisProperty.uiCapability()->setUiTreeChildrenHidden(true);
m_xAxisProperty->setLabelsOnTop(true);
m_xAxisProperty->setTernaryEnabled(false);
CAF_PDM_InitFieldNoDefault(&m_yAxisProperty, "YAxisProperty", "Y-Axis Property", "", "", "");
m_yAxisProperty = new RimEclipseResultDefinition;
m_yAxisProperty.uiCapability()->setUiHidden(true);
m_yAxisProperty.uiCapability()->setUiTreeChildrenHidden(true);
m_yAxisProperty->setLabelsOnTop(true);
m_yAxisProperty->setTernaryEnabled(false);
CAF_PDM_InitFieldNoDefault(&m_groupingProperty, "GroupingProperty", "Data Grouping Property", "", "", "");
m_groupingProperty = new RimEclipseCellColors;
m_groupingProperty.uiCapability()->setUiHidden(true);
m_groupingProperty->legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER);
m_groupingProperty->setTernaryEnabled(false);
CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "Name", "", "", "");
m_nameConfig = new RimGridCrossPlotCurveSetNameConfig(this);
@ -402,9 +405,6 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
{
updateDataSetName();
detachAllCurves();
m_crossPlotCurves.deleteAllChildObjects();
if (m_case() == nullptr)
{
return;
@ -439,7 +439,22 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
{
filterInvalidCurveValues(&result);
}
createCurves(result);
assignCurveDataGroups(result);
if (m_crossPlotCurves.size() != m_groupedResults.size())
{
destroyCurves();
}
if (m_crossPlotCurves.empty())
{
createCurves(result);
}
else
{
fillCurveDataInExistingCurves(result);
}
if (updateParentPlot)
{
@ -450,28 +465,11 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& result)
void RimGridCrossPlotCurveSet::assignCurveDataGroups(const RigEclipseCrossPlotResult& result)
{
m_groupedResults.clear();
if (!groupingEnabled())
{
RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve();
if (m_useCustomColor)
{
curve->setColor(m_customColor());
}
else
{
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
int colorIndex = indexInPlot();
curve->setColor(colors.cycledColor3f(colorIndex));
}
curve->setSymbolEdgeColor(curve->color());
curve->setGroupingInformation(indexInPlot(), 0);
curve->setSamples(result.xValues, result.yValues);
curve->setCurveAutoAppearance();
curve->updateUiIconFromPlotSymbol();
m_crossPlotCurves.push_back(curve);
m_groupedResults[0] = result;
}
else
@ -509,6 +507,42 @@ void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& res
if (!result.groupValuesDiscrete.empty())
m_groupedResults[categoryNum].groupValuesDiscrete.push_back(result.groupValuesDiscrete[i]);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& result)
{
if (!groupingEnabled())
{
RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve();
if (m_useCustomColor)
{
curve->setColor(m_customColor());
}
else
{
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
int colorIndex = indexInPlot();
curve->setColor(colors.cycledColor3f(colorIndex));
}
curve->setSymbolEdgeColor(curve->color());
curve->setGroupingInformation(indexInPlot(), 0);
curve->setSamples(result.xValues, result.yValues);
curve->setCurveAutoAppearance();
curve->updateUiIconFromPlotSymbol();
m_crossPlotCurves.push_back(curve);
}
else
{
std::vector<double> tickValues;
if (!groupingByCategoryResult())
{
legendConfig()->scalarMapper()->majorTickValues(&tickValues);
}
for (auto it = m_groupedResults.rbegin(); it != m_groupedResults.rend(); ++it)
@ -534,6 +568,42 @@ void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& res
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurveSet::fillCurveDataInExistingCurves(const RigEclipseCrossPlotResult& result)
{
if (!groupingEnabled())
{
CVF_ASSERT(m_crossPlotCurves.size() == 1u);
RimGridCrossPlotCurve* curve = m_crossPlotCurves[0];
curve->setSamples(result.xValues, result.yValues);
curve->updateCurveAppearance();
curve->updateUiIconFromPlotSymbol();
}
else
{
auto curveIt = m_crossPlotCurves.begin();
auto groupIt = m_groupedResults.begin();
for (; curveIt != m_crossPlotCurves.end() && groupIt != m_groupedResults.end(); ++curveIt, ++groupIt)
{
RimGridCrossPlotCurve* curve = *curveIt;
curve->setSamples(groupIt->second.xValues, groupIt->second.yValues);
curve->updateCurveAppearance();
curve->updateUiIconFromPlotSymbol();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurveSet::destroyCurves()
{
detachAllCurves();
m_crossPlotCurves.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -680,6 +750,7 @@ void RimGridCrossPlotCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* chang
m_yAxisProperty->updateConnectedEditors();
m_groupingProperty->updateConnectedEditors();
destroyCurves();
loadDataAndUpdate(true);
}
}
@ -690,6 +761,7 @@ void RimGridCrossPlotCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* chang
m_grouping = NO_GROUPING;
}
destroyCurves();
loadDataAndUpdate(true);
}
else if (changedField == &m_grouping)
@ -710,11 +782,13 @@ void RimGridCrossPlotCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* chang
legendConfig()->setMappingMode(RimRegularLegendConfig::LINEAR_DISCRETE);
}
destroyCurves();
loadDataAndUpdate(true);
}
else if (changedField == &m_cellFilterView)
{
m_groupingProperty->setReservoirView(dynamic_cast<RimEclipseView*>(m_cellFilterView()));
loadDataAndUpdate(true);
}
else if (changedField == &m_isChecked)

View File

@ -129,12 +129,15 @@ public:
void configureForPressureSaturationCurves(RimEclipseResultCase* eclipseResultCase, const QString& dynamicResultName);
void addCellFilter(RimPlotCellFilter* cellFilter);
void setCustomColor(const cvf::Color3f color);
void destroyCurves();
protected:
void initAfterRead() override;
void onLoadDataAndUpdate(bool updateParentPlot);
void assignCurveDataGroups(const RigEclipseCrossPlotResult& result);
void createCurves(const RigEclipseCrossPlotResult& result);
void fillCurveDataInExistingCurves(const RigEclipseCrossPlotResult& result);
QString createGroupName(size_t curveIndex) const;
std::map<int, cvf::UByteArray> calculateCellVisibility(RimEclipseCase* eclipseCase) const;

View File

@ -70,6 +70,8 @@ RimEclipseContourMapView::RimEclipseContourMapView()
m_contourMapProjectionPartMgr = new RivContourMapProjectionPartMgr(contourMapProjection(), this);
((RiuViewerToViewInterface*)this)->setCameraPosition(sm_defaultViewMatrix);
cellResult()->setTernaryEnabled(false);
}
//--------------------------------------------------------------------------------------------------

View File

@ -77,6 +77,7 @@ CAF_PDM_SOURCE_INIT(RimEclipseResultDefinition, "ResultDefinition");
RimEclipseResultDefinition::RimEclipseResultDefinition()
: m_diffResultOptionsEnabled(false)
, m_labelsOnTop(false)
, m_ternaryEnabled(true)
{
CAF_PDM_InitObject("Result Definition", "", "", "");
@ -491,11 +492,12 @@ void RimEclipseResultDefinition::loadDataAndUpdate()
}
}
RimGridCrossPlot* crossPlot = nullptr;
this->firstAncestorOrThisOfType(crossPlot);
if (crossPlot)
RimGridCrossPlotCurveSet* crossPlotCurveSet = nullptr;
this->firstAncestorOrThisOfType(crossPlotCurveSet);
if (crossPlotCurveSet)
{
crossPlot->loadDataAndUpdate();
crossPlotCurveSet->destroyCurves();
crossPlotCurveSet->loadDataAndUpdate(true);
}
RimPlotCurve* curve = nullptr;
@ -646,7 +648,8 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
options = calcOptionsForVariableUiFieldStandard(m_resultTypeUiField(),
this->currentGridCellResults(),
showDerivedResultsFirstInVariableUiField(),
addPerCellFaceOptionsForVariableUiField());
addPerCellFaceOptionsForVariableUiField(),
m_ternaryEnabled);
}
else if (fieldNeedingOptions == &m_differenceCase)
{
@ -1460,7 +1463,8 @@ QList<caf::PdmOptionItemInfo>
RimEclipseResultDefinition::calcOptionsForVariableUiFieldStandard(RiaDefines::ResultCatType resultCatType,
const RigCaseCellResultsData* results,
bool showDerivedResultsFirst,
bool addPerCellFaceOptionItems)
bool addPerCellFaceOptionItems,
bool ternaryEnabled)
{
CVF_ASSERT(resultCatType != RiaDefines::FLOW_DIAGNOSTICS && resultCatType != RiaDefines::INJECTION_FLOODING);
@ -1498,20 +1502,23 @@ RimEclipseResultDefinition::calcOptionsForVariableUiFieldStandard(RiaDefines::Re
}
// Ternary Result
bool hasAtLeastOneTernaryComponent = false;
if (cellCenterResultNames.contains("SOIL"))
hasAtLeastOneTernaryComponent = true;
else if (cellCenterResultNames.contains("SGAS"))
hasAtLeastOneTernaryComponent = true;
else if (cellCenterResultNames.contains("SWAT"))
hasAtLeastOneTernaryComponent = true;
if (resultCatType == RiaDefines::DYNAMIC_NATIVE && hasAtLeastOneTernaryComponent)
if (ternaryEnabled)
{
optionList.push_front(
caf::PdmOptionItemInfo(RiaDefines::ternarySaturationResultName(), RiaDefines::ternarySaturationResultName()));
}
bool hasAtLeastOneTernaryComponent = false;
if (cellCenterResultNames.contains("SOIL"))
hasAtLeastOneTernaryComponent = true;
else if (cellCenterResultNames.contains("SGAS"))
hasAtLeastOneTernaryComponent = true;
else if (cellCenterResultNames.contains("SWAT"))
hasAtLeastOneTernaryComponent = true;
if (resultCatType == RiaDefines::DYNAMIC_NATIVE && hasAtLeastOneTernaryComponent)
{
optionList.push_front(
caf::PdmOptionItemInfo(RiaDefines::ternarySaturationResultName(),
RiaDefines::ternarySaturationResultName()));
}
}
if (addPerCellFaceOptionItems)
{
for (QString s : cellFaceResultNames)
@ -1535,6 +1542,14 @@ RimEclipseResultDefinition::calcOptionsForVariableUiFieldStandard(RiaDefines::Re
return QList<caf::PdmOptionItemInfo>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition::setTernaryEnabled(bool enabled)
{
m_ternaryEnabled = enabled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -129,8 +129,10 @@ public:
static QList<caf::PdmOptionItemInfo> calcOptionsForVariableUiFieldStandard(RiaDefines::ResultCatType resultCatType,
const RigCaseCellResultsData* results,
bool showDerivedResultsFirst = false,
bool addPerCellFaceOptionItems = false);
bool addPerCellFaceOptionItems = false,
bool enableTernary = false);
void setTernaryEnabled(bool enabled);
protected:
virtual void updateLegendCategorySettings() {};
@ -220,9 +222,10 @@ private:
bool addPerCellFaceOptionsForVariableUiField() const;
void ensureProcessingOfObsoleteFields();
bool isTernaryEnabled() const;
private:
bool m_diffResultOptionsEnabled;
bool m_labelsOnTop;
bool m_ternaryEnabled;
};