(#396) Save/Restore of WellLog plots partly in place.

Cleaned up ownership in WellLog plot classes
initAfterRead() is implemented
moved code related to command features from the WellLog classes
Still plots are not redrawn/reloaded when opening a project file.
This commit is contained in:
Jacob Støren 2015-09-02 16:46:30 +02:00
parent 30e2495849
commit 2a8533bad0
9 changed files with 44 additions and 44 deletions

View File

@ -50,7 +50,7 @@ void RicNewWellLogPlotCurveFeature::onActionTriggered(bool isChecked)
RimWellLogPlotCurve* curve = new RimWellLogExtractionCurve();
wellLogPlotTrace->addCurve(curve);
curve->setUiName(QString("Curve %1").arg(wellLogPlotTrace->curves.size()));
curve->setDescription(QString("Curve %1").arg(wellLogPlotTrace->curveCount()));
wellLogPlotTrace->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(curve);

View File

@ -24,6 +24,8 @@
#include "cafSelectionManager.h"
#include <QAction>
#include "RimWellLogPlotTrace.h"
#include "RiuMainWindow.h"
CAF_CMD_SOURCE_INIT(RicNewWellLogPlotTraceFeature, "RicNewWellLogPlotTraceFeature");
@ -44,7 +46,12 @@ void RicNewWellLogPlotTraceFeature::onActionTriggered(bool isChecked)
RimWellLogPlot* wellLogPlot = selectedWellLogPlot();
if (wellLogPlot)
{
wellLogPlot->addTrace();
RimWellLogPlotTrace* trace = new RimWellLogPlotTrace;
wellLogPlot->addTrace(trace);
trace->setUiName(QString("Trace %1").arg(wellLogPlot->traceCount()));
wellLogPlot->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(trace);
}
}

View File

@ -139,18 +139,10 @@ caf::PdmFieldHandle* RimWellLogPlot::objectToggleField()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::addTrace()
void RimWellLogPlot::addTrace(RimWellLogPlotTrace* trace)
{
RimWellLogPlotTrace* trace = new RimWellLogPlotTrace();
traces.push_back(trace);
trace->setUiName(QString("Trace %1").arg(traces.size()));
RiuWellLogTracePlot* viewer = m_viewer->createTracePlot();
trace->setViewer(viewer);
updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(trace);
m_viewer->insertTracePlot(trace->viewer());
}
//--------------------------------------------------------------------------------------------------
@ -259,7 +251,10 @@ void RimWellLogPlot::visibleDepthRange(double* minimumDepth, double* maximumDept
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::initAfterRead()
{
for (size_t tIdx = 0; tIdx < traces.size(); ++tIdx)
{
m_viewer->insertTracePlot(traces[tIdx]->viewer());
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -40,11 +40,8 @@ public:
RimWellLogPlot();
virtual ~RimWellLogPlot();
caf::PdmChildArrayField<RimWellLogPlotTrace*> traces;
caf::PdmField<bool> showWindow;
caf::PdmField< std::vector<int> > windowGeometry;
void addTrace();
void addTrace(RimWellLogPlotTrace* trace);
size_t traceCount() { return traces.size();}
RiuWellLogPlot* viewer();
@ -74,6 +71,11 @@ private:
private:
QPointer<RiuWellLogPlot> m_viewer;
caf::PdmField<bool> showWindow;
caf::PdmField< std::vector<int> > windowGeometry;
caf::PdmChildArrayField<RimWellLogPlotTrace*> traces;
caf::PdmField<double> m_minimumVisibleDepth;
caf::PdmField<double> m_maximumVisibleDepth;

View File

@ -39,6 +39,7 @@ class RimWellLogPlotCurve : public caf::PdmObject
public:
RimWellLogPlotCurve();
virtual ~RimWellLogPlotCurve();
void setDescription(QString description) {m_userName = description;}
void setPlot(RiuWellLogTracePlot* plot);
bool depthRange(double* minimumDepth, double* maximumDepth);

View File

@ -46,7 +46,7 @@ RimWellLogPlotTrace::RimWellLogPlotTrace()
CAF_PDM_InitFieldNoDefault(&curves, "Curves", "", "", "", "");
curves.uiCapability()->setUiHidden(true);
m_viewer = NULL;
m_viewer = new RiuWellLogTracePlot;
}
//--------------------------------------------------------------------------------------------------
@ -64,7 +64,7 @@ void RimWellLogPlotTrace::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
{
if (changedField == &show)
{
m_viewer->setVisible(newValue == true);
m_viewer->setVisible(show());
}
}
@ -87,20 +87,6 @@ void RimWellLogPlotTrace::addCurve(RimWellLogPlotCurve* curve)
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotTrace::setViewer(RiuWellLogTracePlot* viewer)
{
if (m_viewer)
{
delete m_viewer;
}
m_viewer = viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -154,3 +140,14 @@ bool RimWellLogPlotTrace::availableDepthRange(double* minimumDepth, double* maxi
return rangeUpdated;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotTrace::initAfterRead()
{
for(size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
{
curves[cIdx]->setPlot(this->m_viewer);
}
}

View File

@ -41,23 +41,23 @@ public:
RimWellLogPlotTrace();
virtual ~RimWellLogPlotTrace();
void setViewer(RiuWellLogTracePlot* viewer);
void addCurve(RimWellLogPlotCurve* curve);
size_t curveCount() { return curves.size(); }
bool availableDepthRange(double* minimumDepth, double* maximumDepth);
RiuWellLogTracePlot* viewer();
caf::PdmChildArrayField<RimWellLogPlotCurve*> curves;
protected:
// Overridden PDM methods
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
private:
virtual void initAfterRead();
virtual caf::PdmFieldHandle* objectToggleField();
private:
caf::PdmField<bool> show;
caf::PdmChildArrayField<RimWellLogPlotCurve*> curves;
QPointer<RiuWellLogTracePlot> m_viewer;
};

View File

@ -66,15 +66,13 @@ RiuWellLogPlot::~RiuWellLogPlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellLogTracePlot* RiuWellLogPlot::createTracePlot()
void RiuWellLogPlot::insertTracePlot(RiuWellLogTracePlot* tracePlot)
{
RiuWellLogTracePlot* tracePlot = new RiuWellLogTracePlot(this);
// Insert the plot to the left of the scroll bar
m_layout->insertWidget(m_layout->count() - 1, tracePlot);
m_tracePlots.append(tracePlot);
return tracePlot;
}
//--------------------------------------------------------------------------------------------------

View File

@ -42,7 +42,7 @@ public:
RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent = NULL);
virtual ~RiuWellLogPlot();
RiuWellLogTracePlot* createTracePlot();
void insertTracePlot(RiuWellLogTracePlot* tracePlot);
void setDepthRange(double minDepth, double maxDepth);