2017-02-13 01:40:27 -06:00
|
|
|
#include "RiuWellLogPlot.h"
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
#include "RimPlotWindow.h"
|
2017-02-13 01:40:27 -06:00
|
|
|
#include "RimWellLogPlot.h"
|
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
#include "RiuQwtPlotWidget.h"
|
|
|
|
#include "RiuWellLogTrack.h"
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
#include "cafAssert.h"
|
|
|
|
#include "cafPdmPointer.h"
|
2017-02-13 01:40:27 -06:00
|
|
|
|
|
|
|
#include <QScrollBar>
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
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 )
|
2019-11-13 05:22:50 -06:00
|
|
|
: RiuMultiPlotWindow( plotDefinition, parent )
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
2019-10-31 07:48:40 -05:00
|
|
|
m_trackScrollBar = new QScrollBar( nullptr );
|
|
|
|
m_trackScrollBar->setOrientation( Qt::Vertical );
|
|
|
|
m_trackScrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
|
|
|
|
|
|
|
|
m_trackScrollBarLayout = new QVBoxLayout;
|
|
|
|
m_trackScrollBarLayout->addWidget( m_trackScrollBar, 0 );
|
|
|
|
|
|
|
|
connect( m_trackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RiuWellLogPlot::isScrollbarVisible() const
|
|
|
|
{
|
|
|
|
return m_trackScrollBar->isVisible();
|
2019-09-06 08:52:45 -05:00
|
|
|
}
|
|
|
|
|
2019-10-04 03:26:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-11 08:54:19 -05:00
|
|
|
RimWellLogPlot* RiuWellLogPlot::wellLogPlotDefinition()
|
2019-10-04 03:26:55 -05:00
|
|
|
{
|
2019-10-11 08:54:19 -05:00
|
|
|
RimWellLogPlot* wellLogPlot = dynamic_cast<RimWellLogPlot*>( m_plotDefinition.p() );
|
|
|
|
CAF_ASSERT( wellLogPlot );
|
|
|
|
return wellLogPlot;
|
2019-10-04 03:26:55 -05:00
|
|
|
}
|
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::setScrollbarVisible( bool visible )
|
|
|
|
{
|
|
|
|
m_trackScrollBar->setVisible( visible );
|
|
|
|
}
|
|
|
|
|
2019-10-07 01:32:34 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-11 08:54:19 -05:00
|
|
|
void RiuWellLogPlot::updateVerticalScrollBar( double minVisible, double maxVisible, double minAvailable, double maxAvailable )
|
2019-10-07 01:32:34 -05:00
|
|
|
{
|
2019-10-11 08:54:19 -05:00
|
|
|
maxAvailable += 0.01 * ( maxAvailable - minAvailable );
|
2019-10-10 06:33:57 -05:00
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
double visibleRange = maxVisible - minVisible;
|
2017-02-13 01:40:27 -06:00
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
m_trackScrollBar->blockSignals( true );
|
2017-02-13 01:40:27 -06:00
|
|
|
{
|
2019-10-31 07:48:40 -05:00
|
|
|
m_trackScrollBar->setRange( (int)minAvailable, (int)( ( maxAvailable - visibleRange ) ) );
|
|
|
|
m_trackScrollBar->setPageStep( (int)visibleRange );
|
|
|
|
m_trackScrollBar->setValue( (int)minVisible );
|
|
|
|
m_trackScrollBar->setVisible( true );
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
2019-10-31 07:48:40 -05:00
|
|
|
m_trackScrollBar->blockSignals( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RiuWellLogPlot::willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const
|
|
|
|
{
|
|
|
|
return dynamic_cast<const RiuWellLogTrack*>( plotWidget ) != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RiuWellLogPlot::showYAxis( int row, int column ) const
|
|
|
|
{
|
|
|
|
return column == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::reinsertScrollbar()
|
|
|
|
{
|
2019-11-05 07:17:24 -06:00
|
|
|
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
|
|
|
|
QList<QPointer<RiuQwtPlotLegend>> legends = this->visibleLegends();
|
|
|
|
int rowCount = this->m_gridLayout->rowCount();
|
|
|
|
int colCount = this->m_gridLayout->columnCount();
|
2019-10-31 07:48:40 -05:00
|
|
|
|
|
|
|
m_trackScrollBar->setVisible( !plotWidgets.empty() );
|
|
|
|
|
2019-11-05 07:17:24 -06:00
|
|
|
m_gridLayout->addLayout( m_trackScrollBarLayout, 2, colCount, rowCount * 2 - 1, 1 );
|
|
|
|
m_gridLayout->setColumnStretch( colCount, 0 );
|
2019-10-31 07:48:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::alignScrollbar( int offset )
|
|
|
|
{
|
|
|
|
m_trackScrollBarLayout->setContentsMargins( 0, offset, 0, 0 );
|
2017-02-13 01:40:27 -06:00
|
|
|
}
|
|
|
|
|
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-10-11 08:54:19 -05:00
|
|
|
wellLogPlotDefinition()->availableDepthRange( &minimumDepth, &maximumDepth );
|
2017-02-13 01:40:27 -06:00
|
|
|
|
|
|
|
double delta = value - minimumDepth;
|
2019-10-11 08:54:19 -05:00
|
|
|
wellLogPlotDefinition()->setDepthAxisRange( minimumDepth + delta, maximumDepth + delta );
|
|
|
|
wellLogPlotDefinition()->setAutoScaleYEnabled( false );
|
2017-03-31 02:17:49 -05:00
|
|
|
}
|
2019-10-31 07:48:40 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogPlot::performUpdate()
|
|
|
|
{
|
|
|
|
reinsertPlotWidgets();
|
|
|
|
reinsertScrollbar();
|
|
|
|
int axisShift = alignCanvasTops();
|
|
|
|
alignScrollbar( axisShift );
|
|
|
|
}
|