#739 Splitted RimWellLogCurve into a RimPlotCurve base class for use with summary plot curves

This commit is contained in:
Jacob Støren 2016-05-23 15:44:15 +02:00
parent 24edb0501e
commit a2ed19c687
2 changed files with 110 additions and 74 deletions

View File

@ -33,35 +33,36 @@
#include "qwt_symbol.h" #include "qwt_symbol.h"
// NB! Special macro for pure virtual class // NB! Special macro for pure virtual class
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimPlotCurve, "PlotCurve");
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimWellLogCurve, "WellLogPlotCurve"); CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimWellLogCurve, "WellLogPlotCurve");
namespace caf namespace caf
{ {
template<> template<>
void caf::AppEnum< RimWellLogCurve::LineStyleEnum >::setUp() void caf::AppEnum< RimPlotCurve::LineStyleEnum >::setUp()
{ {
addItem(RimWellLogCurve::STYLE_NONE, "STYLE_NONE", "None"); addItem(RimPlotCurve::STYLE_NONE, "STYLE_NONE", "None");
addItem(RimWellLogCurve::STYLE_SOLID, "STYLE_SOLID", "Solid"); addItem(RimPlotCurve::STYLE_SOLID, "STYLE_SOLID", "Solid");
addItem(RimWellLogCurve::STYLE_DASH, "STYLE_DASH", "Dashes"); addItem(RimPlotCurve::STYLE_DASH, "STYLE_DASH", "Dashes");
addItem(RimWellLogCurve::STYLE_DOT, "STYLE_DOT", "Dots"); addItem(RimPlotCurve::STYLE_DOT, "STYLE_DOT", "Dots");
addItem(RimWellLogCurve::STYLE_DASH_DOT,"STYLE_DASH_DOT", "Dashes and Dots"); addItem(RimPlotCurve::STYLE_DASH_DOT,"STYLE_DASH_DOT", "Dashes and Dots");
setDefault(RimWellLogCurve::STYLE_SOLID); setDefault(RimPlotCurve::STYLE_SOLID);
} }
template<> template<>
void caf::AppEnum< RimWellLogCurve::PointSymbolEnum >::setUp() void caf::AppEnum< RimPlotCurve::PointSymbolEnum >::setUp()
{ {
addItem(RimWellLogCurve::SYMBOL_NONE, "SYMBOL_NONE", "None"); addItem(RimPlotCurve::SYMBOL_NONE, "SYMBOL_NONE", "None");
addItem(RimWellLogCurve::SYMBOL_ELLIPSE, "SYMBOL_ELLIPSE", "Ellipse"); addItem(RimPlotCurve::SYMBOL_ELLIPSE, "SYMBOL_ELLIPSE", "Ellipse");
addItem(RimWellLogCurve::SYMBOL_RECT, "SYMBOL_RECT", "Rect"); addItem(RimPlotCurve::SYMBOL_RECT, "SYMBOL_RECT", "Rect");
addItem(RimWellLogCurve::SYMBOL_DIAMOND, "SYMBOL_DIAMOND", "Diamond"); addItem(RimPlotCurve::SYMBOL_DIAMOND, "SYMBOL_DIAMOND", "Diamond");
addItem(RimWellLogCurve::SYMBOL_TRIANGLE, "SYMBOL_TRIANGLE", "Triangle"); addItem(RimPlotCurve::SYMBOL_TRIANGLE, "SYMBOL_TRIANGLE", "Triangle");
addItem(RimWellLogCurve::SYMBOL_CROSS, "SYMBOL_CROSS", "Cross"); addItem(RimPlotCurve::SYMBOL_CROSS, "SYMBOL_CROSS", "Cross");
addItem(RimWellLogCurve::SYMBOL_XCROSS, "SYMBOL_XCROSS", "X Cross"); addItem(RimPlotCurve::SYMBOL_XCROSS, "SYMBOL_XCROSS", "X Cross");
setDefault(RimWellLogCurve::SYMBOL_NONE); setDefault(RimPlotCurve::SYMBOL_NONE);
} }
} }
@ -69,14 +70,42 @@ namespace caf
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellLogCurve::RimWellLogCurve() RimWellLogCurve::RimWellLogCurve()
{
CAF_PDM_InitObject("WellLogCurve", ":/WellLogCurve16x16.png", "", "");
m_qwtPlotCurve->setXAxis(QwtPlot::xTop);
m_qwtPlotCurve->setYAxis(QwtPlot::yLeft);
m_ownerQwtTrack = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogCurve::~RimWellLogCurve()
{
m_qwtPlotCurve->detach();
delete m_qwtPlotCurve;
m_qwtPlotCurve = NULL;
if (m_ownerQwtTrack)
{
m_ownerQwtTrack->replot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotCurve::RimPlotCurve()
{ {
CAF_PDM_InitObject("Curve", ":/WellLogCurve16x16.png", "", ""); CAF_PDM_InitObject("Curve", ":/WellLogCurve16x16.png", "", "");
CAF_PDM_InitField(&m_showCurve, "Show", true, "Show curve", "", "", ""); CAF_PDM_InitField(&m_showCurve, "Show", true, "Show curve", "", "", "");
m_showCurve.uiCapability()->setUiHidden(true); m_showCurve.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_curveName, "CurveName", "Curve Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_curveName, "CurveName", "Curve Name", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_customCurveName, "CurveDescription", "Custom Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_customCurveName, "CurveDescription", "Custom Name", "", "", "");
m_customCurveName.uiCapability()->setUiHidden(true); m_customCurveName.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_autoName, "AutoName", true, "Auto Name", "", "", ""); CAF_PDM_InitField(&m_autoName, "AutoName", true, "Auto Name", "", "", "");
@ -93,30 +122,25 @@ RimWellLogCurve::RimWellLogCurve()
CAF_PDM_InitField(&m_pointSymbol, "PointSymbol", pointSymbol, "Point style", "", "", ""); CAF_PDM_InitField(&m_pointSymbol, "PointSymbol", pointSymbol, "Point style", "", "", "");
m_qwtPlotCurve = new RiuLineSegmentQwtPlotCurve; m_qwtPlotCurve = new RiuLineSegmentQwtPlotCurve;
m_qwtPlotCurve->setXAxis(QwtPlot::xTop);
m_qwtPlotCurve->setYAxis(QwtPlot::yLeft);
m_ownerQwtTrack = NULL;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellLogCurve::~RimWellLogCurve() RimPlotCurve::~RimPlotCurve()
{ {
m_qwtPlotCurve->detach(); if (m_qwtPlotCurve)
delete m_qwtPlotCurve;
if (m_ownerQwtTrack)
{ {
m_ownerQwtTrack->replot(); m_qwtPlotCurve->detach();
delete m_qwtPlotCurve;
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) void RimPlotCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{ {
if (changedField == &m_showCurve) if (changedField == &m_showCurve)
{ {
@ -152,7 +176,7 @@ void RimWellLogCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellLogCurve::objectToggleField() caf::PdmFieldHandle* RimPlotCurve::objectToggleField()
{ {
return &m_showCurve; return &m_showCurve;
} }
@ -160,7 +184,7 @@ caf::PdmFieldHandle* RimWellLogCurve::objectToggleField()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::updateCurveVisibility() void RimPlotCurve::updateCurveVisibility()
{ {
if (m_showCurve() && m_ownerQwtTrack) if (m_showCurve() && m_ownerQwtTrack)
{ {
@ -171,26 +195,13 @@ void RimWellLogCurve::updateCurveVisibility()
m_qwtPlotCurve->detach(); m_qwtPlotCurve->detach();
} }
RimWellLogPlot* wellLogPlot; zoomAllOwnerTrackAndPlot();
this->firstAnchestorOrThisOfType(wellLogPlot);
if (wellLogPlot)
{
wellLogPlot->calculateAvailableDepthRange();
}
RimWellLogTrack* wellLogPlotTrack;
this->firstAnchestorOrThisOfType(wellLogPlotTrack);
if (wellLogPlotTrack)
{
wellLogPlotTrack->zoomAllXAndZoomAllDepthOnOwnerPlot();
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::updatePlotConfiguration() void RimPlotCurve::updatePlotConfiguration()
{ {
this->updateCurveVisibility(); this->updateCurveVisibility();
this->updateCurveName(); this->updateCurveName();
@ -203,7 +214,7 @@ void RimWellLogCurve::updatePlotConfiguration()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::setQwtTrack(RiuWellLogTrack* plot) void RimPlotCurve::setQwtTrack(QwtPlot* plot)
{ {
m_ownerQwtTrack = plot; m_ownerQwtTrack = plot;
if (m_showCurve) if (m_showCurve)
@ -216,7 +227,7 @@ void RimWellLogCurve::setQwtTrack(RiuWellLogTrack* plot)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellLogCurve::userDescriptionField() caf::PdmFieldHandle* RimPlotCurve::userDescriptionField()
{ {
return &m_curveName; return &m_curveName;
} }
@ -262,7 +273,7 @@ bool RimWellLogCurve::valueRange(double* minimumValue, double* maximumValue) con
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::setColor(const cvf::Color3f& color) void RimPlotCurve::setColor(const cvf::Color3f& color)
{ {
m_curveColor = color; m_curveColor = color;
} }
@ -270,7 +281,7 @@ void RimWellLogCurve::setColor(const cvf::Color3f& color)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::detachQwtCurve() void RimPlotCurve::detachQwtCurve()
{ {
m_qwtPlotCurve->detach(); m_qwtPlotCurve->detach();
} }
@ -278,7 +289,7 @@ void RimWellLogCurve::detachQwtCurve()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QwtPlotCurve* RimWellLogCurve::plotCurve() const QwtPlotCurve* RimPlotCurve::plotCurve() const
{ {
return m_qwtPlotCurve; return m_qwtPlotCurve;
} }
@ -286,7 +297,7 @@ QwtPlotCurve* RimWellLogCurve::plotCurve() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::updatePlotTitle() void RimPlotCurve::updatePlotTitle()
{ {
m_qwtPlotCurve->setTitle(m_curveName); m_qwtPlotCurve->setTitle(m_curveName);
} }
@ -294,7 +305,7 @@ void RimWellLogCurve::updatePlotTitle()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimWellLogCurve::isCurveVisible() const bool RimPlotCurve::isCurveVisible() const
{ {
return m_showCurve; return m_showCurve;
} }
@ -302,7 +313,7 @@ bool RimWellLogCurve::isCurveVisible() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::initAfterRead() void RimPlotCurve::initAfterRead()
{ {
updateOptionSensitivity(); updateOptionSensitivity();
} }
@ -328,10 +339,11 @@ void RimWellLogCurve::zoomAllOwnerTrackAndPlot()
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::updateCurveName() void RimPlotCurve::updateCurveName()
{ {
if (m_autoName) if (m_autoName)
{ {
@ -346,7 +358,7 @@ void RimWellLogCurve::updateCurveName()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::updateOptionSensitivity() void RimPlotCurve::updateOptionSensitivity()
{ {
m_curveName.uiCapability()->setUiReadOnly(m_autoName); m_curveName.uiCapability()->setUiReadOnly(m_autoName);
} }
@ -362,7 +374,7 @@ const RigWellLogCurveData* RimWellLogCurve::curveData() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurve::updateCurveAppearance() void RimPlotCurve::updateCurveAppearance()
{ {
CVF_ASSERT(m_qwtPlotCurve); CVF_ASSERT(m_qwtPlotCurve);
@ -441,7 +453,7 @@ void RimWellLogCurve::updateCurveAppearance()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimWellLogCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) QList<caf::PdmOptionItemInfo> RimPlotCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
{ {
QList<caf::PdmOptionItemInfo> options; QList<caf::PdmOptionItemInfo> options;

View File

@ -33,6 +33,7 @@ class RigWellLogCurveData;
class RiuWellLogTrack; class RiuWellLogTrack;
class RiuLineSegmentQwtPlotCurve; class RiuLineSegmentQwtPlotCurve;
class QwtPlot;
class QwtPlotCurve; class QwtPlotCurve;
class QString; class QString;
@ -105,7 +106,7 @@ protected:
/// ///
/// ///
//================================================================================================== //==================================================================================================
class RimWellLogCurve : public caf::PdmObject class RimPlotCurve : public caf::PdmObject
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
public: public:
@ -128,42 +129,38 @@ public:
SYMBOL_CROSS, SYMBOL_CROSS,
SYMBOL_XCROSS SYMBOL_XCROSS
}; };
public: public:
RimWellLogCurve(); RimPlotCurve();
virtual ~RimWellLogCurve(); virtual ~RimPlotCurve();
void setColor(const cvf::Color3f& color); void setColor(const cvf::Color3f& color);
bool depthRange(double* minimumDepth, double* maximumDepth) const;
bool valueRange(double* minimumValue, double* maximumValue) const; void setQwtTrack(QwtPlot* plot);
void setQwtTrack(RiuWellLogTrack* plot);
void detachQwtCurve(); void detachQwtCurve();
bool isCurveVisible() const; bool isCurveVisible() const;
QwtPlotCurve* plotCurve() const; QwtPlotCurve* plotCurve() const;
const RigWellLogCurveData* curveData() const;
QString name() const { return m_curveName; } QString name() const { return m_curveName; }
void updateCurveName(); void updateCurveName();
void updatePlotTitle(); void updatePlotTitle();
virtual QString wellName() const = 0;
virtual QString wellLogChannelName() const = 0;
virtual QString wellDate() const { return ""; };
virtual void updatePlotData() = 0; virtual void updatePlotData() = 0;
protected: protected:
virtual QString createCurveName() = 0; virtual QString createCurveName() = 0;
void updatePlotConfiguration(); void updatePlotConfiguration();
void updateCurveVisibility(); void updateCurveVisibility();
void zoomAllOwnerTrackAndPlot(); virtual void zoomAllOwnerTrackAndPlot() = 0;
void updateOptionSensitivity(); void updateOptionSensitivity();
void updateCurveAppearance(); void updateCurveAppearance();
protected:
// Overridden PDM methods // Overridden PDM methods
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual caf::PdmFieldHandle* objectToggleField(); virtual caf::PdmFieldHandle* objectToggleField();
@ -171,10 +168,9 @@ protected:
virtual void initAfterRead(); virtual void initAfterRead();
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly);
protected:
QPointer<RiuWellLogTrack> m_ownerQwtTrack; QPointer<QwtPlot> m_ownerQwtTrack;
RiuLineSegmentQwtPlotCurve* m_qwtPlotCurve; RiuLineSegmentQwtPlotCurve* m_qwtPlotCurve;
cvf::ref<RigWellLogCurveData> m_curveData;
caf::PdmField<bool> m_showCurve; caf::PdmField<bool> m_showCurve;
caf::PdmField<QString> m_curveName; caf::PdmField<QString> m_curveName;
@ -187,3 +183,31 @@ protected:
caf::PdmField< caf::AppEnum< PointSymbolEnum > > m_pointSymbol; caf::PdmField< caf::AppEnum< PointSymbolEnum > > m_pointSymbol;
caf::PdmField< caf::AppEnum< LineStyleEnum > > m_lineStyle; caf::PdmField< caf::AppEnum< LineStyleEnum > > m_lineStyle;
}; };
//==================================================================================================
///
///
//==================================================================================================
class RimWellLogCurve : public RimPlotCurve
{
CAF_PDM_HEADER_INIT;
public:
public:
RimWellLogCurve();
virtual ~RimWellLogCurve();
bool depthRange(double* minimumDepth, double* maximumDepth) const;
bool valueRange(double* minimumValue, double* maximumValue) const;
const RigWellLogCurveData* curveData() const;
virtual QString wellName() const = 0;
virtual QString wellLogChannelName() const = 0;
virtual QString wellDate() const { return ""; };
protected:
void zoomAllOwnerTrackAndPlot() override;
cvf::ref<RigWellLogCurveData> m_curveData;
};