2015-08-26 05:27:29 -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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-09-18 05:29:23 -05:00
|
|
|
#include "RimWellLogPlotTrack.h"
|
2015-08-26 05:27:29 -05:00
|
|
|
|
2015-08-30 19:06:37 -05:00
|
|
|
#include "RimWellLogPlot.h"
|
2015-08-27 09:43:54 -05:00
|
|
|
#include "RimWellLogPlotCurve.h"
|
|
|
|
|
2015-09-18 05:29:23 -05:00
|
|
|
#include "RiuWellLogTrackPlot.h"
|
2015-08-30 19:06:37 -05:00
|
|
|
#include "RiuWellLogPlot.h"
|
2015-08-28 04:45:18 -05:00
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
|
|
|
|
#include "cafPdmUiTreeView.h"
|
2015-08-30 19:06:37 -05:00
|
|
|
#include "cvfAssert.h"
|
2015-08-27 09:13:49 -05:00
|
|
|
|
2015-09-03 07:46:13 -05:00
|
|
|
#include <math.h>
|
2015-09-01 08:15:54 -05:00
|
|
|
|
2015-09-18 05:29:23 -05:00
|
|
|
#define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0
|
|
|
|
#define RI_LOGPLOTTRACK_MAXX_DEFAULT 100.0
|
2015-09-07 08:36:50 -05:00
|
|
|
|
|
|
|
|
2015-09-18 05:29:23 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimWellLogPlotTrack, "WellLogPlotTrack");
|
2015-08-27 09:13:49 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
RimWellLogPlotTrack::RimWellLogPlotTrack()
|
2015-08-27 09:13:49 -05:00
|
|
|
{
|
2015-10-15 03:18:59 -05:00
|
|
|
CAF_PDM_InitObject("Track", ":/WellLogTrack16x16.png", "", "");
|
2015-08-27 09:13:49 -05:00
|
|
|
|
2015-09-18 04:07:21 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_userName, "TrackDescription", "Name", "", "", "");
|
2015-09-18 04:41:14 -05:00
|
|
|
m_userName.uiCapability()->setUiReadOnly(true);
|
2015-09-18 04:07:21 -05:00
|
|
|
|
2015-09-18 05:29:23 -05:00
|
|
|
CAF_PDM_InitField(&m_show, "Show", true, "Show track", "", "", "");
|
2015-09-11 03:44:10 -05:00
|
|
|
m_show.uiCapability()->setUiHidden(true);
|
2015-08-27 09:43:54 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&curves, "Curves", "", "", "", "");
|
|
|
|
curves.uiCapability()->setUiHidden(true);
|
2015-08-30 19:06:37 -05:00
|
|
|
|
2015-09-18 05:29:23 -05:00
|
|
|
CAF_PDM_InitField(&m_visibleXRangeMin, "VisibleXRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_visibleXRangeMax, "VisibleXRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max", "", "", "");
|
2015-08-27 09:13:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
RimWellLogPlotTrack::~RimWellLogPlotTrack()
|
2015-08-27 09:13:49 -05:00
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
delete m_wellLogTrackPlotWidget;
|
2015-08-27 09:13:49 -05:00
|
|
|
}
|
2015-08-26 05:27:29 -05:00
|
|
|
|
2015-09-18 04:07:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
void RimWellLogPlotTrack::setDescription(const QString& description)
|
2015-09-18 04:07:21 -05:00
|
|
|
{
|
|
|
|
m_userName = description;
|
|
|
|
}
|
|
|
|
|
2015-08-26 05:27:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
void RimWellLogPlotTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
2015-08-26 05:27:29 -05:00
|
|
|
{
|
2015-09-11 03:44:10 -05:00
|
|
|
if (changedField == &m_show)
|
2015-08-31 02:57:13 -05:00
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
if (m_wellLogTrackPlotWidget) m_wellLogTrackPlotWidget->setVisible(m_show());
|
2015-08-31 02:57:13 -05:00
|
|
|
}
|
2015-09-18 04:41:14 -05:00
|
|
|
else if (changedField == &m_visibleXRangeMin || changedField == &m_visibleXRangeMax)
|
2015-09-03 05:12:36 -05:00
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax);
|
|
|
|
m_wellLogTrackPlotWidget->replot();
|
2015-09-03 05:12:36 -05:00
|
|
|
}
|
2015-08-26 05:27:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
caf::PdmFieldHandle* RimWellLogPlotTrack::objectToggleField()
|
2015-08-26 05:27:29 -05:00
|
|
|
{
|
2015-09-11 03:44:10 -05:00
|
|
|
return &m_show;
|
2015-08-26 05:27:29 -05:00
|
|
|
}
|
2015-08-28 04:45:18 -05:00
|
|
|
|
2015-09-18 04:07:21 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
caf::PdmFieldHandle* RimWellLogPlotTrack::userDescriptionField()
|
2015-09-18 04:07:21 -05:00
|
|
|
{
|
|
|
|
return &m_userName;
|
|
|
|
}
|
|
|
|
|
2015-08-28 04:45:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
void RimWellLogPlotTrack::addCurve(RimWellLogPlotCurve* curve)
|
2015-08-28 04:45:18 -05:00
|
|
|
{
|
|
|
|
curves.push_back(curve);
|
2015-09-03 08:04:48 -05:00
|
|
|
|
2015-09-22 04:54:58 -05:00
|
|
|
if (m_wellLogTrackPlotWidget)
|
2015-09-03 08:04:48 -05:00
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
curve->setPlot(m_wellLogTrackPlotWidget);
|
2015-09-03 08:04:48 -05:00
|
|
|
}
|
2015-08-30 19:06:37 -05:00
|
|
|
}
|
|
|
|
|
2015-10-19 05:07:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogPlotTrack::removeCurve(RimWellLogPlotCurve* curve)
|
|
|
|
{
|
|
|
|
size_t index = curves.index(curve);
|
|
|
|
if (index >= 0 && index < curves.size())
|
|
|
|
{
|
|
|
|
curves[index]->detachCurve();
|
|
|
|
curves.removeChildObject(curve);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-30 19:06:37 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
RiuWellLogTrackPlot* RimWellLogPlotTrack::viewer()
|
2015-08-30 19:06:37 -05:00
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
return m_wellLogTrackPlotWidget;
|
2015-08-28 04:45:18 -05:00
|
|
|
}
|
2015-09-01 07:50:26 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
bool RimWellLogPlotTrack::availableDepthRange(double* minimumDepth, double* maximumDepth)
|
2015-09-01 07:50:26 -05:00
|
|
|
{
|
2015-09-03 07:21:08 -05:00
|
|
|
double minDepth = HUGE_VAL;
|
|
|
|
double maxDepth = -HUGE_VAL;
|
2015-09-01 07:50:26 -05:00
|
|
|
|
|
|
|
size_t curveCount = curves.size();
|
|
|
|
if (curveCount < 1)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rangeUpdated = false;
|
|
|
|
|
|
|
|
for (size_t cIdx = 0; cIdx < curveCount; cIdx++)
|
|
|
|
{
|
2015-09-03 07:21:08 -05:00
|
|
|
double minCurveDepth = HUGE_VAL;
|
|
|
|
double maxCurveDepth = -HUGE_VAL;
|
2015-09-01 07:50:26 -05:00
|
|
|
|
|
|
|
if (curves[cIdx]->depthRange(&minCurveDepth, &maxCurveDepth))
|
|
|
|
{
|
|
|
|
if (minCurveDepth < minDepth)
|
|
|
|
{
|
|
|
|
minDepth = minCurveDepth;
|
|
|
|
rangeUpdated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxCurveDepth > maxDepth)
|
|
|
|
{
|
|
|
|
maxDepth = maxCurveDepth;
|
|
|
|
rangeUpdated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rangeUpdated)
|
|
|
|
{
|
|
|
|
*minimumDepth = minDepth;
|
|
|
|
*maximumDepth = maxDepth;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rangeUpdated;
|
|
|
|
}
|
2015-09-02 09:46:30 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
void RimWellLogPlotTrack::loadDataAndUpdate()
|
2015-09-02 09:46:30 -05:00
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
CVF_ASSERT(m_wellLogTrackPlotWidget);
|
2015-09-03 07:21:08 -05:00
|
|
|
|
2015-09-11 05:35:59 -05:00
|
|
|
RimWellLogPlot* wellLogPlot;
|
|
|
|
firstAnchestorOrThisOfType(wellLogPlot);
|
|
|
|
if (wellLogPlot)
|
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
m_wellLogTrackPlotWidget->setDepthTitle(wellLogPlot->depthPlotTitle());
|
2015-09-11 05:35:59 -05:00
|
|
|
}
|
|
|
|
|
2015-09-03 07:21:08 -05:00
|
|
|
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
|
2015-09-02 09:46:30 -05:00
|
|
|
{
|
2015-09-03 07:21:08 -05:00
|
|
|
curves[cIdx]->updatePlotData();
|
2015-09-02 09:46:30 -05:00
|
|
|
}
|
|
|
|
}
|
2015-09-03 01:09:06 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
void RimWellLogPlotTrack::recreateViewer()
|
2015-09-03 01:09:06 -05:00
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
CVF_ASSERT(m_wellLogTrackPlotWidget == NULL);
|
2015-09-03 07:21:08 -05:00
|
|
|
|
2015-09-22 04:54:58 -05:00
|
|
|
m_wellLogTrackPlotWidget = new RiuWellLogTrackPlot(this);
|
2015-09-03 01:09:06 -05:00
|
|
|
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
|
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
curves[cIdx]->setPlot(this->m_wellLogTrackPlotWidget);
|
2015-09-03 01:09:06 -05:00
|
|
|
}
|
|
|
|
}
|
2015-09-03 08:10:02 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
void RimWellLogPlotTrack::detachAllCurves()
|
2015-09-03 08:10:02 -05:00
|
|
|
{
|
|
|
|
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
|
|
|
|
{
|
|
|
|
curves[cIdx]->detachCurve();
|
|
|
|
}
|
|
|
|
}
|
2015-09-07 08:36:50 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
void RimWellLogPlotTrack::updateAxisRangesAndReplot()
|
2015-09-07 08:36:50 -05:00
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
if (m_wellLogTrackPlotWidget)
|
2015-09-07 08:36:50 -05:00
|
|
|
{
|
|
|
|
RimWellLogPlot* wellLogPlot;
|
|
|
|
firstAnchestorOrThisOfType(wellLogPlot);
|
|
|
|
if (wellLogPlot)
|
|
|
|
{
|
|
|
|
double minimumDepth, maximumDepth;
|
|
|
|
wellLogPlot->visibleDepthRange(&minimumDepth, &maximumDepth);
|
|
|
|
|
2015-09-22 04:54:58 -05:00
|
|
|
m_wellLogTrackPlotWidget->setDepthRange(minimumDepth, maximumDepth);
|
2015-09-07 08:36:50 -05:00
|
|
|
}
|
|
|
|
|
2015-09-22 04:54:58 -05:00
|
|
|
updateXAxisRangeFromCurves();
|
|
|
|
m_wellLogTrackPlotWidget->setXRange(m_visibleXRangeMin, m_visibleXRangeMax);
|
2015-09-07 08:36:50 -05:00
|
|
|
|
2015-09-22 04:54:58 -05:00
|
|
|
m_wellLogTrackPlotWidget->replot();
|
2015-09-07 08:36:50 -05:00
|
|
|
}
|
|
|
|
}
|
2015-09-17 04:34:03 -05:00
|
|
|
|
2015-09-18 03:50:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
void RimWellLogPlotTrack::updateXAxisRangeFromCurves()
|
2015-09-18 03:50:01 -05:00
|
|
|
{
|
|
|
|
double minValue = HUGE_VAL;
|
|
|
|
double maxValue = -HUGE_VAL;
|
|
|
|
|
2015-09-22 04:54:58 -05:00
|
|
|
for (size_t cIdx = 0; cIdx < curves.size(); cIdx++)
|
2015-09-18 03:50:01 -05:00
|
|
|
{
|
|
|
|
double minCurveValue = HUGE_VAL;
|
|
|
|
double maxCurveValue = -HUGE_VAL;
|
|
|
|
|
|
|
|
if (curves[cIdx]->valueRange(&minCurveValue, &maxCurveValue))
|
|
|
|
{
|
|
|
|
if (minCurveValue < minValue)
|
|
|
|
{
|
|
|
|
minValue = minCurveValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxCurveValue > maxValue)
|
|
|
|
{
|
|
|
|
maxValue = maxCurveValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-22 04:54:58 -05:00
|
|
|
if (minValue == HUGE_VAL)
|
2015-09-18 03:50:01 -05:00
|
|
|
{
|
2015-09-22 04:54:58 -05:00
|
|
|
minValue = RI_LOGPLOTTRACK_MINX_DEFAULT;
|
|
|
|
maxValue = RI_LOGPLOTTRACK_MAXX_DEFAULT;
|
2015-09-18 03:50:01 -05:00
|
|
|
}
|
2015-09-22 04:54:58 -05:00
|
|
|
|
|
|
|
m_visibleXRangeMin = minValue;
|
|
|
|
m_visibleXRangeMax = maxValue;
|
|
|
|
|
|
|
|
updateConnectedEditors();
|
2015-09-18 03:50:01 -05:00
|
|
|
}
|
|
|
|
|
2015-09-17 04:34:03 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
RimWellLogPlotCurve* RimWellLogPlotTrack::curveDefinitionFromCurve(const QwtPlotCurve* curve) const
|
2015-09-17 04:34:03 -05:00
|
|
|
{
|
|
|
|
for (size_t idx = 0; idx < curves.size(); idx++)
|
|
|
|
{
|
|
|
|
if (curves[idx]->plotCurve() == curve)
|
|
|
|
{
|
|
|
|
return curves[idx];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-09-18 04:41:14 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-18 05:29:23 -05:00
|
|
|
void RimWellLogPlotTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
2015-09-18 04:41:14 -05:00
|
|
|
{
|
|
|
|
uiOrdering.add(&m_userName);
|
|
|
|
|
|
|
|
caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup("Visible X Axis Range");
|
|
|
|
gridGroup->add(&m_visibleXRangeMin);
|
|
|
|
gridGroup->add(&m_visibleXRangeMax);
|
|
|
|
}
|