mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 23:46:00 -06:00
Better minimum width for well log tracks (#4824)
* Better minimum width for well log tracks * Fix alignment of scrollbar in Well log plots
This commit is contained in:
parent
3d3ad421dd
commit
4a4653a0df
@ -1492,7 +1492,8 @@ void RimWellLogTrack::initAfterRead()
|
||||
{
|
||||
if ( m_showFormations_OBSOLETE() && m_regionAnnotationType() == RiuPlotAnnotationTool::NO_ANNOTATIONS )
|
||||
{
|
||||
m_regionAnnotationType = RiuPlotAnnotationTool::FORMATION_ANNOTATIONS;
|
||||
m_regionAnnotationType = RiuPlotAnnotationTool::FORMATION_ANNOTATIONS;
|
||||
m_regionAnnotationDisplay = RiuPlotAnnotationTool::DARK_LINES;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,14 +82,10 @@ RiuWellLogPlot::RiuWellLogPlot( RimWellLogPlot* plotDefinition, QWidget* parent
|
||||
|
||||
setAutoFillBackground( true );
|
||||
|
||||
m_scrollBarLayout = new QVBoxLayout;
|
||||
m_scrollBarLayout->setContentsMargins( 0, 50, 0, 0 );
|
||||
m_plotLayout->addLayout( m_scrollBarLayout );
|
||||
|
||||
m_scrollBar = new QScrollBar( nullptr );
|
||||
m_scrollBar->setOrientation( Qt::Vertical );
|
||||
m_scrollBar->setVisible( true );
|
||||
|
||||
m_scrollBarLayout = new QVBoxLayout;
|
||||
m_scrollBarLayout->addWidget( m_scrollBar, 0 );
|
||||
|
||||
new RiuPlotObjectPicker( m_plotTitle, m_plotDefinition );
|
||||
@ -223,8 +219,8 @@ void RiuWellLogPlot::setTitleVisible( bool visible )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::updateChildrenLayout()
|
||||
{
|
||||
reinsertTracks();
|
||||
alignCanvasTops();
|
||||
reinsertTracksAndScrollbar();
|
||||
alignCanvasTopsAndScrollbar();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -287,6 +283,27 @@ void RiuWellLogPlot::resizeEvent( QResizeEvent* event )
|
||||
updateChildrenLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::showEvent( QShowEvent* event )
|
||||
{
|
||||
QWidget::showEvent( event );
|
||||
updateChildrenLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::changeEvent( QEvent* event )
|
||||
{
|
||||
QWidget::changeEvent( event );
|
||||
if ( event->type() == QEvent::WindowStateChange )
|
||||
{
|
||||
updateChildrenLayout();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -312,7 +329,7 @@ void RiuWellLogPlot::updateScrollBar( double minDepth, double maxDepth )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::alignCanvasTops()
|
||||
void RiuWellLogPlot::alignCanvasTopsAndScrollbar()
|
||||
{
|
||||
CVF_ASSERT( m_legends.size() == m_trackPlots.size() );
|
||||
|
||||
@ -333,12 +350,13 @@ void RiuWellLogPlot::alignCanvasTops()
|
||||
m_trackPlots[tIdx]->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtent );
|
||||
}
|
||||
}
|
||||
m_scrollBarLayout->setContentsMargins( 0, maxExtent, 0, 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::reinsertTracks()
|
||||
void RiuWellLogPlot::reinsertTracksAndScrollbar()
|
||||
{
|
||||
clearTrackLayout();
|
||||
|
||||
@ -347,8 +365,8 @@ void RiuWellLogPlot::reinsertTracks()
|
||||
{
|
||||
if ( m_trackPlots[tIdx]->isRimTrackVisible() )
|
||||
{
|
||||
m_trackLayout->addWidget( m_legends[tIdx], 0, static_cast<int>( visibleIndex ) );
|
||||
m_trackLayout->addWidget( m_trackPlots[tIdx], 1, static_cast<int>( visibleIndex ) );
|
||||
m_trackLayout->addWidget( m_legends[tIdx], 0, visibleIndex );
|
||||
m_trackLayout->addWidget( m_trackPlots[tIdx], 1, visibleIndex );
|
||||
|
||||
if ( m_plotDefinition->areTrackLegendsVisible() )
|
||||
{
|
||||
@ -358,7 +376,6 @@ void RiuWellLogPlot::reinsertTracks()
|
||||
legendColumns = 0; // unlimited
|
||||
}
|
||||
m_legends[tIdx]->setMaxColumns( legendColumns );
|
||||
m_trackPlots[tIdx]->updateLegend();
|
||||
int minimumHeight = m_legends[tIdx]->heightForWidth( m_trackPlots[tIdx]->width() );
|
||||
m_legends[tIdx]->setMinimumHeight( minimumHeight );
|
||||
|
||||
@ -388,6 +405,8 @@ void RiuWellLogPlot::reinsertTracks()
|
||||
m_legends[tIdx]->hide();
|
||||
}
|
||||
}
|
||||
m_trackLayout->addLayout( m_scrollBarLayout, 1, visibleIndex );
|
||||
m_scrollBar->setVisible( visibleIndex > 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -77,11 +77,13 @@ protected:
|
||||
QLabel* createTitleLabel() const;
|
||||
|
||||
void resizeEvent( QResizeEvent* event ) override;
|
||||
void showEvent( QShowEvent* event ) override;
|
||||
void changeEvent( QEvent* ) override;
|
||||
|
||||
private:
|
||||
void updateScrollBar( double minDepth, double maxDepth );
|
||||
void alignCanvasTops();
|
||||
void reinsertTracks();
|
||||
void alignCanvasTopsAndScrollbar();
|
||||
void reinsertTracksAndScrollbar();
|
||||
void clearTrackLayout();
|
||||
|
||||
private slots:
|
||||
|
@ -87,9 +87,8 @@ void RiuWellLogTrack::setDefaults()
|
||||
axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Floating, true );
|
||||
setAxisScale( QwtPlot::yLeft, 1000, 0 );
|
||||
setXRange( 0, 100 );
|
||||
QFont font = axisFont( QwtPlot::xTop );
|
||||
int lineHeight = QFontMetrics( font ).height() + axisScaleDraw( QwtPlot::xTop )->tickLength( QwtScaleDiv::MajorTick );
|
||||
axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( lineHeight );
|
||||
axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( axisExtent( QwtPlot::xTop ) );
|
||||
setMinimumWidth( defaultMinimumWidth() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -119,6 +118,7 @@ void RiuWellLogTrack::setDepthTitle( const QString& title )
|
||||
{
|
||||
axisTitleY.setText( title );
|
||||
setAxisTitle( QwtPlot::yLeft, axisTitleY );
|
||||
setMinimumWidth( defaultMinimumWidth() + axisExtent( QwtPlot::yLeft ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,6 +236,14 @@ void RiuWellLogTrack::selectClosestCurve( const QPoint& pos )
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( m_plotTrackDefinition );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuWellLogTrack::defaultMinimumWidth()
|
||||
{
|
||||
return 80;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -374,3 +382,18 @@ double RiuWellLogTrack::getCurrentMinorTickInterval() const
|
||||
|
||||
return minorTicks.at( 1 ) - minorTicks.at( 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuWellLogTrack::axisExtent( QwtPlot::Axis axis ) const
|
||||
{
|
||||
QFont tickLabelFont = axisFont( axis );
|
||||
int lineExtent = static_cast<int>( std::ceil( axisScaleDraw( axis )->extent( tickLabelFont ) ) );
|
||||
if ( !axisTitle( axis ).text().isEmpty() )
|
||||
{
|
||||
QFont titleFont = axisTitle( axis ).font();
|
||||
lineExtent += QFontMetrics( titleFont ).height();
|
||||
}
|
||||
return lineExtent;
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
void setAutoTickIntervalCounts( int maxMajorTickIntervalCount, int maxMinorTickIntervalCount );
|
||||
double getCurrentMajorTickInterval() const;
|
||||
double getCurrentMinorTickInterval() const;
|
||||
int axisExtent( QwtPlot::Axis axis ) const;
|
||||
|
||||
protected:
|
||||
bool eventFilter( QObject* watched, QEvent* event ) override;
|
||||
@ -67,8 +68,9 @@ protected:
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
private:
|
||||
void setDefaults();
|
||||
void selectClosestCurve( const QPoint& pos );
|
||||
void setDefaults();
|
||||
void selectClosestCurve( const QPoint& pos );
|
||||
static int defaultMinimumWidth();
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimWellLogTrack> m_plotTrackDefinition;
|
||||
|
Loading…
Reference in New Issue
Block a user