mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#1842 RFT Plot. Command enabling criteria. Minor refactoring
This commit is contained in:
parent
d283e3aa8c
commit
b6c74ee559
@ -35,6 +35,7 @@
|
||||
#include "RimWellPath.h"
|
||||
#include "RimRftPlotCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
|
||||
#include "RiuMainPlotWindow.h"
|
||||
|
||||
@ -55,9 +56,30 @@ CAF_CMD_SOURCE_INIT(RicNewRftPlotFeature, "RicNewRftPlotFeature");
|
||||
bool RicNewRftPlotFeature::isCommandEnabled()
|
||||
{
|
||||
if (RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot()) return false;
|
||||
return true;
|
||||
int branchIndex;
|
||||
return (selectedWellLogPlotTrack() != nullptr || selectedWellPath() != nullptr || selectedSimulationWell(&branchIndex) != nullptr) && caseAvailable();
|
||||
|
||||
//int branchIndex;
|
||||
|
||||
auto eclWell = selectedPdmObject<RimEclipseWell*>();
|
||||
auto rimWellPath = eclWell == nullptr ? selectedPdmObject<RimWellPath*>() : nullptr;
|
||||
|
||||
bool enable = true;
|
||||
if (eclWell != nullptr)
|
||||
{
|
||||
auto eclCase = selectedPdmObject<RimEclipseResultCase*>();
|
||||
if (eclWell != nullptr)
|
||||
{
|
||||
enable &= RimWellRftPlot::hasPressureData(eclCase);
|
||||
}
|
||||
}
|
||||
else if (rimWellPath)
|
||||
{
|
||||
auto wellLogFile = rimWellPath->wellLogFile();
|
||||
if (wellLogFile != nullptr)
|
||||
{
|
||||
enable &= RimWellRftPlot::hasPressureData(wellLogFile);
|
||||
}
|
||||
}
|
||||
return enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -65,29 +87,26 @@ bool RicNewRftPlotFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewRftPlotFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
if (RicWellLogPlotCurveFeatureImpl::parentWellRftPlot()) return;
|
||||
//if (RicWellLogPlotCurveFeatureImpl::parentWellRftPlot()) return;
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
|
||||
auto rftPlotColl = proj->mainPlotCollection()->rftPlotCollection();
|
||||
if (rftPlotColl)
|
||||
{
|
||||
std::vector<caf::PdmUiItem*> selectedItems;
|
||||
caf::SelectionManager::instance()->selectedItems(selectedItems);
|
||||
|
||||
QString wellName = "(unknown well name)";
|
||||
QString wellName;
|
||||
RimWellPath* wellPath = nullptr;
|
||||
RimEclipseWell* eclipseWell = nullptr;
|
||||
if ((wellPath = dynamic_cast<RimWellPath*>(selectedItems.front())) != nullptr)
|
||||
if ((wellPath = selectedPdmObject<RimWellPath*>()) != nullptr)
|
||||
{
|
||||
wellName = wellPath->name();
|
||||
}
|
||||
else if ((eclipseWell = dynamic_cast<RimEclipseWell*>(selectedItems.front())) != nullptr)
|
||||
else if ((eclipseWell = selectedPdmObject<RimEclipseWell*>()) != nullptr)
|
||||
{
|
||||
wellName = eclipseWell->name();
|
||||
}
|
||||
|
||||
QString plotName = QString("RFT: %1").arg(wellName);
|
||||
QString plotName = QString(RimWellRftPlot::plotNameFormatString()).arg(wellName);
|
||||
|
||||
auto rftPlot = new RimWellRftPlot();
|
||||
rftPlot->setCurrentWellName(wellName);
|
||||
@ -171,3 +190,4 @@ bool RicNewRftPlotFeature::caseAvailable() const
|
||||
|
||||
return cases.size() > 0;
|
||||
}
|
||||
|
||||
|
@ -47,4 +47,26 @@ private:
|
||||
RimWellPath* selectedWellPath() const;
|
||||
RimEclipseWell* selectedSimulationWell(int * branchIndex) const;
|
||||
bool caseAvailable() const;
|
||||
|
||||
template<typename T>
|
||||
T selectedPdmObject() const;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
T RicNewRftPlotFeature::selectedPdmObject() const
|
||||
{
|
||||
T objToFind = nullptr;
|
||||
|
||||
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
|
||||
|
||||
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
|
||||
if (objHandle)
|
||||
{
|
||||
objHandle->firstAncestorOrThisOfType(objToFind);
|
||||
}
|
||||
|
||||
return objToFind;
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ CAF_PDM_SOURCE_INIT(RimWellRftPlot, "WellRftPlot");
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const char RimWellRftPlot::PRESSURE_DATA_NAME[] = "PRESSURE";
|
||||
const char RimWellRftPlot::PLOT_NAME_QFORMAT_STRING[] = "RFT: %1";
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -171,7 +172,7 @@ void RimWellRftPlot::updateWidgetTitleWindowTitle()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellRftPlot::loadDataAndUpdatePlot()
|
||||
void RimWellRftPlot::syncCurvesFromUiSelection()
|
||||
{
|
||||
auto plotTrack = m_wellLogPlot->trackByIndex(0);
|
||||
const auto& allCurveDefs = selectedCurveDefs();
|
||||
@ -204,26 +205,6 @@ void RimWellRftPlot::loadDataAndUpdatePlot()
|
||||
updateCurvesInPlot(allCurveDefs, newCurveDefs, curvesToDelete);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellRftPlot::hasPressureData(RimWellLogFileChannel* channel)
|
||||
{
|
||||
// Todo: read pressure channel names from config/defines
|
||||
return QString::compare(channel->name(), PRESSURE_DATA_NAME) == 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellRftPlot::hasPressureData(RimEclipseResultCase* gridCase)
|
||||
{
|
||||
auto eclipseCaseData = gridCase->eclipseCaseData();
|
||||
size_t resultIndex = eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->
|
||||
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, PRESSURE_DATA_NAME);
|
||||
return resultIndex != cvf::UNDEFINED_SIZE_T;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -239,19 +220,10 @@ std::vector<RimWellPath*> RimWellRftPlot::wellPathsContainingPressure(const QStr
|
||||
{
|
||||
bool hasPressure = false;
|
||||
const auto& wellLogFile = wellPath->wellLogFile();
|
||||
const auto& wellLogChannels = wellLogFile->wellLogChannelNames();
|
||||
|
||||
if (QString::compare(wellLogFile->wellName(), wellName) != 0) continue;
|
||||
|
||||
for (const auto& wellLogChannel : *wellLogChannels)
|
||||
{
|
||||
if (hasPressureData(wellLogChannel))
|
||||
{
|
||||
hasPressure = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasPressure)
|
||||
if (hasPressureData(wellLogFile))
|
||||
wellPaths.push_back(wellPath);
|
||||
}
|
||||
}
|
||||
@ -510,7 +482,7 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set<std::pair<RimWellRftAddre
|
||||
}
|
||||
}
|
||||
}
|
||||
m_wellLogPlot->loadDataAndUpdate();
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -553,6 +525,47 @@ QString RimWellRftPlot::currentWellName() const
|
||||
return m_wellName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellRftPlot::hasPressureData(RimWellLogFile* wellLogFile)
|
||||
{
|
||||
const auto& wellLogChannels = wellLogFile->wellLogChannelNames();
|
||||
for (const auto& wellLogChannel : *wellLogChannels)
|
||||
{
|
||||
if (hasPressureData(wellLogChannel)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellRftPlot::hasPressureData(RimWellLogFileChannel* channel)
|
||||
{
|
||||
// Todo: read pressure channel names from config/defines
|
||||
return QString::compare(channel->name(), PRESSURE_DATA_NAME) == 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellRftPlot::hasPressureData(RimEclipseResultCase* gridCase)
|
||||
{
|
||||
auto eclipseCaseData = gridCase->eclipseCaseData();
|
||||
size_t resultIndex = eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->
|
||||
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, PRESSURE_DATA_NAME);
|
||||
return resultIndex != cvf::UNDEFINED_SIZE_T;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const char* RimWellRftPlot::plotNameFormatString()
|
||||
{
|
||||
return PLOT_NAME_QFORMAT_STRING;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -605,13 +618,21 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
|
||||
{
|
||||
RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
|
||||
|
||||
if (changedField == &m_selectedSources)
|
||||
if (changedField == &m_wellName)
|
||||
{
|
||||
loadDataAndUpdatePlot();
|
||||
setDescription(QString(plotNameFormatString()).arg(m_wellName));
|
||||
}
|
||||
else if (changedField == &m_selectedSources)
|
||||
{
|
||||
syncCurvesFromUiSelection();
|
||||
}
|
||||
else if (changedField == &m_selectedTimeSteps)
|
||||
{
|
||||
loadDataAndUpdatePlot();
|
||||
syncCurvesFromUiSelection();
|
||||
}
|
||||
else if (changedField == &m_showPlotTitle)
|
||||
{
|
||||
//m_wellLogPlot->setShowDescription(m_showPlotTitle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -646,7 +667,7 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
||||
caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroupWithKeyword("Time Steps", "TimeSteps");
|
||||
timeStepsGroup->add(&m_selectedTimeSteps);
|
||||
|
||||
uiOrdering.add(&m_showPlotTitle);
|
||||
//uiOrdering.add(&m_showPlotTitle);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -774,14 +795,3 @@ QWidget* RimWellRftPlot::createViewWidget(QWidget* mainWindowParent)
|
||||
return m_wellLogPlotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3f RimWellRftPlot::getTracerColor(const QString& tracerName)
|
||||
{
|
||||
|
||||
if (tracerName == RIG_FLOW_OIL_NAME) return cvf::Color3f::DARK_GREEN;
|
||||
if (tracerName == RIG_FLOW_GAS_NAME) return cvf::Color3f::DARK_RED;
|
||||
if (tracerName == RIG_FLOW_WATER_NAME) return cvf::Color3f::BLUE;
|
||||
return cvf::Color3f::DARK_GRAY;
|
||||
}
|
||||
|
@ -61,9 +61,7 @@ class RimWellRftPlot : public RimViewWindow
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
static const char PRESSURE_DATA_NAME[];
|
||||
|
||||
public:
|
||||
enum FlowType { ACCUMULATED, INFLOW};
|
||||
static const char PLOT_NAME_QFORMAT_STRING[];
|
||||
|
||||
public:
|
||||
RimWellRftPlot();
|
||||
@ -82,6 +80,11 @@ public:
|
||||
void setCurrentWellName(const QString& currWellName);
|
||||
QString currentWellName() const;
|
||||
|
||||
static bool hasPressureData(RimWellLogFile* wellLogFile);
|
||||
static bool hasPressureData(RimWellLogFileChannel* channel);
|
||||
static bool hasPressureData(RimEclipseResultCase* gridCase);
|
||||
static const char* plotNameFormatString();
|
||||
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
||||
@ -101,10 +104,8 @@ private:
|
||||
void updateEditorsFromCurves();
|
||||
void updateWidgetTitleWindowTitle();
|
||||
|
||||
void loadDataAndUpdatePlot();
|
||||
void syncCurvesFromUiSelection();
|
||||
|
||||
static bool hasPressureData(RimWellLogFileChannel* channel);
|
||||
static bool hasPressureData(RimEclipseResultCase* gridCase);
|
||||
std::vector<RimWellPath*> wellPathsContainingPressure(const QString& wellName) const;
|
||||
std::vector<RimWellLogFileChannel*> getPressureChannelsFromWellPath(const RimWellPath* wellPath) const;
|
||||
RimEclipseResultCase* gridCaseFromCaseId(int caseId);
|
||||
@ -125,14 +126,12 @@ private:
|
||||
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
virtual void deleteViewWidget() override;
|
||||
|
||||
cvf::Color3f getTracerColor(const QString& tracerName);
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showPlotTitle;
|
||||
caf::PdmField<QString> m_userName;
|
||||
|
||||
caf::PdmField<QString> m_wellName;
|
||||
caf::PdmField<int> m_branchIndex; // Temp field
|
||||
caf::PdmField<int> m_branchIndex;
|
||||
caf::PdmField<std::vector<RimWellRftAddress>> m_selectedSources;
|
||||
|
||||
caf::PdmField<std::vector<QDateTime>> m_selectedTimeSteps;
|
||||
|
@ -89,6 +89,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <QMenu>
|
||||
#include "RimRftPlotCollection.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -264,6 +265,10 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicNewWellLogPlotFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimRftPlotCollection*>(uiItem))
|
||||
{
|
||||
commandIds << "RicNewRftPlotFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimSummaryPlotCollection*>(uiItem))
|
||||
{
|
||||
commandIds << "RicPasteSummaryPlotFeature";
|
||||
|
@ -76,24 +76,6 @@ RiuWellRftPlot::RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent)
|
||||
mainLayout->addLayout(plotWidgetsLayout);
|
||||
plotWidgetsLayout->addLayout(rightColumnLayout);
|
||||
|
||||
//m_legendWidget = new RiuNightchartsWidget(this);
|
||||
//new RiuPlotObjectPicker(m_legendWidget, m_plotDefinition->plotLegend());
|
||||
|
||||
//QStringList commandIds;
|
||||
//commandIds << "RicShowTotalAllocationDataFeature";
|
||||
//new RiuContextMenuLauncher(m_legendWidget, commandIds);
|
||||
|
||||
//rightColumnLayout->addWidget(m_legendWidget);
|
||||
//m_legendWidget->showPie(false);
|
||||
|
||||
//QWidget* totalFlowAllocationWidget = m_plotDefinition->totalWellFlowPlot()->createViewWidget(this);
|
||||
//new RiuPlotObjectPicker(totalFlowAllocationWidget, m_plotDefinition->totalWellFlowPlot());
|
||||
//new RiuContextMenuLauncher(totalFlowAllocationWidget, commandIds);
|
||||
|
||||
//rightColumnLayout->addWidget(totalFlowAllocationWidget, Qt::AlignTop);
|
||||
//rightColumnLayout->addWidget(m_plotDefinition->tofAccumulatedPhaseFractionsPlot()->createViewWidget(this), Qt::AlignTop);
|
||||
//rightColumnLayout->addStretch();
|
||||
|
||||
QWidget* wellFlowWidget = m_plotDefinition->wellLogPlot()->createViewWidget(this);
|
||||
|
||||
plotWidgetsLayout->addWidget(wellFlowWidget);
|
||||
@ -144,41 +126,6 @@ void RiuWellRftPlot::hideTitle()
|
||||
m_titleLabel->hide();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//void RiuWellRftPlot::showLegend(bool doShow)
|
||||
//{
|
||||
// if (doShow)
|
||||
// m_legendWidget->show();
|
||||
// else
|
||||
// m_legendWidget->hide();
|
||||
//}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//void RiuWellRftPlot::addLegendItem(const QString& name, const cvf::Color3f& color, float value)
|
||||
//{
|
||||
// QColor sliceColor(color.rByte(), color.gByte(), color.bByte());
|
||||
//
|
||||
// m_legendWidget->addItem(name, sliceColor, value);
|
||||
// m_legendWidget->updateGeometry();
|
||||
// m_legendWidget->update();
|
||||
//}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//void RiuWellRftPlot::clearLegend()
|
||||
//{
|
||||
// m_legendWidget->clear();
|
||||
//}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -192,17 +139,6 @@ QSize RiuWellRftPlot::minimumSizeHint() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellRftPlot::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
//QMenu menu;
|
||||
//QStringList commandIds;
|
||||
|
||||
//commandIds << "RicShowContributingWellsFromPlotFeature";
|
||||
|
||||
//RimContextCommandBuilder::appendCommandsToMenu(commandIds, &menu);
|
||||
|
||||
//if (menu.actions().size() > 0)
|
||||
//{
|
||||
// menu.exec(event->globalPos());
|
||||
//}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -219,4 +155,3 @@ QSize RiuWellRftPlot::sizeHint() const
|
||||
void RiuWellRftPlot::setDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -53,10 +53,6 @@ public:
|
||||
|
||||
void showTitle(const QString& title);
|
||||
void hideTitle();
|
||||
// void showLegend(bool doShow);
|
||||
// void addLegendItem(const QString& name, const cvf::Color3f& color, float value);
|
||||
// void clearLegend();
|
||||
|
||||
|
||||
protected:
|
||||
virtual QSize sizeHint() const override;
|
||||
|
Loading…
Reference in New Issue
Block a user