Merged Well Communication Lines into dev

This commit is contained in:
Jacob Støren 2017-03-14 19:22:18 +01:00
commit 7f1d88e487
13 changed files with 177 additions and 38 deletions

View File

@ -92,13 +92,12 @@ QList<caf::PdmOptionItemInfo> RicSelectViewUI::calculateValueOptions(const caf::
if (fieldNeedingOptions == &m_selectedView)
{
QIcon icon;
if (m_currentCase)
{
icon = m_currentCase->uiCapability()->uiIcon();
for (RimView* v : m_currentCase->views())
{
QString displayName = m_currentCase->caseUserDescription() + ": " + v->name;
QIcon icon = v->uiCapability()->uiIcon();
QString displayName = v->name;
options.push_back(caf::PdmOptionItemInfo(displayName, v, false, icon));
}

View File

@ -41,18 +41,12 @@ CAF_CMD_SOURCE_INIT(RicShowWellAllocationPlotFeature, "RicShowWellAllocationPlot
//--------------------------------------------------------------------------------------------------
bool RicShowWellAllocationPlotFeature::isCommandEnabled()
{
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return false;
std::vector<RimEclipseWell*> collection;
caf::SelectionManager::instance()->objectsByType(&collection);
RimEclipseResultCase* eclCase = nullptr;
activeView->firstAncestorOrThisOfType(eclCase);
if (eclCase)
if (collection.size() > 0)
{
RimFlowDiagSolution* defaultFlowDiagSolution = eclCase->defaultFlowDiagSolution();
if (defaultFlowDiagSolution)
{
return true;
}
return true;
}
return false;

View File

@ -58,8 +58,8 @@ namespace caf
template<>
void AppEnum<RimWellAllocationPlot::FlowType>::setUp()
{
addItem(RimWellAllocationPlot::ACCUMULATED, "ACCUMULATED", "Well Flow");
addItem(RimWellAllocationPlot::INFLOW, "INFLOW", "In Flow");
addItem(RimWellAllocationPlot::ACCUMULATED, "ACCUMULATED", "Accumulated");
addItem(RimWellAllocationPlot::INFLOW, "INFLOW", "Inflow Rates");
setDefault(RimWellAllocationPlot::ACCUMULATED);
}

View File

@ -30,6 +30,9 @@
#include "qwt_plot.h"
#include "cvfMath.h"
#include <cmath>
//==================================================================================================
@ -152,10 +155,10 @@ void RimWellFlowRateCurve::updateCurveAppearance()
void RimWellFlowRateCurve::updateStackedPlotData()
{
RimWellLogPlot* wellLogPlot;
firstAncestorOrThisOfType(wellLogPlot);
firstAncestorOrThisOfTypeAsserted(wellLogPlot);
RimWellLogTrack* wellLogTrack;
firstAncestorOrThisOfType(wellLogTrack);
firstAncestorOrThisOfTypeAsserted(wellLogTrack);
bool isFirstTrack = (wellLogTrack == wellLogPlot->trackByIndex(0));
@ -186,6 +189,29 @@ void RimWellFlowRateCurve::updateStackedPlotData()
depthValues.insert(depthValues.begin(), depthValues[0]);
stackedValues.insert(stackedValues.begin(), 0.0);
polyLineStartStopIndices.front().second += 1;
if (wellLogPlot->trackCount() > 1 && isFirstTrack)
{
// Add a dummy negative depth value to make the contribution
// from other branches connected to well head visible
double availableMinDepth;
double availableMaxDepth;
wellLogPlot->availableDepthRange(&availableMinDepth, &availableMaxDepth);
double depthSpan = 0.1 * cvf::Math::abs(availableMinDepth - availableMaxDepth);
// Round off value to floored decade
double logDecValue = log10(depthSpan);
logDecValue = cvf::Math::floor(logDecValue);
depthSpan = pow(10.0, logDecValue);
double dummyNegativeDepthValue = depthValues.back() - depthSpan;
depthValues.push_back(dummyNegativeDepthValue);
stackedValues.push_back(stackedValues.back());
polyLineStartStopIndices.front().second += 1;
}
}
// Add a dummy point for the zeroth connection to make the "end" distribution show better.
@ -233,10 +259,11 @@ RimWellAllocationPlot* RimWellFlowRateCurve::wellAllocationPlot() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellFlowRateCurve::setFlowValuesPrDepthValue(const QString& tracerName, const std::vector<double>& connectionNumbers, const std::vector<double>& flowRates)
void RimWellFlowRateCurve::setFlowValuesPrDepthValue(const QString& tracerName, const std::vector<double>& depthValues, const std::vector<double>& flowRates)
{
m_curveData = new RigWellLogCurveData;
m_curveData->setValuesAndMD(flowRates, connectionNumbers, RimDefines::UNIT_NONE, false);
m_curveData->setValuesAndMD(flowRates, depthValues, RimDefines::UNIT_NONE, false);
m_tracerName = tracerName;
}

View File

@ -38,7 +38,7 @@ public:
RimWellFlowRateCurve();
virtual ~RimWellFlowRateCurve();
void setFlowValuesPrDepthValue(const QString& tracerName , const std::vector<double>& connectionNumbers, const std::vector<double>& flowRates);
void setFlowValuesPrDepthValue(const QString& tracerName , const std::vector<double>& depthValues, const std::vector<double>& flowRates);
void updateStackedPlotData();
virtual QString wellName() const override;

View File

@ -22,12 +22,14 @@
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigFlowDiagResults.h"
#include "RigFormationNames.h"
#include "RimEclipseCase.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h"
#include "RimFlowDiagSolution.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimViewController.h"
@ -37,8 +39,8 @@
#include "cvfAssert.h"
#include "cvfMath.h"
#include "RigFlowDiagResults.h"
#include "RimFlowDiagSolution.h"
#include <cmath> // Needed for HUGE_VAL on Linux
namespace caf
@ -74,6 +76,11 @@ RimEclipsePropertyFilter::RimEclipsePropertyFilter()
resultDefinition.uiCapability()->setUiHidden(true);
resultDefinition.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitField(&m_rangeLabelText, "Dummy_keyword", QString("Range Type"), "Range Type", "", "", "");
m_rangeLabelText.xmlCapability()->setIOReadable(false);
m_rangeLabelText.xmlCapability()->setIOWritable(false);
m_rangeLabelText.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&m_lowerBound, "LowerBound", 0.0, "Min", "", "", "");
m_lowerBound.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
@ -180,6 +187,8 @@ void RimEclipsePropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUi
// Fields declared in RimCellFilter
uiOrdering.add(&filterMode);
uiOrdering.add(&m_rangeLabelText);
if (resultDefinition->hasCategoryResult())
{
@ -199,6 +208,7 @@ void RimEclipsePropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUi
uiOrdering.setForgetRemainingFields(true);
updateReadOnlyStateOfAllFields();
updateRangeLabel();
}
//--------------------------------------------------------------------------------------------------
@ -226,9 +236,26 @@ void RimEclipsePropertyFilter::updateReadOnlyStateOfAllFields()
objFields.push_back(&(resultDefinition->m_porosityModelUiField));
objFields.push_back(&(resultDefinition->m_resultVariableUiField));
for (size_t i = 0; i < objFields.size(); i++)
for (auto f : objFields)
{
objFields[i]->uiCapability()->setUiReadOnly(readOnlyState);
if (f == &m_rangeLabelText) continue;
f->uiCapability()->setUiReadOnly(readOnlyState);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::updateRangeLabel()
{
if (resultDefinition->resultType() == RimDefines::FLOW_DIAGNOSTICS)
{
m_rangeLabelText = "Current Timestep";
}
else
{
m_rangeLabelText = "All Timesteps";
}
}
@ -237,7 +264,7 @@ void RimEclipsePropertyFilter::updateReadOnlyStateOfAllFields()
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilter::isPropertyFilterControlled()
{
RimView* rimView = NULL;
RimView* rimView = nullptr;
firstAncestorOrThisOfType(rimView);
CVF_ASSERT(rimView);
@ -293,8 +320,8 @@ void RimEclipsePropertyFilter::computeResultValueRange()
{
CVF_ASSERT(parentContainer());
double min = 0.0;
double max = 0.0;
double min = HUGE_VAL;
double max = -HUGE_VAL;
clearCategories();
@ -309,7 +336,7 @@ void RimEclipsePropertyFilter::computeResultValueRange()
if ( resultDefinition->flowDiagSolution() )
{
RigFlowDiagResults* results = resultDefinition->flowDiagSolution()->flowDiagResults();
results->minMaxScalarValues(resAddr, timeStep, &max, &max);
results->minMaxScalarValues(resAddr, timeStep, &min, &max);
if ( resultDefinition->hasCategoryResult() )
{
@ -352,6 +379,81 @@ void RimEclipsePropertyFilter::computeResultValueRange()
m_upperBound.uiCapability()->setUiName(QString("Max (%1)").arg(max));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::updateFromCurrentTimeStep()
{
if (resultDefinition->resultType() != RimDefines::FLOW_DIAGNOSTICS)
{
return;
}
double threshold = 1e-6;
bool followMin = false;
if (fabs(m_lowerBound - m_minimumResultValue) < threshold || m_minimumResultValue == HUGE_VAL)
{
followMin = true;
}
bool followMax = false;
if (fabs(m_upperBound - m_maximumResultValue) < threshold || m_maximumResultValue == -HUGE_VAL)
{
followMax = true;
}
double min = HUGE_VAL;
double max = -HUGE_VAL;
clearCategories();
RimView* view = nullptr;
this->firstAncestorOrThisOfTypeAsserted(view);
int timeStep = view->currentTimeStep();
RigFlowDiagResultAddress resAddr = resultDefinition->flowDiagResAddress();
if (resultDefinition->flowDiagSolution())
{
RigFlowDiagResults* results = resultDefinition->flowDiagSolution()->flowDiagResults();
results->minMaxScalarValues(resAddr, timeStep, &min, &max);
if (resultDefinition->hasCategoryResult())
{
setCategoryNames(resultDefinition->flowDiagSolution()->tracerNames());
}
}
if (min == HUGE_VAL && max == -HUGE_VAL)
{
m_lowerBound.uiCapability()->setUiName(QString("Min (inf)"));
m_upperBound.uiCapability()->setUiName(QString("Max (inf)"));
}
else
{
m_maximumResultValue = max;
m_minimumResultValue = min;
if (followMin)
{
m_lowerBound = min;
}
if (followMax)
{
m_upperBound = m_maximumResultValue;
}
m_lowerBound.uiCapability()->setUiName(QString("Min (%1)").arg(min));
m_upperBound.uiCapability()->setUiName(QString("Max (%1)").arg(max));
}
m_lowerBound.uiCapability()->updateConnectedEditors();
m_upperBound.uiCapability()->updateConnectedEditors();
updateFilterName();
this->name.uiCapability()->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -53,11 +53,11 @@ public:
void setToDefaultValues();
void updateFilterName();
void computeResultValueRange();
void updateFromCurrentTimeStep();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void initAfterRead();
protected:
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering);
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName);
@ -70,9 +70,11 @@ private:
void updateActiveState();
void updateReadOnlyStateOfAllFields();
void updateRangeLabel();
bool isPropertyFilterControlled();
private:
caf::PdmField<QString> m_rangeLabelText;
caf::PdmField<double> m_lowerBound;
caf::PdmField<double> m_upperBound;

View File

@ -167,3 +167,14 @@ void RimEclipsePropertyFilterCollection::updateIconState()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::updateFromCurrentTimeStep()
{
for (RimEclipsePropertyFilter* cellFilter : propertyFilters())
{
cellFilter->updateFromCurrentTimeStep();
}
}

View File

@ -51,6 +51,7 @@ public:
void loadAndInitializePropertyFilters();
void updateIconState();
void updateFromCurrentTimeStep();
protected:
// Overridden methods

View File

@ -471,6 +471,8 @@ void RimEclipseView::createDisplayModel()
//--------------------------------------------------------------------------------------------------
void RimEclipseView::updateCurrentTimeStep()
{
m_propertyFilterCollection()->updateFromCurrentTimeStep();
updateLegends(); // To make sure the scalar mappers are set up correctly
std::vector<RivCellSetEnum> geometriesToRecolor;

View File

@ -298,14 +298,8 @@ void RimView::scheduleCreateDisplayModelAndRedraw()
//--------------------------------------------------------------------------------------------------
void RimView::setCurrentTimeStepAndUpdate(int frameIndex)
{
m_currentTimeStep = frameIndex;
clampCurrentTimestep();
setCurrentTimeStep(frameIndex);
this->hasUserRequestedAnimation = true;
if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters())
{
m_currentReservoirCellVisibility = NULL;
}
this->updateCurrentTimeStep();
}

View File

@ -48,7 +48,7 @@
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cvfAssert.h"
#include "cafAssert.h"
#include <QAction>
@ -109,7 +109,7 @@ void CmdAddItemFeature::onActionTriggered(bool isChecked)
}
else
{
CVF_ASSERT(0);
CAF_ASSERT(0);
}
}
}

View File

@ -69,6 +69,10 @@ public:
m_proxyDoubleField = 0;
if (!(m_proxyDoubleField == 3)) { std::cout << "Double is not 3 " << std::endl; }
CAF_PDM_InitFieldNoDefault(&m_multiSelectList, "SelectedItems", " ", "", "", "");
m_multiSelectList.xmlCapability()->setIOReadable(false);
m_multiSelectList.xmlCapability()->setIOWritable(false);
m_multiSelectList.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
}
@ -77,6 +81,9 @@ public:
caf::PdmField<QString> m_textField;
caf::PdmProxyValueField<double> m_proxyDoubleField;
caf::PdmField<std::vector<QString> > m_multiSelectList;
caf::PdmField<bool> m_toggleField;
virtual caf::PdmFieldHandle* objectToggleField()
{