mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#775 Added user editable curve display name to summary cases
This commit is contained in:
parent
adb6c74f3a
commit
ab4829b2d9
@ -85,6 +85,8 @@ QString RimGridSummaryCase::summaryHeaderFilename() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridSummaryCase::initAfterRead()
|
||||
{
|
||||
RimSummaryCase::updateOptionSensitivity();
|
||||
|
||||
updateUiNames();
|
||||
}
|
||||
|
||||
@ -95,7 +97,7 @@ void RimGridSummaryCase::updateUiNames()
|
||||
{
|
||||
m_summaryHeaderFilename = summaryHeaderFilename();
|
||||
|
||||
m_userName = baseName();
|
||||
m_userName = curveDisplayName() + " - " + baseName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -68,6 +68,8 @@ public:
|
||||
void setColor(const cvf::Color3f& color);
|
||||
void setLineStyle(LineStyleEnum lineStyle);
|
||||
bool isCurveVisible() const;
|
||||
|
||||
void updateCurveName();
|
||||
QString curveName() const { return m_curveName; }
|
||||
|
||||
protected:
|
||||
@ -77,7 +79,6 @@ protected:
|
||||
virtual void onLoadDataAndUpdate() = 0;
|
||||
|
||||
void updateCurvePresentation();
|
||||
void updateCurveName();
|
||||
void updateCurveVisibility();
|
||||
void updateCurveAppearance();
|
||||
|
||||
|
@ -17,9 +17,15 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimEclipseCase.h"
|
||||
|
||||
#include "RigSummaryCaseData.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
|
||||
CAF_PDM_ABSTRACT_SOURCE_INIT(RimSummaryCase,"SummaryCase");
|
||||
|
||||
@ -30,6 +36,8 @@ RimSummaryCase::RimSummaryCase()
|
||||
{
|
||||
CAF_PDM_InitObject("Summary Case",":/Cases16x16.png","","");
|
||||
|
||||
CAF_PDM_InitField(&curveDisplayName, "CurveDisplayName", QString("Curve Display Name"), "Curve Display Name", "", "", "");
|
||||
CAF_PDM_InitField(&autoCurveDisplayName, "AutoCurveDisplayName", true, "Auto Curve Display Name", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -55,5 +63,42 @@ QString RimSummaryCase::caseName()
|
||||
{
|
||||
QFileInfo caseFileName(this->summaryHeaderFilename());
|
||||
|
||||
return caseFileName.completeBaseName();
|
||||
return caseFileName.completeBaseName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &autoCurveDisplayName)
|
||||
{
|
||||
if (autoCurveDisplayName)
|
||||
{
|
||||
RimSummaryCaseCollection* summaryCaseCollection = NULL;
|
||||
this->firstAnchestorOrThisOfType(summaryCaseCollection);
|
||||
if (summaryCaseCollection)
|
||||
{
|
||||
curveDisplayName = summaryCaseCollection->uniqueShortNameForCase(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RimProject* proj = NULL;
|
||||
this->firstAnchestorOrThisOfType(proj);
|
||||
|
||||
RimMainPlotCollection* mainPlotColl = proj->mainPlotCollection();
|
||||
RimSummaryPlotCollection* summaryPlotColl = mainPlotColl->summaryPlotCollection();
|
||||
|
||||
summaryPlotColl->updateSummaryNameHasChanged();
|
||||
|
||||
updateOptionSensitivity();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCase::updateOptionSensitivity()
|
||||
{
|
||||
curveDisplayName.uiCapability()->setUiReadOnly(autoCurveDisplayName);
|
||||
}
|
||||
|
@ -46,7 +46,16 @@ public:
|
||||
|
||||
RigSummaryCaseData* caseData() { return m_summaryCaseData.p(); }
|
||||
|
||||
protected:
|
||||
caf::PdmField<QString> curveDisplayName;
|
||||
caf::PdmField<bool> autoCurveDisplayName;
|
||||
|
||||
void updateOptionSensitivity();
|
||||
|
||||
protected:
|
||||
cvf::ref<RigSummaryCaseData> m_summaryCaseData;
|
||||
|
||||
private:
|
||||
// Overridden PDM methods
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
};
|
||||
|
@ -128,9 +128,50 @@ RimGridSummaryCase* RimSummaryCaseCollection::createAndAddSummaryCaseFromEclipse
|
||||
{
|
||||
RimGridSummaryCase* newSumCase = new RimGridSummaryCase();
|
||||
newSumCase->setAssociatedEclipseCase(eclResCase);
|
||||
newSumCase->curveDisplayName = uniqueShortNameForCase(newSumCase);
|
||||
newSumCase->updateOptionSensitivity();
|
||||
this->m_cases.push_back(newSumCase);
|
||||
return newSumCase;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryCaseCollection::uniqueShortNameForCase(RimSummaryCase* summaryCase)
|
||||
{
|
||||
QStringList allAutoShortNames;
|
||||
|
||||
for (RimSummaryCase* sumCase : m_cases)
|
||||
{
|
||||
if (sumCase && sumCase != summaryCase)
|
||||
{
|
||||
allAutoShortNames.push_back(sumCase->curveDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
bool foundUnique = false;
|
||||
|
||||
QString caseName = summaryCase->caseName();
|
||||
QString candidateBase = caseName.left(2);
|
||||
QString candidate = candidateBase;
|
||||
int autoNumber = 0;
|
||||
while (!foundUnique)
|
||||
{
|
||||
bool foundExisting = false;
|
||||
for (QString autoName : allAutoShortNames)
|
||||
{
|
||||
if (autoName.left(candidate.size()) == candidate)
|
||||
{
|
||||
candidate = candidateBase + QString::number(autoNumber++);
|
||||
foundExisting = true;
|
||||
}
|
||||
}
|
||||
|
||||
foundUnique = !foundExisting;
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
|
||||
void loadAllSummaryCaseData();
|
||||
|
||||
QString uniqueShortNameForCase(RimSummaryCase* summaryCase);
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimSummaryCase*> m_cases;
|
||||
};
|
||||
|
@ -167,7 +167,7 @@ RimSummaryCurve::RimSummaryCurve()
|
||||
m_curveVariable = new RimSummaryAddress;
|
||||
|
||||
// Add some space before name to indicate these belong to the Auto Name field
|
||||
CAF_PDM_InitField(&m_addCaseNameToCurveName, "AddCaseNameToCurveName", false, " Case Name", "", "", "");
|
||||
CAF_PDM_InitField(&m_addCaseNameToCurveName, "AddCaseNameToCurveName", true, " Case Name", "", "", "");
|
||||
|
||||
m_symbolSkipPixelDistance = 10.0f;
|
||||
|
||||
@ -309,7 +309,7 @@ QString RimSummaryCurve::createCurveAutoName()
|
||||
generatedCurveName += ", ";
|
||||
}
|
||||
|
||||
generatedCurveName += m_summaryCase->caseName();
|
||||
generatedCurveName += m_summaryCase->curveDisplayName();
|
||||
}
|
||||
|
||||
return generatedCurveName;
|
||||
|
@ -484,3 +484,15 @@ void RimSummaryCurveFilter::createCurvesFromCurveDefinitions(const std::set<std:
|
||||
m_curves.push_back(curve);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveFilter::updateCaseNameHasChanged()
|
||||
{
|
||||
for (RimSummaryCurve* curve : m_curves)
|
||||
{
|
||||
curve->updateCurveName();
|
||||
curve->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const;
|
||||
std::set<std::string> unitNames();
|
||||
|
||||
void updateCaseNameHasChanged();
|
||||
private:
|
||||
void syncCurvesFromUiSelection();
|
||||
|
||||
|
@ -135,6 +135,23 @@ void RimSummaryPlot::updateYAxisUnit()
|
||||
m_qwtPlot->setYAxisTitle(assembledYAxisText);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::updateCaseNameHasChanged()
|
||||
{
|
||||
for (RimSummaryCurve* curve : m_curves)
|
||||
{
|
||||
curve->updateCurveName();
|
||||
curve->updateConnectedEditors();
|
||||
}
|
||||
|
||||
for (RimSummaryCurveFilter* curveFilter : m_curveFilters)
|
||||
{
|
||||
curveFilter->updateCaseNameHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
void loadDataAndUpdate();
|
||||
void handleViewerDeletion();
|
||||
void updateYAxisUnit();
|
||||
void updateCaseNameHasChanged();
|
||||
|
||||
QWidget* viewer();
|
||||
|
||||
|
@ -119,3 +119,14 @@ RifReaderEclipseSummary* RimSummaryPlotCollection::createSummaryFileReader(const
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotCollection::updateSummaryNameHasChanged()
|
||||
{
|
||||
for (RimSummaryPlot* plot : m_summaryPlots)
|
||||
{
|
||||
plot->updateCaseNameHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
|
||||
caf::PdmChildArrayField<RimSummaryPlot*> m_summaryPlots;
|
||||
|
||||
void updateSummaryNameHasChanged();
|
||||
private:
|
||||
RifReaderEclipseSummary* createSummaryFileReader(const QString& eclipseCaseFilePathBasename);
|
||||
RifReaderEclipseSummary* getOrCreateSummaryFileReader(const QString& eclipseCaseFilePathBasename);
|
||||
|
Loading…
Reference in New Issue
Block a user