mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#396) Handling scroll wheel event to zoom all well log trace plots
This commit is contained in:
parent
8485e76bf5
commit
ba1b2ec110
@ -43,8 +43,8 @@ RimWellLogPlot::RimWellLogPlot()
|
||||
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show well log plot", "", "", "");
|
||||
showWindow.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&minimumDepth, "MinimumDepth", 0.0, "Set minimum depth", "", "", "");
|
||||
CAF_PDM_InitField(&maximumDepth, "MaximumDepth", 1000.0, "Set maximum depth", "", "", "");
|
||||
CAF_PDM_InitField(&m_minimumDepth, "MinimumDepth", 0.0, "Set minimum depth", "", "", "");
|
||||
CAF_PDM_InitField(&m_maximumDepth, "MaximumDepth", 1000.0, "Set maximum depth", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&traces, "Traces", "", "", "", "");
|
||||
traces.uiCapability()->setUiHidden(true);
|
||||
@ -71,7 +71,7 @@ void RimWellLogPlot::updateViewerWidget()
|
||||
bool isViewerCreated = false;
|
||||
if (!m_viewer)
|
||||
{
|
||||
m_viewer = new RiuWellLogPlot(RiuMainWindow::instance());
|
||||
m_viewer = new RiuWellLogPlot(this, RiuMainWindow::instance());
|
||||
|
||||
RiuMainWindow::instance()->addWellLogViewer(m_viewer);
|
||||
isViewerCreated = true;
|
||||
@ -116,9 +116,9 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (changedField == &minimumDepth || changedField == &maximumDepth)
|
||||
else if (changedField == &m_minimumDepth || changedField == &m_maximumDepth)
|
||||
{
|
||||
m_viewer->setDepthRange(minimumDepth, maximumDepth);
|
||||
m_viewer->setDepthRange(m_minimumDepth, m_maximumDepth);
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,3 +154,23 @@ RiuWellLogPlot* RimWellLogPlot::viewer()
|
||||
{
|
||||
return m_viewer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::zoomDepth(double zoomFactor)
|
||||
{
|
||||
double center = (m_maximumDepth + m_minimumDepth)/2;
|
||||
double newHalfDepth = zoomFactor*(m_maximumDepth - m_minimumDepth)/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);
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ public:
|
||||
|
||||
RiuWellLogPlot* viewer();
|
||||
|
||||
void zoomDepth(double zoomFactor);
|
||||
|
||||
protected:
|
||||
|
||||
// Overridden PDM methods
|
||||
@ -54,12 +56,13 @@ protected:
|
||||
|
||||
private:
|
||||
void updateViewerWidget();
|
||||
void setDepthRange(double minimumDepth, double maximumDepth);
|
||||
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
||||
private:
|
||||
QPointer<RiuWellLogPlot> m_viewer;
|
||||
|
||||
caf::PdmField<double> minimumDepth;
|
||||
caf::PdmField<double> maximumDepth;
|
||||
caf::PdmField<double> m_minimumDepth;
|
||||
caf::PdmField<double> m_maximumDepth;
|
||||
};
|
||||
|
@ -27,13 +27,19 @@
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QWheelEvent>
|
||||
|
||||
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.05
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellLogPlot::RiuWellLogPlot(QWidget* parent)
|
||||
RiuWellLogPlot::RiuWellLogPlot(RimWellLogPlot* dataModelPlot, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
Q_ASSERT(dataModelPlot);
|
||||
m_dataModelPlot = dataModelPlot;
|
||||
|
||||
m_layout = new QHBoxLayout(this);
|
||||
m_layout->setMargin(0);
|
||||
|
||||
@ -70,3 +76,27 @@ void RiuWellLogPlot::setDepthRange(double minDepth, double maxDepth)
|
||||
m_tracePlots[tpIdx]->setDepthRange(minDepth, maxDepth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
if (!m_dataModelPlot)
|
||||
{
|
||||
QWidget::wheelEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->delta() > 0)
|
||||
{
|
||||
m_dataModelPlot->zoomDepth(RIU_SCROLLWHEEL_ZOOMFACTOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dataModelPlot->zoomDepth(1.0/RIU_SCROLLWHEEL_ZOOMFACTOR);
|
||||
}
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
@ -24,7 +24,9 @@
|
||||
|
||||
class RimWellLogPlot;
|
||||
class RiuWellLogTracePlot;
|
||||
|
||||
class QHBoxLayout;
|
||||
class QWheelEvent;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -36,18 +38,22 @@ class RiuWellLogPlot : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RiuWellLogPlot(QWidget* parent = NULL);
|
||||
RiuWellLogPlot(RimWellLogPlot* dataModelPlot, QWidget* parent = NULL);
|
||||
virtual ~RiuWellLogPlot();
|
||||
|
||||
RiuWellLogTracePlot* createTracePlot();
|
||||
|
||||
void setDepthRange(double minDepth, double maxDepth);
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent* event);
|
||||
|
||||
private:
|
||||
void setDefults();
|
||||
|
||||
private:
|
||||
QHBoxLayout* m_layout;
|
||||
QHBoxLayout* m_layout;
|
||||
QList<RiuWellLogTracePlot*> m_tracePlots;
|
||||
RimWellLogPlot* m_dataModelPlot;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user