mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Made RiuQwtPlotWidget axis operations much more general
This commit is contained in:
parent
0e9cda8e84
commit
edead9e3af
@ -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() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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;
|
||||
|
@ -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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -611,8 +611,8 @@ void RiuGridPlotWindow::reinsertPlotWidgetsAndScrollbar()
|
||||
legends[visibleIndex]->hide();
|
||||
}
|
||||
|
||||
plotWidgets[visibleIndex]->setYAxisLabelsAndTicksEnabled( column == 0 );
|
||||
plotWidgets[visibleIndex]->setYTitleEnabled( column == 0 );
|
||||
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, column == 0 );
|
||||
plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, column == 0 );
|
||||
|
||||
plotWidgets[visibleIndex]->show();
|
||||
|
||||
|
@ -92,14 +92,11 @@ bool RiuQwtPlotWidget::isChecked() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuQwtPlotWidget::fontSize() const
|
||||
int RiuQwtPlotWidget::axisTitleFontSize( QwtPlot::Axis axis ) const
|
||||
{
|
||||
for ( int axisId = 0; axisId < QwtPlot::axisCnt; ++axisId )
|
||||
if ( this->axisEnabled( axis ) )
|
||||
{
|
||||
if ( this->axisEnabled( axisId ) )
|
||||
{
|
||||
return this->axisFont( axisId ).pointSize();
|
||||
}
|
||||
return this->axisFont( axis ).pointSize();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -107,31 +104,36 @@ int RiuQwtPlotWidget::fontSize() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setFontSize( int fontSize )
|
||||
int RiuQwtPlotWidget::axisValueFontSize( QwtPlot::Axis axis ) const
|
||||
{
|
||||
if ( this->axisEnabled( axis ) )
|
||||
{
|
||||
return this->axisTitle( axis ).font().pointSize();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setAxisFontsAndAlignment(
|
||||
QwtPlot::Axis axis, int titleFontSize, int valueFontSize, bool titleBold, Qt::AlignmentFlag alignment )
|
||||
{
|
||||
// Axis number font
|
||||
QFont axisFont = this->axisFont( QwtPlot::xBottom );
|
||||
axisFont.setPointSize( fontSize );
|
||||
|
||||
setAxisFont( QwtPlot::xBottom, axisFont );
|
||||
setAxisFont( QwtPlot::xTop, axisFont );
|
||||
setAxisFont( QwtPlot::yLeft, axisFont );
|
||||
setAxisFont( QwtPlot::yRight, axisFont );
|
||||
QFont axisFont = this->axisFont( axis );
|
||||
axisFont.setPointSize( valueFontSize );
|
||||
axisFont.setBold( false );
|
||||
this->setAxisFont( axis, axisFont );
|
||||
|
||||
// Axis title font
|
||||
std::vector<QwtPlot::Axis> axes = { QwtPlot::xBottom, QwtPlot::xTop, QwtPlot::yLeft, QwtPlot::yRight };
|
||||
QwtText axisTitle = this->axisTitle( axis );
|
||||
QFont axisTitleFont = axisTitle.font();
|
||||
axisTitleFont.setPointSize( titleFontSize );
|
||||
axisTitleFont.setBold( titleBold );
|
||||
axisTitle.setFont( axisTitleFont );
|
||||
axisTitle.setRenderFlags( alignment );
|
||||
|
||||
for ( QwtPlot::Axis axis : axes )
|
||||
{
|
||||
QwtText axisTitle = this->axisTitle( axis );
|
||||
QFont axisTitleFont = axisTitle.font();
|
||||
axisTitleFont.setPointSize( fontSize );
|
||||
axisTitleFont.setBold( false );
|
||||
axisTitle.setFont( axisTitleFont );
|
||||
axisTitle.setRenderFlags( Qt::AlignRight );
|
||||
|
||||
setAxisTitle( axis, axisTitle );
|
||||
}
|
||||
setAxisTitle( axis, axisTitle );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -169,10 +171,12 @@ void RiuQwtPlotWidget::setEnabledAxes( const std::set<QwtPlot::Axis> enabledAxes
|
||||
|
||||
axisScaleDraw( axis )->enableComponent( QwtAbstractScaleDraw::Backbone, false );
|
||||
axisWidget( axis )->setMargin( 0 );
|
||||
m_axisTitlesEnabled[axis] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
enableAxis( axis, false );
|
||||
m_axisTitlesEnabled[axis] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,32 +184,26 @@ void RiuQwtPlotWidget::setEnabledAxes( const std::set<QwtPlot::Axis> enabledAxes
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setXTitle( const QString& title )
|
||||
void RiuQwtPlotWidget::setAxisTitleText( QwtPlot::Axis axis, const QString& title )
|
||||
{
|
||||
QwtText axisTitleX = axisTitle( QwtPlot::xTop );
|
||||
if ( title != axisTitleX.text() )
|
||||
m_axisTitles[axis] = title;
|
||||
|
||||
QwtText axisTitleText = axisTitle( axis );
|
||||
if ( title != axisTitleText.text() )
|
||||
{
|
||||
axisTitleX.setText( title );
|
||||
setAxisTitle( QwtPlot::xTop, axisTitleX );
|
||||
axisTitleText.setText( title );
|
||||
setAxisTitle( axis, axisTitleText );
|
||||
}
|
||||
applyAxisTitleToQwt( axis );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setYTitle( const QString& title )
|
||||
void RiuQwtPlotWidget::setAxisTitleEnabled( QwtPlot::Axis axis, bool enable )
|
||||
{
|
||||
m_yAxisTitle = title;
|
||||
applyYTitleToQwt();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setYTitleEnabled( bool enable )
|
||||
{
|
||||
m_yAxisTitleEnabled = enable;
|
||||
applyYTitleToQwt();
|
||||
m_axisTitlesEnabled[axis] = enable;
|
||||
applyAxisTitleToQwt( axis );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -219,24 +217,16 @@ QwtInterval RiuQwtPlotWidget::axisRange( QwtPlot::Axis axis )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setXRange( double min, double max, QwtPlot::Axis axis )
|
||||
void RiuQwtPlotWidget::setAxisRange( QwtPlot::Axis axis, double min, double max )
|
||||
{
|
||||
setAxisScale( axis, min, max );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setYRange( double min, double max )
|
||||
{
|
||||
// Note: Y-axis may be inverted
|
||||
if ( axisScaleEngine( QwtPlot::yLeft )->testAttribute( QwtScaleEngine::Inverted ) )
|
||||
// Note: Especially the Y-axis may be inverted
|
||||
if ( axisScaleEngine( axis )->testAttribute( QwtScaleEngine::Inverted ) )
|
||||
{
|
||||
setAxisScale( QwtPlot::yLeft, max, min );
|
||||
setAxisScale( axis, max, min );
|
||||
}
|
||||
else
|
||||
{
|
||||
setAxisScale( QwtPlot::yLeft, min, max );
|
||||
setAxisScale( axis, min, max );
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,24 +241,33 @@ void RiuQwtPlotWidget::setAxisInverted( QwtPlot::Axis axis )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setYAxisLabelsAndTicksEnabled( bool enable )
|
||||
void RiuQwtPlotWidget::setAxisLabelsAndTicksEnabled( QwtPlot::Axis axis, bool enable )
|
||||
{
|
||||
this->axisScaleDraw( QwtPlot::yLeft )->enableComponent( QwtAbstractScaleDraw::Ticks, enable );
|
||||
this->axisScaleDraw( QwtPlot::yLeft )->enableComponent( QwtAbstractScaleDraw::Labels, enable );
|
||||
this->axisScaleDraw( axis )->enableComponent( QwtAbstractScaleDraw::Ticks, enable );
|
||||
this->axisScaleDraw( axis )->enableComponent( QwtAbstractScaleDraw::Labels, enable );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::enableXGridLines( bool majorGridLines, bool minorGridLines )
|
||||
void RiuQwtPlotWidget::enableGridLines( QwtPlot::Axis axis, bool majorGridLines, bool minorGridLines )
|
||||
{
|
||||
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 );
|
||||
if ( axis == QwtPlot::xTop || axis == QwtPlot::xBottom )
|
||||
{
|
||||
grid->setXAxis( axis );
|
||||
grid->enableX( majorGridLines );
|
||||
grid->enableXMin( minorGridLines );
|
||||
}
|
||||
else
|
||||
{
|
||||
grid->setYAxis( axis );
|
||||
grid->enableY( majorGridLines );
|
||||
grid->enableYMin( minorGridLines );
|
||||
}
|
||||
grid->setMajorPen( Qt::lightGray, 1.0, Qt::SolidLine );
|
||||
grid->setMinorPen( Qt::lightGray, 1.0, Qt::DashLine );
|
||||
}
|
||||
@ -277,28 +276,8 @@ void RiuQwtPlotWidget::enableXGridLines( bool majorGridLines, bool minorGridLine
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::enableYGridLines( bool majorGridLines, bool minorGridLines )
|
||||
{
|
||||
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 RiuQwtPlotWidget::setMajorAndMinorTickIntervals( double majorTickInterval,
|
||||
double minorTickInterval,
|
||||
double minValue,
|
||||
double maxValue,
|
||||
QwtPlot::Axis axis /*= QwtPlot::xTop */ )
|
||||
void RiuQwtPlotWidget::setMajorAndMinorTickIntervals(
|
||||
QwtPlot::Axis axis, double majorTickInterval, double minorTickInterval, double minValue, double maxValue )
|
||||
{
|
||||
RiuQwtLinearScaleEngine* scaleEngine = dynamic_cast<RiuQwtLinearScaleEngine*>( this->axisScaleEngine( axis ) );
|
||||
if ( scaleEngine )
|
||||
@ -315,9 +294,9 @@ void RiuQwtPlotWidget::setMajorAndMinorTickIntervals( double majorTickInt
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setAutoTickIntervalCounts( int maxMajorTickIntervalCount,
|
||||
int maxMinorTickIntervalCount,
|
||||
QwtPlot::Axis axis )
|
||||
void RiuQwtPlotWidget::setAutoTickIntervalCounts( QwtPlot::Axis axis,
|
||||
int maxMajorTickIntervalCount,
|
||||
int maxMinorTickIntervalCount )
|
||||
{
|
||||
this->setAxisMaxMajor( axis, maxMajorTickIntervalCount );
|
||||
this->setAxisMaxMinor( axis, maxMinorTickIntervalCount );
|
||||
@ -329,9 +308,9 @@ void RiuQwtPlotWidget::setAutoTickIntervalCounts( int maxMajorTickInte
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RiuQwtPlotWidget::getCurrentMajorTickInterval() const
|
||||
double RiuQwtPlotWidget::majorTickInterval( QwtPlot::Axis axis ) const
|
||||
{
|
||||
QwtScaleDiv scaleDiv = this->axisScaleDiv( QwtPlot::xTop );
|
||||
QwtScaleDiv scaleDiv = this->axisScaleDiv( axis );
|
||||
QList<double> majorTicks = scaleDiv.ticks( QwtScaleDiv::MajorTick );
|
||||
if ( majorTicks.size() < 2 ) return 0.0;
|
||||
|
||||
@ -341,7 +320,7 @@ double RiuQwtPlotWidget::getCurrentMajorTickInterval() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RiuQwtPlotWidget::getCurrentMinorTickInterval() const
|
||||
double RiuQwtPlotWidget::minorTickInterval( QwtPlot::Axis axis ) const
|
||||
{
|
||||
QwtScaleDiv scaleDiv = this->axisScaleDiv( QwtPlot::xTop );
|
||||
QList<double> minorTicks = scaleDiv.ticks( QwtScaleDiv::MinorTick );
|
||||
@ -584,15 +563,18 @@ void RiuQwtPlotWidget::hideEvent( QHideEvent* event )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::applyYTitleToQwt()
|
||||
void RiuQwtPlotWidget::applyAxisTitleToQwt( QwtPlot::Axis axis )
|
||||
{
|
||||
QString titleToApply = m_yAxisTitleEnabled ? m_yAxisTitle : QString( "" );
|
||||
QwtText axisTitleY = axisTitle( QwtPlot::yLeft );
|
||||
if ( titleToApply != axisTitleY.text() )
|
||||
QString titleToApply = m_axisTitlesEnabled[axis] ? m_axisTitles[axis] : QString( "" );
|
||||
QwtText axisTitle = this->axisTitle( QwtPlot::yLeft );
|
||||
if ( titleToApply != axisTitle.text() )
|
||||
{
|
||||
axisTitleY.setText( titleToApply );
|
||||
setAxisTitle( QwtPlot::yLeft, axisTitleY );
|
||||
setMinimumWidth( defaultMinimumWidth() + axisExtent( QwtPlot::yLeft ) );
|
||||
axisTitle.setText( titleToApply );
|
||||
setAxisTitle( axis, axisTitle );
|
||||
if ( axis == QwtPlot::yLeft || axis == QwtPlot::yRight )
|
||||
{
|
||||
setMinimumWidth( defaultMinimumWidth() + axisExtent( axis ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,36 +58,33 @@ public:
|
||||
|
||||
bool isChecked() const;
|
||||
|
||||
int fontSize() const;
|
||||
void setFontSize( int fontSize );
|
||||
int axisTitleFontSize( QwtPlot::Axis axis ) const;
|
||||
int axisValueFontSize( QwtPlot::Axis axis ) const;
|
||||
void setAxisFontsAndAlignment( QwtPlot::Axis,
|
||||
int titleFontSize,
|
||||
int valueFontSize,
|
||||
bool titleBold = false,
|
||||
Qt::AlignmentFlag alignment = Qt::AlignRight );
|
||||
|
||||
void setEnabledAxes( const std::set<QwtPlot::Axis> enabledAxes );
|
||||
|
||||
void setXTitle( const QString& title );
|
||||
void setYTitle( const QString& title );
|
||||
void setYTitleEnabled( bool enable );
|
||||
void setAxisTitleText( QwtPlot::Axis axis, const QString& title );
|
||||
void setAxisTitleEnabled( QwtPlot::Axis axis, bool enable );
|
||||
|
||||
QwtInterval axisRange( QwtPlot::Axis axis );
|
||||
void setXRange( double min, double max, QwtPlot::Axis axis = QwtPlot::xTop );
|
||||
void setYRange( double min, double max );
|
||||
void setAxisRange( QwtPlot::Axis axis, double min, double max );
|
||||
|
||||
void setAxisInverted( QwtPlot::Axis axis );
|
||||
|
||||
void setYAxisLabelsAndTicksEnabled( bool enable );
|
||||
void setAxisLabelsAndTicksEnabled( QwtPlot::Axis axis, bool enable );
|
||||
|
||||
void enableXGridLines( bool majorGridLines, bool minorGridLines );
|
||||
void enableYGridLines( bool majorGridLines, bool minorGridLines );
|
||||
void enableGridLines( QwtPlot::Axis axis, bool majorGridLines, bool minorGridLines );
|
||||
|
||||
void setMajorAndMinorTickIntervals( double majorTickInterval,
|
||||
double minorTickInterval,
|
||||
double minValue,
|
||||
double maxValue,
|
||||
QwtPlot::Axis axis = QwtPlot::xTop );
|
||||
void setAutoTickIntervalCounts( int maxMajorTickIntervalCount,
|
||||
int maxMinorTickIntervalCount,
|
||||
QwtPlot::Axis axis = QwtPlot::xTop );
|
||||
double getCurrentMajorTickInterval() const;
|
||||
double getCurrentMinorTickInterval() const;
|
||||
void setMajorAndMinorTickIntervals(
|
||||
QwtPlot::Axis axis, double majorTickInterval, double minorTickInterval, double minValue, double maxValue );
|
||||
void setAutoTickIntervalCounts( QwtPlot::Axis axis, int maxMajorTickIntervalCount, int maxMinorTickIntervalCount );
|
||||
double majorTickInterval( QwtPlot::Axis axis ) const;
|
||||
double minorTickInterval( QwtPlot::Axis axis ) const;
|
||||
|
||||
int axisExtent( QwtPlot::Axis axis ) const;
|
||||
|
||||
@ -107,7 +104,7 @@ protected:
|
||||
bool eventFilter( QObject* watched, QEvent* event ) override;
|
||||
void hideEvent( QHideEvent* event ) override;
|
||||
|
||||
void applyYTitleToQwt();
|
||||
void applyAxisTitleToQwt( QwtPlot::Axis axis );
|
||||
|
||||
virtual void selectPoint( QwtPlotCurve* curve, int pointNumber );
|
||||
virtual void clearPointSelection();
|
||||
@ -126,11 +123,11 @@ private:
|
||||
void onAxisSelected( QwtScaleWidget* scale, bool toggleItemInSelection );
|
||||
|
||||
private:
|
||||
caf::PdmPointer<caf::PdmObject> m_plotOwner;
|
||||
QPoint m_clickPosition;
|
||||
QString m_yAxisTitle;
|
||||
bool m_yAxisTitleEnabled;
|
||||
QPointer<QwtPlotPicker> m_plotPicker;
|
||||
caf::PdmPointer<caf::PdmObject> m_plotOwner;
|
||||
QPoint m_clickPosition;
|
||||
std::map<QwtPlot::Axis, QString> m_axisTitles;
|
||||
std::map<QwtPlot::Axis, bool> m_axisTitlesEnabled;
|
||||
QPointer<QwtPlotPicker> m_plotPicker;
|
||||
|
||||
struct CurveColors
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user