Skip to content

Commit

Permalink
(#396) Save/Restore of WellLog plots partly in place.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JacobStoren committed Sep 3, 2015
1 parent 30e2495 commit 2a8533b
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion ApplicationCode/Commands/RicNewWellLogPlotCurveFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion ApplicationCode/Commands/RicNewWellLogPlotTraceFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "cafSelectionManager.h"

#include <QAction>
#include "RimWellLogPlotTrace.h"
#include "RiuMainWindow.h"


CAF_CMD_SOURCE_INIT(RicNewWellLogPlotTraceFeature, "RicNewWellLogPlotTraceFeature");
Expand All @@ -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);
}
}

Expand Down
17 changes: 6 additions & 11 deletions ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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());
}
}

//--------------------------------------------------------------------------------------------------
Expand Down
12 changes: 7 additions & 5 deletions ApplicationCode/ProjectDataModel/RimWellLogPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ class RimWellLogPlot : public caf::PdmObject
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();

Expand Down Expand Up @@ -74,6 +71,11 @@ class RimWellLogPlot : public caf::PdmObject
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;

Expand Down
1 change: 1 addition & 0 deletions ApplicationCode/ProjectDataModel/RimWellLogPlotCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
29 changes: 13 additions & 16 deletions ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RimWellLogPlotTrace::RimWellLogPlotTrace()
CAF_PDM_InitFieldNoDefault(&curves, "Curves", "", "", "", "");
curves.uiCapability()->setUiHidden(true);

m_viewer = NULL;
m_viewer = new RiuWellLogTracePlot;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -64,7 +64,7 @@ void RimWellLogPlotTrace::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
{
if (changedField == &show)
{
m_viewer->setVisible(newValue == true);
m_viewer->setVisible(show());
}
}

Expand All @@ -87,20 +87,6 @@ void RimWellLogPlotTrace::addCurve(RimWellLogPlotCurve* curve)
}


//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlotTrace::setViewer(RiuWellLogTracePlot* viewer)
{
if (m_viewer)
{
delete m_viewer;
}

m_viewer = viewer;
}


//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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);
}
}
10 changes: 5 additions & 5 deletions ApplicationCode/ProjectDataModel/RimWellLogPlotTrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ class RimWellLogPlotTrace : public caf::PdmObject
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;
};
6 changes: 2 additions & 4 deletions ApplicationCode/UserInterface/RiuWellLogPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion ApplicationCode/UserInterface/RiuWellLogPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RiuWellLogPlot : public QWidget
RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent = NULL);
virtual ~RiuWellLogPlot();

RiuWellLogTracePlot* createTracePlot();
void insertTracePlot(RiuWellLogTracePlot* tracePlot);

void setDepthRange(double minDepth, double maxDepth);

Expand Down

0 comments on commit 2a8533b

Please sign in to comment.