Made RiuQwtPlotWidget axis operations much more general

This commit is contained in:
Gaute Lindkvist
2019-10-25 10:53:12 +02:00
parent 0e9cda8e84
commit edead9e3af
9 changed files with 157 additions and 196 deletions

View File

@@ -374,7 +374,7 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot )
RiuQwtPlotWidget* viewer = wellLogTrack->viewer();
if ( viewer )
{
viewer->setYTitle( "PL/" + wellLogPlot->depthAxisTitle() );
viewer->setAxisTitleText( QwtPlot::yLeft, "PL/" + wellLogPlot->depthAxisTitle() );
}
}

View File

@@ -649,6 +649,11 @@ void RimWellLogPlot::initAfterRead()
{
m_nameConfig->setCustomName( m_description() );
}
if ( m_depthAxisGridVisibility() == AXIS_GRID_MINOR )
{
m_depthAxisGridVisibility = AXIS_GRID_MAJOR_AND_MINOR;
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -58,9 +58,10 @@ public:
enum AxisGridVisibility
{
AXIS_GRID_NONE,
AXIS_GRID_MAJOR,
AXIS_GRID_MAJOR_AND_MINOR
AXIS_GRID_NONE = 0x00,
AXIS_GRID_MAJOR = 0x01,
AXIS_GRID_MINOR = 0x02,
AXIS_GRID_MAJOR_AND_MINOR = 0x03
};
typedef caf::AppEnum<AxisGridVisibility> AxisGridEnum;

View File

@@ -464,19 +464,19 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
if ( m_derivedMDSource == NO_SOURCE )
{
viewer->setYTitle( "TVDMSL" );
viewer->setAxisTitleText( QwtPlot::yLeft, "TVDMSL" );
}
else if ( m_derivedMDSource == PSEUDO_LENGTH )
{
viewer->setYTitle( "PL/" + wellLogPlot->depthAxisTitle() );
viewer->setAxisTitleText( QwtPlot::yLeft, "PL/" + wellLogPlot->depthAxisTitle() );
}
else if ( m_derivedMDSource == WELL_PATH )
{
viewer->setYTitle( "WELL/" + wellLogPlot->depthAxisTitle() );
viewer->setAxisTitleText( QwtPlot::yLeft, "WELL/" + wellLogPlot->depthAxisTitle() );
}
else
{
viewer->setYTitle( "OBS/" + wellLogPlot->depthAxisTitle() );
viewer->setAxisTitleText( QwtPlot::yLeft, "OBS/" + wellLogPlot->depthAxisTitle() );
}
}
}

View File

