2015-08-27 09:13:49 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RimWellLogPlot.h"
|
|
|
|
|
2015-08-27 09:43:54 -05:00
|
|
|
#include "RimWellLogPlotTrace.h"
|
|
|
|
|
2015-08-27 09:13:49 -05:00
|
|
|
#include "RiuWellLogPlot.h"
|
2015-08-30 19:06:37 -05:00
|
|
|
#include "RiuWellLogTracePlot.h"
|
2015-08-27 09:13:49 -05:00
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
|
2015-08-28 04:32:25 -05:00
|
|
|
#include "cafPdmUiTreeView.h"
|
|
|
|
|
2015-08-30 19:06:37 -05:00
|
|
|
#include "cvfAssert.h"
|
2015-08-28 04:32:25 -05:00
|
|
|
|
2015-09-03 07:46:13 -05:00
|
|
|
#include <math.h>
|
2015-09-01 08:15:54 -05:00
|
|
|
|
2015-09-04 07:14:56 -05:00
|
|
|
#define RI_LOGPLOT_MINDEPTH_DEFAULT 0.0
|
|
|
|
#define RI_LOGPLOT_MAXDEPTH_DEFAULT 1000.0
|
|
|
|
|
2015-08-27 09:13:49 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimWellLogPlot, "WellLogPlot");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellLogPlot::RimWellLogPlot()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Well Log Plot", ":/WellCollection.png", "", "");
|
|
|
|
|
|
|
|
m_viewer = NULL;
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show well log plot", "", "", "");
|
|
|
|
showWindow.uiCapability()->setUiHidden(true);
|
2015-08-31 10:21:21 -05:00
|
|
|
|
2015-09-03 05:02:13 -05:00
|
|
|
CAF_PDM_InitField(&m_minimumVisibleDepth, "MinimumDepth", 0.0, "Minimum depth", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_maximumVisibleDepth, "MaximumDepth", 1000.0, "Maximum depth", "", "", "");
|
2015-08-27 09:13:49 -05:00
|
|
|
|
2015-08-27 09:43:54 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&traces, "Traces", "", "", "", "");
|
|
|
|
traces.uiCapability()->setUiHidden(true);
|
|
|
|
|
2015-09-02 08:53:49 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&windowGeometry, "WindowGeometry", "", "", "", "");
|
|
|
|
windowGeometry.uiCapability()->setUiHidden(true);
|
2015-09-03 07:21:08 -05:00
|
|
|
|
2015-09-04 07:14:56 -05:00
|
|
|
m_depthRangeMinimum = HUGE_VAL;
|
|
|
|
m_depthRangeMaximum = -HUGE_VAL;
|
2015-08-27 09:13:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellLogPlot::~RimWellLogPlot()
|
|
|
|
{
|
2015-09-02 08:53:49 -05:00
|
|
|
RiuMainWindow::instance()->removeViewer(m_viewer);
|
2015-09-03 08:10:02 -05:00
|
|
|
detachAllCurves();
|
2015-08-31 04:05:55 -05:00
|
|
|
delete m_viewer;
|
2015-08-27 09:13:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogPlot::updateViewerWidget()
|
|
|
|
{
|
|
|
|
if (showWindow())
|
|
|
|
{
|
|
|
|
if (!m_viewer)
|
|
|
|
{
|
2015-09-01 04:14:58 -05:00
|
|
|
m_viewer = new RiuWellLogPlot(this, RiuMainWindow::instance());
|
2015-08-27 09:13:49 -05:00
|
|
|
|
2015-09-03 07:21:08 -05:00
|
|
|
recreateTracePlots();
|
2015-08-31 03:12:45 -05:00
|
|
|
}
|
2015-08-27 09:13:49 -05:00
|
|
|
|
2015-09-03 07:21:08 -05:00
|
|
|
RiuMainWindow::instance()->addViewer(m_viewer, windowGeometry());
|
2015-09-02 08:53:49 -05:00
|
|
|
RiuMainWindow::instance()->setActiveViewer(m_viewer);
|
2015-09-03 07:21:08 -05:00
|
|
|
updateAxisRanges();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_viewer)
|
|
|
|
{
|
|
|
|
windowGeometry = RiuMainWindow::instance()->windowGeometryForViewer(m_viewer);
|
|
|
|
|
|
|
|
RiuMainWindow::instance()->removeViewer(m_viewer);
|
2015-09-03 08:10:02 -05:00
|
|
|
detachAllCurves();
|
2015-09-03 07:21:08 -05:00
|
|
|
delete m_viewer;
|
|
|
|
m_viewer = NULL;
|
|
|
|
|
|
|
|
}
|
2015-08-27 09:13:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
|
|
|
if (changedField == &showWindow)
|
|
|
|
{
|
2015-09-03 07:21:08 -05:00
|
|
|
updateViewerWidget();
|
2015-08-27 09:13:49 -05:00
|
|
|
}
|
2015-09-01 07:50:26 -05:00
|
|
|
else if (changedField == &m_minimumVisibleDepth || changedField == &m_maximumVisibleDepth)
|
2015-08-31 10:21:21 -05:00
|
|
|
{
|
2015-09-04 07:14:56 -05:00
|
|
|
updateAxisRanges();
|
2015-08-31 10:21:21 -05:00
|
|
|
}
|
2015-08-27 09:13:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimWellLogPlot::objectToggleField()
|
|
|
|
{
|
|
|
|
return &showWindow;
|
|
|
|
}
|
2015-08-28 04:32:25 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-02 09:46:30 -05:00
|
|
|
void RimWellLogPlot::addTrace(RimWellLogPlotTrace* trace)
|
2015-08-28 04:32:25 -05:00
|
|
|
{
|
|
|
|
traces.push_back(trace);
|
2015-09-03 07:21:08 -05:00
|
|
|
if(m_viewer)
|
|
|
|
{
|
|
|
|
trace->recreateViewer();
|
|
|
|
m_viewer->insertTracePlot(trace->viewer());
|
|
|
|
}
|
2015-08-30 19:06:37 -05:00
|
|
|
}
|
2015-08-28 07:25:14 -05:00
|
|
|
|
2015-08-30 19:06:37 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiuWellLogPlot* RimWellLogPlot::viewer()
|
|
|
|
{
|
|
|
|
return m_viewer;
|
2015-08-28 04:32:25 -05:00
|
|
|
}
|
2015-09-01 04:14:58 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogPlot::zoomDepth(double zoomFactor)
|
|
|
|
{
|
2015-09-01 07:50:26 -05:00
|
|
|
double center = (m_maximumVisibleDepth + m_minimumVisibleDepth)/2;
|
|
|
|
double newHalfDepth = zoomFactor*(m_maximumVisibleDepth - m_minimumVisibleDepth)/2;
|
2015-09-01 04:14:58 -05:00
|
|
|
|
|
|
|
double newMinimum = center - newHalfDepth;
|
|
|
|
double newMaximum = center + newHalfDepth;
|
|
|
|
|
2015-09-04 07:14:56 -05:00
|
|
|
setVisibleDepthRange(newMinimum, newMaximum);
|
2015-09-01 07:50:26 -05:00
|
|
|
}
|
|
|
|
|
2015-09-02 09:30:37 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogPlot::panDepth(double panFactor)
|
|
|
|
{
|
|
|
|
double delta = panFactor*(m_maximumVisibleDepth - m_minimumVisibleDepth);
|
2015-09-04 07:14:56 -05:00
|
|
|
setVisibleDepthRange(m_minimumVisibleDepth + delta, m_maximumVisibleDepth + delta);
|
2015-09-02 09:30:37 -05:00
|
|
|
}
|
|
|
|
|
2015-09-01 07:50:26 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-04 07:14:56 -05:00
|
|
|
void RimWellLogPlot::setVisibleDepthRange(double minimumDepth, double maximumDepth)
|
2015-09-01 07:50:26 -05:00
|
|
|
{
|
|
|
|
m_minimumVisibleDepth = minimumDepth;
|
|
|
|
m_maximumVisibleDepth = maximumDepth;
|
|
|
|
|
|
|
|
m_minimumVisibleDepth.uiCapability()->updateConnectedEditors();
|
|
|
|
m_maximumVisibleDepth.uiCapability()->updateConnectedEditors();
|
|
|
|
|
2015-09-04 07:14:56 -05:00
|
|
|
updateAxisRanges();
|
2015-09-01 07:50:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogPlot::updateAvailableDepthRange()
|
|
|
|
{
|
2015-09-03 07:21:08 -05:00
|
|
|
double minDepth = HUGE_VAL;
|
|
|
|
double maxDepth = -HUGE_VAL;
|
2015-09-01 07:50:26 -05:00
|
|
|
|
|
|
|
for (size_t tIdx = 0; tIdx < traces.size(); tIdx++)
|
|
|
|
{
|
2015-09-03 07:21:08 -05:00
|
|
|
double minTraceDepth = HUGE_VAL;
|
|
|
|
double maxTraceDepth = -HUGE_VAL;
|
2015-09-01 07:50:26 -05:00
|
|
|
|
|
|
|
if (traces[tIdx]->availableDepthRange(&minTraceDepth, &maxTraceDepth))
|
|
|
|
{
|
|
|
|
if (minTraceDepth < minDepth)
|
|
|
|
{
|
|
|
|
minDepth = minTraceDepth;
|
|
|
|
}
|
2015-09-01 04:14:58 -05:00
|
|
|
|
2015-09-01 07:50:26 -05:00
|
|
|
if (maxTraceDepth > maxDepth)
|
|
|
|
{
|
|
|
|
maxDepth = maxTraceDepth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-04 07:14:56 -05:00
|
|
|
m_depthRangeMinimum = minDepth;
|
|
|
|
m_depthRangeMaximum = maxDepth;
|
2015-09-01 07:50:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-04 07:14:56 -05:00
|
|
|
void RimWellLogPlot::availableDepthRange(double* minimumDepth, double* maximumDepth) const
|
2015-09-01 07:50:26 -05:00
|
|
|
{
|
2015-09-04 07:14:56 -05:00
|
|
|
if (hasAvailableDepthRange())
|
2015-09-01 07:50:26 -05:00
|
|
|
{
|
|
|
|
*minimumDepth = m_depthRangeMinimum;
|
|
|
|
*maximumDepth = m_depthRangeMaximum;
|
|
|
|
}
|
2015-09-04 07:14:56 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*minimumDepth = RI_LOGPLOT_MINDEPTH_DEFAULT;
|
|
|
|
*maximumDepth = RI_LOGPLOT_MAXDEPTH_DEFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-01 07:50:26 -05:00
|
|
|
|
2015-09-04 07:14:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimWellLogPlot::hasAvailableDepthRange() const
|
|
|
|
{
|
|
|
|
return m_depthRangeMinimum < HUGE_VAL && m_depthRangeMaximum > -HUGE_VAL;
|
2015-09-01 07:50:26 -05:00
|
|
|
}
|
2015-09-01 04:14:58 -05:00
|
|
|
|
2015-09-01 07:50:26 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-03 07:21:08 -05:00
|
|
|
void RimWellLogPlot::visibleDepthRange(double* minimumDepth, double* maximumDepth) const
|
2015-09-01 07:50:26 -05:00
|
|
|
{
|
|
|
|
*minimumDepth = m_minimumVisibleDepth;
|
|
|
|
*maximumDepth = m_maximumVisibleDepth;
|
2015-09-01 04:14:58 -05:00
|
|
|
}
|
2015-09-02 08:53:49 -05:00
|
|
|
|
2015-09-03 07:21:08 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogPlot::setupBeforeSave()
|
|
|
|
{
|
|
|
|
if (m_viewer)
|
|
|
|
{
|
|
|
|
windowGeometry = RiuMainWindow::instance()->windowGeometryForViewer(m_viewer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-02 08:53:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-03 07:21:08 -05:00
|
|
|
void RimWellLogPlot::loadDataAndUpdate()
|
2015-09-02 08:53:49 -05:00
|
|
|
{
|
2015-09-03 07:21:08 -05:00
|
|
|
updateViewerWidget();
|
|
|
|
|
2015-09-02 09:46:30 -05:00
|
|
|
for (size_t tIdx = 0; tIdx < traces.size(); ++tIdx)
|
|
|
|
{
|
2015-09-03 07:21:08 -05:00
|
|
|
traces[tIdx]->loadDataAndUpdate();
|
2015-09-02 09:46:30 -05:00
|
|
|
}
|
2015-09-03 07:21:08 -05:00
|
|
|
|
|
|
|
updateAvailableDepthRange();
|
|
|
|
updateAxisRanges();
|
2015-09-02 08:53:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-03 07:21:08 -05:00
|
|
|
void RimWellLogPlot::updateAxisRanges()
|
2015-09-02 08:53:49 -05:00
|
|
|
{
|
2015-09-04 07:14:56 -05:00
|
|
|
if (m_viewer)
|
|
|
|
{
|
|
|
|
double minDepth = m_minimumVisibleDepth < HUGE_VAL ? m_minimumVisibleDepth : RI_LOGPLOT_MINDEPTH_DEFAULT;
|
|
|
|
double maxDepth = m_maximumVisibleDepth > -HUGE_VAL ? m_maximumVisibleDepth : RI_LOGPLOT_MAXDEPTH_DEFAULT;
|
|
|
|
|
|
|
|
m_viewer->setDepthRange(minDepth, maxDepth);
|
|
|
|
}
|
2015-09-02 08:53:49 -05:00
|
|
|
}
|
2015-09-03 01:09:06 -05:00
|
|
|
|
2015-09-04 05:21:41 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogPlot::setVisibleDepthRangeFromContents()
|
|
|
|
{
|
2015-09-04 07:14:56 -05:00
|
|
|
if (hasAvailableDepthRange())
|
|
|
|
{
|
|
|
|
setVisibleDepthRange(m_depthRangeMinimum, m_depthRangeMaximum);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setVisibleDepthRange(RI_LOGPLOT_MINDEPTH_DEFAULT, RI_LOGPLOT_MAXDEPTH_DEFAULT);
|
|
|
|
}
|
2015-09-04 05:21:41 -05:00
|
|
|
}
|
|
|
|
|
2015-09-03 01:09:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-03 07:21:08 -05:00
|
|
|
void RimWellLogPlot::recreateTracePlots()
|
2015-09-03 01:09:06 -05:00
|
|
|
{
|
2015-09-03 07:21:08 -05:00
|
|
|
CVF_ASSERT(m_viewer);
|
|
|
|
|
2015-09-03 01:09:06 -05:00
|
|
|
for (size_t tIdx = 0; tIdx < traces.size(); ++tIdx)
|
|
|
|
{
|
2015-09-03 07:21:08 -05:00
|
|
|
traces[tIdx]->recreateViewer();
|
|
|
|
m_viewer->insertTracePlot(traces[tIdx]->viewer());
|
2015-09-03 01:09:06 -05:00
|
|
|
}
|
|
|
|
}
|
2015-09-03 08:10:02 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogPlot::detachAllCurves()
|
|
|
|
{
|
|
|
|
for (size_t tIdx = 0; tIdx < traces.size(); ++tIdx)
|
|
|
|
{
|
|
|
|
traces[tIdx]->detachAllCurves();
|
|
|
|
}
|
|
|
|
}
|