Merge branch 'master' into release-2019.11

This commit is contained in:
Magne Sjaastad
2019-12-19 08:00:41 +01:00
2 changed files with 157 additions and 157 deletions

View File

@@ -1,114 +1,114 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2015- Statoil ASA // Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS // Copyright (C) 2015- Ceetron Solutions AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RiuWellLogTrack.h" #include "RiuWellLogTrack.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
#include "qwt_scale_draw.h" #include "qwt_scale_draw.h"
#include "qwt_scale_engine.h" #include "qwt_scale_engine.h"
#include "qwt_scale_widget.h" #include "qwt_scale_widget.h"
#include <QWheelEvent> #include <QWheelEvent>
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1 #define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
#define RIU_SCROLLWHEEL_PANFACTOR 0.1 #define RIU_SCROLLWHEEL_PANFACTOR 0.1
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent /*= nullptr */ ) RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent /*= nullptr */ )
: RiuQwtPlotWidget( plotTrackDefinition, parent ) : RiuQwtPlotWidget( plotTrackDefinition, parent )
{ {
setAxisEnabled( QwtPlot::yLeft, true ); setAxisEnabled( QwtPlot::yLeft, true );
setAxisEnabled( QwtPlot::yRight, false ); setAxisEnabled( QwtPlot::yRight, false );
setAxisEnabled( QwtPlot::xTop, true ); setAxisEnabled( QwtPlot::xTop, true );
setAxisEnabled( QwtPlot::xBottom, false ); setAxisEnabled( QwtPlot::xBottom, false );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuWellLogTrack::~RiuWellLogTrack() {} RiuWellLogTrack::~RiuWellLogTrack() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RiuWellLogTrack::eventFilter( QObject* watched, QEvent* event ) bool RiuWellLogTrack::eventFilter( QObject* watched, QEvent* event )
{ {
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>( event ); QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>( event );
if ( wheelEvent && watched == canvas() ) if ( wheelEvent && watched == canvas() )
{ {
RimWellLogTrack* track = dynamic_cast<RimWellLogTrack*>( plotDefinition() ); RimWellLogTrack* track = dynamic_cast<RimWellLogTrack*>( plotDefinition() );
CAF_ASSERT( track ); CAF_ASSERT( track );
RimWellLogPlot* wellLogPlot = nullptr; RimWellLogPlot* wellLogPlot = nullptr;
track->firstAncestorOrThisOfType( wellLogPlot ); track->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot ) if ( wellLogPlot )
{ {
if ( wheelEvent->modifiers() & Qt::ControlModifier ) if ( wheelEvent->modifiers() & Qt::ControlModifier )
{ {
QwtScaleMap scaleMap = canvasMap( QwtPlot::yLeft ); QwtScaleMap scaleMap = canvasMap( QwtPlot::yLeft );
double zoomCenter = scaleMap.invTransform( wheelEvent->pos().y() ); double zoomCenter = scaleMap.invTransform( wheelEvent->pos().y() );
if ( wheelEvent->delta() > 0 ) if ( wheelEvent->delta() > 0 )
{ {
wellLogPlot->setDepthAxisRangeByFactorAndCenter( RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter ); wellLogPlot->setDepthAxisRangeByFactorAndCenter( RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
} }
else else
{ {
wellLogPlot->setDepthAxisRangeByFactorAndCenter( 1.0 / RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter ); wellLogPlot->setDepthAxisRangeByFactorAndCenter( 1.0 / RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
} }
} }
else else
{ {
wellLogPlot->setDepthAxisRangeByPanDepth( wheelEvent->delta() < 0 ? RIU_SCROLLWHEEL_PANFACTOR wellLogPlot->setDepthAxisRangeByPanDepth( wheelEvent->delta() < 0 ? RIU_SCROLLWHEEL_PANFACTOR
: -RIU_SCROLLWHEEL_PANFACTOR ); : -RIU_SCROLLWHEEL_PANFACTOR );
} }
event->accept(); event->accept();
return true; return true;
} }
} }
return RiuQwtPlotWidget::eventFilter( watched, event ); return RiuQwtPlotWidget::eventFilter( watched, event );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::setAxisEnabled( QwtPlot::Axis axis, bool enabled ) void RiuWellLogTrack::setAxisEnabled( QwtPlot::Axis axis, bool enabled )
{ {
if ( enabled ) if ( enabled )
{ {
enableAxis( axis, true ); enableAxis( axis, true );
// Align the canvas with the actual min and max values of the curves // Align the canvas with the actual min and max values of the curves
axisScaleEngine( axis )->setAttribute( QwtScaleEngine::Floating, true ); axisScaleEngine( axis )->setAttribute( QwtScaleEngine::Floating, true );
setAxisScale( axis, 0.0, 100.0 ); setAxisScale( axis, 0.0, 100.0 );
axisScaleDraw( axis )->setMinimumExtent( axisExtent( axis ) ); axisScaleDraw( axis )->setMinimumExtent( axisExtent( axis ) );
axisWidget( axis )->setMargin( 0 ); axisWidget( axis )->setMargin( 0 );
setAxisTitleEnabled( axis, true ); setAxisTitleEnabled( axis, true );
} }
else else
{ {
enableAxis( axis, false ); enableAxis( axis, false );
} }
} }

View File

@@ -1,43 +1,43 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2015- Statoil ASA // Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS // Copyright (C) 2015- Ceetron Solutions AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#pragma once #pragma once
#include "RiuQwtPlotWidget.h" #include "RiuQwtPlotWidget.h"
class RimWellLogTrack; class RimWellLogTrack;
//================================================================================================== //==================================================================================================
// //
// //
// //
//================================================================================================== //==================================================================================================
class RiuWellLogTrack : public RiuQwtPlotWidget class RiuWellLogTrack : public RiuQwtPlotWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent = nullptr ); RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent = nullptr );
~RiuWellLogTrack() override; ~RiuWellLogTrack() override;
protected: protected:
bool eventFilter( QObject* watched, QEvent* event ) override; bool eventFilter( QObject* watched, QEvent* event ) override;
private: private:
void setAxisEnabled( QwtPlot::Axis axis, bool enabled ); void setAxisEnabled( QwtPlot::Axis axis, bool enabled );
}; };