#4683 clang-format on all files in ApplicationCode

This commit is contained in:
Magne Sjaastad
2019-09-06 10:40:57 +02:00
parent 3a317504bb
commit fe9e567825
2092 changed files with 117952 additions and 111846 deletions

View File

@@ -2,17 +2,17 @@
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,9 +21,9 @@
#include "RiaApplication.h"
#include "RimWellLogCurve.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimWellLogCurve.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtCurvePointTracker.h"
@@ -48,134 +48,130 @@
#include <cfloat>
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
#define RIU_SCROLLWHEEL_PANFACTOR 0.1
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
#define RIU_SCROLLWHEEL_PANFACTOR 0.1
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuWellLogTrack::RiuWellLogTrack(RimWellLogTrack* plotTrackDefinition, QWidget* parent)
: QwtPlot(parent)
RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent )
: QwtPlot( parent )
{
Q_ASSERT(plotTrackDefinition);
Q_ASSERT( plotTrackDefinition );
m_plotTrackDefinition = plotTrackDefinition;
setDefaults();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuWellLogTrack::~RiuWellLogTrack()
{
}
RiuWellLogTrack::~RiuWellLogTrack() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::setDefaults()
{
RiuQwtPlotTools::setCommonPlotBehaviour(this);
RiuQwtPlotTools::setCommonPlotBehaviour( this );
enableAxis(QwtPlot::xTop, true);
enableAxis(QwtPlot::yLeft, true);
enableAxis(QwtPlot::xBottom, false);
enableAxis(QwtPlot::yRight, false);
enableAxis( QwtPlot::xTop, true );
enableAxis( QwtPlot::yLeft, true );
enableAxis( QwtPlot::xBottom, false );
enableAxis( QwtPlot::yRight, false );
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Inverted, true);
axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Inverted, true );
// Align the canvas with the actual min and max values of the curves
axisScaleEngine(QwtPlot::xTop)->setAttribute(QwtScaleEngine::Floating, true);
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating, true);
setAxisScale(QwtPlot::yLeft, 1000, 0);
setXRange(0, 100);
axisScaleEngine( QwtPlot::xTop )->setAttribute( QwtScaleEngine::Floating, true );
axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Floating, true );
setAxisScale( QwtPlot::yLeft, 1000, 0 );
setXRange( 0, 100 );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::setDepthZoom(double minDepth, double maxDepth)
void RiuWellLogTrack::setDepthZoom( double minDepth, double maxDepth )
{
// Note: Y-axis is inverted
setAxisScale(QwtPlot::yLeft, maxDepth, minDepth);
setAxisScale( QwtPlot::yLeft, maxDepth, minDepth );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::setXRange(double min, double max, QwtPlot::Axis axis)
void RiuWellLogTrack::setXRange( double min, double max, QwtPlot::Axis axis )
{
setAxisScale(axis, min, max);
setAxisScale( axis, min, max );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::setDepthTitle(const QString& title)
void RiuWellLogTrack::setDepthTitle( const QString& title )
{
QwtText axisTitleY = axisTitle(QwtPlot::yLeft);
if (title != axisTitleY.text())
QwtText axisTitleY = axisTitle( QwtPlot::yLeft );
if ( title != axisTitleY.text() )
{
axisTitleY.setText(title);
setAxisTitle(QwtPlot::yLeft, axisTitleY);
axisTitleY.setText( title );
setAxisTitle( QwtPlot::yLeft, axisTitleY );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::setXTitle(const QString& title)
void RiuWellLogTrack::setXTitle( const QString& title )
{
QwtText axisTitleX = axisTitle(QwtPlot::xTop);
if (title != axisTitleX.text())
QwtText axisTitleX = axisTitle( QwtPlot::xTop );
if ( title != axisTitleX.text() )
{
axisTitleX.setText(title);
setAxisTitle(QwtPlot::xTop, axisTitleX);
axisTitleX.setText( title );
setAxisTitle( QwtPlot::xTop, axisTitleX );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuWellLogTrack::eventFilter(QObject* watched, QEvent* event)
bool RiuWellLogTrack::eventFilter( QObject* watched, QEvent* event )
{
if (watched == canvas())
if ( watched == canvas() )
{
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>(event);
if (wheelEvent)
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>( event );
if ( wheelEvent )
{
if (!m_plotTrackDefinition)
if ( !m_plotTrackDefinition )
{
return QwtPlot::eventFilter(watched, event);
return QwtPlot::eventFilter( watched, event );
}
RimWellLogPlot* plotDefinition;
m_plotTrackDefinition->firstAncestorOrThisOfType(plotDefinition);
if (!plotDefinition)
m_plotTrackDefinition->firstAncestorOrThisOfType( plotDefinition );
if ( !plotDefinition )
{
return QwtPlot::eventFilter(watched, event);
return QwtPlot::eventFilter( watched, event );
}
if (wheelEvent->modifiers() & Qt::ControlModifier)
if ( wheelEvent->modifiers() & Qt::ControlModifier )
{
QwtScaleMap scaleMap = canvasMap(QwtPlot::yLeft);
double zoomCenter = scaleMap.invTransform(wheelEvent->pos().y());
QwtScaleMap scaleMap = canvasMap( QwtPlot::yLeft );
double zoomCenter = scaleMap.invTransform( wheelEvent->pos().y() );
if (wheelEvent->delta() > 0)
if ( wheelEvent->delta() > 0 )
{
plotDefinition->setDepthZoomByFactorAndCenter(RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter);
plotDefinition->setDepthZoomByFactorAndCenter( RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
}
else
{
plotDefinition->setDepthZoomByFactorAndCenter(1.0/RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter);
plotDefinition->setDepthZoomByFactorAndCenter( 1.0 / RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
}
}
else
{
plotDefinition->panDepth(wheelEvent->delta() < 0 ? RIU_SCROLLWHEEL_PANFACTOR : -RIU_SCROLLWHEEL_PANFACTOR);
plotDefinition->panDepth( wheelEvent->delta() < 0 ? RIU_SCROLLWHEEL_PANFACTOR
: -RIU_SCROLLWHEEL_PANFACTOR );
}
event->accept();
@@ -183,97 +179,96 @@ bool RiuWellLogTrack::eventFilter(QObject* watched, QEvent* event)
}
else
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (mouseEvent)
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>( event );
if ( mouseEvent )
{
if (mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonRelease)
if ( mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonRelease )
{
selectClosestCurve(mouseEvent->pos());
selectClosestCurve( mouseEvent->pos() );
}
}
}
}
return QwtPlot::eventFilter(watched, event);
return QwtPlot::eventFilter( watched, event );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::selectClosestCurve(const QPoint& pos)
void RiuWellLogTrack::selectClosestCurve( const QPoint& pos )
{
QwtPlotCurve* closestCurve = nullptr;
double distMin = DBL_MAX;
double distMin = DBL_MAX;
const QwtPlotItemList& itmList = itemList();
for (QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++)
for ( QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++ )
{
if ((*it )->rtti() == QwtPlotItem::Rtti_PlotCurve )
if ( ( *it )->rtti() == QwtPlotItem::Rtti_PlotCurve )
{
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>(*it);
double dist = DBL_MAX;
candidateCurve->closestPoint(pos, &dist);
if (dist < distMin)
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>( *it );
double dist = DBL_MAX;
candidateCurve->closestPoint( pos, &dist );
if ( dist < distMin )
{
closestCurve = candidateCurve;
distMin = dist;
distMin = dist;
}
}
}
if (closestCurve && distMin < 20)
if ( closestCurve && distMin < 20 )
{
RimWellLogCurve* selectedCurve = m_plotTrackDefinition->curveDefinitionFromCurve(closestCurve);
if (selectedCurve)
RimWellLogCurve* selectedCurve = m_plotTrackDefinition->curveDefinitionFromCurve( closestCurve );
if ( selectedCurve )
{
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem(selectedCurve);
RiuPlotMainWindowTools::selectAsCurrentItem( selectedCurve );
return;
}
}
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem(m_plotTrackDefinition);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiuWellLogTrack::sizeHint() const
{
return QSize(0, 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiuWellLogTrack::minimumSizeHint() const
{
return QSize(0, 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellLogTrack::isRimTrackVisible()
{
if (m_plotTrackDefinition)
{
return m_plotTrackDefinition->isVisible();
}
return false;
RiuPlotMainWindowTools::selectAsCurrentItem( m_plotTrackDefinition );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::enableDepthAxisLabelsAndTitle(bool enable)
QSize RiuWellLogTrack::sizeHint() const
{
this->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtAbstractScaleDraw::Ticks, enable);
this->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtAbstractScaleDraw::Labels, enable);
return QSize( 0, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiuWellLogTrack::minimumSizeHint() const
{
return QSize( 0, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellLogTrack::isRimTrackVisible()
{
if ( m_plotTrackDefinition )
{
return m_plotTrackDefinition->isVisible();
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::enableDepthAxisLabelsAndTitle( bool enable )
{
this->axisScaleDraw( QwtPlot::yLeft )->enableComponent( QwtAbstractScaleDraw::Ticks, enable );
this->axisScaleDraw( QwtPlot::yLeft )->enableComponent( QwtAbstractScaleDraw::Labels, enable );
}
//--------------------------------------------------------------------------------------------------
@@ -281,7 +276,7 @@ void RiuWellLogTrack::enableDepthAxisLabelsAndTitle(bool enable)
//--------------------------------------------------------------------------------------------------
int RiuWellLogTrack::widthScaleFactor() const
{
if (m_plotTrackDefinition)
if ( m_plotTrackDefinition )
{
return m_plotTrackDefinition->widthScaleFactor();
}
@@ -291,63 +286,66 @@ int RiuWellLogTrack::widthScaleFactor() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::enableXGridLines(bool majorGridLines, bool minorGridLines)
void RiuWellLogTrack::enableXGridLines( bool majorGridLines, bool minorGridLines )
{
QwtPlotItemList plotItems = this->itemList(QwtPlotItem::Rtti_PlotGrid);
for (QwtPlotItem* plotItem : plotItems)
QwtPlotItemList plotItems = this->itemList( QwtPlotItem::Rtti_PlotGrid );
for ( QwtPlotItem* plotItem : plotItems )
{
QwtPlotGrid* grid = static_cast<QwtPlotGrid*>(plotItem);
grid->setXAxis(QwtPlot::xTop);
grid->enableX(majorGridLines);
grid->enableXMin(minorGridLines);
grid->setMajorPen(Qt::lightGray, 1.0, Qt::SolidLine);
grid->setMinorPen(Qt::lightGray, 1.0, Qt::DashLine);
QwtPlotGrid* grid = static_cast<QwtPlotGrid*>( plotItem );
grid->setXAxis( QwtPlot::xTop );
grid->enableX( majorGridLines );
grid->enableXMin( minorGridLines );
grid->setMajorPen( Qt::lightGray, 1.0, Qt::SolidLine );
grid->setMinorPen( Qt::lightGray, 1.0, Qt::DashLine );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::enableDepthGridLines(bool majorGridLines, bool minorGridLines)
void RiuWellLogTrack::enableDepthGridLines( bool majorGridLines, bool minorGridLines )
{
QwtPlotItemList plotItems = this->itemList(QwtPlotItem::Rtti_PlotGrid);
for (QwtPlotItem* plotItem : plotItems)
QwtPlotItemList plotItems = this->itemList( QwtPlotItem::Rtti_PlotGrid );
for ( QwtPlotItem* plotItem : plotItems )
{
QwtPlotGrid* grid = static_cast<QwtPlotGrid*>(plotItem);
grid->setYAxis(QwtPlot::yLeft);
grid->enableY(majorGridLines);
grid->enableYMin(minorGridLines);
grid->setMajorPen(Qt::lightGray, 1.0, Qt::SolidLine);
grid->setMinorPen(Qt::lightGray, 1.0, Qt::DashLine);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::setMajorAndMinorTickIntervals(double majorTickInterval, double minorTickInterval)
{
RiuQwtLinearScaleEngine* scaleEngine = dynamic_cast<RiuQwtLinearScaleEngine*>(this->axisScaleEngine(QwtPlot::xTop));
if (scaleEngine)
{
QwtInterval currentRange = this->axisInterval(QwtPlot::xTop);
QwtScaleDiv scaleDiv = scaleEngine->divideScaleWithExplicitIntervals(currentRange.minValue(), currentRange.maxValue(), majorTickInterval, minorTickInterval);
this->setAxisScaleDiv(QwtPlot::xTop, scaleDiv);
QwtPlotGrid* grid = static_cast<QwtPlotGrid*>( plotItem );
grid->setYAxis( QwtPlot::yLeft );
grid->enableY( majorGridLines );
grid->enableYMin( minorGridLines );
grid->setMajorPen( Qt::lightGray, 1.0, Qt::SolidLine );
grid->setMinorPen( Qt::lightGray, 1.0, Qt::DashLine );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::setAutoTickIntervalCounts(int maxMajorTickIntervalCount, int maxMinorTickIntervalCount)
void RiuWellLogTrack::setMajorAndMinorTickIntervals( double majorTickInterval, double minorTickInterval )
{
this->setAxisMaxMajor(QwtPlot::xTop, maxMajorTickIntervalCount);
this->setAxisMaxMinor(QwtPlot::xTop, maxMinorTickIntervalCount);
// Reapply axis limits to force Qwt to use the tick settings.
QwtInterval currentRange = this->axisInterval(QwtPlot::xTop);
this->setXRange(currentRange.minValue(), currentRange.maxValue());
RiuQwtLinearScaleEngine* scaleEngine = dynamic_cast<RiuQwtLinearScaleEngine*>(
this->axisScaleEngine( QwtPlot::xTop ) );
if ( scaleEngine )
{
QwtInterval currentRange = this->axisInterval( QwtPlot::xTop );
QwtScaleDiv scaleDiv = scaleEngine->divideScaleWithExplicitIntervals( currentRange.minValue(),
currentRange.maxValue(),
majorTickInterval,
minorTickInterval );
this->setAxisScaleDiv( QwtPlot::xTop, scaleDiv );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTrack::setAutoTickIntervalCounts( int maxMajorTickIntervalCount, int maxMinorTickIntervalCount )
{
this->setAxisMaxMajor( QwtPlot::xTop, maxMajorTickIntervalCount );
this->setAxisMaxMinor( QwtPlot::xTop, maxMinorTickIntervalCount );
// Reapply axis limits to force Qwt to use the tick settings.
QwtInterval currentRange = this->axisInterval( QwtPlot::xTop );
this->setXRange( currentRange.minValue(), currentRange.maxValue() );
}
//--------------------------------------------------------------------------------------------------
@@ -355,11 +353,11 @@ void RiuWellLogTrack::setAutoTickIntervalCounts(int maxMajorTickIntervalCount, i
//--------------------------------------------------------------------------------------------------
double RiuWellLogTrack::getCurrentMajorTickInterval() const
{
QwtScaleDiv scaleDiv = this->axisScaleDiv(QwtPlot::xTop);
QList<double> majorTicks = scaleDiv.ticks(QwtScaleDiv::MajorTick);
if (majorTicks.size() < 2) return 0.0;
QwtScaleDiv scaleDiv = this->axisScaleDiv( QwtPlot::xTop );
QList<double> majorTicks = scaleDiv.ticks( QwtScaleDiv::MajorTick );
if ( majorTicks.size() < 2 ) return 0.0;
return majorTicks.at(1) - majorTicks.at(0);
return majorTicks.at( 1 ) - majorTicks.at( 0 );
}
//--------------------------------------------------------------------------------------------------
@@ -367,11 +365,9 @@ double RiuWellLogTrack::getCurrentMajorTickInterval() const
//--------------------------------------------------------------------------------------------------
double RiuWellLogTrack::getCurrentMinorTickInterval() const
{
QwtScaleDiv scaleDiv = this->axisScaleDiv(QwtPlot::xTop);
QList<double> minorTicks = scaleDiv.ticks(QwtScaleDiv::MinorTick);
if (minorTicks.size() < 2) return 0.0;
return minorTicks.at(1) - minorTicks.at(0);
QwtScaleDiv scaleDiv = this->axisScaleDiv( QwtPlot::xTop );
QList<double> minorTicks = scaleDiv.ticks( QwtScaleDiv::MinorTick );
if ( minorTicks.size() < 2 ) return 0.0;
return minorTicks.at( 1 ) - minorTicks.at( 0 );
}