2017-02-13 01:40:27 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 06:17:36 -05:00
|
|
|
//
|
2017-02-13 01:40:27 -06:00
|
|
|
// 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.
|
2019-09-06 06:17:36 -05:00
|
|
|
//
|
2017-02-13 01:40:27 -06:00
|
|
|
// 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.
|
2019-09-06 06:17:36 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-02-13 01:40:27 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RiuWellLogPlot.h"
|
|
|
|
|
2018-06-29 04:29:18 -05:00
|
|
|
#include "RiaApplication.h"
|
2019-10-04 01:50:35 -05:00
|
|
|
#include "RiaPreferences.h"
|
2018-06-29 04:29:18 -05:00
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
#include "WellLogCommands/RicWellLogPlotTrackFeatureImpl.h"
|
|
|
|
|
2017-03-16 02:23:27 -05:00
|
|
|
#include "RimContextCommandBuilder.h"
|
2017-02-13 01:40:27 -06:00
|
|
|
#include "RimWellLogPlot.h"
|
|
|
|
#include "RimWellLogTrack.h"
|
2017-03-16 02:23:27 -05:00
|
|
|
|
2017-02-13 01:40:27 -06:00
|
|
|
#include "RiuMainWindow.h"
|
2018-06-29 04:29:18 -05:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2019-09-04 13:18:18 -05:00
|
|
|
#include "RiuPlotObjectPicker.h"
|
2017-02-13 01:40:27 -06:00
|
|
|
#include "RiuWellLogTrack.h"
|
|
|
|
|
2017-11-18 18:12:39 -06:00
|
|
|
#include "cafCmdFeatureMenuBuilder.h"
|
2019-09-06 06:17:36 -05:00
|
|
|
#include "cafSelectionManager.h"
|
2017-02-13 01:40:27 -06:00
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
2017-03-16 02:23:27 -05:00
|
|
|
#include "qwt_legend.h"
|
2018-06-26 04:01:21 -05:00
|
|
|
#include "qwt_plot_layout.h"
|
2019-10-03 07:41:37 -05:00
|
|
|
#include "qwt_scale_draw.h"
|
2017-03-16 02:23:27 -05:00
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
#include <QDebug>
|
2017-02-13 01:40:27 -06:00
|
|
|
#include <QFocusEvent>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QMdiSubWindow>
|
2018-06-26 03:24:29 -05:00
|
|
|
#include <QMenu>
|
2017-02-13 01:40:27 -06:00
|
|
|
#include <QScrollBar>
|
|
|
|
#include <QTimer>
|
|
|
|
|
2019-01-10 09:16:49 -06:00
|
|
|
#include <cmath>
|
2017-02-13 01:40:27 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
RiuWellLogPlot::RiuWellLogPlot( RimWellLogPlot* plotDefinition, QWidget* parent )
|
|
|
|
: QWidget( parent )
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
Q_ASSERT( plotDefinition );
|
2017-02-13 01:40:27 -06:00
|
|
|
m_plotDefinition = plotDefinition;
|
|
|
|
|
2019-09-06 08:52:45 -05:00
|
|
|
m_layout = new QVBoxLayout( this );
|
2019-09-09 07:25:30 -05:00
|
|
|
m_layout->setMargin( 0 );
|
|
|
|
m_layout->setSpacing( 2 );
|
2019-09-06 08:52:45 -05:00
|
|
|
|
|
|
|
m_plotTitle = createTitleLabel();
|
|
|
|
m_layout->addWidget( m_plotTitle );
|
|
|
|
|
|
|
|
m_plotLayout = new QHBoxLayout;
|
|
|
|
m_layout->addLayout( m_plotLayout );
|
|
|
|
|
2019-10-03 08:32:35 -05:00
|
|
|
m_trackFrame = new QFrame;
|
|
|
|
m_trackFrame->setVisible( true );
|
|
|
|
m_plotLayout->addWidget( m_trackFrame, 1 );
|
2019-09-06 08:52:45 -05:00
|
|
|
|
2019-10-03 08:32:35 -05:00
|
|
|
m_trackLayout = new QGridLayout( m_trackFrame );
|
2019-09-09 07:25:30 -05:00
|
|
|
m_trackLayout->setMargin( 0 );
|
|
|
|
m_trackLayout->setSpacing( 2 );
|
2019-09-06 08:52:45 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
QPalette newPalette( palette() );
|
|
|
|
newPalette.setColor( QPalette::Background, Qt::white );
|
|
|
|
setPalette( newPalette );
|
2017-02-13 01:40:27 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
setAutoFillBackground( true );
|
2017-02-13 01:40:27 -06:00
|
|
|
|
2019-09-09 09:00:52 -05:00
|
|
|
m_scrollBar = new QScrollBar( nullptr );
|
2019-09-06 06:17:36 -05:00
|
|
|
m_scrollBar->setOrientation( Qt::Vertical );
|
2019-10-10 06:33:57 -05:00
|
|
|
m_scrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
|
2019-09-09 09:00:52 -05:00
|
|
|
|
2019-10-07 01:32:34 -05:00
|
|
|
m_scrollBarLayout = new QVBoxLayout;
|
2019-09-09 09:00:52 -05:00
|
|
|
m_scrollBarLayout->addWidget( m_scrollBar, 0 );
|
2019-09-06 06:17:36 -05:00
|
|
|
|
|
|
|
new RiuPlotObjectPicker( m_plotTitle, m_plotDefinition );
|
2017-02-13 01:40:27 -06:00
|
|
|
|
2019-10-04 03:26:55 -05:00
|
|
|
this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding );
|
2019-09-04 13:25:41 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
setFocusPolicy( Qt::StrongFocus );
|
|
|
|
connect( m_scrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) );
|
2019-10-10 06:33:57 -05:00
|
|
|
|
|
|
|
setAcceptDrops( true );
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiuWellLogPlot::~RiuWellLogPlot()
|
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_plotDefinition )
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
|
|
|
m_plotDefinition->detachAllCurves();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RiuWellLogPlot::addTrackPlot( RiuWellLogTrack* trackPlot )
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
|
|
|
// Insert the plot to the left of the scroll bar
|
2019-09-06 06:17:36 -05:00
|
|
|
insertTrackPlot( trackPlot, m_trackPlots.size() );
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-10 06:33:57 -05:00
|
|
|
void RiuWellLogPlot::insertTrackPlot( RiuWellLogTrack* trackPlot, size_t index, bool updateLayoutAfter )
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_trackPlots.insert( static_cast<int>( index ), trackPlot );
|
|
|
|
|
2019-09-06 08:52:45 -05:00
|
|
|
QwtLegend* legend = new QwtLegend( nullptr );
|
2019-09-06 06:17:36 -05:00
|
|
|
int legendColumns = 1;
|
|
|
|
if ( m_plotDefinition->areTrackLegendsHorizontal() )
|
2018-06-26 04:38:07 -05:00
|
|
|
{
|
|
|
|
legendColumns = 0; // unlimited
|
|
|
|
}
|
2019-09-06 06:17:36 -05:00
|
|
|
legend->setMaxColumns( legendColumns );
|
|
|
|
legend->horizontalScrollBar()->setVisible( false );
|
|
|
|
legend->verticalScrollBar()->setVisible( false );
|
|
|
|
|
|
|
|
legend->connect( trackPlot,
|
|
|
|
SIGNAL( legendDataChanged( const QVariant&, const QList<QwtLegendData>& ) ),
|
|
|
|
SLOT( updateLegend( const QVariant&, const QList<QwtLegendData>& ) ) );
|
|
|
|
legend->contentsWidget()->layout()->setAlignment( Qt::AlignBottom | Qt::AlignHCenter );
|
2019-10-10 06:33:57 -05:00
|
|
|
trackPlot->updateLegend();
|
2019-09-06 06:17:36 -05:00
|
|
|
m_legends.insert( static_cast<int>( index ), legend );
|
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
if ( updateLayoutAfter )
|
|
|
|
{
|
|
|
|
updateChildrenLayout();
|
|
|
|
}
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-10 06:33:57 -05:00
|
|
|
void RiuWellLogPlot::removeTrackPlot( RiuWellLogTrack* trackPlot, bool updateLayoutAfter )
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( !trackPlot ) return;
|
2017-02-13 01:40:27 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
int trackIdx = m_trackPlots.indexOf( trackPlot );
|
|
|
|
CVF_ASSERT( trackIdx >= 0 );
|
2017-02-13 01:40:27 -06:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
m_trackPlots.removeAt( trackIdx );
|
|
|
|
trackPlot->setParent( nullptr );
|
2017-02-13 01:40:27 -06:00
|
|
|
|
|
|
|
QwtLegend* legend = m_legends[trackIdx];
|
2019-09-06 06:17:36 -05:00
|
|
|
m_legends.removeAt( trackIdx );
|
2017-02-13 01:40:27 -06:00
|
|
|
delete legend;
|
2019-09-10 06:31:26 -05:00
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
if ( updateLayoutAfter )
|
|
|
|
{
|
|
|
|
updateChildrenLayout();
|
|
|
|
}
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RiuWellLogPlot::setDepthZoomAndReplot( double minDepth, double maxDepth )
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( int tpIdx = 0; tpIdx < m_trackPlots.count(); tpIdx++ )
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_trackPlots[tpIdx]->setDepthZoom( minDepth, maxDepth );
|
2017-02-13 01:40:27 -06:00
|
|
|
m_trackPlots[tpIdx]->replot();
|
|
|
|
}
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
updateScrollBar( minDepth, maxDepth );
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
|
|
|
|
2018-06-26 03:24:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RiuWellLogPlot::setPlotTitle( const QString& plotTitle )
|
2018-06-26 03:24:29 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_plotTitle->setText( plotTitle );
|
2018-06-26 03:24:29 -05:00
|
|
|
}
|
|
|
|
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-03 07:41:37 -05:00
|
|
|
int RiuWellLogPlot::preferredWidth() const
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
2019-10-03 07:41:37 -05:00
|
|
|
int titleWidth = 0;
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( m_plotTitle && m_plotTitle->isVisible() )
|
2018-07-03 05:54:51 -05:00
|
|
|
{
|
2019-10-03 07:41:37 -05:00
|
|
|
titleWidth = m_plotTitle->width();
|
2018-07-03 05:54:51 -05:00
|
|
|
}
|
|
|
|
|
2019-10-03 07:41:37 -05:00
|
|
|
int sumTrackWidth = 0;
|
2019-09-06 06:17:36 -05:00
|
|
|
for ( QPointer<RiuWellLogTrack> track : m_trackPlots )
|
2018-07-03 05:54:51 -05:00
|
|
|
{
|
2019-10-03 07:41:37 -05:00
|
|
|
if ( track->isVisible() )
|
|
|
|
{
|
|
|
|
sumTrackWidth += track->width();
|
|
|
|
}
|
2018-07-03 05:54:51 -05:00
|
|
|
}
|
2019-10-03 07:41:37 -05:00
|
|
|
return std::max( titleWidth, sumTrackWidth );
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
|
|
|
|
2019-09-04 08:51:44 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 08:52:45 -05:00
|
|
|
void RiuWellLogPlot::setTitleVisible( bool visible )
|
2019-09-04 08:51:44 -05:00
|
|
|
{
|
2019-09-06 08:52:45 -05:00
|
|
|
m_plotTitle->setVisible( visible );
|
2019-09-09 07:25:30 -05:00
|
|
|
}
|
|
|
|
|
2019-10-09 02:21:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::setScrollbarVisible( bool visible )
|
|
|
|
{
|
|
|
|
m_scrollBar->setVisible( visible );
|
|
|
|
}
|
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RiuWellLogPlot::indexOfTrackPlot( RiuWellLogTrack* track )
|
|
|
|
{
|
|
|
|
return m_trackPlots.indexOf( track );
|
|
|
|
}
|
|
|
|
|
2019-09-09 07:25:30 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::updateChildrenLayout()
|
|
|
|
{
|
2019-10-07 01:32:34 -05:00
|
|
|
reinsertTracksAndScrollbar();
|
|
|
|
alignCanvasTopsAndScrollbar();
|
2019-09-04 08:51:44 -05:00
|
|
|
}
|
|
|
|
|
2017-03-16 02:23:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-03-16 02:23:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RiuWellLogPlot::contextMenuEvent( QContextMenuEvent* event )
|
2017-03-16 02:23:27 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
QMenu menu;
|
2017-11-18 18:12:39 -06:00
|
|
|
caf::CmdFeatureMenuBuilder menuBuilder;
|
2017-03-16 02:23:27 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
caf::SelectionManager::instance()->setSelectedItem( ownerPlotDefinition() );
|
2017-03-16 02:23:27 -05:00
|
|
|
|
2017-11-18 18:12:39 -06:00
|
|
|
menuBuilder << "RicShowPlotDataFeature";
|
|
|
|
menuBuilder << "RicShowContributingWellsFromPlotFeature";
|
2017-03-16 02:23:27 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
menuBuilder.appendToMenu( &menu );
|
2017-03-16 02:23:27 -05:00
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
if ( menu.actions().size() > 0 )
|
2017-03-16 02:23:27 -05:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
menu.exec( event->globalPos() );
|
2017-03-16 02:23:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-03 05:54:51 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-09 07:25:30 -05:00
|
|
|
void RiuWellLogPlot::keyPressEvent( QKeyEvent* keyEvent )
|
2018-07-03 05:54:51 -05:00
|
|
|
{
|
2019-09-09 07:25:30 -05:00
|
|
|
m_plotDefinition->handleKeyPressEvent( keyEvent );
|
2018-07-03 05:54:51 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 08:52:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-04 03:26:55 -05:00
|
|
|
QLabel* RiuWellLogPlot::createTitleLabel() const
|
2019-09-06 08:52:45 -05:00
|
|
|
{
|
2019-10-04 03:26:55 -05:00
|
|
|
QLabel* plotTitle = new QLabel( "PLOT TITLE HERE", nullptr );
|
2019-10-04 01:50:35 -05:00
|
|
|
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
|
|
|
|
|
|
|
QFont font = plotTitle->font();
|
|
|
|
int defaultFontSize = RiaFontCache::pointSizeFromFontSizeEnum( app->preferences()->defaultPlotFontSize() );
|
|
|
|
|
|
|
|
font.setPointSize( defaultFontSize + 1 );
|
2019-09-06 08:52:45 -05:00
|
|
|
font.setBold( true );
|
|
|
|
plotTitle->setFont( font );
|
|
|
|
plotTitle->setVisible( m_plotDefinition->isPlotTitleVisible() );
|
|
|
|
plotTitle->setAlignment( Qt::AlignHCenter );
|
2019-10-04 01:50:35 -05:00
|
|
|
plotTitle->setWordWrap( true );
|
2019-10-04 03:26:55 -05:00
|
|
|
plotTitle->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
2019-09-06 08:52:45 -05:00
|
|
|
return plotTitle;
|
|
|
|
}
|
|
|
|
|
2019-10-04 03:26:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::resizeEvent( QResizeEvent* event )
|
|
|
|
{
|
|
|
|
QWidget::resizeEvent( event );
|
|
|
|
updateChildrenLayout();
|
|
|
|
}
|
|
|
|
|
2019-10-07 01:32:34 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::showEvent( QShowEvent* event )
|
|
|
|
{
|
|
|
|
QWidget::showEvent( event );
|
|
|
|
updateChildrenLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::changeEvent( QEvent* event )
|
|
|
|
{
|
|
|
|
QWidget::changeEvent( event );
|
|
|
|
if ( event->type() == QEvent::WindowStateChange )
|
|
|
|
{
|
|
|
|
updateChildrenLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::dragEnterEvent( QDragEnterEvent* event )
|
|
|
|
{
|
|
|
|
if ( this->geometry().contains( event->pos() ) )
|
|
|
|
{
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::dragMoveEvent( QDragMoveEvent* event )
|
|
|
|
{
|
|
|
|
if ( this->geometry().contains( event->pos() ) )
|
|
|
|
{
|
|
|
|
RiuWellLogTrack* source = dynamic_cast<RiuWellLogTrack*>( event->source() );
|
|
|
|
if ( source )
|
|
|
|
{
|
|
|
|
QRect originalGeometry = source->geometry();
|
|
|
|
QPoint offset = source->dragStartPosition();
|
|
|
|
QRect newRect( event->pos() - offset, originalGeometry.size() );
|
|
|
|
|
|
|
|
QList<QPointer<RiuWellLogTrack>> visibleTracks = this->visibleTracks();
|
|
|
|
|
|
|
|
int insertBeforeIndex = visibleTracks.size();
|
|
|
|
for ( int visibleIndex = 0; visibleIndex < visibleTracks.size(); ++visibleIndex )
|
|
|
|
{
|
|
|
|
visibleTracks[visibleIndex]->setDefaultStyleSheet();
|
|
|
|
|
|
|
|
if ( visibleTracks[visibleIndex]->frameIsInFrontOfThis( newRect ) )
|
|
|
|
{
|
|
|
|
insertBeforeIndex = std::min( insertBeforeIndex, visibleIndex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( insertBeforeIndex >= 0 && insertBeforeIndex < visibleTracks.size() )
|
|
|
|
{
|
|
|
|
visibleTracks[insertBeforeIndex]->setStyleSheetForThisObject(
|
|
|
|
"border-left: 2px solid red; border-top: none; border-bottom: none; border-right: none;" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( insertBeforeIndex > 0 )
|
|
|
|
{
|
|
|
|
int insertAfterIndex = insertBeforeIndex - 1;
|
|
|
|
visibleTracks[insertAfterIndex]->setStyleSheetForThisObject(
|
|
|
|
"border-left: none; border-top: none; border-bottom: none; border-right: 2px solid red;" );
|
|
|
|
}
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::dragLeaveEvent( QDragLeaveEvent* event )
|
|
|
|
{
|
|
|
|
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
|
|
|
{
|
|
|
|
m_trackPlots[tIdx]->setDefaultStyleSheet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::dropEvent( QDropEvent* event )
|
|
|
|
{
|
|
|
|
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
|
|
|
{
|
|
|
|
m_trackPlots[tIdx]->setDefaultStyleSheet();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( this->geometry().contains( event->pos() ) )
|
|
|
|
{
|
|
|
|
RiuWellLogTrack* source = dynamic_cast<RiuWellLogTrack*>( event->source() );
|
|
|
|
|
|
|
|
if ( source )
|
|
|
|
{
|
|
|
|
event->acceptProposedAction();
|
|
|
|
|
|
|
|
QRect originalGeometry = source->geometry();
|
|
|
|
QPoint offset = source->dragStartPosition();
|
|
|
|
QRect newRect( event->pos() - offset, originalGeometry.size() );
|
|
|
|
|
|
|
|
int beforeIndex = m_trackPlots.size();
|
|
|
|
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
|
|
|
{
|
|
|
|
if ( m_trackPlots[tIdx]->isVisible() )
|
|
|
|
{
|
|
|
|
if ( m_trackPlots[tIdx]->frameIsInFrontOfThis( newRect ) )
|
|
|
|
{
|
|
|
|
beforeIndex = tIdx;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RimWellLogTrack* insertAfter = nullptr;
|
|
|
|
if ( beforeIndex > 0 )
|
|
|
|
{
|
|
|
|
insertAfter = m_trackPlots[beforeIndex - 1]->plotDefinition();
|
|
|
|
}
|
|
|
|
|
|
|
|
RimWellLogTrack* rimTrack = source->plotDefinition();
|
|
|
|
|
|
|
|
if ( insertAfter != rimTrack )
|
|
|
|
{
|
|
|
|
RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot( m_plotDefinition, {rimTrack}, insertAfter );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::pair<int, int> RiuWellLogPlot::rowAndColumnCount( int trackCount ) const
|
|
|
|
{
|
|
|
|
int columnCount = std::max( 1, std::min( m_plotDefinition->columnCount(), trackCount ) );
|
|
|
|
int rowCount = static_cast<int>( std::ceil( trackCount / static_cast<double>( columnCount ) ) );
|
|
|
|
return std::make_pair( rowCount, columnCount );
|
|
|
|
}
|
|
|
|
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RiuWellLogPlot::updateScrollBar( double minDepth, double maxDepth )
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
|
|
|
double availableMinDepth;
|
|
|
|
double availableMaxDepth;
|
2019-09-06 06:17:36 -05:00
|
|
|
m_plotDefinition->availableDepthRange( &availableMinDepth, &availableMaxDepth );
|
|
|
|
availableMaxDepth += 0.01 * ( availableMaxDepth - availableMinDepth );
|
2017-02-13 01:40:27 -06:00
|
|
|
|
|
|
|
double visibleDepth = maxDepth - minDepth;
|
|
|
|
|
2019-09-06 06:17:36 -05:00
|
|
|
m_scrollBar->blockSignals( true );
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
2019-09-06 06:17:36 -05:00
|
|
|
m_scrollBar->setRange( (int)availableMinDepth, (int)( ( availableMaxDepth - visibleDepth ) ) );
|
|
|
|
m_scrollBar->setPageStep( (int)visibleDepth );
|
|
|
|
m_scrollBar->setValue( (int)minDepth );
|
|
|
|
m_scrollBar->setVisible( true );
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
2019-09-06 06:17:36 -05:00
|
|
|
m_scrollBar->blockSignals( false );
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-07 01:32:34 -05:00
|
|
|
void RiuWellLogPlot::alignCanvasTopsAndScrollbar()
|
2019-09-09 07:25:30 -05:00
|
|
|
{
|
|
|
|
CVF_ASSERT( m_legends.size() == m_trackPlots.size() );
|
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
QList<QPointer<RiuWellLogTrack>> tracks = visibleTracks();
|
|
|
|
|
|
|
|
auto rowAndColumnCount = this->rowAndColumnCount( tracks.size() );
|
|
|
|
|
|
|
|
std::vector<double> maxExtents( rowAndColumnCount.first, 0.0 );
|
|
|
|
|
|
|
|
for ( int visibleIndex = 0; visibleIndex < tracks.size(); ++visibleIndex )
|
2019-09-09 07:25:30 -05:00
|
|
|
{
|
2019-10-10 06:33:57 -05:00
|
|
|
int row = visibleIndex / rowAndColumnCount.second;
|
|
|
|
|
|
|
|
QFont font = m_trackPlots[visibleIndex]->axisFont( QwtPlot::xTop );
|
|
|
|
maxExtents[row] = std::max( maxExtents[row],
|
|
|
|
tracks[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->extent( font ) );
|
2019-09-09 07:25:30 -05:00
|
|
|
}
|
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
for ( int visibleIndex = 0; visibleIndex < tracks.size(); ++visibleIndex )
|
2019-09-09 07:25:30 -05:00
|
|
|
{
|
2019-10-10 06:33:57 -05:00
|
|
|
int row = visibleIndex / rowAndColumnCount.second;
|
|
|
|
tracks[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtents[row] );
|
2019-09-09 07:25:30 -05:00
|
|
|
}
|
2019-10-10 06:33:57 -05:00
|
|
|
m_scrollBarLayout->setContentsMargins( 0, maxExtents[0], 0, 0 );
|
2019-09-09 07:25:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-07 01:32:34 -05:00
|
|
|
void RiuWellLogPlot::reinsertTracksAndScrollbar()
|
2019-09-10 06:31:26 -05:00
|
|
|
{
|
2019-10-03 07:41:37 -05:00
|
|
|
clearTrackLayout();
|
|
|
|
|
2019-09-10 06:31:26 -05:00
|
|
|
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
|
|
|
{
|
2019-10-10 06:33:57 -05:00
|
|
|
m_trackPlots[tIdx]->hide();
|
|
|
|
}
|
2019-10-04 03:26:55 -05:00
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
QList<QPointer<RiuWellLogTrack>> tracks = this->visibleTracks();
|
|
|
|
QList<QPointer<QwtLegend>> legends = this->visibleLegends();
|
2019-10-04 03:26:55 -05:00
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
auto rowAndColumnCount = this->rowAndColumnCount( tracks.size() );
|
2019-10-03 07:41:37 -05:00
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
for ( int visibleIndex = 0; visibleIndex < tracks.size(); ++visibleIndex )
|
|
|
|
{
|
|
|
|
int row = visibleIndex / rowAndColumnCount.second;
|
|
|
|
int column = visibleIndex % rowAndColumnCount.second;
|
2019-10-03 07:41:37 -05:00
|
|
|
|
2019-10-10 06:33:57 -05:00
|
|
|
m_trackLayout->addWidget( legends[visibleIndex], 2 * row, column );
|
|
|
|
m_trackLayout->addWidget( tracks[visibleIndex], 2 * row + 1, column );
|
|
|
|
|
|
|
|
if ( m_plotDefinition->areTrackLegendsVisible() )
|
|
|
|
{
|
|
|
|
int legendColumns = 1;
|
|
|
|
if ( m_plotDefinition->areTrackLegendsHorizontal() )
|
2019-10-04 03:26:55 -05:00
|
|
|
{
|
2019-10-10 06:33:57 -05:00
|
|
|
legendColumns = 0; // unlimited
|
2019-10-04 03:26:55 -05:00
|
|
|
}
|
2019-10-10 06:33:57 -05:00
|
|
|
legends[visibleIndex]->setMaxColumns( legendColumns );
|
|
|
|
int minimumHeight = legends[visibleIndex]->heightForWidth( tracks[visibleIndex]->width() );
|
|
|
|
legends[visibleIndex]->setMinimumHeight( minimumHeight );
|
|
|
|
|
|
|
|
legends[visibleIndex]->show();
|
2019-09-10 06:31:26 -05:00
|
|
|
}
|
2019-10-03 07:41:37 -05:00
|
|
|
else
|
|
|
|
{
|
2019-10-10 06:33:57 -05:00
|
|
|
legends[visibleIndex]->hide();
|
2019-10-03 07:41:37 -05:00
|
|
|
}
|
2019-10-10 06:33:57 -05:00
|
|
|
|
|
|
|
tracks[visibleIndex]->setDepthTitle( column == 0 ? m_plotDefinition->depthPlotTitle() : "" );
|
|
|
|
tracks[visibleIndex]->enableDepthAxisLabelsAndTicks( column == 0 );
|
|
|
|
tracks[visibleIndex]->show();
|
|
|
|
|
|
|
|
int widthScaleFactor = tracks[visibleIndex]->widthScaleFactor();
|
|
|
|
if ( column == 0 )
|
|
|
|
{
|
|
|
|
widthScaleFactor += 1; // Give it a bit extra room due to depth axis
|
|
|
|
}
|
|
|
|
m_trackLayout->setColumnStretch( column,
|
|
|
|
std::max( m_trackLayout->columnStretch( column ),
|
|
|
|
tracks[visibleIndex]->widthScaleFactor() ) );
|
|
|
|
m_trackLayout->setRowStretch( 2 * row + 1, 1 );
|
2019-10-03 07:41:37 -05:00
|
|
|
}
|
2019-10-10 06:33:57 -05:00
|
|
|
m_trackLayout->addLayout( m_scrollBarLayout, 1, rowAndColumnCount.second, rowAndColumnCount.first * 2 - 1, 1 );
|
|
|
|
m_trackLayout->setColumnStretch( rowAndColumnCount.second, 0 );
|
|
|
|
m_scrollBar->setVisible( tracks.size() > 0 );
|
2019-10-03 07:41:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::clearTrackLayout()
|
|
|
|
{
|
|
|
|
if ( m_trackLayout )
|
|
|
|
{
|
2019-10-10 06:33:57 -05:00
|
|
|
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
|
|
|
{
|
|
|
|
m_trackLayout->removeWidget( m_legends[tIdx] );
|
|
|
|
m_trackLayout->removeWidget( m_trackPlots[tIdx] );
|
|
|
|
}
|
|
|
|
|
2019-10-03 07:41:37 -05:00
|
|
|
QLayoutItem* item;
|
|
|
|
while ( ( item = m_trackLayout->takeAt( 0 ) ) != 0 )
|
|
|
|
{
|
|
|
|
}
|
2019-10-10 06:33:57 -05:00
|
|
|
QWidget().setLayout( m_trackLayout );
|
|
|
|
delete m_trackLayout;
|
|
|
|
m_trackLayout = new QGridLayout( m_trackFrame );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<QPointer<RiuWellLogTrack>> RiuWellLogPlot::visibleTracks() const
|
|
|
|
{
|
|
|
|
QList<QPointer<RiuWellLogTrack>> tracks;
|
|
|
|
for ( QPointer<RiuWellLogTrack> track : m_trackPlots )
|
|
|
|
{
|
|
|
|
if ( track->isRimTrackVisible() )
|
|
|
|
{
|
|
|
|
tracks.push_back( track );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tracks;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<QPointer<QwtLegend>> RiuWellLogPlot::visibleLegends() const
|
|
|
|
{
|
|
|
|
QList<QPointer<QwtLegend>> legends;
|
|
|
|
for ( int i = 0; i < m_trackPlots.size(); ++i )
|
|
|
|
{
|
|
|
|
if ( m_trackPlots[i]->isRimTrackVisible() )
|
|
|
|
{
|
|
|
|
legends.push_back( m_legends[i] );
|
|
|
|
}
|
2019-09-10 06:31:26 -05:00
|
|
|
}
|
2019-10-10 06:33:57 -05:00
|
|
|
return legends;
|
2019-09-10 06:31:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
void RiuWellLogPlot::slotSetMinDepth( int value )
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
|
|
|
double minimumDepth;
|
|
|
|
double maximumDepth;
|
2019-09-06 06:17:36 -05:00
|
|
|
m_plotDefinition->depthZoomMinMax( &minimumDepth, &maximumDepth );
|
2017-02-13 01:40:27 -06:00
|
|
|
|
|
|
|
double delta = value - minimumDepth;
|
2019-09-06 06:17:36 -05:00
|
|
|
m_plotDefinition->setDepthZoomMinMax( minimumDepth + delta, maximumDepth + delta );
|
|
|
|
m_plotDefinition->setDepthAutoZoom( false );
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-02-13 01:40:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellLogPlot* RiuWellLogPlot::ownerPlotDefinition()
|
|
|
|
{
|
|
|
|
return m_plotDefinition;
|
|
|
|
}
|
|
|
|
|
2017-03-31 02:17:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 06:17:36 -05:00
|
|
|
///
|
2017-03-31 02:17:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimViewWindow* RiuWellLogPlot::ownerViewWindow() const
|
|
|
|
{
|
|
|
|
return m_plotDefinition;
|
|
|
|
}
|