Refactor WellLogPlot, RftPlot, PlotPlot and WellAllocationPlot

This commit is contained in:
Gaute Lindkvist
2019-09-04 15:51:44 +02:00
parent 2795855621
commit a03435b2fe
18 changed files with 357 additions and 820 deletions

View File

@@ -73,20 +73,21 @@ const char RimWellRftPlot::PLOT_NAME_QFORMAT_STRING[] = "RFT: %1";
///
//--------------------------------------------------------------------------------------------------
RimWellRftPlot::RimWellRftPlot()
: RimWellLogPlot()
{
CAF_PDM_InitObject("Well Allocation Plot", ":/RFTPlot16x16.png", "", "");
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("RFT Plot"), "Name", "", "", "");
m_userName.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&m_showPlotTitle_OBSOLETE, "ShowPlotTitle", false, "Show Plot Title", "", "", "");
m_showPlotTitle_OBSOLETE.xmlCapability()->setIOWritable(false);
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "");
CAF_PDM_InitField(&m_showStatisticsCurves, "ShowStatisticsCurves", true, "Show Statistics Curves", "", "", "");
CAF_PDM_InitField(&m_showEnsembleCurves, "ShowEnsembleCurves", true, "Show Ensemble Curves", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellLogPlot, "WellLog", "Well Log", "", "", "");
m_wellLogPlot.uiCapability()->setUiHidden(true);
m_wellLogPlot = new RimWellLogPlot();
m_wellLogPlot->setDepthType(RimWellLogPlot::TRUE_VERTICAL_DEPTH);
CAF_PDM_InitFieldNoDefault(&m_wellLogPlot_OBSOLETE, "WellLog", "Well Log", "", "", "");
m_wellLogPlot_OBSOLETE.uiCapability()->setUiHidden(true);
m_wellLogPlot_OBSOLETE = new RimWellLogPlot();
m_wellLogPlot_OBSOLETE->setDepthType(RimWellLogPlot::TRUE_VERTICAL_DEPTH);
m_wellLogPlot_OBSOLETE.xmlCapability()->setIOWritable(false);
CAF_PDM_InitFieldNoDefault(&m_wellPathNameOrSimWellName, "WellName", "Well Name", "", "", "");
CAF_PDM_InitField(&m_branchIndex, "BranchIndex", 0, "Branch Index", "", "", "");
@@ -124,18 +125,6 @@ RimWellRftPlot::~RimWellRftPlot()
deleteViewWidget();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::deleteViewWidget()
{
if (m_wellLogPlotWidget)
{
m_wellLogPlotWidget->deleteLater();
m_wellLogPlotWidget = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -153,7 +142,7 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve)
if (m_showStatisticsCurves)
{
cvf::Color3f backgroundColor =
RiaColorTools::fromQColorTo3f(m_wellLogPlot->trackByIndex(0)->viewer()->canvasBackground().color());
RiaColorTools::fromQColorTo3f(trackByIndex(0)->viewer()->canvasBackground().color());
currentColor = RiaColorTools::blendCvfColors(backgroundColor, currentColor, 2, 1);
}
}
@@ -184,12 +173,12 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve)
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::updateFormationsOnPlot() const
{
if (m_wellLogPlot->trackCount() > 0)
if (trackCount() > 0)
{
RimProject* proj = RiaApplication::instance()->project();
RimWellPath* wellPath = proj->wellPathByName(m_wellPathNameOrSimWellName);
RimCase* formationNamesCase = m_wellLogPlot->trackByIndex(0)->formationNamesCase();
RimCase* formationNamesCase = trackByIndex(0)->formationNamesCase();
if (!formationNamesCase)
{
@@ -205,11 +194,11 @@ void RimWellRftPlot::updateFormationsOnPlot() const
if (wellPath)
{
m_wellLogPlot->trackByIndex(0)->setAndUpdateWellPathFormationNamesData(formationNamesCase, wellPath);
trackByIndex(0)->setAndUpdateWellPathFormationNamesData(formationNamesCase, wellPath);
}
else
{
m_wellLogPlot->trackByIndex(0)->setAndUpdateSimWellFormationNamesAndBranchData(
trackByIndex(0)->setAndUpdateSimWellFormationNamesAndBranchData(
formationNamesCase, associatedSimWellName(), m_branchIndex, m_branchDetection);
}
}
@@ -304,32 +293,12 @@ void RimWellRftPlot::updateEditorsFromCurves()
m_selectedTimeSteps = std::vector<QDateTime>(selectedTimeSteps.begin(), selectedTimeSteps.end());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::updateWidgetTitleWindowTitle()
{
updateMdiWindowTitle();
if (m_wellLogPlotWidget)
{
if (m_showPlotTitle)
{
m_wellLogPlotWidget->showTitle(m_userName);
}
else
{
m_wellLogPlotWidget->hideTitle();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::syncCurvesFromUiSelection()
{
RimWellLogTrack* plotTrack = m_wellLogPlot->trackByIndex(0);
RimWellLogTrack* plotTrack = trackByIndex(0);
const std::set<RiaRftPltCurveDefinition>& allCurveDefs = selectedCurveDefs();
const std::set<RiaRftPltCurveDefinition>& curveDefsInPlot = curveDefsFromCurves();
@@ -388,7 +357,7 @@ std::set<RiaRftPltCurveDefinition> RimWellRftPlot::curveDefsFromCurves() const
{
std::set<RiaRftPltCurveDefinition> curveDefs;
RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0);
RimWellLogTrack* const plotTrack = trackByIndex(0);
for (RimWellLogCurve* const curve : plotTrack->curvesVector())
{
curveDefs.insert(RimWellPlotTools::curveDefFromCurve(curve));
@@ -404,7 +373,7 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set<RiaRftPltCurveDefinition>
const std::set<RimWellLogCurve*>& curvesToDelete)
{
const QString simWellName = associatedSimWellName();
RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0);
RimWellLogTrack* const plotTrack = trackByIndex(0);
// Delete curves
plotTrack->deleteAllCurves();
@@ -548,15 +517,15 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set<RiaRftPltCurveDefinition>
}
}
if (m_wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH)
if (depthType() == RimWellLogPlot::MEASURED_DEPTH)
{
assignWellPathToExtractionCurves();
}
m_wellLogPlot->loadDataAndUpdate();
loadDataAndUpdate();
if (plotTrack->curveCount())
{
m_wellLogPlot->zoomAll();
zoomAll();
}
}
@@ -582,30 +551,6 @@ std::vector<RifDataSourceForRftPlt> RimWellRftPlot::selectedSourcesExpanded() co
return sources;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimWellRftPlot::viewWidget()
{
return m_wellLogPlotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::zoomAll()
{
m_wellLogPlot()->zoomAll();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlot* RimWellRftPlot::wellLogPlot() const
{
return m_wellLogPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -647,7 +592,7 @@ const char* RimWellRftPlot::plotNameFormatString()
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::deleteCurvesAssosicatedWithObservedData(const RimObservedFmuRftData* observedFmuRftData)
{
for (auto track : m_wellLogPlot->tracks())
for (auto track : m_wellLogPlot_OBSOLETE->tracks())
{
auto curves = track->curvesVector();
for (auto curve : curves)
@@ -779,7 +724,7 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
m_branchIndex = 0;
RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0);
RimWellLogTrack* const plotTrack = m_wellLogPlot_OBSOLETE->trackByIndex(0);
if (plotTrack)
{
plotTrack->deleteAllCurves();
@@ -808,7 +753,7 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
syncCurvesFromUiSelection();
}
else if (changedField == &m_showPlotTitle)
else if (changedField == &m_showTitleInPlot)
{
// m_wellLogPlot->setShowDescription(m_showPlotTitle);
}
@@ -822,28 +767,11 @@ void RimWellRftPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering
uiTreeOrdering.skipRemainingChildren(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QImage RimWellRftPlot::snapshotWindowContent()
{
QImage image;
if (m_wellLogPlotWidget)
{
QPixmap pix = QPixmap::grabWidget(m_wellLogPlotWidget);
image = pix.toImage();
}
return image;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_userName);
uiOrdering.add(&m_wellPathNameOrSimWellName);
uiOrdering.add(&m_showStatisticsCurves);
uiOrdering.add(&m_showEnsembleCurves);
@@ -869,20 +797,18 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroupWithKeyword("Time Steps", "TimeSteps");
timeStepsGroup->add(&m_selectedTimeSteps);
if (m_wellLogPlot && m_wellLogPlot->trackCount() > 0)
if (trackCount() > 0)
{
RimWellLogTrack* track = m_wellLogPlot->trackByIndex(0);
RimWellLogTrack* track = m_wellLogPlot_OBSOLETE->trackByIndex(0);
track->uiOrderingForRftPltFormations(uiOrdering);
caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup("Legend and Axis");
legendAndAxisGroup->setCollapsedByDefault(true);
m_wellLogPlot->uiOrderingForPlotSettings(*legendAndAxisGroup);
uiOrderingForPlotSettings(*legendAndAxisGroup);
track->uiOrderingForXAxisSettings(*legendAndAxisGroup);
m_wellLogPlot->uiOrderingForDepthAxis(*legendAndAxisGroup);
uiOrderingForDepthAxis(*legendAndAxisGroup);
}
uiOrdering.skipRemainingFields(true);
@@ -962,24 +888,6 @@ void RimWellRftPlot::calculateValueOptionsForWells(QList<caf::PdmOptionItemInfo>
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::setDescription(const QString& description)
{
m_userName = description;
updateWidgetTitleWindowTitle();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellRftPlot::description() const
{
return m_userName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -987,9 +895,9 @@ void RimWellRftPlot::onLoadDataAndUpdate()
{
if (m_isOnLoad)
{
if (m_wellLogPlot->trackCount() > 0)
if (trackCount() > 0)
{
m_wellLogPlot->trackByIndex(0)->setShowFormations(true);
trackByIndex(0)->setShowFormations(true);
}
m_isOnLoad = false;
@@ -998,17 +906,33 @@ void RimWellRftPlot::onLoadDataAndUpdate()
updateMdiWindowVisibility();
updateFormationsOnPlot();
if (m_wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH)
if (depthType() == RimWellLogPlot::MEASURED_DEPTH)
{
assignWellPathToExtractionCurves();
}
m_wellLogPlot->loadDataAndUpdate();
RimWellLogPlot::loadDataAndUpdate();
updateEditorsFromCurves();
updateWidgetTitleWindowTitle();
}
// applyInitialSelections();
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::initAfterRead()
{
if (m_wellLogPlot_OBSOLETE)
{
RimWellLogPlot& wellLogPlot = dynamic_cast<RimWellLogPlot&>(*this);
wellLogPlot = std::move(*m_wellLogPlot_OBSOLETE.value());
m_wellLogPlot_OBSOLETE = nullptr;
}
if (m_showPlotTitle_OBSOLETE() && !m_showTitleInPlot())
{
m_showTitleInPlot = m_showPlotTitle_OBSOLETE();
}
RimWellLogPlot::initAfterRead();
}
//--------------------------------------------------------------------------------------------------
@@ -1021,7 +945,7 @@ void RimWellRftPlot::assignWellPathToExtractionCurves()
if (wellPath)
{
for (RimWellLogCurve* curve : m_wellLogPlot->trackByIndex(0)->curvesVector())
for (RimWellLogCurve* curve : trackByIndex(0)->curvesVector())
{
auto extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>(curve);
if (extractionCurve)
@@ -1038,9 +962,8 @@ void RimWellRftPlot::assignWellPathToExtractionCurves()
//--------------------------------------------------------------------------------------------------
QWidget* RimWellRftPlot::createViewWidget(QWidget* mainWindowParent)
{
m_wellLogPlotWidget = new RiuWellRftPlot(this, mainWindowParent);
return m_wellLogPlotWidget;
m_viewer = new RiuWellRftPlot(this, mainWindowParent);
return m_viewer;
}
//--------------------------------------------------------------------------------------------------
@@ -1127,6 +1050,14 @@ void RimWellRftPlot::defineCurveColorsAndSymbols(const std::set<RiaRftPltCurveDe
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::onDepthTypeChanged()
{
loadDataAndUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------