diff --git a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index 9735763c30..c4c3d805df 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -93,7 +93,6 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromIndex(curveIdx); curve->setColor(curveColor); - curve->setDescription(wellLog->name()); curve->setWellPath(wellPath); curve->setWellLogChannelName(wellLog->name()); diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp index d77aed2a56..51fa7ed4ab 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp @@ -88,8 +88,7 @@ void RicNewWellLogCurveExtractionFeature::addCurve(RimWellLogPlotTrack* plotTrac cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromIndex(curveIndex); curve->setColor(curveColor); - curve->setDescription(QString("Curve %1").arg(plotTrack->curveCount())); - plotTrack->updateConnectedEditors(); + RiuMainWindow::instance()->setCurrentObjectInTreeView(curve); } diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveLasFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveLasFeature.cpp index 0daac26a0a..42f5945f57 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveLasFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveLasFeature.cpp @@ -88,8 +88,7 @@ void RicNewWellLogCurveLasFeature::addCurve(RimWellLogPlotTrack* plotTrack) cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromIndex(curveIndex); curve->setColor(curveColor); - curve->setDescription(QString("Curve %1").arg(plotTrack->curveCount())); - plotTrack->updateConnectedEditors(); + RiuMainWindow::instance()->setCurrentObjectInTreeView(curve); } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 6a814f69fd..ddf5ca51c1 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -112,9 +112,9 @@ void RimWellLogExtractionCurve::fieldChangedByUi(const caf::PdmFieldHandle* chan //-------------------------------------------------------------------------------------------------- void RimWellLogExtractionCurve::updatePlotData() { - RimWellLogPlotCurve::updatePlotData(); + RimWellLogPlotCurve::updatePlotConfiguration(); - if (m_showCurve) + if (isCurveVisibile()) { // Make sure we have set correct case data into the result definitions. @@ -217,10 +217,9 @@ void RimWellLogExtractionCurve::updatePlotData() } } - updateCurveTitle(); + updatePlotTitle(); m_plot->replot(); } - } //-------------------------------------------------------------------------------------------------- @@ -277,16 +276,17 @@ QList RimWellLogExtractionCurve::calculateValueOptions(c //-------------------------------------------------------------------------------------------------- void RimWellLogExtractionCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { + RimWellLogPlotCurve::defineUiOrdering(uiConfigName, uiOrdering); + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); - uiOrdering.add(&m_userName); + uiOrdering.add(&m_wellPath); caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Result"); group1->add(&m_case); if (eclipseCase) { - group1->add(&(m_eclipseResultDefinition->m_resultTypeUiField)); group1->add(&(m_eclipseResultDefinition->m_porosityModelUiField)); group1->add(&(m_eclipseResultDefinition->m_resultVariableUiField)); @@ -310,33 +310,6 @@ void RimWellLogExtractionCurve::initAfterRead() m_geomResultDefinition->setGeoMechCase(geomCase); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellLogExtractionCurve::updateCurveTitle() -{ - RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); - RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); - QString resVar; - if (eclipseCase) - { - resVar = m_eclipseResultDefinition->resultVariable(); - } - - if (geomCase) - { - QString resCompName = m_geomResultDefinition->resultComponentUiName(); - if (resCompName.isEmpty()) - resVar = m_geomResultDefinition->resultFieldUiName(); - else - resVar = m_geomResultDefinition->resultFieldUiName() + "." + resCompName ; - } - - m_userName = resVar; - - m_plotCurve->setTitle(m_userName); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -442,3 +415,29 @@ void RimWellLogExtractionCurve::filteredIntervals(const std::vector< std::pair(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + QString resVar; + if (eclipseCase) + { + resVar = m_eclipseResultDefinition->resultVariable(); + } + + if (geomCase) + { + QString resCompName = m_geomResultDefinition->resultComponentUiName(); + if (resCompName.isEmpty()) + resVar = m_geomResultDefinition->resultFieldUiName(); + else + resVar = m_geomResultDefinition->resultFieldUiName() + "." + resCompName; + } + + return resVar; +} + diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h index 8695dc1291..5fa37fc13a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h @@ -42,7 +42,7 @@ public: virtual void updatePlotData(); protected: - void updateCurveTitle(); + virtual QString createCurveName(); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp index ac5a7b172c..23049387a8 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp @@ -65,9 +65,9 @@ RimWellLogFileCurve::~RimWellLogFileCurve() //-------------------------------------------------------------------------------------------------- void RimWellLogFileCurve::updatePlotData() { - RimWellLogPlotCurve::updatePlotData(); + RimWellLogPlotCurve::updatePlotConfiguration(); - if (m_showCurve) + if (isCurveVisibile()) { if (m_wellPath) { @@ -81,7 +81,7 @@ void RimWellLogFileCurve::updatePlotData() if (values.size() > 0 && depthValues.size() > 0) { - m_plotCurve->setSamples(values.data(), depthValues.data(), (int) depthValues.size()); + m_plotCurve->setSamples(values.data(), depthValues.data(), (int)depthValues.size()); } else { @@ -127,6 +127,7 @@ void RimWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFie if (changedField == &m_wellPath) { + this->updatePlotTitle(); this->updatePlotData(); if (wellLoglot) @@ -142,11 +143,7 @@ void RimWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFie } else if (changedField == &m_wellLogChannnelName) { - if (oldValue.toString() == m_userName) - { - m_userName = m_wellLogChannnelName; - } - + this->updatePlotTitle(); this->updatePlotData(); if (wellLoglot) @@ -172,7 +169,8 @@ void RimWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFie //-------------------------------------------------------------------------------------------------- void RimWellLogFileCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - uiOrdering.add(&m_userName); + RimWellLogPlotCurve::defineUiOrdering(uiConfigName, uiOrdering); + uiOrdering.add(&m_wellPath); uiOrdering.add(&m_wellLogChannnelName); } @@ -237,3 +235,11 @@ QList RimWellLogFileCurve::calculateValueOptions(const c return optionList; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellLogFileCurve::createCurveName() +{ + return "The method or operation is not implemented."; +} + diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h index 6f9176f6e1..523b3a7f71 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.h @@ -40,13 +40,18 @@ class RimWellLogFileCurve : public RimWellLogPlotCurve public: RimWellLogFileCurve(); virtual ~RimWellLogFileCurve(); - - virtual void updatePlotData(); void setWellPath(RimWellPath* wellPath); void setWellLogChannelName(const QString& name); + + // Overrides from RimWellLogPlotCurve + virtual void updatePlotData(); protected: + // Overrides from RimWellLogPlotCurve + virtual QString createCurveName(); + + // Pdm overrrides virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = ""); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp index e08cfff5b3..aca8538d4a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.cpp @@ -26,7 +26,8 @@ #include "cvfAssert.h" -CAF_PDM_SOURCE_INIT(RimWellLogPlotCurve, "WellLogPlotCurve"); +// NB! Special macro for pure virtual class +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimWellLogPlotCurve, "WellLogPlotCurve"); //-------------------------------------------------------------------------------------------------- /// @@ -37,7 +38,14 @@ RimWellLogPlotCurve::RimWellLogPlotCurve() CAF_PDM_InitField(&m_showCurve, "Show", true, "Show curve", "", "", ""); m_showCurve.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_userName, "CurveDescription", "Name", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_customCurveName, "CurveDescription", "Name", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_generatedCurveName, "GeneratedCurveName", "Generated Curve Name", "", "", ""); + m_generatedCurveName.uiCapability()->setUiReadOnly(true); + m_generatedCurveName.xmlCapability()->setIOReadable(false); + m_generatedCurveName.xmlCapability()->setIOWritable(false); + + CAF_PDM_InitField(&m_useCustomCurveName, "UseCustomCurveName", false, "Custom Curve Name", "", "", ""); CAF_PDM_InitField(&m_curveColor, "Color", cvf::Color3f(cvf::Color3::BLACK), "Color", "", "", ""); @@ -65,23 +73,24 @@ void RimWellLogPlotCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFie if (changedField == &m_showCurve) { this->updateCurveVisibility(); - m_plot->replot(); } - if (m_showCurve()) + if (changedField == &m_customCurveName) { - if (changedField == &m_userName) - { - m_plotCurve->setTitle(this->m_userName()); - m_plot->replot(); - } - - if (&m_curveColor == changedField) - { - m_plotCurve->setPen(QPen(QColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte()))); - m_plot->replot(); - } + updatePlotTitle(); } + + if (&m_curveColor == changedField) + { + m_plotCurve->setPen(QPen(QColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte()))); + } + + if (changedField == &m_useCustomCurveName) + { + updatePlotTitle(); + } + + m_plot->replot(); } //-------------------------------------------------------------------------------------------------- @@ -110,11 +119,10 @@ void RimWellLogPlotCurve::updateCurveVisibility() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogPlotCurve::updatePlotData() +void RimWellLogPlotCurve::updatePlotConfiguration() { this->updateCurveVisibility(); - m_plotCurve->setTitle(this->m_userName()); m_plotCurve->setPen(QPen(QColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte()))); // Todo: Rest of the curve setup controlled from this class } @@ -137,7 +145,14 @@ void RimWellLogPlotCurve::setPlot(RiuWellLogTrackPlot* plot) //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimWellLogPlotCurve::userDescriptionField() { - return &m_userName; + if (m_useCustomCurveName) + { + return &m_customCurveName; + } + else + { + return &m_generatedCurveName; + } } //-------------------------------------------------------------------------------------------------- @@ -202,3 +217,38 @@ QwtPlotCurve* RimWellLogPlotCurve::plotCurve() const { return m_plotCurve; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlotCurve::updatePlotTitle() +{ + if (m_useCustomCurveName) + { + m_plotCurve->setTitle(m_customCurveName); + } + else + { + m_generatedCurveName = this->createCurveName(); + m_plotCurve->setTitle(m_generatedCurveName); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogPlotCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&m_customCurveName); + uiOrdering.add(&m_generatedCurveName); + uiOrdering.add(&m_useCustomCurveName); + uiOrdering.add(&m_curveColor); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogPlotCurve::isCurveVisibile() +{ + return m_showCurve; +} diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h index 4d6ad30aa7..3f4c6208c4 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h @@ -19,9 +19,9 @@ #pragma once -#include "cafPdmObject.h" #include "cafPdmField.h" #include "cafPdmFieldCvfColor.h" +#include "cafPdmObject.h" #include @@ -41,7 +41,6 @@ public: RimWellLogPlotCurve(); virtual ~RimWellLogPlotCurve(); - void setDescription(QString description) {m_userName = description;} void setColor(const cvf::Color3f& color); bool depthRange(double* minimumDepth, double* maximumDepth) const; @@ -50,25 +49,33 @@ public: void setPlot(RiuWellLogTrackPlot* plot); void detachCurve(); - QwtPlotCurve* plotCurve() const; + bool isCurveVisibile(); + + QwtPlotCurve* plotCurve() const; - virtual void updatePlotData(); + virtual void updatePlotData() = 0; protected: + virtual QString createCurveName() = 0; + + void updatePlotConfiguration(); void updateCurveVisibility(); + void updatePlotTitle(); // Overridden PDM methods - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual caf::PdmFieldHandle* objectToggleField(); - virtual caf::PdmFieldHandle* userDescriptionField(); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual caf::PdmFieldHandle* objectToggleField(); + virtual caf::PdmFieldHandle* userDescriptionField(); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); - caf::PdmField m_showCurve; - caf::PdmField m_userName; - caf::PdmField m_curveColor; - // caf::PdmField m_lineStyle; - // caf::PdmField m_lineWidth; - RiuWellLogTrackPlot* m_plot; RiuWellLogPlotCurve* m_plotCurve; + +private: + caf::PdmField m_showCurve; + caf::PdmField m_customCurveName; + caf::PdmField m_generatedCurveName; + caf::PdmField m_useCustomCurveName; + caf::PdmField m_curveColor; };