mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4156 Don't show the common part of Grid Cross Plout curve names in legend
This commit is contained in:
@@ -40,6 +40,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaQIconTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaCellDividingTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaFieldHandleTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaBoundingBoxTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaGridCrossPlotCurveNameHelper.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -80,6 +81,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaQIconTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaCellDividingTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaFieldHandleTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaBoundingBoxTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaGridCrossPlotCurveNameHelper.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RiaGridCrossPlotCurveNameHelper.h"
|
||||
|
||||
#include "RimGridCrossPlotCurveSet.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaGridCrossPlotCurveNameHelper::addCurveSet(RimGridCrossPlotCurveSet* curveSet)
|
||||
{
|
||||
m_caseNameSet.insert(curveSet->caseNameString());
|
||||
m_axisVariablesSet.insert(curveSet->axisVariableString());
|
||||
m_timeStepSet.insert(curveSet->timeStepString());
|
||||
for (QString categoryName : curveSet->categoryStrings())
|
||||
{
|
||||
m_categoryNameSet.insert(categoryName);
|
||||
}
|
||||
m_curveSets.push_back(curveSet);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaGridCrossPlotCurveNameHelper::applyCurveNames()
|
||||
{
|
||||
for (auto curveSet : m_curveSets)
|
||||
{
|
||||
curveSet->updateCurveNames(m_caseNameSet.size() > 1u, m_axisVariablesSet.size() > 1u, m_timeStepSet.size() > 1u, m_categoryNameSet.size() > 1u);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaGridCrossPlotCurveNameHelper::reset()
|
||||
{
|
||||
m_caseNameSet.clear();
|
||||
m_axisVariablesSet.clear();
|
||||
m_timeStepSet.clear();
|
||||
m_categoryNameSet.clear();
|
||||
m_curveSets.clear();
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
class RimGridCrossPlotCurveSet;
|
||||
|
||||
class RiaGridCrossPlotCurveNameHelper
|
||||
{
|
||||
public:
|
||||
void addCurveSet(RimGridCrossPlotCurveSet* curveSet);
|
||||
void applyCurveNames();
|
||||
void reset();
|
||||
|
||||
private:
|
||||
std::set<QString> m_caseNameSet;
|
||||
std::set<QString> m_axisVariablesSet;
|
||||
std::set<QString> m_timeStepSet;
|
||||
std::set<QString> m_categoryNameSet;
|
||||
|
||||
std::vector<RimGridCrossPlotCurveSet*> m_curveSets;
|
||||
|
||||
};
|
||||
|
||||
@@ -49,7 +49,6 @@ void RicCreateGridCrossPlotCurveSetFeature::onActionTriggered(bool isChecked)
|
||||
RimGridCrossPlotCurveSet* curveSet = crossPlot->createCurveSet();
|
||||
curveSet->loadDataAndUpdate(true);
|
||||
|
||||
RiaApplication::instance()->project()->updateConnectedEditors();
|
||||
RiaApplication::instance()->getOrCreateMainPlotWindow();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(curveSet);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ void RicCreateGridCrossPlotFeature::onActionTriggered(bool isChecked)
|
||||
plot->zoomAll();
|
||||
plot->updateConnectedEditors();
|
||||
|
||||
RiaApplication::instance()->project()->updateConnectedEditors();
|
||||
collection->updateAllRequiredEditors();
|
||||
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(plot);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RimGridCrossPlot.h"
|
||||
|
||||
#include "RiaGridCrossPlotCurveNameHelper.h"
|
||||
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
@@ -190,7 +192,7 @@ QString RimGridCrossPlot::createAutoName() const
|
||||
}
|
||||
if (!dataSets.isEmpty())
|
||||
{
|
||||
autoName += QString("(%1)").arg(dataSets.join(", "));
|
||||
autoName += QString("(%1)").arg(dataSets.join("; "));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +335,7 @@ void RimGridCrossPlot::onLoadDataAndUpdate()
|
||||
curveSet->loadDataAndUpdate(false);
|
||||
}
|
||||
|
||||
performAutoNameUpdate();
|
||||
updateCurveNamesAndPlotTitle();
|
||||
updateAllRequiredEditors();
|
||||
|
||||
updatePlot();
|
||||
@@ -415,10 +417,7 @@ QList<caf::PdmOptionItemInfo> RimGridCrossPlot::calculateValueOptions(const caf:
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::performAutoNameUpdate()
|
||||
{
|
||||
if (m_qwtPlot)
|
||||
{
|
||||
m_qwtPlot->setTitle(this->createAutoName());
|
||||
}
|
||||
updateCurveNamesAndPlotTitle();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -456,6 +455,19 @@ void RimGridCrossPlot::updatePlot()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::updateCurveNamesAndPlotTitle()
|
||||
{
|
||||
updateCurveNames();
|
||||
|
||||
if (m_qwtPlot)
|
||||
{
|
||||
m_qwtPlot->setTitle(this->createAutoName());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -599,6 +611,21 @@ void RimGridCrossPlot::updateAxisFromQwt(RiaDefines::PlotAxis axisType)
|
||||
axisProperties->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlot::updateCurveNames()
|
||||
{
|
||||
m_curveNameHelper.reset();
|
||||
|
||||
for (auto curveSet : m_crossPlotCurveSets())
|
||||
{
|
||||
m_curveNameHelper.addCurveSet(curveSet);
|
||||
}
|
||||
|
||||
m_curveNameHelper.applyCurveNames();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Name Configuration
|
||||
///
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RiaGridCrossPlotCurveNameHelper.h"
|
||||
#include "RimRiuQwtPlotOwnerInterface.h"
|
||||
#include "RimNameConfig.h"
|
||||
#include "RimViewWindow.h"
|
||||
@@ -66,6 +67,7 @@ public:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
void detachAllCurves();
|
||||
void performAutoNameUpdate() override;
|
||||
void updateCurveNamesAndPlotTitle();
|
||||
|
||||
public:
|
||||
// Rim2dPlotInterface overrides
|
||||
@@ -88,6 +90,8 @@ protected:
|
||||
bool* useOptionsOnly) override;
|
||||
|
||||
void updatePlot();
|
||||
void updateCurveNames();
|
||||
|
||||
QString xAxisParameterString() const;
|
||||
QString yAxisParameterString() const;
|
||||
|
||||
@@ -104,8 +108,8 @@ private:
|
||||
|
||||
caf::PdmChildArrayField<RimGridCrossPlotCurveSet*> m_crossPlotCurveSets;
|
||||
|
||||
QPointer<RiuQwtPlot> m_qwtPlot;
|
||||
|
||||
QPointer<RiuQwtPlot> m_qwtPlot;
|
||||
RiaGridCrossPlotCurveNameHelper m_curveNameHelper;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
void setSamples(const std::vector<double>& xValues, const std::vector<double>& yValues);
|
||||
void updateCurveAppearance() override;
|
||||
int categoryIndex() const;
|
||||
|
||||
protected:
|
||||
|
||||
void determineColorAndSymbol();
|
||||
|
||||
@@ -50,8 +50,8 @@ namespace caf
|
||||
template<>
|
||||
void RimGridCrossPlotCurveSet::CurveCategorizationEnum::setUp()
|
||||
{
|
||||
addItem(RigGridCrossPlotCurveCategorization::NO_CATEGORIZATION, "NONE", "None");
|
||||
addItem(RigGridCrossPlotCurveCategorization::TIME_CATEGORIZATION, "TIME", "Time");
|
||||
addItem(RigGridCrossPlotCurveCategorization::NO_CATEGORIZATION, "NONE", "Nothing");
|
||||
addItem(RigGridCrossPlotCurveCategorization::TIME_CATEGORIZATION, "TIME", "Time Step");
|
||||
addItem(RigGridCrossPlotCurveCategorization::FORMATION_CATEGORIZATION, "FORMATION", "Formations");
|
||||
addItem(RigGridCrossPlotCurveCategorization::RESULT_CATEGORIZATION, "RESULT", "Result Property");
|
||||
setDefault(RigGridCrossPlotCurveCategorization::TIME_CATEGORIZATION);
|
||||
@@ -72,7 +72,7 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_cellFilterView, "VisibleCellView", "Filter by Cells Visible in 3d View", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_categorization, "Categorization", "Data Categorization", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_categorization, "Categorization", "Group Data by", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_xAxisProperty, "XAxisProperty", "X-Axis Property", "", "", "");
|
||||
m_xAxisProperty = new RimEclipseResultDefinition;
|
||||
@@ -84,12 +84,12 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet()
|
||||
m_yAxisProperty.uiCapability()->setUiHidden(true);
|
||||
m_yAxisProperty.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_categoryProperty, "CategoryProperty", "Categorisation Property", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_categoryProperty, "CategoryProperty", "Data Grouping Property", "", "", "");
|
||||
m_categoryProperty = new RimEclipseResultDefinition;
|
||||
m_categoryProperty.uiCapability()->setUiHidden(true);
|
||||
m_categoryProperty.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&m_categoryBinCount, "CategoryBinCount", 2, "Category Bin Count", "", "", "");
|
||||
CAF_PDM_InitField(&m_categoryBinCount, "CategoryBinCount", 2, "Number of Data Groups", "", "", "");
|
||||
m_categoryBinCount.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "Name", "", "", "");
|
||||
@@ -174,73 +174,38 @@ QString RimGridCrossPlotCurveSet::createAutoName() const
|
||||
|
||||
if (m_nameConfig->addCaseName())
|
||||
{
|
||||
nameTags += m_case->caseUserDescription();
|
||||
nameTags += caseNameString();
|
||||
}
|
||||
|
||||
if (m_nameConfig->addAxisVariables())
|
||||
{
|
||||
nameTags += QString("%1 x %2").arg(xAxisName(), yAxisName());
|
||||
nameTags += axisVariableString();
|
||||
}
|
||||
|
||||
if (m_nameConfig->addTimestep())
|
||||
if (m_nameConfig->addTimestep() && !timeStepString().isEmpty())
|
||||
{
|
||||
if (m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult())
|
||||
{
|
||||
if (m_timeStep() == -1)
|
||||
{
|
||||
nameTags += "All Time Steps";
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList timeStepNames = m_case->timeStepStrings();
|
||||
nameTags += timeStepNames[m_timeStep()];
|
||||
}
|
||||
}
|
||||
nameTags += timeStepString();
|
||||
}
|
||||
|
||||
if (m_nameConfig->addCategorization)
|
||||
{
|
||||
if (m_categorization() == FORMATION_CATEGORIZATION)
|
||||
if (m_categorization() == TIME_CATEGORIZATION)
|
||||
{
|
||||
nameTags += QString("Categorized by formations");
|
||||
nameTags += QString("Grouped by Time");
|
||||
}
|
||||
else if (m_categorization() == FORMATION_CATEGORIZATION)
|
||||
{
|
||||
nameTags += QString("Grouped by formations");
|
||||
}
|
||||
else if (m_categorization() == RESULT_CATEGORIZATION && m_categoryProperty->hasResult())
|
||||
{
|
||||
nameTags += QString("Categorized by %1").arg(m_categoryProperty->resultVariableUiShortName());
|
||||
nameTags += QString("Grouped by %1").arg(m_categoryProperty->resultVariableUiShortName());
|
||||
}
|
||||
}
|
||||
|
||||
return nameTags.join(", ");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGridCrossPlotCurveSet::createCurveName() const
|
||||
{
|
||||
if (m_case() == nullptr)
|
||||
{
|
||||
return "Undefined";
|
||||
}
|
||||
|
||||
QStringList nameTags;
|
||||
if (!m_nameConfig->customName().isEmpty())
|
||||
{
|
||||
nameTags += m_nameConfig->customName();
|
||||
}
|
||||
|
||||
if (m_nameConfig->addCaseName())
|
||||
{
|
||||
nameTags += m_case->caseUserDescription();
|
||||
}
|
||||
|
||||
if (m_nameConfig->addAxisVariables())
|
||||
{
|
||||
nameTags += QString("%1 x %2").arg(xAxisName(), yAxisName());
|
||||
}
|
||||
return nameTags.join(", ");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -271,6 +236,59 @@ std::vector<RimGridCrossPlotCurve*> RimGridCrossPlotCurveSet::curves() const
|
||||
return m_crossPlotCurves.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGridCrossPlotCurveSet::caseNameString() const
|
||||
{
|
||||
if (m_case())
|
||||
{
|
||||
return m_case->caseUserDescription();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGridCrossPlotCurveSet::axisVariableString() const
|
||||
{
|
||||
return QString("%1 x %2").arg(xAxisName(), yAxisName());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGridCrossPlotCurveSet::timeStepString() const
|
||||
{
|
||||
// If using time categorization, the time step will be included as a category, so skip it here.
|
||||
if (m_categorization() != RigGridCrossPlotCurveCategorization::TIME_CATEGORIZATION)
|
||||
{
|
||||
if (m_case() && (m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult()))
|
||||
{
|
||||
if (m_timeStep == -1)
|
||||
{
|
||||
return "All Time Steps";
|
||||
}
|
||||
return m_case->timeStepStrings()[m_timeStep];
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RimGridCrossPlotCurveSet::categoryStrings() const
|
||||
{
|
||||
std::vector<QString> categoryNames;
|
||||
for (auto categoryIndexNamePair : m_categoryNames)
|
||||
{
|
||||
categoryNames.push_back(categoryIndexNamePair.second);
|
||||
}
|
||||
return categoryNames;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -290,7 +308,7 @@ void RimGridCrossPlotCurveSet::initAfterRead()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||
{
|
||||
updatePlotName();
|
||||
updateDataSetName();
|
||||
|
||||
detachAllCurves();
|
||||
m_crossPlotCurves.deleteAllChildObjects();
|
||||
@@ -336,11 +354,9 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||
m_crossPlotCurves.push_back(curve);
|
||||
}
|
||||
|
||||
updateCurveNames();
|
||||
|
||||
if (updateParentPlot)
|
||||
{
|
||||
triggerReplotAndTreeRebuild();
|
||||
triggerPlotNameUpdateAndReplot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,9 +404,15 @@ void RimGridCrossPlotCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUi
|
||||
uiOrdering.add(&m_cellFilterView);
|
||||
uiOrdering.add(&m_categorization);
|
||||
|
||||
if (m_categorization() == TIME_CATEGORIZATION &&
|
||||
!(m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult()))
|
||||
{
|
||||
m_categorization = NO_CATEGORIZATION;
|
||||
}
|
||||
|
||||
if (m_categorization() == RESULT_CATEGORIZATION)
|
||||
{
|
||||
caf::PdmUiGroup* categoryGroup = uiOrdering.addNewGroup("Categorization Property");
|
||||
caf::PdmUiGroup* categoryGroup = uiOrdering.addNewGroup("Data Grouping Property");
|
||||
m_categoryProperty->uiOrdering(uiConfigName, *categoryGroup);
|
||||
categoryGroup->add(&m_categoryBinCount);
|
||||
}
|
||||
@@ -445,7 +467,7 @@ void RimGridCrossPlotCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* chang
|
||||
}
|
||||
else if (changedField == &m_isChecked)
|
||||
{
|
||||
triggerReplotAndTreeRebuild();
|
||||
triggerPlotNameUpdateAndReplot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,37 +513,71 @@ QList<caf::PdmOptionItemInfo> RimGridCrossPlotCurveSet::calculateValueOptions(co
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_categorization)
|
||||
{
|
||||
std::set<RigGridCrossPlotCurveCategorization> validOptions = { NO_CATEGORIZATION, TIME_CATEGORIZATION, FORMATION_CATEGORIZATION, RESULT_CATEGORIZATION };
|
||||
if (m_timeStep() != -1 || !(m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult()))
|
||||
{
|
||||
validOptions.erase(TIME_CATEGORIZATION);
|
||||
}
|
||||
for (auto optionItem : validOptions)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(CurveCategorizationEnum::uiText(optionItem), optionItem));
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlotCurveSet::triggerReplotAndTreeRebuild()
|
||||
void RimGridCrossPlotCurveSet::triggerPlotNameUpdateAndReplot()
|
||||
{
|
||||
RimGridCrossPlot* parent;
|
||||
this->firstAncestorOrThisOfTypeAsserted(parent);
|
||||
parent->updateCurveNamesAndPlotTitle();
|
||||
parent->reattachCurvesToQwtAndReplot();
|
||||
parent->updateAllRequiredEditors();
|
||||
parent->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlotCurveSet::updateCurveNames()
|
||||
void RimGridCrossPlotCurveSet::updateCurveNames(bool applyCaseName,
|
||||
bool applyAxisVariables,
|
||||
bool applyTimeStep,
|
||||
bool applyCategories)
|
||||
{
|
||||
for (auto curve : m_crossPlotCurves())
|
||||
{
|
||||
QString categoryName = m_categoryNames[curve->categoryIndex()];
|
||||
QStringList nameTags;
|
||||
|
||||
if (categoryName.isEmpty())
|
||||
if (applyCaseName)
|
||||
{
|
||||
curve->setCustomName(createCurveName());
|
||||
nameTags += caseNameString();
|
||||
}
|
||||
else
|
||||
|
||||
if (applyAxisVariables)
|
||||
{
|
||||
curve->setCustomName(QString("%1 : %2").arg(createCurveName()).arg(categoryName));
|
||||
nameTags += axisVariableString();
|
||||
}
|
||||
|
||||
if (applyTimeStep && !timeStepString().isEmpty())
|
||||
{
|
||||
nameTags += timeStepString();
|
||||
}
|
||||
|
||||
if (applyCategories)
|
||||
{
|
||||
QString categoryName = m_categoryNames[curve->categoryIndex()];
|
||||
if (!categoryName.isEmpty())
|
||||
{
|
||||
nameTags += categoryName;
|
||||
}
|
||||
}
|
||||
|
||||
curve->setCustomName(nameTags.join(", "));
|
||||
curve->updateCurveNameAndUpdatePlotLegendAndTitle();
|
||||
}
|
||||
}
|
||||
@@ -529,12 +585,9 @@ void RimGridCrossPlotCurveSet::updateCurveNames()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlotCurveSet::updatePlotName()
|
||||
void RimGridCrossPlotCurveSet::updateDataSetName()
|
||||
{
|
||||
this->setName(createAutoName());
|
||||
RimGridCrossPlot* parent;
|
||||
this->firstAncestorOrThisOfTypeAsserted(parent);
|
||||
parent->performAutoNameUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -542,9 +595,8 @@ void RimGridCrossPlotCurveSet::updatePlotName()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlotCurveSet::performAutoNameUpdate()
|
||||
{
|
||||
updatePlotName();
|
||||
updateCurveNames();
|
||||
triggerReplotAndTreeRebuild();
|
||||
updateDataSetName();
|
||||
triggerPlotNameUpdateAndReplot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -83,12 +83,18 @@ public:
|
||||
|
||||
int indexInPlot() const;
|
||||
QString createAutoName() const override;
|
||||
QString createCurveName() const;
|
||||
void detachAllCurves();
|
||||
void cellFilterViewUpdated();
|
||||
|
||||
std::vector< RimGridCrossPlotCurve*> curves() const;
|
||||
|
||||
QString caseNameString() const;
|
||||
QString axisVariableString() const;
|
||||
QString timeStepString() const;
|
||||
std::vector<QString> categoryStrings() const;
|
||||
|
||||
void updateCurveNames(bool applyCaseName, bool applyAxisVariables, bool applyTimeStep, bool applyCategories);
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
void onLoadDataAndUpdate(bool updateParentPlot);
|
||||
@@ -99,9 +105,8 @@ protected:
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly) override;
|
||||
void triggerReplotAndTreeRebuild();
|
||||
void updateCurveNames();
|
||||
void updatePlotName();
|
||||
void triggerPlotNameUpdateAndReplot();
|
||||
void updateDataSetName();
|
||||
void performAutoNameUpdate() override;
|
||||
void setDefaults();
|
||||
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
||||
|
||||
Reference in New Issue
Block a user