mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 23:23:01 -06:00
(#396) Added scrollbar for panning of well trace plots
This commit is contained in:
parent
7103b196e3
commit
2de4d0df29
@ -33,6 +33,7 @@
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimView.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
@ -104,6 +105,13 @@ void RicDeleteItemExec::redo()
|
||||
{
|
||||
wellPathColl->scheduleGeometryRegenAndRedrawViews();
|
||||
}
|
||||
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
parentObj->firstAnchestorOrThisOfType(wellLogPlot);
|
||||
if (wellLogPlot)
|
||||
{
|
||||
wellLogPlot->updateAvailableDepthRange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,14 @@ RimWellLogPlot::RimWellLogPlot()
|
||||
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show well log plot", "", "", "");
|
||||
showWindow.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&m_minimumDepth, "MinimumDepth", 0.0, "Set minimum depth", "", "", "");
|
||||
CAF_PDM_InitField(&m_maximumDepth, "MaximumDepth", 1000.0, "Set maximum depth", "", "", "");
|
||||
CAF_PDM_InitField(&m_minimumVisibleDepth, "MinimumDepth", 0.0, "Set minimum depth", "", "", "");
|
||||
CAF_PDM_InitField(&m_maximumVisibleDepth, "MaximumDepth", 1000.0, "Set maximum depth", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&traces, "Traces", "", "", "", "");
|
||||
traces.uiCapability()->setUiHidden(true);
|
||||
|
||||
updateViewerWidget();
|
||||
updateAvailableDepthRange();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -116,9 +117,9 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (changedField == &m_minimumDepth || changedField == &m_maximumDepth)
|
||||
else if (changedField == &m_minimumVisibleDepth || changedField == &m_maximumVisibleDepth)
|
||||
{
|
||||
m_viewer->setDepthRange(m_minimumDepth, m_maximumDepth);
|
||||
m_viewer->setDepthRange(m_minimumVisibleDepth, m_maximumVisibleDepth);
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,17 +161,81 @@ RiuWellLogPlot* RimWellLogPlot::viewer()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::zoomDepth(double zoomFactor)
|
||||
{
|
||||
double center = (m_maximumDepth + m_minimumDepth)/2;
|
||||
double newHalfDepth = zoomFactor*(m_maximumDepth - m_minimumDepth)/2;
|
||||
double center = (m_maximumVisibleDepth + m_minimumVisibleDepth)/2;
|
||||
double newHalfDepth = zoomFactor*(m_maximumVisibleDepth - m_minimumVisibleDepth)/2;
|
||||
|
||||
double newMinimum = center - newHalfDepth;
|
||||
double newMaximum = center + newHalfDepth;
|
||||
|
||||
m_minimumDepth = newMinimum;
|
||||
m_maximumDepth = newMaximum;
|
||||
|
||||
m_minimumDepth.uiCapability()->updateConnectedEditors();
|
||||
m_maximumDepth.uiCapability()->updateConnectedEditors();
|
||||
|
||||
m_viewer->setDepthRange(m_minimumDepth, m_maximumDepth);
|
||||
setDepthRange(newMinimum, newMaximum);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::setDepthRange(double minimumDepth, double maximumDepth)
|
||||
{
|
||||
m_minimumVisibleDepth = minimumDepth;
|
||||
m_maximumVisibleDepth = maximumDepth;
|
||||
|
||||
m_minimumVisibleDepth.uiCapability()->updateConnectedEditors();
|
||||
m_maximumVisibleDepth.uiCapability()->updateConnectedEditors();
|
||||
|
||||
m_viewer->setDepthRange(m_minimumVisibleDepth, m_maximumVisibleDepth);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::updateAvailableDepthRange()
|
||||
{
|
||||
double minDepth = DBL_MAX;
|
||||
double maxDepth = DBL_MIN;
|
||||
|
||||
for (size_t tIdx = 0; tIdx < traces.size(); tIdx++)
|
||||
{
|
||||
double minTraceDepth = DBL_MAX;
|
||||
double maxTraceDepth = DBL_MIN;
|
||||
|
||||
if (traces[tIdx]->availableDepthRange(&minTraceDepth, &maxTraceDepth))
|
||||
{
|
||||
if (minTraceDepth < minDepth)
|
||||
{
|
||||
minDepth = minTraceDepth;
|
||||
}
|
||||
|
||||
if (maxTraceDepth > maxDepth)
|
||||
{
|
||||
maxDepth = maxTraceDepth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_depthRangeMinimum = minDepth;
|
||||
m_depthRangeMaximum = maxDepth;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellLogPlot::availableDepthRange(double* minimumDepth, double* maximumDepth)
|
||||
{
|
||||
if (m_maximumVisibleDepth > m_minimumVisibleDepth)
|
||||
{
|
||||
*minimumDepth = m_depthRangeMinimum;
|
||||
*maximumDepth = m_depthRangeMaximum;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::visibleDepthRange(double* minimumDepth, double* maximumDepth)
|
||||
{
|
||||
*minimumDepth = m_minimumVisibleDepth;
|
||||
*maximumDepth = m_maximumVisibleDepth;
|
||||
}
|
||||
|
@ -48,6 +48,12 @@ public:
|
||||
RiuWellLogPlot* viewer();
|
||||
|
||||
void zoomDepth(double zoomFactor);
|
||||
void setDepthRange(double minimumDepth, double maximumDepth);
|
||||
|
||||
void updateAvailableDepthRange();
|
||||
bool availableDepthRange(double* minimumDepth, double* maximumDepth);
|
||||
|
||||
void visibleDepthRange(double* minimumDepth, double* maximumDepth);
|
||||
|
||||
protected:
|
||||
|
||||
@ -56,13 +62,15 @@ protected:
|
||||
|
||||
private:
|
||||
void updateViewerWidget();
|
||||
void setDepthRange(double minimumDepth, double maximumDepth);
|
||||
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
||||
private:
|
||||
QPointer<RiuWellLogPlot> m_viewer;
|
||||
|
||||
caf::PdmField<double> m_minimumDepth;
|
||||
caf::PdmField<double> m_maximumDepth;
|
||||
caf::PdmField<double> m_minimumVisibleDepth;
|
||||
caf::PdmField<double> m_maximumVisibleDepth;
|
||||
|
||||
double m_depthRangeMinimum;
|
||||
double m_depthRangeMaximum;
|
||||
};
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "RimWellLogPlotCurve.h"
|
||||
|
||||
#include "RimWellLogPlot.h"
|
||||
|
||||
#include "RiuWellLogTracePlot.h"
|
||||
|
||||
#include "qwt_plot_curve.h"
|
||||
@ -108,7 +110,14 @@ void RimWellLogPlotCurve::updatePlotData()
|
||||
depthValues.push_back(1000);
|
||||
|
||||
m_plotCurve->setSamples(values.data(), depthValues.data(), (int) depthValues.size());
|
||||
|
||||
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
firstAnchestorOrThisOfType(wellLogPlot);
|
||||
|
||||
if (wellLogPlot)
|
||||
{
|
||||
wellLogPlot->updateAvailableDepthRange();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -128,3 +137,22 @@ caf::PdmFieldHandle* RimWellLogPlotCurve::userDescriptionField()
|
||||
{
|
||||
return &m_userName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellLogPlotCurve::depthRange(double* minimumDepth, double* maximumDepth)
|
||||
{
|
||||
CVF_ASSERT(minimumDepth && maximumDepth);
|
||||
CVF_ASSERT(m_plotCurve);
|
||||
|
||||
if (m_plotCurve->data()->size() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*minimumDepth = m_plotCurve->minYValue();
|
||||
*maximumDepth = m_plotCurve->maxYValue();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
virtual ~RimWellLogPlotCurve();
|
||||
|
||||
void setPlot(RiuWellLogTracePlot* plot);
|
||||
bool depthRange(double* minimumDepth, double* maximumDepth);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -106,3 +106,49 @@ RiuWellLogTracePlot* RimWellLogPlotTrace::viewer()
|
||||
{
|
||||
return m_viewer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellLogPlotTrace::availableDepthRange(double* minimumDepth, double* maximumDepth)
|
||||
{
|
||||
double minDepth = DBL_MAX;
|
||||
double maxDepth = DBL_MIN;
|
||||
|
||||
size_t curveCount = curves.size();
|
||||
if (curveCount < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool rangeUpdated = false;
|
||||
|
||||
for (size_t cIdx = 0; cIdx < curveCount; cIdx++)
|
||||
{
|
||||
double minCurveDepth = DBL_MAX;
|
||||
double maxCurveDepth = DBL_MIN;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
|
||||
void setViewer(RiuWellLogTracePlot* viewer);
|
||||
void addCurve(RimWellLogPlotCurve* curve);
|
||||
bool availableDepthRange(double* minimumDepth, double* maximumDepth);
|
||||
|
||||
RiuWellLogTracePlot* viewer();
|
||||
|
||||
|
@ -28,22 +28,29 @@
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QWheelEvent>
|
||||
#include <QScrollBar>
|
||||
|
||||
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.05
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellLogPlot::RiuWellLogPlot(RimWellLogPlot* dataModelPlot, QWidget* parent)
|
||||
RiuWellLogPlot::RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
Q_ASSERT(dataModelPlot);
|
||||
m_dataModelPlot = dataModelPlot;
|
||||
Q_ASSERT(plotDefinition);
|
||||
m_plotDefinition = plotDefinition;
|
||||
|
||||
m_layout = new QHBoxLayout(this);
|
||||
m_layout->setMargin(0);
|
||||
|
||||
setLayout(m_layout);
|
||||
|
||||
m_scrollBar = new QScrollBar(this);
|
||||
m_scrollBar->setOrientation(Qt::Vertical);
|
||||
m_scrollBar->setVisible(false);
|
||||
m_layout->addWidget(m_scrollBar);
|
||||
|
||||
connect(m_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotSetMinDepth(int)));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -60,7 +67,8 @@ RiuWellLogTracePlot* RiuWellLogPlot::createTracePlot()
|
||||
{
|
||||
RiuWellLogTracePlot* tracePlot = new RiuWellLogTracePlot(this);
|
||||
|
||||
m_layout->addWidget(tracePlot);
|
||||
// Insert the plot to the left of the scroll bar
|
||||
m_layout->insertWidget(m_layout->count() - 1, tracePlot);
|
||||
m_tracePlots.append(tracePlot);
|
||||
|
||||
return tracePlot;
|
||||
@ -75,15 +83,37 @@ void RiuWellLogPlot::setDepthRange(double minDepth, double maxDepth)
|
||||
{
|
||||
m_tracePlots[tpIdx]->setDepthRange(minDepth, maxDepth);
|
||||
}
|
||||
|
||||
updateScrollBar(minDepth, maxDepth);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::updateScrollBar(double minDepth, double maxDepth)
|
||||
{
|
||||
double availableMinDepth;
|
||||
double availableMaxDepth;
|
||||
if (m_plotDefinition->availableDepthRange(&availableMinDepth, &availableMaxDepth))
|
||||
{
|
||||
double availableDepth = availableMaxDepth - availableMinDepth;
|
||||
double visibleDepth = maxDepth - minDepth;
|
||||
|
||||
m_scrollBar->setRange((int) availableMinDepth, (int) (ceil(availableMaxDepth - visibleDepth)));
|
||||
m_scrollBar->setPageStep((int) visibleDepth);
|
||||
m_scrollBar->setValue((int) minDepth);
|
||||
|
||||
m_scrollBar->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
if (!m_dataModelPlot)
|
||||
if (!m_plotDefinition)
|
||||
{
|
||||
QWidget::wheelEvent(event);
|
||||
return;
|
||||
@ -91,12 +121,25 @@ void RiuWellLogPlot::wheelEvent(QWheelEvent* event)
|
||||
|
||||
if (event->delta() > 0)
|
||||
{
|
||||
m_dataModelPlot->zoomDepth(RIU_SCROLLWHEEL_ZOOMFACTOR);
|
||||
m_plotDefinition->zoomDepth(RIU_SCROLLWHEEL_ZOOMFACTOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dataModelPlot->zoomDepth(1.0/RIU_SCROLLWHEEL_ZOOMFACTOR);
|
||||
m_plotDefinition->zoomDepth(1.0/RIU_SCROLLWHEEL_ZOOMFACTOR);
|
||||
}
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::slotSetMinDepth(int value)
|
||||
{
|
||||
double minimumDepth;
|
||||
double maximumDepth;
|
||||
m_plotDefinition->visibleDepthRange(&minimumDepth, &maximumDepth);
|
||||
|
||||
double delta = value - minimumDepth;
|
||||
m_plotDefinition->setDepthRange(minimumDepth + delta, maximumDepth + delta);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ class RiuWellLogTracePlot;
|
||||
|
||||
class QHBoxLayout;
|
||||
class QWheelEvent;
|
||||
class QScrollBar;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -38,7 +39,7 @@ class RiuWellLogPlot : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RiuWellLogPlot(RimWellLogPlot* dataModelPlot, QWidget* parent = NULL);
|
||||
RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent = NULL);
|
||||
virtual ~RiuWellLogPlot();
|
||||
|
||||
RiuWellLogTracePlot* createTracePlot();
|
||||
@ -49,11 +50,15 @@ protected:
|
||||
void wheelEvent(QWheelEvent* event);
|
||||
|
||||
private:
|
||||
void setDefults();
|
||||
void updateScrollBar(double minDepth, double maxDepth);
|
||||
|
||||
private slots:
|
||||
void slotSetMinDepth(int value);
|
||||
|
||||
private:
|
||||
QHBoxLayout* m_layout;
|
||||
QScrollBar* m_scrollBar;
|
||||
QList<RiuWellLogTracePlot*> m_tracePlots;
|
||||
RimWellLogPlot* m_dataModelPlot;
|
||||
RimWellLogPlot* m_plotDefinition;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user