mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 08:25:03 -05:00
Update Curve Names when changing parameters
This commit is contained in:
1 parent
d1c14f9729
commit
b4d8dc7819
5 files changed
+131
-55
No files matched your search
@@ -156,15 +156,18 @@ void RimGridCrossPlot::calculateZoomRangeAndUpdateQwt()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimGridCrossPlot::reattachCurvesToQwtAndReplot()
|
void RimGridCrossPlot::reattachCurvesToQwtAndReplot()
|
||||||
{
|
{
|
||||||
for (auto curveSet : m_crossPlotCurveSets)
|
if (m_qwtPlot)
|
||||||
{
|
{
|
||||||
curveSet->detachAllCurves();
|
for (auto curveSet : m_crossPlotCurveSets)
|
||||||
if (curveSet->isChecked())
|
|
||||||
{
|
{
|
||||||
curveSet->setParentQwtPlotNoReplot(m_qwtPlot);
|
curveSet->detachAllCurves();
|
||||||
|
if (curveSet->isChecked())
|
||||||
|
{
|
||||||
|
curveSet->setParentQwtPlotNoReplot(m_qwtPlot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
m_qwtPlot->replot();
|
||||||
}
|
}
|
||||||
m_qwtPlot->replot();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -42,39 +42,13 @@
|
|||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurve, "GridCrossPlotCurve");
|
CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurve, "GridCrossPlotCurve");
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimGridCrossPlotCurve::determineColorAndSymbol(int curveSetIndex, int categoryIndex, int nCategories, bool contrastColors)
|
|
||||||
{
|
|
||||||
if (contrastColors)
|
|
||||||
{
|
|
||||||
const caf::ColorTable& colors = RiaColorTables::categoryPaletteColors();
|
|
||||||
int colorIndex = categoryIndex + curveSetIndex; // Offset cycle for each curve set
|
|
||||||
setColor(colors.cycledColor3f(colorIndex));
|
|
||||||
int numColors = (int)colors.size();
|
|
||||||
|
|
||||||
// Retain same symbol until we've gone full cycle in colors
|
|
||||||
int symbolIndex = categoryIndex / numColors;
|
|
||||||
|
|
||||||
RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledSymbolStyle(curveSetIndex, symbolIndex);
|
|
||||||
setSymbol(symbol);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
|
|
||||||
cvf::Color3ub cycledBaseColor = colors.cycledColor3ub(curveSetIndex);
|
|
||||||
caf::ColorTable hueConstColTable = RiaColorTables::createBrightnessBasedColorTable(cycledBaseColor, nCategories);
|
|
||||||
setColor(hueConstColTable.cycledColor3f(categoryIndex));
|
|
||||||
RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledFilledSymbolStyle(curveSetIndex);
|
|
||||||
setSymbol(symbol);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimGridCrossPlotCurve::RimGridCrossPlotCurve()
|
RimGridCrossPlotCurve::RimGridCrossPlotCurve()
|
||||||
|
: m_curveSetIndex(0)
|
||||||
|
, m_categoryIndex(0)
|
||||||
|
, m_categoryCount(0)
|
||||||
{
|
{
|
||||||
CAF_PDM_InitObject("Cross Plot Points", ":/WellLogCurve16x16.png", "", "");
|
CAF_PDM_InitObject("Cross Plot Points", ":/WellLogCurve16x16.png", "", "");
|
||||||
|
|
||||||
@@ -83,6 +57,24 @@ RimGridCrossPlotCurve::RimGridCrossPlotCurve()
|
|||||||
setSymbolSize(6);
|
setSymbolSize(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimGridCrossPlotCurve::setCategoryInformation(int curveSetIndex, int categoryIndex, int categoryCount)
|
||||||
|
{
|
||||||
|
m_curveSetIndex = curveSetIndex;
|
||||||
|
m_categoryIndex = categoryIndex;
|
||||||
|
m_categoryCount = categoryCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimGridCrossPlotCurve::setUseContrastColors(bool useContrastColors)
|
||||||
|
{
|
||||||
|
m_useContrastColors = useContrastColors;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -93,6 +85,52 @@ void RimGridCrossPlotCurve::setSamples(const std::vector<double>& xValues, const
|
|||||||
m_qwtPlotCurve->setSamples(&xValues[0], &yValues[0], static_cast<int>(xValues.size()));
|
m_qwtPlotCurve->setSamples(&xValues[0], &yValues[0], static_cast<int>(xValues.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimGridCrossPlotCurve::updateCurveAppearance()
|
||||||
|
{
|
||||||
|
determineColorAndSymbol();
|
||||||
|
RimPlotCurve::updateCurveAppearance();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
int RimGridCrossPlotCurve::categoryIndex() const
|
||||||
|
{
|
||||||
|
return m_categoryIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimGridCrossPlotCurve::determineColorAndSymbol()
|
||||||
|
{
|
||||||
|
if (m_useContrastColors)
|
||||||
|
{
|
||||||
|
const caf::ColorTable& colors = RiaColorTables::categoryPaletteColors();
|
||||||
|
int colorIndex = m_categoryIndex + m_curveSetIndex; // Offset cycle for each curve set
|
||||||
|
setColor(colors.cycledColor3f(colorIndex));
|
||||||
|
int numColors = (int)colors.size();
|
||||||
|
|
||||||
|
// Retain same symbol until we've gone full cycle in colors
|
||||||
|
int symbolIndex = m_categoryIndex / numColors;
|
||||||
|
|
||||||
|
RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledSymbolStyle(m_curveSetIndex, symbolIndex);
|
||||||
|
setSymbol(symbol);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
|
||||||
|
cvf::Color3ub cycledBaseColor = colors.cycledColor3ub(m_curveSetIndex);
|
||||||
|
caf::ColorTable hueConstColTable = RiaColorTables::createBrightnessBasedColorTable(cycledBaseColor, m_categoryCount);
|
||||||
|
setColor(hueConstColTable.cycledColor3f(m_categoryIndex));
|
||||||
|
RiuQwtSymbol::PointSymbolEnum symbol = RiuQwtSymbol::cycledFilledSymbolStyle(m_curveSetIndex);
|
||||||
|
setSymbol(symbol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -40,14 +40,24 @@ class RimGridCrossPlotCurve : public RimPlotCurve
|
|||||||
public:
|
public:
|
||||||
RimGridCrossPlotCurve();
|
RimGridCrossPlotCurve();
|
||||||
~RimGridCrossPlotCurve() override = default;
|
~RimGridCrossPlotCurve() override = default;
|
||||||
void determineColorAndSymbol(int curveSetIndex, int categoryIndex, int nCategories, bool contrastColors = false);
|
void setCategoryInformation(int curveSetIndex, int categoryIndex, int categoryCount);
|
||||||
|
void setUseContrastColors(bool useContrastColors);
|
||||||
void setSamples(const std::vector<double>& xValues, const std::vector<double>& yValues);
|
void setSamples(const std::vector<double>& xValues, const std::vector<double>& yValues);
|
||||||
|
void updateCurveAppearance() override;
|
||||||
|
int categoryIndex() const;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void determineColorAndSymbol();
|
||||||
void updateZoomInParentPlot() override;
|
void updateZoomInParentPlot() override;
|
||||||
void updateLegendsInPlot() override;
|
void updateLegendsInPlot() override;
|
||||||
QString createCurveAutoName() override;
|
QString createCurveAutoName() override;
|
||||||
void onLoadDataAndUpdate(bool updateParentPlot) override;
|
void onLoadDataAndUpdate(bool updateParentPlot) override;
|
||||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_curveSetIndex;
|
||||||
|
int m_categoryIndex;
|
||||||
|
int m_categoryCount;
|
||||||
|
bool m_useContrastColors;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ QString RimGridCrossPlotCurveSet::createAutoName() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimGridCrossPlotCurveSet::createShortAutoName() const
|
QString RimGridCrossPlotCurveSet::createCurveName() const
|
||||||
{
|
{
|
||||||
if (m_case() == nullptr)
|
if (m_case() == nullptr)
|
||||||
{
|
{
|
||||||
@@ -282,7 +282,7 @@ void RimGridCrossPlotCurveSet::initAfterRead()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||||
{
|
{
|
||||||
performAutoNameUpdate();
|
updatePlotName();
|
||||||
|
|
||||||
detachAllCurves();
|
detachAllCurves();
|
||||||
m_crossPlotCurves.deleteAllChildObjects();
|
m_crossPlotCurves.deleteAllChildObjects();
|
||||||
@@ -315,29 +315,21 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
|||||||
RigEclipseCrossPlotResult result = RigEclipseCrossPlotDataExtractor::extract(
|
RigEclipseCrossPlotResult result = RigEclipseCrossPlotDataExtractor::extract(
|
||||||
eclipseCase->eclipseCaseData(), m_timeStep(), xAddress, yAddress, m_categorization(), catAddress, m_categoryBinCount, timeStepCellVisibilityMap);
|
eclipseCase->eclipseCaseData(), m_timeStep(), xAddress, yAddress, m_categorization(), catAddress, m_categoryBinCount, timeStepCellVisibilityMap);
|
||||||
|
|
||||||
|
m_categoryNames = result.categoryNameMap;
|
||||||
for (const auto& sampleCategory : result.categorySamplesMap)
|
for (const auto& sampleCategory : result.categorySamplesMap)
|
||||||
{
|
{
|
||||||
RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve();
|
RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve();
|
||||||
|
curve->setCategoryInformation(indexInPlot(), sampleCategory.first, (int)result.categorySamplesMap.size());
|
||||||
QString categoryName = result.categoryNameMap[sampleCategory.first];
|
curve->setUseContrastColors(m_categorization() == FORMATION_CATEGORIZATION);
|
||||||
|
|
||||||
if (categoryName.isEmpty())
|
|
||||||
{
|
|
||||||
curve->setCustomName(createShortAutoName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
curve->setCustomName(QString("%1 : %2").arg(createShortAutoName()).arg(categoryName));
|
|
||||||
}
|
|
||||||
curve->determineColorAndSymbol(indexInPlot(), sampleCategory.first, (int)result.categorySamplesMap.size(), m_categorization() == FORMATION_CATEGORIZATION);
|
|
||||||
curve->setSamples(sampleCategory.second.first, sampleCategory.second.second);
|
curve->setSamples(sampleCategory.second.first, sampleCategory.second.second);
|
||||||
curve->updateCurveAppearance();
|
curve->updateCurveAppearance();
|
||||||
curve->updateCurveNameAndUpdatePlotLegendAndTitle();
|
|
||||||
curve->updateUiIconFromPlotSymbol();
|
curve->updateUiIconFromPlotSymbol();
|
||||||
|
|
||||||
m_crossPlotCurves.push_back(curve);
|
m_crossPlotCurves.push_back(curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCurveNames();
|
||||||
|
|
||||||
if (updateParentPlot)
|
if (updateParentPlot)
|
||||||
{
|
{
|
||||||
triggerReplotAndTreeRebuild();
|
triggerReplotAndTreeRebuild();
|
||||||
@@ -508,7 +500,28 @@ void RimGridCrossPlotCurveSet::triggerReplotAndTreeRebuild()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimGridCrossPlotCurveSet::performAutoNameUpdate()
|
void RimGridCrossPlotCurveSet::updateCurveNames()
|
||||||
|
{
|
||||||
|
for (auto curve : m_crossPlotCurves())
|
||||||
|
{
|
||||||
|
QString categoryName = m_categoryNames[curve->categoryIndex()];
|
||||||
|
|
||||||
|
if (categoryName.isEmpty())
|
||||||
|
{
|
||||||
|
curve->setCustomName(createCurveName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curve->setCustomName(QString("%1 : %2").arg(createCurveName()).arg(categoryName));
|
||||||
|
}
|
||||||
|
curve->updateCurveNameAndUpdatePlotLegendAndTitle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimGridCrossPlotCurveSet::updatePlotName()
|
||||||
{
|
{
|
||||||
this->setName(createAutoName());
|
this->setName(createAutoName());
|
||||||
RimGridCrossPlot* parent;
|
RimGridCrossPlot* parent;
|
||||||
@@ -516,6 +529,16 @@ void RimGridCrossPlotCurveSet::performAutoNameUpdate()
|
|||||||
parent->performAutoNameUpdate();
|
parent->performAutoNameUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimGridCrossPlotCurveSet::performAutoNameUpdate()
|
||||||
|
{
|
||||||
|
updatePlotName();
|
||||||
|
updateCurveNames();
|
||||||
|
triggerReplotAndTreeRebuild();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public:
|
|||||||
|
|
||||||
int indexInPlot() const;
|
int indexInPlot() const;
|
||||||
QString createAutoName() const override;
|
QString createAutoName() const override;
|
||||||
QString createShortAutoName() const;
|
QString createCurveName() const;
|
||||||
void detachAllCurves();
|
void detachAllCurves();
|
||||||
void cellFilterViewUpdated();
|
void cellFilterViewUpdated();
|
||||||
|
|
||||||
@@ -99,12 +99,13 @@ protected:
|
|||||||
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||||
bool* useOptionsOnly) override;
|
bool* useOptionsOnly) override;
|
||||||
void triggerReplotAndTreeRebuild();
|
void triggerReplotAndTreeRebuild();
|
||||||
|
void updateCurveNames();
|
||||||
|
void updatePlotName();
|
||||||
void performAutoNameUpdate() override;
|
void performAutoNameUpdate() override;
|
||||||
void setDefaults();
|
void setDefaults();
|
||||||
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
caf::PdmPtrField<RimCase*> m_case;
|
caf::PdmPtrField<RimCase*> m_case;
|
||||||
caf::PdmField<int> m_timeStep;
|
caf::PdmField<int> m_timeStep;
|
||||||
caf::PdmPtrField<RimGridView*> m_cellFilterView;
|
caf::PdmPtrField<RimGridView*> m_cellFilterView;
|
||||||
@@ -118,4 +119,5 @@ private:
|
|||||||
|
|
||||||
caf::PdmChildArrayField<RimGridCrossPlotCurve*> m_crossPlotCurves;
|
caf::PdmChildArrayField<RimGridCrossPlotCurve*> m_crossPlotCurves;
|
||||||
|
|
||||||
|
std::map<int, QString> m_categoryNames;
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user