@@ -478,7 +478,7 @@ void RimWellLogTrack::updateXZoom()
componentRangeMin = -1.5;
}
m_plotWidget->setXRange( componentRangeMin, componentRangeMax, QwtPlot::xBottom );
m_plotWidget->setAxisRange( QwtPlot::xBottom, componentRangeMin, componentRangeMax );
}
//--------------------------------------------------------------------------------------------------
@@ -488,7 +488,7 @@ void RimWellLogTrack::updateYZoom()
{
if ( !m_plotWidget ) return;
m_plotWidget->setYRange( m_visibleYRangeMin(), m_visibleYRangeMax() );
m_plotWidget->setAxisRange( QwtPlot::yLeft, m_visibleYRangeMin(), m_visibleYRangeMax() );
}
//--------------------------------------------------------------------------------------------------
@@ -520,8 +520,8 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
{
if ( m_plotWidget )
{
m_majorTickInterval = m_plotWidget->getCurrentMajorTickInterval();
m_minorTickInterval = m_plotWidget->getCurrentMinorTickInterval();
m_majorTickInterval = m_plotWidget->majorTickInterval( QwtPlot::xTop );
m_minorTickInterval = m_plotWidget->minorTickInterval( QwtPlot::xTop );
}
m_majorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() );
m_minorTickInterval.uiCapability()->setUiHidden( !m_explicitTickIntervals() );
@@ -693,7 +693,8 @@ void RimWellLogTrack::updateXAxisAndGridTickIntervals()
if ( m_explicitTickIntervals )
{
m_plotWidget->setMajorAndMinorTickIntervals( m_majorTickInterval(),
m_plotWidget->setMajorAndMinorTickIntervals( QwtPlot::xTop,
m_majorTickInterval(),
m_minorTickInterval(),
m_visibleXRangeMin(),
m_visibleXRangeMax() );
@@ -725,36 +726,20 @@ void RimWellLogTrack::updateXAxisAndGridTickIntervals()
minorTickIntervals = 10;
break;
}
m_plotWidget->setAutoTickIntervalCounts( majorTickIntervals, minorTickIntervals );
m_plotWidget->setXRange( m_visibleXRangeMin, m_visibleXRangeMax );
m_plotWidget->setAutoTickIntervalCounts( QwtPlot::xTop, majorTickIntervals, minorTickIntervals );
m_plotWidget->setAxisRange( QwtPlot::xTop, m_visibleXRangeMin, m_visibleXRangeMax );
}
switch ( m_xAxisGridVisibility() )
{
case RimWellLogPlot::AXIS_GRID_NONE:
m_plotWidget->enableXGridLines( false, false );
break;
case RimWellLogPlot::AXIS_GRID_MAJOR:
m_plotWidget->enableXGridLines( true, false );
break;
case RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR:
m_plotWidget->enableXGridLines( true, true );
break;
}
m_plotWidget->enableGridLines( QwtPlot::xTop,
m_xAxisGridVisibility() & RimWellLogPlot::AXIS_GRID_MAJOR,
m_xAxisGridVisibility() & RimWellLogPlot::AXIS_GRID_MINOR );
RimWellLogPlot* plot = nullptr;
this->firstAncestorOrThisOfTypeAsserted( plot );
switch ( plot->depthAxisGridLinesEnabled() )
{
case RimWellLogPlot::AXIS_GRID_NONE:
m_plotWidget->enableYGridLines( false, false );
break;
case RimWellLogPlot::AXIS_GRID_MAJOR:
m_plotWidget->enableYGridLines( true, false );
break;
case RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR:
m_plotWidget->enableYGridLines( true, true );
break;
}
m_plotWidget->enableGridLines( QwtPlot::yLeft,
plot->depthAxisGridLinesEnabled() & RimWellLogPlot::AXIS_GRID_MAJOR,
plot->depthAxisGridLinesEnabled() & RimWellLogPlot::AXIS_GRID_MINOR );
m_plotWidget->scheduleReplot();
}
@@ -857,7 +842,7 @@ bool RimWellLogTrack::hasCustomFontSizes( RiaDefines::FontSettingType fontSettin
{
if ( fontSettingType == RiaDefines::PLOT_FONT && m_plotWidget )
{
return defaultFontSize != m_plotWidget->fontSize();
return defaultFontSize != m_plotWidget->axisTitleFontSize( QwtPlot::xTop );
}
return false;
}
@@ -872,9 +857,10 @@ bool RimWellLogTrack::applyFontSize( RiaDefines::FontSettingType fontSettingType
{
if ( fontSettingType == RiaDefines::PLOT_FONT && m_plotWidget )
{
if ( oldFontSize == m_plotWidget->fontSize() || forceChange )
if ( oldFontSize == m_plotWidget->axisTitleFontSize( QwtPlot::xTop ) || forceChange )
{
m_plotWidget->setFontSize( fontSize );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xTop, fontSize, fontSize );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, fontSize, fontSize );
return true;
}
}
@@ -1121,8 +1107,8 @@ void RimWellLogTrack::loadDataAndUpdate()
if ( wellLogPlot && m_plotWidget )
{
m_plotWidget->setXTitle( m_xAxisTitle );
m_plotWidget->setYTitle( wellLogPlot->depthAxisTitle() );
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, m_xAxisTitle );
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, wellLogPlot->depthAxisTitle() );
}
for ( size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx )
@@ -1678,6 +1664,11 @@ void RimWellLogTrack::initAfterRead()
m_regionAnnotationType = RiuPlotAnnotationTool::FORMATION_ANNOTATIONS;
m_regionAnnotationDisplay = RiuPlotAnnotationTool::DARK_LINES;
}
if ( m_xAxisGridVisibility() == RimWellLogPlot::AXIS_GRID_MINOR )
{
m_xAxisGridVisibility = RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR;
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -1078,36 +1078,21 @@ void RimSummaryPlot::updateTimeAxis()
m_plotWidget->enableAxis( QwtPlot::xBottom, true );
{
QString axisTitle;
if ( m_timeAxisProperties->showTitle ) axisTitle = m_timeAxisProperties->title();
QString axisTitle = m_timeAxisProperties->title();
QwtText timeAxisTitle = m_plotWidget->axisTitle( QwtPlot::xBottom );
QFont font = timeAxisTitle.font();
font.setBold( true );
font.setPointSize( m_timeAxisProperties->titleFontSize() );
timeAxisTitle.setFont( font );
timeAxisTitle.setText( axisTitle );
switch ( m_timeAxisProperties->titlePosition() )
Qt::AlignmentFlag alignment = Qt::AlignCenter;
if ( m_timeAxisProperties->titlePosition() == RimPlotAxisPropertiesInterface::AXIS_TITLE_END )
{
case RimSummaryTimeAxisProperties::AXIS_TITLE_CENTER:
timeAxisTitle.setRenderFlags( Qt::AlignCenter );
break;
case RimSummaryTimeAxisProperties::AXIS_TITLE_END:
timeAxisTitle.setRenderFlags( Qt::AlignRight );
break;
alignment = Qt::AlignRight;
}
m_plotWidget->setAxisTitle( QwtPlot::xBottom, timeAxisTitle );
}
{
QFont timeAxisFont = m_plotWidget->axisFont( QwtPlot::xBottom );
timeAxisFont.setBold( false );
timeAxisFont.setPointSize( m_timeAxisProperties->valuesFontSize() );
m_plotWidget->setAxisFont( QwtPlot::xBottom, timeAxisFont );
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom,
m_timeAxisProperties->titleFontSize(),
m_timeAxisProperties->valuesFontSize(),
true,
alignment );
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, m_timeAxisProperties->title() );
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, m_timeAxisProperties->showTitle );
}
}