mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#778 Display unit on Y-Axis. Added unit to legend. Cosmetics on Curve Filter Prop-panel
This commit is contained in:
@@ -350,6 +350,19 @@ bool RifReaderEclipseSummary::hasAddress(const RifEclipseSummaryAddress& resultA
|
|||||||
return (it != m_resultAddressToErtNodeIdx.end());
|
return (it != m_resultAddressToErtNodeIdx.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::string RifReaderEclipseSummary::unitName(const RifEclipseSummaryAddress& resultAddress)
|
||||||
|
{
|
||||||
|
int variableIndex = indexFromAddress(resultAddress);
|
||||||
|
|
||||||
|
if(variableIndex < 0) return "";
|
||||||
|
|
||||||
|
const smspec_node_type * ertSumVarNode = ecl_smspec_iget_node(eclSmSpec, variableIndex);
|
||||||
|
return smspec_node_get_unit(ertSumVarNode);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
std::vector<time_t> timeSteps() const;
|
std::vector<time_t> timeSteps() const;
|
||||||
|
|
||||||
bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values);
|
bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values);
|
||||||
|
std::string unitName(const RifEclipseSummaryAddress& resultAddress);
|
||||||
|
|
||||||
// TODO: Move this to a tools class with static members
|
// TODO: Move this to a tools class with static members
|
||||||
static std::vector<QDateTime> fromTimeT(const std::vector<time_t>& timeSteps);
|
static std::vector<QDateTime> fromTimeT(const std::vector<time_t>& timeSteps);
|
||||||
|
|||||||
@@ -220,6 +220,16 @@ void RimSummaryCurve::setSummaryAddress(const RifEclipseSummaryAddress& address)
|
|||||||
m_curveVariable->setAddress(address);
|
m_curveVariable->setAddress(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::string RimSummaryCurve::unitName()
|
||||||
|
{
|
||||||
|
RifReaderEclipseSummary* reader = summaryReader();
|
||||||
|
if (reader) return reader->unitName(this->summaryAddress());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -287,7 +297,7 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions(const caf::
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimSummaryCurve::createCurveAutoName()
|
QString RimSummaryCurve::createCurveAutoName()
|
||||||
{
|
{
|
||||||
return QString::fromStdString( m_curveVariable->address().uiText());
|
return QString::fromStdString( m_curveVariable->address().uiText()) + "["+ this->unitName().c_str() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -361,7 +371,7 @@ void RimSummaryCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
|||||||
void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||||
{
|
{
|
||||||
this->RimPlotCurve::fieldChangedByUi(changedField,oldValue,newValue);
|
this->RimPlotCurve::fieldChangedByUi(changedField,oldValue,newValue);
|
||||||
|
|
||||||
if(changedField == &m_uiFilterResultSelection)
|
if(changedField == &m_uiFilterResultSelection)
|
||||||
{
|
{
|
||||||
if (0 <= m_uiFilterResultSelection() && m_uiFilterResultSelection() < summaryReader()->allResultAddresses().size())
|
if (0 <= m_uiFilterResultSelection() && m_uiFilterResultSelection() < summaryReader()->allResultAddresses().size())
|
||||||
@@ -374,6 +384,16 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->loadDataAndUpdate();
|
this->loadDataAndUpdate();
|
||||||
|
|
||||||
|
RimSummaryPlot* plot = nullptr;
|
||||||
|
firstAnchestorOrThisOfType(plot);
|
||||||
|
plot->updateYAxisUnit();
|
||||||
|
}
|
||||||
|
else if (&m_showCurve == changedField)
|
||||||
|
{
|
||||||
|
RimSummaryPlot* plot = nullptr;
|
||||||
|
firstAnchestorOrThisOfType(plot);
|
||||||
|
plot->updateYAxisUnit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
|
|
||||||
RifEclipseSummaryAddress summaryAddress();
|
RifEclipseSummaryAddress summaryAddress();
|
||||||
void setSummaryAddress(const RifEclipseSummaryAddress& address);
|
void setSummaryAddress(const RifEclipseSummaryAddress& address);
|
||||||
|
std::string unitName();
|
||||||
protected:
|
protected:
|
||||||
// RimPlotCurve overrides
|
// RimPlotCurve overrides
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ RimSummaryCurveFilter::RimSummaryCurveFilter()
|
|||||||
m_selectedSummaryCases.uiCapability()->setAutoAddingOptionFromValue(false);
|
m_selectedSummaryCases.uiCapability()->setAutoAddingOptionFromValue(false);
|
||||||
m_selectedSummaryCases.xmlCapability()->setIOWritable(false);
|
m_selectedSummaryCases.xmlCapability()->setIOWritable(false);
|
||||||
m_selectedSummaryCases.xmlCapability()->setIOReadable(false);
|
m_selectedSummaryCases.xmlCapability()->setIOReadable(false);
|
||||||
|
m_selectedSummaryCases.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&m_selectedVariableDisplayField, "SelectedVariableDisplayVar", "Variables", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&m_selectedVariableDisplayField, "SelectedVariableDisplayVar", "Variables", "", "", "");
|
||||||
m_selectedVariableDisplayField.xmlCapability()->setIOWritable(false);
|
m_selectedVariableDisplayField.xmlCapability()->setIOWritable(false);
|
||||||
@@ -173,7 +174,7 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurveFilter::calculateValueOptions(const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryCurveFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
void RimSummaryCurveFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||||
{
|
{
|
||||||
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Summary Vector");
|
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Summary Vectors");
|
||||||
curveDataGroup->add(&m_selectedSummaryCases);
|
curveDataGroup->add(&m_selectedSummaryCases);
|
||||||
curveDataGroup->add(&m_selectedVariableDisplayField);
|
curveDataGroup->add(&m_selectedVariableDisplayField);
|
||||||
|
|
||||||
@@ -202,6 +203,10 @@ void RimSummaryCurveFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedF
|
|||||||
syncCurvesFromUiSelection();
|
syncCurvesFromUiSelection();
|
||||||
loadDataAndUpdate();
|
loadDataAndUpdate();
|
||||||
m_applyButtonField = false;
|
m_applyButtonField = false;
|
||||||
|
|
||||||
|
RimSummaryPlot* plot = nullptr;
|
||||||
|
firstAnchestorOrThisOfType(plot);
|
||||||
|
plot->updateYAxisUnit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,3 +425,16 @@ void RimSummaryCurveFilter::loadDataAndUpdate()
|
|||||||
|
|
||||||
syncUiSelectionFromCurves();
|
syncUiSelectionFromCurves();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::set<std::string> RimSummaryCurveFilter::unitNames()
|
||||||
|
{
|
||||||
|
std::set<std::string> unitNames;
|
||||||
|
for(RimSummaryCurve* curve: m_curves)
|
||||||
|
{
|
||||||
|
if (curve->isCurveVisible()) unitNames.insert( curve->unitName());
|
||||||
|
}
|
||||||
|
return unitNames;
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
void detachQwtCurves();
|
void detachQwtCurves();
|
||||||
|
|
||||||
RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const;
|
RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const;
|
||||||
|
std::set<std::string> unitNames();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void syncCurvesFromUiSelection();
|
void syncCurvesFromUiSelection();
|
||||||
|
|||||||
@@ -95,6 +95,36 @@ void RimSummaryPlot::handleViewerDeletion()
|
|||||||
updateConnectedEditors();
|
updateConnectedEditors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryPlot::updateYAxisUnit()
|
||||||
|
{
|
||||||
|
if (!m_qwtPlot) return;
|
||||||
|
|
||||||
|
std::set<std::string> unitNames;
|
||||||
|
|
||||||
|
for(RimSummaryCurve* rimCurve: m_curves)
|
||||||
|
{
|
||||||
|
if (rimCurve->isCurveVisible()) unitNames.insert(rimCurve->unitName());
|
||||||
|
}
|
||||||
|
|
||||||
|
for(RimSummaryCurveFilter* curveFilter: m_curveFilters)
|
||||||
|
{
|
||||||
|
std::set<std::string> filterUnitNames = curveFilter->unitNames();
|
||||||
|
unitNames.insert(filterUnitNames.begin(), filterUnitNames.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString assembledYAxisText;
|
||||||
|
|
||||||
|
for (const std::string& unitName : unitNames)
|
||||||
|
{
|
||||||
|
assembledYAxisText += "[" + QString::fromStdString(unitName) + "] ";
|
||||||
|
}
|
||||||
|
|
||||||
|
m_qwtPlot->setYAxisTitle(assembledYAxisText);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -106,6 +136,7 @@ void RimSummaryPlot::addCurve(RimSummaryCurve* curve)
|
|||||||
if (m_qwtPlot)
|
if (m_qwtPlot)
|
||||||
{
|
{
|
||||||
curve->setParentQwtPlot(m_qwtPlot);
|
curve->setParentQwtPlot(m_qwtPlot);
|
||||||
|
this->updateYAxisUnit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,6 +152,7 @@ void RimSummaryPlot::addCurveFilter(RimSummaryCurveFilter* curveFilter)
|
|||||||
if(m_qwtPlot)
|
if(m_qwtPlot)
|
||||||
{
|
{
|
||||||
curveFilter->setParentQwtPlot(m_qwtPlot);
|
curveFilter->setParentQwtPlot(m_qwtPlot);
|
||||||
|
this->updateYAxisUnit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,6 +205,8 @@ void RimSummaryPlot::loadDataAndUpdate()
|
|||||||
curve->loadDataAndUpdate();
|
curve->loadDataAndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->updateYAxisUnit();
|
||||||
|
|
||||||
// Todo: Update zoom
|
// Todo: Update zoom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
|
|
||||||
void loadDataAndUpdate();
|
void loadDataAndUpdate();
|
||||||
void handleViewerDeletion();
|
void handleViewerDeletion();
|
||||||
|
void updateYAxisUnit();
|
||||||
protected:
|
protected:
|
||||||
// Overridden PDM methods
|
// Overridden PDM methods
|
||||||
virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; }
|
virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; }
|
||||||
|
|||||||
@@ -69,6 +69,16 @@ RimSummaryPlot* RiuSummaryQwtPlot::ownerPlotDefinition()
|
|||||||
return m_plotDefinition;
|
return m_plotDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuSummaryQwtPlot::setYAxisTitle(const QString& title)
|
||||||
|
{
|
||||||
|
QwtText axisTitleY = axisTitle(QwtPlot::yLeft);
|
||||||
|
axisTitleY.setText(title);
|
||||||
|
setAxisTitle(QwtPlot::yLeft, axisTitleY);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public:
|
|||||||
virtual ~RiuSummaryQwtPlot();
|
virtual ~RiuSummaryQwtPlot();
|
||||||
|
|
||||||
RimSummaryPlot* ownerPlotDefinition();
|
RimSummaryPlot* ownerPlotDefinition();
|
||||||
|
void setYAxisTitle(const QString& title);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool eventFilter(QObject* watched, QEvent* event);
|
virtual bool eventFilter(QObject* watched, QEvent* event);
|
||||||
|
|||||||
Reference in New Issue
Block a user