mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1842 RFT Plot. Show plot when new RFT plot command is triggered
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "RimView.h"
|
||||
#include "RimWellLogExtractionCurve.h"
|
||||
#include "RimWellRftPlot.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
#include "RimWellLogTrack.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimRftPlotCollection.h"
|
||||
@@ -74,26 +75,39 @@ void RicNewRftPlotFeature::onActionTriggered(bool isChecked)
|
||||
std::vector<caf::PdmUiItem*> selectedItems;
|
||||
caf::SelectionManager::instance()->selectedItems(selectedItems);
|
||||
|
||||
// Todo: support other classes as well
|
||||
RimWellPath* simWellPath = dynamic_cast<RimWellPath*>(selectedItems.front());
|
||||
QString wellName = "(unknown well name)";
|
||||
RimWellPath* wellPath = nullptr;
|
||||
RimEclipseWell* eclipseWell = nullptr;
|
||||
if ((wellPath = dynamic_cast<RimWellPath*>(selectedItems.front())) != nullptr)
|
||||
{
|
||||
wellName = wellPath->name();
|
||||
}
|
||||
else if ((eclipseWell = dynamic_cast<RimEclipseWell*>(selectedItems.front())) != nullptr)
|
||||
{
|
||||
wellName = eclipseWell->name();
|
||||
}
|
||||
|
||||
QString plotName = QString("RFT: %1").arg(simWellPath != nullptr ? simWellPath->name() : QString("(Unknown)"));
|
||||
QString plotName = QString("RFT: %1").arg(wellName);
|
||||
|
||||
auto plot = new RimWellRftPlot();
|
||||
plot->setCurrentWellName(simWellPath->name());
|
||||
rftPlotColl->addPlot(plot);
|
||||
auto rftPlot = new RimWellRftPlot();
|
||||
rftPlot->setCurrentWellName(wellName);
|
||||
|
||||
plot->setDescription(plotName);
|
||||
plot->loadDataAndUpdate();
|
||||
auto plotTrack = new RimWellLogTrack();
|
||||
rftPlot->wellLogPlot()->addTrack(plotTrack);
|
||||
plotTrack->setDescription(QString("Track %1").arg(rftPlot->wellLogPlot()->trackCount()));
|
||||
|
||||
rftPlotColl->updateConnectedEditors();
|
||||
rftPlotColl->addPlot(rftPlot);
|
||||
rftPlot->setDescription(plotName);
|
||||
|
||||
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow();
|
||||
if (mainPlotWindow)
|
||||
{
|
||||
mainPlotWindow->selectAsCurrentItem(plot);
|
||||
mainPlotWindow->setExpanded(plot, true);
|
||||
mainPlotWindow->selectAsCurrentItem(rftPlot);
|
||||
mainPlotWindow->setExpanded(rftPlot, true);
|
||||
}
|
||||
|
||||
rftPlot->loadDataAndUpdate();
|
||||
rftPlotColl->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,8 @@ RimWellRftPlot::RimWellRftPlot()
|
||||
m_selectedTimeSteps.xmlCapability()->setIOReadable(false);
|
||||
m_selectedTimeSteps.xmlCapability()->setIOWritable(false);
|
||||
m_selectedTimeSteps.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
//this->setAsPlotMdiWindow();
|
||||
|
||||
this->setAsPlotMdiWindow();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -206,13 +207,16 @@ QList<caf::PdmOptionItemInfo> RimWellRftPlot::calculateValueOptions(const caf::P
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_selectedSources)
|
||||
{
|
||||
calculateValueOptionsForObservedData(options);
|
||||
options.push_back(caf::PdmOptionItemInfo::createHeader("RFT Cases", true));
|
||||
options.push_back(caf::PdmOptionItemInfo::createHeader("Grid Cases", true));
|
||||
|
||||
options.push_back(caf::PdmOptionItemInfo::createHeader("Observed Data", true));
|
||||
calculateValueOptionsForObservedData(options, 1);
|
||||
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_selectedTimeSteps)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo("TimeStep 1", "TimeStep 1"));
|
||||
options.push_back(caf::PdmOptionItemInfo("TimeStep 2", "TimeStep 2"));
|
||||
calculateValueOptionsForTimeSteps(options);
|
||||
}
|
||||
|
||||
return options;
|
||||
@@ -223,7 +227,7 @@ QList<caf::PdmOptionItemInfo> RimWellRftPlot::calculateValueOptions(const caf::P
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
//RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
|
||||
RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
|
||||
|
||||
//if (changedField == &m_userName ||
|
||||
// changedField == &m_showPlotTitle)
|
||||
@@ -317,7 +321,7 @@ void RimWellRftPlot::calculateValueOptionsForWells(QList<caf::PdmOptionItemInfo>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellRftPlot::calculateValueOptionsForObservedData(QList<caf::PdmOptionItemInfo>& options)
|
||||
void RimWellRftPlot::calculateValueOptionsForObservedData(QList<caf::PdmOptionItemInfo>& options, int level)
|
||||
{
|
||||
auto project = RiaApplication::instance()->project();
|
||||
|
||||
@@ -333,9 +337,43 @@ void RimWellRftPlot::calculateValueOptionsForObservedData(QList<caf::PdmOptionIt
|
||||
{
|
||||
auto name = channel->name();
|
||||
|
||||
if (QString::compare(name, "GR") == 0) // Test code
|
||||
if (QString::compare(name, "PRESSURE") == 0) // Todo: Move constant to config/defines
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(name, name));
|
||||
auto item = caf::PdmOptionItemInfo(name, name);
|
||||
if (level > 0)
|
||||
{
|
||||
item.setLevel(level);
|
||||
}
|
||||
options.push_back(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellRftPlot::calculateValueOptionsForTimeSteps(QList<caf::PdmOptionItemInfo>& options)
|
||||
{
|
||||
auto project = RiaApplication::instance()->project();
|
||||
|
||||
for (RimOilField* oilField : project->oilFields)
|
||||
{
|
||||
auto wellPathColl = oilField->wellPathCollection();
|
||||
for (const auto& wellPath : wellPathColl->wellPaths)
|
||||
{
|
||||
const auto& wellLogFile = wellPath->wellLogFile();
|
||||
const auto& channels = wellLogFile->wellLogChannelNames();
|
||||
|
||||
for (const auto& channel : *channels)
|
||||
{
|
||||
auto name = channel->name();
|
||||
|
||||
if (QString::compare(name, "PRESSURE") == 0) // Todo: Move constant to config/defines
|
||||
{
|
||||
auto item = caf::PdmOptionItemInfo(wellLogFile->date(), name);
|
||||
options.push_back(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,9 @@ protected:
|
||||
|
||||
private:
|
||||
void calculateValueOptionsForWells(QList<caf::PdmOptionItemInfo>& options);
|
||||
void calculateValueOptionsForObservedData(QList<caf::PdmOptionItemInfo>& options);
|
||||
void calculateValueOptionsForObservedData(QList<caf::PdmOptionItemInfo>& options, int level);
|
||||
void calculateValueOptionsForTimeSteps(QList<caf::PdmOptionItemInfo>& options);
|
||||
|
||||
void updateFromWell();
|
||||
void updateWidgetTitleWindowTitle();
|
||||
|
||||
|
||||
@@ -45,6 +45,11 @@ RimWellLogFile::RimWellLogFile()
|
||||
m_wellName.uiCapability()->setUiHidden(true);
|
||||
m_wellName.xmlCapability()->setIOWritable(false);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_date, "Date", "", "", "", "");
|
||||
m_date.uiCapability()->setUiReadOnly(true);
|
||||
m_date.uiCapability()->setUiHidden(true);
|
||||
m_date.xmlCapability()->setIOWritable(false);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_fileName, "FileName", "Filename", "", "", "");
|
||||
m_fileName.uiCapability()->setUiReadOnly(true);
|
||||
|
||||
@@ -131,6 +136,7 @@ bool RimWellLogFile::readFile(QString* errorMessage)
|
||||
}
|
||||
|
||||
m_wellName = m_wellLogDataFile->wellName();
|
||||
m_date = m_wellLogDataFile->date();
|
||||
|
||||
m_wellLogChannelNames.deleteAllChildObjects();
|
||||
|
||||
@@ -162,3 +168,11 @@ QString RimWellLogFile::wellName() const
|
||||
{
|
||||
return m_wellName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellLogFile::date() const
|
||||
{
|
||||
return m_date;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
bool readFile(QString* errorMessage);
|
||||
|
||||
QString wellName() const;
|
||||
QString date() const;
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; }
|
||||
|
||||
RigWellLogFile* wellLogFile() { return m_wellLogDataFile.p(); }
|
||||
@@ -66,4 +67,5 @@ private:
|
||||
caf::PdmField<QString> m_wellName;
|
||||
caf::PdmField<QString> m_fileName;
|
||||
caf::PdmField<QString> m_name;
|
||||
caf::PdmField<QString> m_date;
|
||||
};
|
||||
|
||||
@@ -147,6 +147,15 @@ QString RigWellLogFile::wellName() const
|
||||
return QString::fromStdString(m_wellLogFile->GetWellName());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RigWellLogFile::date() const
|
||||
{
|
||||
CVF_ASSERT(m_wellLogFile);
|
||||
return QString::fromStdString(m_wellLogFile->GetDate());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
bool open(const QString& fileName, QString* errorMessage);
|
||||
|
||||
QString wellName() const;
|
||||
QString date() const;
|
||||
QStringList wellLogChannelNames() const;
|
||||
|
||||
std::vector<double> depthValues() const;
|
||||
|
||||
@@ -79,12 +79,12 @@ RiuWellRftPlot::RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent)
|
||||
//m_legendWidget = new RiuNightchartsWidget(this);
|
||||
//new RiuPlotObjectPicker(m_legendWidget, m_plotDefinition->plotLegend());
|
||||
|
||||
QStringList commandIds;
|
||||
commandIds << "RicShowTotalAllocationDataFeature";
|
||||
new RiuContextMenuLauncher(m_legendWidget, commandIds);
|
||||
//QStringList commandIds;
|
||||
//commandIds << "RicShowTotalAllocationDataFeature";
|
||||
//new RiuContextMenuLauncher(m_legendWidget, commandIds);
|
||||
|
||||
rightColumnLayout->addWidget(m_legendWidget);
|
||||
m_legendWidget->showPie(false);
|
||||
//rightColumnLayout->addWidget(m_legendWidget);
|
||||
//m_legendWidget->showPie(false);
|
||||
|
||||
//QWidget* totalFlowAllocationWidget = m_plotDefinition->totalWellFlowPlot()->createViewWidget(this);
|
||||
//new RiuPlotObjectPicker(totalFlowAllocationWidget, m_plotDefinition->totalWellFlowPlot());
|
||||
@@ -148,35 +148,35 @@ void RiuWellRftPlot::hideTitle()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellRftPlot::showLegend(bool doShow)
|
||||
{
|
||||
if (doShow)
|
||||
m_legendWidget->show();
|
||||
else
|
||||
m_legendWidget->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::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();
|
||||
}
|
||||
//void RiuWellRftPlot::clearLegend()
|
||||
//{
|
||||
// m_legendWidget->clear();
|
||||
//}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -192,17 +192,17 @@ QSize RiuWellRftPlot::minimumSizeHint() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellRftPlot::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
QMenu menu;
|
||||
QStringList commandIds;
|
||||
//QMenu menu;
|
||||
//QStringList commandIds;
|
||||
|
||||
commandIds << "RicShowContributingWellsFromPlotFeature";
|
||||
//commandIds << "RicShowContributingWellsFromPlotFeature";
|
||||
|
||||
RimContextCommandBuilder::appendCommandsToMenu(commandIds, &menu);
|
||||
//RimContextCommandBuilder::appendCommandsToMenu(commandIds, &menu);
|
||||
|
||||
if (menu.actions().size() > 0)
|
||||
{
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
//if (menu.actions().size() > 0)
|
||||
//{
|
||||
// menu.exec(event->globalPos());
|
||||
//}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -48,14 +48,14 @@ public:
|
||||
RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent = NULL);
|
||||
virtual ~RiuWellRftPlot();
|
||||
|
||||
RimWellRftPlot* ownerPlotDefinition();
|
||||
RimWellRftPlot* ownerPlotDefinition();
|
||||
virtual RimViewWindow* ownerViewWindow() const override;
|
||||
|
||||
void showTitle(const QString& title);
|
||||
void hideTitle();
|
||||
void showLegend(bool doShow);
|
||||
void addLegendItem(const QString& name, const cvf::Color3f& color, float value);
|
||||
void clearLegend();
|
||||
// void showLegend(bool doShow);
|
||||
// void addLegendItem(const QString& name, const cvf::Color3f& color, float value);
|
||||
// void clearLegend();
|
||||
|
||||
|
||||
protected:
|
||||
@@ -69,6 +69,5 @@ private:
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimWellRftPlot> m_plotDefinition;
|
||||
QPointer<RiuNightchartsWidget> m_legendWidget;
|
||||
QPointer<QLabel> m_titleLabel;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user