diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp index 0aee07182e..b707fb358d 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp @@ -113,8 +113,8 @@ void RicNewPltPlotFeature::onActionTriggered(bool isChecked) pltPlot->setCurrentWellName(wellPathName); RimWellLogTrack* plotTrack = new RimWellLogTrack(); - pltPlot->wellLogPlot()->addTrack(plotTrack); - plotTrack->setDescription(QString("Track %1").arg(pltPlot->wellLogPlot()->trackCount())); + pltPlot->addTrack(plotTrack); + plotTrack->setDescription(QString("Track %1").arg(pltPlot->trackCount())); pltPlotColl->addPlot(pltPlot); pltPlot->setDescription(plotName); diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp index 4d0b01efe4..a341b30ba8 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp @@ -74,8 +74,8 @@ void RicNewRftPlotFeature::onActionTriggered(bool isChecked) rftPlot->setSimWellOrWellPathName(wellName); RimWellLogTrack* plotTrack = new RimWellLogTrack(); - rftPlot->wellLogPlot()->addTrack(plotTrack); - plotTrack->setDescription(QString("Track %1").arg(rftPlot->wellLogPlot()->trackCount())); + rftPlot->addTrack(plotTrack); + plotTrack->setDescription(QString("Track %1").arg(rftPlot->trackCount())); rftPlotColl->addPlot(rftPlot); rftPlot->setDescription(plotName); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 66bbe90973..97e84a7497 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -40,14 +40,15 @@ #include "RimTotalWellAllocationPlot.h" #include "RimWellAllocationPlotLegend.h" #include "RimWellFlowRateCurve.h" +#include "RimWellLogFile.h" #include "RimWellLogPlot.h" +#include "RimWellPlotTools.h" #include "RimWellLogTrack.h" +#include "RiuWellLogPlot.h" #include "RiuPlotMainWindow.h" #include "RiuWellAllocationPlot.h" #include "RiuWellLogTrack.h" -#include "RimWellLogFile.h" -#include "RimWellPlotTools.h" CAF_PDM_SOURCE_INIT(RimWellAllocationPlot, "WellAllocationPlot"); @@ -72,13 +73,12 @@ void AppEnum::setUp() /// //-------------------------------------------------------------------------------------------------- RimWellAllocationPlot::RimWellAllocationPlot() + : RimWellLogPlot() { CAF_PDM_InitObject("Well Allocation Plot", ":/WellAllocPlot16x16.png", "", ""); - CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Flow Diagnostics Plot"), "Name", "", "", ""); - m_userName.uiCapability()->setUiReadOnly(true); - - CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", ""); + CAF_PDM_InitField(&m_showPlotTitle_OBSOLETE, "ShowPlotTitle", true, "Show Plot Title", "", "", ""); + m_showPlotTitle_OBSOLETE.xmlCapability()->setIOWritable(false); CAF_PDM_InitField(&m_branchDetection, "BranchDetection", true, "Branch Detection", "", "Compute branches based on how simulation well cells are organized", ""); @@ -92,13 +92,14 @@ RimWellAllocationPlot::RimWellAllocationPlot() CAF_PDM_InitFieldNoDefault(&m_flowType, "FlowType", "Flow Type", "", "", ""); CAF_PDM_InitField(&m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions", "", "", ""); CAF_PDM_InitField(&m_smallContributionsThreshold, "SmallContributionsThreshold", 0.005, "Threshold", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_accumulatedWellFlowPlot, "AccumulatedWellFlowPlot", "Accumulated Well Flow", "", "", ""); - m_accumulatedWellFlowPlot.uiCapability()->setUiHidden(true); - m_accumulatedWellFlowPlot = new RimWellLogPlot; - m_accumulatedWellFlowPlot->setDepthUnit(RiaDefines::UNIT_NONE); - m_accumulatedWellFlowPlot->setDepthType(RimWellLogPlot::CONNECTION_NUMBER); - m_accumulatedWellFlowPlot->setTrackLegendsVisible(false); - m_accumulatedWellFlowPlot->uiCapability()->setUiIconFromResourceString(":/WellFlowPlot16x16.png"); + CAF_PDM_InitFieldNoDefault(&m_accumulatedWellFlowPlot_OBSOLETE, "AccumulatedWellFlowPlot", "Accumulated Well Flow", "", "", ""); + m_accumulatedWellFlowPlot_OBSOLETE.uiCapability()->setUiHidden(true); + m_accumulatedWellFlowPlot_OBSOLETE = new RimWellLogPlot; + m_accumulatedWellFlowPlot_OBSOLETE->setDepthUnit(RiaDefines::UNIT_NONE); + m_accumulatedWellFlowPlot_OBSOLETE->setDepthType(RimWellLogPlot::CONNECTION_NUMBER); + m_accumulatedWellFlowPlot_OBSOLETE->setTrackLegendsVisible(false); + m_accumulatedWellFlowPlot_OBSOLETE->uiCapability()->setUiIconFromResourceString(":/WellFlowPlot16x16.png"); + m_accumulatedWellFlowPlot_OBSOLETE.xmlCapability()->setIOWritable(false); CAF_PDM_InitFieldNoDefault(&m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow", "", "", ""); m_totalWellAllocationPlot.uiCapability()->setUiHidden(true); @@ -122,7 +123,6 @@ RimWellAllocationPlot::~RimWellAllocationPlot() { removeMdiWindowFromMdiArea(); - delete m_accumulatedWellFlowPlot(); delete m_totalWellAllocationPlot(); delete m_tofAccumulatedPhaseFractionsPlot(); @@ -153,18 +153,6 @@ void RimWellAllocationPlot::setFromSimulationWell(RimSimWellInView* simWell) onLoadDataAndUpdate(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellAllocationPlot::deleteViewWidget() -{ - if (m_wellAllocationPlotWidget) - { - m_wellAllocationPlotWidget->deleteLater(); - m_wellAllocationPlotWidget = nullptr; - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -173,22 +161,22 @@ void RimWellAllocationPlot::updateFromWell() // Delete existing tracks { std::vector tracks; - accumulatedWellFlowPlot()->descendantsIncludingThisOfType(tracks); + descendantsIncludingThisOfType(tracks); for (RimWellLogTrack* t : tracks) { - accumulatedWellFlowPlot()->removeTrack(t); + removeTrack(t); delete t; } } - CVF_ASSERT(accumulatedWellFlowPlot()->trackCount() == 0); + CVF_ASSERT(trackCount() == 0); QString description; if (m_flowType() == ACCUMULATED) description = "Accumulated Flow"; if (m_flowType() == INFLOW) description = "Inflow Rates"; - accumulatedWellFlowPlot()->setDescription(description + " (" + m_wellName + ")"); + setDescription(description + " (" + m_wellName + ")"); if (!m_case) return; @@ -238,9 +226,9 @@ void RimWellAllocationPlot::updateFromWell() } } - auto depthType = accumulatedWellFlowPlot()->depthType(); + auto depthType = this->depthType(); - if ( depthType == RimWellLogPlot::MEASURED_DEPTH ) return; + if (depthType == RimWellLogPlot::MEASURED_DEPTH) return; // Create tracks and curves from the calculated data @@ -256,7 +244,7 @@ void RimWellAllocationPlot::updateFromWell() plotTrack->setFormationsForCaseWithSimWellOnly(true); plotTrack->setFormationBranchIndex((int)brIdx); - accumulatedWellFlowPlot()->addTrack(plotTrack); + addTrack(plotTrack); const std::vector& depthValues = depthType == RimWellLogPlot::CONNECTION_NUMBER ? wfCalculator->connectionNumbersFromTop(brIdx) : depthType == RimWellLogPlot::PSEUDO_LENGTH ? wfCalculator->pseudoLengthFromTop(brIdx) : @@ -302,7 +290,10 @@ void RimWellAllocationPlot::updateFromWell() /// Pie chart m_totalWellAllocationPlot->clearSlices(); - if (m_wellAllocationPlotWidget) m_wellAllocationPlotWidget->clearLegend(); + if (allocationPlotWidget()) + { + allocationPlotWidget()->clearLegend(); + } if (wfCalculator) { @@ -319,19 +310,18 @@ void RimWellAllocationPlot::updateFromWell() double tracerPercent = 100*tracerVal.second; m_totalWellAllocationPlot->addSlice(tracerVal.first, color, tracerPercent); - if ( m_wellAllocationPlotWidget ) m_wellAllocationPlotWidget->addLegendItem(tracerVal.first, color, tracerPercent); + if (allocationPlotWidget()) allocationPlotWidget()->addLegendItem(tracerVal.first, color, tracerPercent); } } - if (m_wellAllocationPlotWidget) m_wellAllocationPlotWidget->showLegend(m_wellAllocationPlotLegend->isShowingLegend()); + if (allocationPlotWidget()) allocationPlotWidget()->showLegend(m_wellAllocationPlotLegend->isShowingLegend()); m_totalWellAllocationPlot->updateConnectedEditors(); - - accumulatedWellFlowPlot()->updateConnectedEditors(); + updateConnectedEditors(); m_tofAccumulatedPhaseFractionsPlot->reloadFromWell(); m_tofAccumulatedPhaseFractionsPlot->updateConnectedEditors(); - if (m_wellAllocationPlotWidget) m_wellAllocationPlotWidget->updateGeometry(); + if (allocationPlotWidget()) allocationPlotWidget()->updateGeometry(); } //-------------------------------------------------------------------------------------------------- @@ -454,26 +444,6 @@ void RimWellAllocationPlot::addStackedCurve(const QString& tracerName, curve->loadDataAndUpdate(true); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellAllocationPlot::updateWidgetTitleWindowTitle() -{ - updateMdiWindowTitle(); - - if (m_wellAllocationPlotWidget) - { - if (m_showPlotTitle) - { - m_wellAllocationPlotWidget->showTitle(m_userName); - } - else - { - m_wellAllocationPlotWidget->hideTitle(); - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -519,30 +489,6 @@ QString RimWellAllocationPlot::wellStatusTextForTimeStep(const QString& wellName return statusText; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QWidget* RimWellAllocationPlot::viewWidget() -{ - return m_wellAllocationPlotWidget; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellAllocationPlot::zoomAll() -{ - m_accumulatedWellFlowPlot()->zoomAll(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellLogPlot* RimWellAllocationPlot::accumulatedWellFlowPlot() -{ - return m_accumulatedWellFlowPlot(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -679,7 +625,7 @@ void RimWellAllocationPlot::removeFromMdiAreaAndDeleteViewWidget() //-------------------------------------------------------------------------------------------------- void RimWellAllocationPlot::showPlotLegend(bool doShow) { - if (m_wellAllocationPlotWidget) m_wellAllocationPlotWidget->showLegend(doShow); + if (allocationPlotWidget()) allocationPlotWidget()->showLegend(doShow); } //-------------------------------------------------------------------------------------------------- @@ -689,12 +635,7 @@ void RimWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedF { RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue); - if (changedField == &m_userName || - changedField == &m_showPlotTitle) - { - updateWidgetTitleWindowTitle(); - } - else if ( changedField == &m_case) + if ( changedField == &m_case) { if ( m_flowDiagSolution && m_case ) { @@ -748,30 +689,11 @@ std::set RimWellAllocationPlot::findSortedWellNames() return sortedWellNames; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QImage RimWellAllocationPlot::snapshotWindowContent() -{ - QImage image; - - if (m_wellAllocationPlotWidget) - { - QPixmap pix = QPixmap::grabWidget(m_wellAllocationPlotWidget); - image = pix.toImage(); - } - - return image; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellAllocationPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - uiOrdering.add(&m_userName); - uiOrdering.add(&m_showPlotTitle); - caf::PdmUiGroup& dataGroup = *uiOrdering.addNewGroup("Plot Data"); dataGroup.add(&m_case); dataGroup.add(&m_timeStep); @@ -786,24 +708,6 @@ void RimWellAllocationPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd m_smallContributionsThreshold.uiCapability()->setUiReadOnly(!m_groupSmallContributions()); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellAllocationPlot::setDescription(const QString& description) -{ - m_userName = description; - - updateWidgetTitleWindowTitle(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimWellAllocationPlot::description() const -{ - return m_userName(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -811,17 +715,37 @@ void RimWellAllocationPlot::onLoadDataAndUpdate() { updateMdiWindowVisibility(); updateFromWell(); - m_accumulatedWellFlowPlot->loadDataAndUpdate(); + RimWellLogPlot::loadDataAndUpdate(); updateFormationNamesData(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellAllocationPlot::initAfterRead() +{ + if (m_accumulatedWellFlowPlot_OBSOLETE) + { + RimWellLogPlot& wellLogPlot = dynamic_cast(*this); + wellLogPlot = std::move(*m_accumulatedWellFlowPlot_OBSOLETE.value()); + m_accumulatedWellFlowPlot_OBSOLETE = nullptr; + } + + if (m_showPlotTitle_OBSOLETE() && !m_showTitleInPlot()) + { + m_showTitleInPlot = m_showPlotTitle_OBSOLETE(); + } + + RimWellLogPlot::initAfterRead(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QWidget* RimWellAllocationPlot::createViewWidget(QWidget* mainWindowParent) { - m_wellAllocationPlotWidget = new RiuWellAllocationPlot(this, mainWindowParent); - return m_wellAllocationPlotWidget; + m_viewer = new RiuWellAllocationPlot(this, mainWindowParent); + return m_viewer; } //-------------------------------------------------------------------------------------------------- @@ -841,10 +765,42 @@ cvf::Color3f RimWellAllocationPlot::getTracerColor(const QString& tracerName) //-------------------------------------------------------------------------------------------------- void RimWellAllocationPlot::updateFormationNamesData() const { - for (size_t i = 0; i < m_accumulatedWellFlowPlot->trackCount(); ++i) + for (size_t i = 0; i < trackCount(); ++i) { - RimWellLogTrack* track = m_accumulatedWellFlowPlot->trackByIndex(i); + RimWellLogTrack* track = trackByIndex(i); track->setAndUpdateSimWellFormationNamesData(m_case, m_wellName); } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimWellAllocationPlot::availableDepthUnits() const +{ + return {}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimWellAllocationPlot::availableDepthTypes() const +{ + return {TRUE_VERTICAL_DEPTH, PSEUDO_LENGTH, CONNECTION_NUMBER}; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellAllocationPlot::onDepthTypeChanged() +{ + loadDataAndUpdate(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuWellAllocationPlot* RimWellAllocationPlot::allocationPlotWidget() const +{ + RiuWellAllocationPlot* plotWidget = dynamic_cast(m_viewer.data()); + return plotWidget; +} diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h index c19d58d7a5..f27e9a09c7 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.h @@ -18,8 +18,8 @@ #pragma once - #include "RimViewWindow.h" +#include "RimWellLogPlot.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -34,7 +34,7 @@ class RimSimWellInView; class RimTofAccumulatedPhaseFractionsPlot; class RimTotalWellAllocationPlot; class RimWellAllocationPlotLegend; -class RimWellLogPlot; + class RimWellLogTrack; class RiuWellAllocationPlot; @@ -51,7 +51,7 @@ namespace caf { /// /// //================================================================================================== -class RimWellAllocationPlot : public RimViewWindow +class RimWellAllocationPlot : public RimWellLogPlot { CAF_PDM_HEADER_INIT; public: @@ -63,13 +63,6 @@ public: void setFromSimulationWell(RimSimWellInView* simWell); - void setDescription(const QString& description); - QString description() const; - - QWidget* viewWidget() override; - void zoomAll() override; - - RimWellLogPlot* accumulatedWellFlowPlot(); RimTotalWellAllocationPlot* totalWellFlowPlot(); RimTofAccumulatedPhaseFractionsPlot* tofAccumulatedPhaseFractionsPlot(); caf::PdmObject* plotLegend(); @@ -83,18 +76,15 @@ public: void showPlotLegend(bool doShow); protected: // Overridden PDM methods - caf::PdmFieldHandle* userDescriptionField() override { return &m_userName; } void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; std::set findSortedWellNames(); QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; - QImage snapshotWindowContent() override; - - - void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; - void onLoadDataAndUpdate() override; + void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + void onLoadDataAndUpdate() override; + void initAfterRead() override; private: void updateFromWell(); @@ -108,22 +98,19 @@ private: const std::vector& accFlow, RimWellLogTrack* plotTrack); - void updateWidgetTitleWindowTitle(); static QString wellStatusTextForTimeStep(const QString& wellName, const RimEclipseResultCase* eclipseResultCase, size_t timeStep); - // RimViewWindow overrides - - QWidget* createViewWidget(QWidget* mainWindowParent) override; - void deleteViewWidget() override; + QWidget* createViewWidget(QWidget* mainWindowParent) override; cvf::Color3f getTracerColor(const QString& tracerName); void updateFormationNamesData() const; + std::set availableDepthUnits() const override; + std::set availableDepthTypes() const override; + void onDepthTypeChanged() override; + RiuWellAllocationPlot* allocationPlotWidget() const; private: - caf::PdmField m_showPlotTitle; - caf::PdmField m_userName; - caf::PdmField m_branchDetection; caf::PdmPtrField m_case; @@ -134,10 +121,10 @@ private: caf::PdmField m_smallContributionsThreshold; caf::PdmField > m_flowType; - QPointer m_wellAllocationPlotWidget; - - caf::PdmChildField m_accumulatedWellFlowPlot; caf::PdmChildField m_totalWellAllocationPlot; caf::PdmChildField m_wellAllocationPlotLegend; caf::PdmChildField m_tofAccumulatedPhaseFractionsPlot; + + caf::PdmChildField m_accumulatedWellFlowPlot_OBSOLETE; + caf::PdmField m_showPlotTitle_OBSOLETE; }; diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index 142f59cab4..d3ae0c1ae7 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -100,18 +100,18 @@ const char RimWellPltPlot::PLOT_NAME_QFORMAT_STRING[] = "PLT: %1"; /// //-------------------------------------------------------------------------------------------------- RimWellPltPlot::RimWellPltPlot() + : RimWellLogPlot() { CAF_PDM_InitObject("Well Allocation Plot", ":/WellFlowPlot16x16.png", "", ""); - CAF_PDM_InitField(&m_userName, "PlotDescription", QString("PLT 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_InitFieldNoDefault(&m_wellLogPlot, "WellLog", "WellLog", "", "", ""); - m_wellLogPlot.uiCapability()->setUiHidden(true); - m_wellLogPlot = new RimWellLogPlot(); - m_wellLogPlot->setDepthType(RimWellLogPlot::MEASURED_DEPTH); + CAF_PDM_InitFieldNoDefault(&m_wellLogPlot_OBSOLETE, "WellLog", "WellLog", "", "", ""); + m_wellLogPlot_OBSOLETE.uiCapability()->setUiHidden(true); + m_wellLogPlot_OBSOLETE = new RimWellLogPlot(); + m_wellLogPlot_OBSOLETE->setDepthType(RimWellLogPlot::MEASURED_DEPTH); + m_wellLogPlot_OBSOLETE.xmlCapability()->setIOWritable(false); CAF_PDM_InitFieldNoDefault(&m_wellPathName, "WellName", "Well Name", "", "", ""); @@ -152,18 +152,6 @@ RimWellPltPlot::~RimWellPltPlot() deleteViewWidget(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPltPlot::deleteViewWidget() -{ - if (m_wellLogPlotWidget) - { - m_wellLogPlotWidget->deleteLater(); - m_wellLogPlotWidget = nullptr; - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -238,12 +226,12 @@ void RimWellPltPlot::setPlotXAxisTitles(RimWellLogTrack* plotTrack) //-------------------------------------------------------------------------------------------------- void RimWellPltPlot::updateFormationsOnPlot() const { - if (m_wellLogPlot->trackCount() > 0) + if (trackCount() > 0) { RimProject* proj = RiaApplication::instance()->project(); RimWellPath* wellPath = proj->wellPathByName(m_wellPathName); - RimCase* formationNamesCase = m_wellLogPlot->trackByIndex(0)->formationNamesCase(); + RimCase* formationNamesCase = trackByIndex(0)->formationNamesCase(); if (!formationNamesCase) { @@ -257,28 +245,16 @@ void RimWellPltPlot::updateFormationsOnPlot() const } } - m_wellLogPlot->trackByIndex(0)->setAndUpdateWellPathFormationNamesData(formationNamesCase, wellPath); + trackByIndex(0)->setAndUpdateWellPathFormationNamesData(formationNamesCase, wellPath); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPltPlot::updateWidgetTitleWindowTitle() +std::set RimWellPltPlot::availableDepthTypes() const { - updateMdiWindowTitle(); - - if (m_wellLogPlotWidget) - { - if (m_showPlotTitle) - { - m_wellLogPlotWidget->showTitle(m_userName); - } - else - { - m_wellLogPlotWidget->hideTitle(); - } - } + return {RimWellLogPlot::MEASURED_DEPTH}; } //-------------------------------------------------------------------------------------------------- @@ -506,7 +482,7 @@ public: //-------------------------------------------------------------------------------------------------- void RimWellPltPlot::syncCurvesFromUiSelection() { - RimWellLogTrack* plotTrack = m_wellLogPlot->trackByIndex(0); + RimWellLogTrack* plotTrack = trackByIndex(0); const std::set& curveDefs = selectedCurveDefs(); setPlotXAxisTitles(plotTrack); @@ -715,8 +691,7 @@ void RimWellPltPlot::syncCurvesFromUiSelection() curveGroupId++; } - updateWidgetTitleWindowTitle(); - m_wellLogPlot->loadDataAndUpdate(); + loadDataAndUpdate(); plotTrack->calculateXZoomRange(); } @@ -773,30 +748,6 @@ std::vector RimWellPltPlot::selectedSourcesExpanded() co return sources; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QWidget* RimWellPltPlot::viewWidget() -{ - return m_wellLogPlotWidget; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPltPlot::zoomAll() -{ - m_wellLogPlot()->zoomAll(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellLogPlot* RimWellPltPlot::wellLogPlot() const -{ - return m_wellLogPlot(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -917,7 +868,7 @@ void RimWellPltPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c if (changedField == &m_wellPathName) { - RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0); + RimWellLogTrack* const plotTrack = trackByIndex(0); plotTrack->deleteAllCurves(); m_selectedSources.v().clear(); m_selectedTimeSteps.v().clear(); @@ -953,9 +904,9 @@ void RimWellPltPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c updateFormationsOnPlot(); syncSourcesIoFieldFromGuiField(); syncCurvesFromUiSelection(); - m_wellLogPlot->updateDepthZoom(); + updateDepthZoom(); - RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0); + RimWellLogTrack* const plotTrack = trackByIndex(0); plotTrack->calculateXZoomRangeAndUpdateQwt(); } @@ -963,9 +914,9 @@ void RimWellPltPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c changedField == &m_phases) { syncCurvesFromUiSelection(); - m_wellLogPlot->updateDepthZoom(); + updateDepthZoom(); - RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0); + RimWellLogTrack* const plotTrack = trackByIndex(0); plotTrack->calculateXZoomRangeAndUpdateQwt(); } } @@ -978,22 +929,6 @@ void RimWellPltPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.skipRemainingChildren(true); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QImage RimWellPltPlot::snapshotWindowContent() -{ - QImage image; - - if (m_wellLogPlotWidget) - { - QPixmap pix = QPixmap::grabWidget(m_wellLogPlotWidget); - image = pix.toImage(); - } - - return image; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1001,7 +936,6 @@ void RimWellPltPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& { const QString simWellName = RimWellPlotTools::simWellName(m_wellPathName); - uiOrdering.add(&m_userName); uiOrdering.add(&m_wellPathName); caf::PdmUiGroup* sourcesGroup = uiOrdering.addNewGroupWithKeyword("Sources", "Sources"); @@ -1016,20 +950,20 @@ void RimWellPltPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& flowGroup->add(&m_phases); - if (m_wellLogPlot && m_wellLogPlot->trackCount() > 0) + if (trackCount() > 0) { - RimWellLogTrack* track = m_wellLogPlot->trackByIndex(0); + RimWellLogTrack* track = 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); @@ -1057,6 +991,20 @@ void RimWellPltPlot::initAfterRead() { RimViewWindow::initAfterRead(); + if (m_wellLogPlot_OBSOLETE) + { + RimWellLogPlot& wellLogPlot = dynamic_cast(*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(); + // Postpone init until data has been loaded m_doInitAfterLoad = true; } @@ -1117,24 +1065,6 @@ void RimWellPltPlot::calculateValueOptionsForWells(QList options.push_back(caf::PdmOptionItemInfo("None", "")); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPltPlot::setDescription(const QString& description) -{ - m_userName = description; - - updateWidgetTitleWindowTitle(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimWellPltPlot::description() const -{ - return m_userName(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1148,9 +1078,9 @@ void RimWellPltPlot::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; } @@ -1158,7 +1088,7 @@ void RimWellPltPlot::onLoadDataAndUpdate() updateMdiWindowVisibility(); updateFormationsOnPlot(); syncCurvesFromUiSelection(); - m_wellLogPlot->loadDataAndUpdate(); + RimWellLogPlot::loadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- @@ -1166,6 +1096,6 @@ void RimWellPltPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- QWidget* RimWellPltPlot::createViewWidget(QWidget* mainWindowParent) { - m_wellLogPlotWidget = new RiuWellPltPlot(this, mainWindowParent); - return m_wellLogPlotWidget; + m_viewer = new RiuWellPltPlot(this, mainWindowParent); + return m_viewer; } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.h index 307adb7113..39a3ad82dd 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.h @@ -19,6 +19,7 @@ #include "RifDataSourceForRftPltQMetaType.h" +#include "RimWellLogPlot.h" #include "RimWellPlotTools.h" #include "cafPdmField.h" @@ -38,7 +39,6 @@ class RimEclipseCase; class RimEclipseResultCase; class RimWellLogCurve; class RimWellLogFileChannel; -class RimWellLogPlot; class RimWellPath; class RiuWellPltPlot; class RimWellLogTrack; @@ -58,7 +58,7 @@ namespace caf { /// /// //================================================================================================== -class RimWellPltPlot : public RimViewWindow +class RimWellPltPlot : public RimWellLogPlot { CAF_PDM_HEADER_INIT; @@ -68,14 +68,6 @@ public: RimWellPltPlot(); ~RimWellPltPlot() override; - void setDescription(const QString& description); - QString description() const; - - QWidget* viewWidget() override; - void zoomAll() override; - - RimWellLogPlot* wellLogPlot() const; - void setCurrentWellName(const QString& currWellName); static const char* plotNameFormatString(); @@ -83,15 +75,12 @@ public: protected: // Overridden PDM methods - caf::PdmFieldHandle* userDescriptionField() override { return &m_userName; } void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override; QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; void calculateValueOptionsForWells(QList& options); - QImage snapshotWindowContent() override; - void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; void onLoadDataAndUpdate() override; @@ -117,17 +106,14 @@ private: // RimViewWindow overrides - void updateWidgetTitleWindowTitle(); - QWidget* createViewWidget(QWidget* mainWindowParent) override; - void deleteViewWidget() override; + QWidget* createViewWidget(QWidget* mainWindowParent) override; void setPlotXAxisTitles(RimWellLogTrack* plotTrack); void updateFormationsOnPlot() const; - + std::set availableDepthTypes() const override; private: - caf::PdmField m_showPlotTitle; - caf::PdmField m_userName; + caf::PdmField m_showPlotTitle_OBSOLETE; caf::PdmField m_wellPathName; @@ -136,9 +122,7 @@ private: caf::PdmField> m_selectedTimeSteps; - QPointer m_wellLogPlotWidget; - - caf::PdmChildField m_wellLogPlot; + caf::PdmChildField m_wellLogPlot_OBSOLETE; caf::PdmField m_useStandardConditionCurves; caf::PdmField m_useReservoirConditionCurves; diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 4be3a3efbd..c76153974f 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -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(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& allCurveDefs = selectedCurveDefs(); const std::set& curveDefsInPlot = curveDefsFromCurves(); @@ -388,7 +357,7 @@ std::set RimWellRftPlot::curveDefsFromCurves() const { std::set 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 const std::set& 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 } } - 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 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 } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -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(*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(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 calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; - QImage snapshotWindowContent() override; - void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; void onLoadDataAndUpdate() override; + void initAfterRead() override; private: void calculateValueOptionsForWells(QList& options); void updateEditorsFromCurves(); - void updateWidgetTitleWindowTitle(); void syncCurvesFromUiSelection(); void assignWellPathToExtractionCurves(); @@ -130,7 +115,6 @@ private: // RimViewWindow overrides QWidget* createViewWidget(QWidget* mainWindowParent) override; - void deleteViewWidget() override; void applyCurveAppearance(RimWellLogCurve* newCurve); @@ -142,10 +126,8 @@ private: void defineCurveColorsAndSymbols(const std::set& allCurveDefs); + void onDepthTypeChanged() override; private: - caf::PdmField m_showPlotTitle; - caf::PdmField m_userName; - caf::PdmField m_wellPathNameOrSimWellName; caf::PdmField m_branchIndex; caf::PdmField m_branchDetection; @@ -156,9 +138,8 @@ private: caf::PdmField> m_selectedTimeSteps; - caf::PdmChildField m_wellLogPlot; - - QPointer m_wellLogPlotWidget; + caf::PdmField m_showPlotTitle_OBSOLETE; + caf::PdmChildField m_wellLogPlot_OBSOLETE; std::map m_dataSourceColors; std::map m_timeStepSymbols; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 26d2ef975f..3e359dd264 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -26,12 +26,9 @@ #include "RimGeoMechCase.h" #include "RimEclipseCase.h" -#include "RimWellAllocationPlot.h" #include "RimWellLogCurve.h" #include "RimWellLogCurveCommonDataSource.h" #include "RimWellLogTrack.h" -#include "RimWellRftPlot.h" -#include "RimWellPltPlot.h" #include "RiuPlotMainWindow.h" #include "RiuWellLogPlot.h" @@ -82,7 +79,7 @@ RimWellLogPlot::RimWellLogPlot() m_viewer = nullptr; - CAF_PDM_InitField(&m_userName_OBSOLETE, "PlotDescription", QString(""),"Name", "", "", ""); + CAF_PDM_InitField(&m_userName_OBSOLETE, "PlotDescription", QString(""), "Name", "", "", ""); m_userName_OBSOLETE.xmlCapability()->setIOWritable(false); CAF_PDM_InitFieldNoDefault(&m_commonDataSource, "CommonDataSource", "Data Source", "", "Change the Data Source of All Curves in the Plot", ""); @@ -92,13 +89,13 @@ RimWellLogPlot::RimWellLogPlot() m_commonDataSource.xmlCapability()->disableIO(); caf::AppEnum< RimWellLogPlot::DepthTypeEnum > depthType = MEASURED_DEPTH; - CAF_PDM_InitField(&m_depthType, "DepthType", depthType, "Type", "", "", ""); + CAF_PDM_InitField(&m_depthType, "DepthType", depthType, "Type", "", "", ""); caf::AppEnum< RiaDefines::DepthUnitType > depthUnit = RiaDefines::UNIT_METER; CAF_PDM_InitField(&m_depthUnit, "DepthUnit", depthUnit, "Unit", "", "", ""); CAF_PDM_InitField(&m_minVisibleDepth, "MinimumDepth", 0.0, "Min", "", "", ""); - CAF_PDM_InitField(&m_maxVisibleDepth, "MaximumDepth", 1000.0, "Max", "", "", ""); + CAF_PDM_InitField(&m_maxVisibleDepth, "MaximumDepth", 1000.0, "Max", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_depthAxisGridVisibility, "ShowDepthGridLines", "Show Grid Lines", "", "", ""); CAF_PDM_InitField(&m_isAutoScaleDepthEnabled, "AutoScaleDepthEnabled", true, "Auto Scale", "", "", ""); m_isAutoScaleDepthEnabled.uiCapability()->setUiHidden(true); @@ -107,7 +104,7 @@ RimWellLogPlot::RimWellLogPlot() CAF_PDM_InitField(&m_trackLegendsHorizontal, "TrackLegendsHorizontal", false, "Legend Orientation", "", "", ""); m_trackLegendsHorizontal.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName()); - CAF_PDM_InitFieldNoDefault(&m_tracks, "Tracks", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_tracks, "Tracks", "", "", "", ""); m_tracks.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "", "", "", ""); @@ -119,6 +116,43 @@ RimWellLogPlot::RimWellLogPlot() m_maxAvailableDepth = -HUGE_VAL; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogPlot& RimWellLogPlot::operator=(RimWellLogPlot&& rhs) +{ + m_userName_OBSOLETE = rhs.m_userName_OBSOLETE(); + auto dataSource = rhs.m_commonDataSource(); + rhs.m_commonDataSource.removeChildObject(dataSource); + m_commonDataSource = dataSource; + + m_depthType = rhs.m_depthType(); + m_depthUnit = rhs.m_depthUnit(); + m_minVisibleDepth = rhs.m_minVisibleDepth(); + m_maxVisibleDepth = rhs.m_maxVisibleDepth(); + m_depthAxisGridVisibility = rhs.m_depthAxisGridVisibility(); + m_isAutoScaleDepthEnabled = rhs.m_isAutoScaleDepthEnabled(); + m_showTitleInPlot = rhs.m_showTitleInPlot(); + m_showTrackLegends = rhs.m_showTrackLegends(); + m_trackLegendsHorizontal = rhs.m_trackLegendsHorizontal(); + + // Move all tracks + std::vector tracks = rhs.m_tracks.childObjects(); + rhs.m_tracks.clear(); + for (RimWellLogTrack* track : tracks) + { + m_tracks.push_back(track); + } + + auto nameConfig = rhs.m_nameConfig(); + rhs.m_nameConfig.removeChildObject(nameConfig); + m_nameConfig = nameConfig; + + m_minAvailableDepth = rhs.m_minAvailableDepth; + m_maxAvailableDepth = rhs.m_maxAvailableDepth; + return *this; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -176,17 +210,7 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c } else if ( changedField == &m_depthType ) { - RimWellAllocationPlot* wellAllocPlot; - firstAncestorOrThisOfType(wellAllocPlot); - if (wellAllocPlot) - { - wellAllocPlot->loadDataAndUpdate(); - } - else if (isRftPlotChild()) - { - rftPlot()->loadDataAndUpdate(); - } - + onDepthTypeChanged(); updateTracks(); updateDepthZoom(); } @@ -196,21 +220,7 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c updateDepthZoom(); } - RimWellRftPlot* rftPlot(nullptr); - this->firstAncestorOrThisOfType(rftPlot); - - if (rftPlot) - { - rftPlot->updateConnectedEditors(); - } - - RimWellPltPlot* pltPlot(nullptr); - this->firstAncestorOrThisOfType(pltPlot); - - if (pltPlot) - { - pltPlot->updateConnectedEditors(); - } + updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -227,7 +237,7 @@ QList RimWellLogPlot::calculateValueOptions(const caf::P { DepthTypeEnum enumVal = DepthAppEnum::fromIndex(i); - if (m_disabledDepthTypes.count( enumVal) == 0) + if (availableDepthTypes().count(enumVal)) { options.push_back(caf::PdmOptionItemInfo(DepthAppEnum::uiText(enumVal), enumVal)); } @@ -236,8 +246,10 @@ QList RimWellLogPlot::calculateValueOptions(const caf::P else if ( fieldNeedingOptions == &m_depthUnit) { using UnitAppEnum = caf::AppEnum< RiaDefines::DepthUnitType >; - options.push_back(caf::PdmOptionItemInfo(UnitAppEnum::uiText(RiaDefines::UNIT_METER), RiaDefines::UNIT_METER)); - options.push_back(caf::PdmOptionItemInfo(UnitAppEnum::uiText(RiaDefines::UNIT_FEET), RiaDefines::UNIT_FEET)); + for (auto depthUnit : availableDepthUnits()) + { + options.push_back(caf::PdmOptionItemInfo(UnitAppEnum::uiText(depthUnit), depthUnit)); + } } else if (fieldNeedingOptions == &m_trackLegendsHorizontal) { @@ -309,7 +321,7 @@ void RimWellLogPlot::removeTrack(RimWellLogTrack* track) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellLogTrack* RimWellLogPlot::trackByIndex(size_t index) +RimWellLogTrack* RimWellLogPlot::trackByIndex(size_t index) const { return m_tracks[index]; } @@ -464,19 +476,7 @@ void RimWellLogPlot::enableAllAutoNameTags(bool enable) //-------------------------------------------------------------------------------------------------- QString RimWellLogPlot::asciiDataForPlotExport() const { - QString out; - - RimWellAllocationPlot* wellAllocPlot = nullptr; - this->firstAncestorOrThisOfType(wellAllocPlot); - if (wellAllocPlot) - { - out += wellAllocPlot->description(); - } - else - { - out += description(); - } - out += "\n"; + QString out = description() + "\n"; for (RimWellLogTrack* track : m_tracks) { @@ -555,42 +555,6 @@ QString RimWellLogPlot::asciiDataForPlotExport() const return out; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellRftPlot* RimWellLogPlot::rftPlot() const -{ - RimWellRftPlot* rftPlot; - firstAncestorOrThisOfType(rftPlot); - return rftPlot; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimWellLogPlot::isRftPlotChild() const -{ - return rftPlot() != nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPltPlot* RimWellLogPlot::pltPlot() const -{ - RimWellPltPlot* pltPlot; - firstAncestorOrThisOfType(pltPlot); - return pltPlot; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimWellLogPlot::isPltPlotChild() const -{ - return pltPlot() != nullptr; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -598,18 +562,16 @@ void RimWellLogPlot::uiOrderingForDepthAxis(caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup("Depth Axis"); - if (!pltPlot()) + if (availableDepthTypes().size() > 1u) { gridGroup->add(&m_depthType); } - RimWellAllocationPlot* wap; - firstAncestorOrThisOfType(wap); - - if (!wap) + if (availableDepthUnits().size() > 1u) { gridGroup->add(&m_depthUnit); } + gridGroup->add(&m_minVisibleDepth); gridGroup->add(&m_maxVisibleDepth); gridGroup->add(&m_depthAxisGridVisibility); @@ -817,8 +779,6 @@ void RimWellLogPlot::updateTracks(bool autoScaleXAxis) { if (m_showWindow) { - updateDisabledDepthTypes(); - for (size_t tIdx = 0; tIdx < m_tracks.size(); ++tIdx) { m_tracks[tIdx]->loadDataAndUpdate(); @@ -875,7 +835,6 @@ void RimWellLogPlot::applyDepthZoomFromVisibleDepth() } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1120,38 +1079,20 @@ void RimWellLogPlot::setDepthUnit(RiaDefines::DepthUnitType depthUnit) updateTracks(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimWellLogPlot::availableDepthUnits() const +{ + return {RiaDefines::UNIT_METER, RiaDefines::UNIT_FEET}; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogPlot::updateDisabledDepthTypes() +std::set RimWellLogPlot::availableDepthTypes() const { - m_disabledDepthTypes.clear(); - RimWellAllocationPlot* wap; - firstAncestorOrThisOfType(wap); - if (wap) - { - m_disabledDepthTypes.insert(MEASURED_DEPTH); - if (m_disabledDepthTypes.count(m_depthType() )) - { - m_depthType = CONNECTION_NUMBER; - } - } - else if (isRftPlotChild()) - { - m_disabledDepthTypes.insert(PSEUDO_LENGTH); - m_disabledDepthTypes.insert(CONNECTION_NUMBER); - } - else if (isPltPlotChild()) - { - m_disabledDepthTypes.insert(TRUE_VERTICAL_DEPTH); - m_disabledDepthTypes.insert(PSEUDO_LENGTH); - m_disabledDepthTypes.insert(CONNECTION_NUMBER); - } - else - { - m_disabledDepthTypes.insert(PSEUDO_LENGTH); - m_disabledDepthTypes.insert(CONNECTION_NUMBER); - } + return {MEASURED_DEPTH, TRUE_VERTICAL_DEPTH}; } //-------------------------------------------------------------------------------------------------- @@ -1166,3 +1107,10 @@ void RimWellLogPlot::updatePlotTitle() updateMdiWindowTitle(); } +//-------------------------------------------------------------------------------------------------- +/// Default empty implementation +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlot::onDepthTypeChanged() +{ +} + diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h index 67918ae2f5..56155a0307 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.h @@ -31,11 +31,11 @@ #include +#include + class RimWellLogCurveCommonDataSource; class RiuWellLogPlot; class RimWellLogTrack; -class RimWellRftPlot; -class RimWellPltPlot; class QKeyEvent; //================================================================================================== @@ -63,8 +63,11 @@ public: RimWellLogPlot(); ~RimWellLogPlot() override; + // Move-assignment operator + RimWellLogPlot& operator=(RimWellLogPlot&& rhs); + QWidget* createPlotWidget(); - QWidget* viewWidget() override; + QWidget* viewWidget() override; void setDescription(const QString& description); QString description() const; @@ -88,11 +91,11 @@ public: void addTrack(RimWellLogTrack* track); void insertTrack(RimWellLogTrack* track, size_t index); - size_t trackCount() { return m_tracks.size();} + size_t trackCount() const { return m_tracks.size();} void removeTrack(RimWellLogTrack* track); size_t trackIndex(const RimWellLogTrack* track) const; - RimWellLogTrack* trackByIndex(size_t index); + RimWellLogTrack* trackByIndex(size_t index) const; size_t firstVisibleTrackIndex() const; std::vector tracks() const; void updateTracks(bool autoScaleXAxis = false); @@ -114,11 +117,6 @@ public: QString asciiDataForPlotExport() const; - RimWellRftPlot* rftPlot() const; - bool isRftPlotChild() const; - RimWellPltPlot* pltPlot() const; - bool isPltPlotChild() const; - void uiOrderingForDepthAxis(caf::PdmUiOrdering& uiOrdering); void uiOrderingForPlotSettings(caf::PdmUiOrdering& uiOrdering); @@ -149,17 +147,18 @@ private: void recreateTrackPlots(); void detachAllCurves(); - void updateDisabledDepthTypes(); + virtual std::set availableDepthUnits() const; + virtual std::set availableDepthTypes() const; void updatePlotTitle(); + virtual void onDepthTypeChanged(); -private: +protected: caf::PdmField m_userName_OBSOLETE; caf::PdmChildField m_commonDataSource; caf::PdmChildArrayField m_tracks; caf::PdmField< caf::AppEnum> m_depthType; caf::PdmField< caf::AppEnum> m_depthUnit; - std::set m_disabledDepthTypes; caf::PdmField m_minVisibleDepth; caf::PdmField m_maxVisibleDepth; caf::PdmField m_depthAxisGridVisibility; diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp index 518208df9c..3ddec96630 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp @@ -44,8 +44,7 @@ /// //-------------------------------------------------------------------------------------------------- RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent) - : QFrame(parent) - , m_plotDefinition(plotDefinition) + : RiuWellLogPlot(plotDefinition, parent) { Q_ASSERT(m_plotDefinition); @@ -54,21 +53,9 @@ RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefiniti this->layout()->setMargin(0); this->layout()->setSpacing(2); - m_titleLabel = new QLabel(this); - new RiuPlotObjectPicker(m_titleLabel, m_plotDefinition->accumulatedWellFlowPlot()); + new RiuPlotObjectPicker(m_plotTitle, m_plotDefinition); - QFont font = m_titleLabel->font(); - font.setPointSize(14); - font.setBold(true); - m_titleLabel->setFont(font); - - // White background - QPalette pal = this->palette(); - pal.setColor(QPalette::Background, Qt::white); - this->setAutoFillBackground(true); - this->setPalette(pal); - - mainLayout->addWidget(m_titleLabel, 0, Qt::AlignCenter); + mainLayout->addWidget(m_plotTitle, 0, Qt::AlignCenter); auto plotWidgetsLayout = new QHBoxLayout(); auto rightColumnLayout = new QVBoxLayout(); @@ -77,7 +64,8 @@ RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefiniti plotWidgetsLayout->addLayout(rightColumnLayout); m_legendWidget = new RiuNightchartsWidget(this); - new RiuPlotObjectPicker(m_legendWidget, m_plotDefinition->plotLegend()); + RimWellAllocationPlot* wellAllocationPlot = dynamic_cast(m_plotDefinition.p()); + new RiuPlotObjectPicker(m_legendWidget, wellAllocationPlot->plotLegend()); caf::CmdFeatureMenuBuilder menuBuilder; menuBuilder << "RicShowTotalAllocationDataFeature"; @@ -86,15 +74,15 @@ RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefiniti rightColumnLayout->addWidget(m_legendWidget); m_legendWidget->showPie(false); - QWidget* totalFlowAllocationWidget = m_plotDefinition->totalWellFlowPlot()->createViewWidget(this); - new RiuPlotObjectPicker(totalFlowAllocationWidget, m_plotDefinition->totalWellFlowPlot()); + QWidget* totalFlowAllocationWidget = wellAllocationPlot->totalWellFlowPlot()->createViewWidget(this); + new RiuPlotObjectPicker(totalFlowAllocationWidget, wellAllocationPlot->totalWellFlowPlot()); new RiuContextMenuLauncher(totalFlowAllocationWidget, menuBuilder); rightColumnLayout->addWidget(totalFlowAllocationWidget, Qt::AlignTop); - rightColumnLayout->addWidget(m_plotDefinition->tofAccumulatedPhaseFractionsPlot()->createViewWidget(this), Qt::AlignTop); + rightColumnLayout->addWidget(wellAllocationPlot->tofAccumulatedPhaseFractionsPlot()->createViewWidget(this), Qt::AlignTop); rightColumnLayout->addStretch(); - QWidget* wellFlowWidget = m_plotDefinition->accumulatedWellFlowPlot()->createPlotWidget(); + QWidget* wellFlowWidget = m_plotDefinition->createPlotWidget(); plotWidgetsLayout->addWidget(wellFlowWidget); } @@ -106,41 +94,6 @@ RiuWellAllocationPlot::~RiuWellAllocationPlot() { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellAllocationPlot* RiuWellAllocationPlot::ownerPlotDefinition() -{ - return m_plotDefinition; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewWindow* RiuWellAllocationPlot::ownerViewWindow() const -{ - return m_plotDefinition; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellAllocationPlot::showTitle(const QString& title) -{ - m_titleLabel->show(); - - m_titleLabel->setText(title); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellAllocationPlot::hideTitle() -{ - m_titleLabel->hide(); -} - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -208,11 +161,3 @@ QSize RiuWellAllocationPlot::sizeHint() const { return QSize(0, 0); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellAllocationPlot::setDefaults() -{ -} - diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.h b/ApplicationCode/UserInterface/RiuWellAllocationPlot.h index eb4af0d0b6..17da3c9eae 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.h +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.h @@ -18,15 +18,15 @@ #pragma once -#include "qwt_plot.h" +#include "RiuWellLogPlot.h" #include "cafPdmPointer.h" +#include "qwt_plot.h" + #include #include -#include "RiuInterfaceToViewWindow.h" - class RimWellAllocationPlot; class RiuNightchartsWidget; @@ -41,23 +41,17 @@ namespace cvf { // // //================================================================================================== -class RiuWellAllocationPlot : public QFrame, public RiuInterfaceToViewWindow +class RiuWellAllocationPlot : public RiuWellLogPlot { Q_OBJECT; public: RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent = nullptr); ~RiuWellAllocationPlot() override; - RimWellAllocationPlot* ownerPlotDefinition(); - 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(); - protected: QSize sizeHint() const override; QSize minimumSizeHint() const override; @@ -65,10 +59,5 @@ protected: void contextMenuEvent(QContextMenuEvent *) override; private: - void setDefaults(); - -private: - caf::PdmPointer m_plotDefinition; QPointer m_legendWidget; - QPointer m_titleLabel; }; diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp index 65875b9e36..592928df73 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp @@ -204,6 +204,22 @@ QSize RiuWellLogPlot::preferredSize() const return QSize(std::max(titleWidth, sumTrackWidth), titleHeight + maxTrackHeight); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellLogPlot::showTitle() +{ + m_plotTitle->show(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellLogPlot::hideTitle() +{ + m_plotTitle->hide(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.h b/ApplicationCode/UserInterface/RiuWellLogPlot.h index 188fcf86be..1046a5fb59 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.h +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.h @@ -51,7 +51,7 @@ public: ~RiuWellLogPlot() override; RimWellLogPlot* ownerPlotDefinition(); - RimViewWindow* ownerViewWindow() const override; + RimViewWindow* ownerViewWindow() const override; void addTrackPlot(RiuWellLogTrack* trackPlot); void insertTrackPlot(RiuWellLogTrack* trackPlot, size_t index); @@ -60,6 +60,10 @@ public: void setDepthZoomAndReplot(double minDepth, double maxDepth); void setPlotTitle(const QString& plotTitle); virtual QSize preferredSize() const; + + void showTitle(); + void hideTitle(); + public slots: void updateChildrenLayout(); @@ -83,12 +87,12 @@ private slots: void slotSetMinDepth(int value); void scheduleUpdateChildrenLayout(); -private: - QLabel* m_plotTitle; - QScrollBar* m_scrollBar; - QList > m_legends; - QList > m_trackPlots; - caf::PdmPointer m_plotDefinition; - QTimer* m_scheduleUpdateChildrenLayoutTimer; +protected: + QPointer m_plotTitle; + QScrollBar* m_scrollBar; + QList> m_legends; + QList> m_trackPlots; + caf::PdmPointer m_plotDefinition; + QTimer* m_scheduleUpdateChildrenLayoutTimer; }; diff --git a/ApplicationCode/UserInterface/RiuWellPltPlot.cpp b/ApplicationCode/UserInterface/RiuWellPltPlot.cpp index 0a9852f412..8a644713a4 100644 --- a/ApplicationCode/UserInterface/RiuWellPltPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellPltPlot.cpp @@ -44,9 +44,7 @@ /// //-------------------------------------------------------------------------------------------------- RiuWellPltPlot::RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent) - : QFrame(parent) - , m_plotDefinition(plotDefinition) - + : RiuWellLogPlot(plotDefinition, parent) { Q_ASSERT(m_plotDefinition); @@ -55,21 +53,9 @@ RiuWellPltPlot::RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent) this->layout()->setMargin(0); this->layout()->setSpacing(2); - m_titleLabel = new QLabel(this); - new RiuPlotObjectPicker(m_titleLabel, m_plotDefinition->wellLogPlot()); + new RiuPlotObjectPicker(m_plotTitle, m_plotDefinition); - QFont font = m_titleLabel->font(); - font.setPointSize(14); - font.setBold(true); - m_titleLabel->setFont(font); - - // White background - QPalette pal = this->palette(); - pal.setColor(QPalette::Background, Qt::white); - this->setAutoFillBackground(true); - this->setPalette(pal); - - mainLayout->addWidget(m_titleLabel, 0, Qt::AlignCenter); + mainLayout->addWidget(m_plotTitle, 0, Qt::AlignCenter); auto plotWidgetsLayout = new QHBoxLayout(); auto rightColumnLayout = new QVBoxLayout(); @@ -77,7 +63,7 @@ RiuWellPltPlot::RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent) mainLayout->addLayout(plotWidgetsLayout); plotWidgetsLayout->addLayout(rightColumnLayout); - QWidget* wellFlowWidget = m_plotDefinition->wellLogPlot()->createPlotWidget(); + QWidget* wellFlowWidget = m_plotDefinition->createPlotWidget(); plotWidgetsLayout->addWidget(wellFlowWidget); } @@ -89,40 +75,6 @@ RiuWellPltPlot::~RiuWellPltPlot() { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellPltPlot* RiuWellPltPlot::ownerPlotDefinition() -{ - return m_plotDefinition; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewWindow* RiuWellPltPlot::ownerViewWindow() const -{ - return m_plotDefinition; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellPltPlot::showTitle(const QString& title) -{ - m_titleLabel->show(); - - m_titleLabel->setText(title); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellPltPlot::hideTitle() -{ - m_titleLabel->hide(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -145,10 +97,3 @@ QSize RiuWellPltPlot::sizeHint() const { return QSize(0, 0); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellPltPlot::setDefaults() -{ -} diff --git a/ApplicationCode/UserInterface/RiuWellPltPlot.h b/ApplicationCode/UserInterface/RiuWellPltPlot.h index 84846b4d02..d5c4b36c20 100644 --- a/ApplicationCode/UserInterface/RiuWellPltPlot.h +++ b/ApplicationCode/UserInterface/RiuWellPltPlot.h @@ -18,15 +18,15 @@ #pragma once -#include "qwt_plot.h" +#include "RiuWellLogPlot.h" #include "cafPdmPointer.h" +#include "qwt_plot.h" + #include #include -#include "RiuInterfaceToViewWindow.h" - class RimWellPltPlot; class RiuNightchartsWidget; @@ -41,29 +41,17 @@ namespace cvf { // // //================================================================================================== -class RiuWellPltPlot : public QFrame, public RiuInterfaceToViewWindow +class RiuWellPltPlot : public RiuWellLogPlot { Q_OBJECT; public: RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent = nullptr); ~RiuWellPltPlot() override; - RimWellPltPlot* ownerPlotDefinition(); - RimViewWindow* ownerViewWindow() const override; - - void showTitle(const QString& title); - void hideTitle(); - protected: QSize sizeHint() const override; QSize minimumSizeHint() const override; void contextMenuEvent(QContextMenuEvent *) override; -private: - void setDefaults(); - -private: - caf::PdmPointer m_plotDefinition; - QPointer m_titleLabel; }; diff --git a/ApplicationCode/UserInterface/RiuWellRftPlot.cpp b/ApplicationCode/UserInterface/RiuWellRftPlot.cpp index 9c9b20537a..d4f459f9eb 100644 --- a/ApplicationCode/UserInterface/RiuWellRftPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellRftPlot.cpp @@ -44,9 +44,7 @@ /// //-------------------------------------------------------------------------------------------------- RiuWellRftPlot::RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent) - : QFrame(parent) - , m_plotDefinition(plotDefinition) - + : RiuWellLogPlot(plotDefinition, parent) { Q_ASSERT(m_plotDefinition); @@ -55,21 +53,9 @@ RiuWellRftPlot::RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent) this->layout()->setMargin(0); this->layout()->setSpacing(2); - m_titleLabel = new QLabel(this); - new RiuPlotObjectPicker(m_titleLabel, m_plotDefinition->wellLogPlot()); + new RiuPlotObjectPicker(m_plotTitle, m_plotDefinition); - QFont font = m_titleLabel->font(); - font.setPointSize(14); - font.setBold(true); - m_titleLabel->setFont(font); - - // White background - QPalette pal = this->palette(); - pal.setColor(QPalette::Background, Qt::white); - this->setAutoFillBackground(true); - this->setPalette(pal); - - mainLayout->addWidget(m_titleLabel, 0, Qt::AlignCenter); + mainLayout->addWidget(m_plotTitle, 0, Qt::AlignCenter); auto plotWidgetsLayout = new QHBoxLayout(); auto rightColumnLayout = new QVBoxLayout(); @@ -77,7 +63,7 @@ RiuWellRftPlot::RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent) mainLayout->addLayout(plotWidgetsLayout); plotWidgetsLayout->addLayout(rightColumnLayout); - QWidget* wellFlowWidget = m_plotDefinition->wellLogPlot()->createPlotWidget(); + QWidget* wellFlowWidget = m_plotDefinition->createPlotWidget(); plotWidgetsLayout->addWidget(wellFlowWidget); } @@ -89,40 +75,6 @@ RiuWellRftPlot::~RiuWellRftPlot() { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellRftPlot* RiuWellRftPlot::ownerPlotDefinition() -{ - return m_plotDefinition; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimViewWindow* RiuWellRftPlot::ownerViewWindow() const -{ - return m_plotDefinition; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellRftPlot::showTitle(const QString& title) -{ - m_titleLabel->show(); - - m_titleLabel->setText(title); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellRftPlot::hideTitle() -{ - m_titleLabel->hide(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -145,10 +97,3 @@ QSize RiuWellRftPlot::sizeHint() const { return QSize(0, 0); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuWellRftPlot::setDefaults() -{ -} diff --git a/ApplicationCode/UserInterface/RiuWellRftPlot.h b/ApplicationCode/UserInterface/RiuWellRftPlot.h index 40ccc207ff..2583432e6e 100644 --- a/ApplicationCode/UserInterface/RiuWellRftPlot.h +++ b/ApplicationCode/UserInterface/RiuWellRftPlot.h @@ -26,6 +26,7 @@ #include #include "RiuInterfaceToViewWindow.h" +#include "RiuWellLogPlot.h" class RimWellRftPlot; class RiuNightchartsWidget; @@ -41,29 +42,17 @@ namespace cvf { // // //================================================================================================== -class RiuWellRftPlot : public QFrame, public RiuInterfaceToViewWindow +class RiuWellRftPlot : public RiuWellLogPlot { Q_OBJECT; public: RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent = nullptr); ~RiuWellRftPlot() override; - RimWellRftPlot* ownerPlotDefinition(); - RimViewWindow* ownerViewWindow() const override; - - void showTitle(const QString& title); - void hideTitle(); - protected: QSize sizeHint() const override; QSize minimumSizeHint() const override; void contextMenuEvent(QContextMenuEvent *) override; -private: - void setDefaults(); - -private: - caf::PdmPointer m_plotDefinition; - QPointer m_titleLabel; };