#8794 Multi Axes: Highlight relevant axes

This commit is contained in:
Kristian Bendiksen 2022-05-23 10:10:54 +02:00
parent 05ce13b533
commit 039ec05ab8
2 changed files with 61 additions and 0 deletions

View File

@ -41,6 +41,7 @@
#include "cafAssert.h"
#include "qwt_axis.h"
#include "qwt_date_scale_engine.h"
#include "qwt_legend.h"
#include "qwt_legend_label.h"
@ -986,6 +987,7 @@ void RiuQwtPlotWidget::highlightPlotItems( const std::set<const QwtPlotItem*>& c
if ( closestItems.count( plotCurve ) > 0 )
{
plotCurve->setZ( zValue + 100.0 );
highlightPlotAxes( plotCurve->xAxis(), plotCurve->yAxis() );
}
else
{
@ -1057,6 +1059,36 @@ void RiuQwtPlotWidget::resetPlotItemHighlighting()
}
m_originalCurveColors.clear();
m_originalZValues.clear();
resetPlotAxisHighlighting();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::resetPlotAxisHighlighting()
{
// Reset axis widgets highlighting
std::vector<QwtAxis::Position> axisPositions = { QwtAxis::Position::YLeft,
QwtAxis::Position::YRight,
QwtAxis::Position::XTop,
QwtAxis::Position::XBottom };
// Use text color from theme
QColor textColor = RiuGuiTheme::getColorByVariableName( "text-color" );
QString style =
QString( "color: rgb(%1, %2, %3);" ).arg( textColor.red() ).arg( textColor.green() ).arg( textColor.blue() );
for ( auto pos : axisPositions )
{
int count = m_plot->axesCount( pos );
for ( int i = 0; i < count; i++ )
{
QwtAxisId axisId( pos, i );
auto axisWidget = m_plot->axisWidget( axisId );
axisWidget->setStyleSheet( style );
}
}
}
//--------------------------------------------------------------------------------------------------
@ -1083,6 +1115,33 @@ void RiuQwtPlotWidget::highlightPlotItemsForQwtAxis( QwtAxisId axisId )
highlightPlotItems( plotItems );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::highlightPlotAxes( QwtAxisId axisIdX, QwtAxisId axisIdY )
{
std::vector<QwtAxis::Position> axisPositions = { QwtAxis::Position::YLeft,
QwtAxis::Position::YRight,
QwtAxis::Position::XTop,
QwtAxis::Position::XBottom };
// Highlight selected axis by toning down the others in same dimension
for ( auto pos : axisPositions )
{
int count = m_plot->axesCount( pos );
for ( int i = 0; i < count; i++ )
{
QwtAxisId axisId( pos, i );
if ( axisId != axisIdX && axisId != axisIdY )
{
auto axisWidget = m_plot->axisWidget( axisId );
axisWidget->setStyleSheet( "color: gray" );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -208,9 +208,11 @@ private:
static int defaultMinimumWidth();
void replot() override;
void highlightPlotAxes( QwtAxisId axisIdX, QwtAxisId axisIdY );
void highlightPlotItemsForQwtAxis( QwtAxisId axisId );
void highlightPlotItems( const std::set<const QwtPlotItem*>& closestItems );
void resetPlotItemHighlighting();
void resetPlotAxisHighlighting();
void onAxisSelected( QwtScaleWidget* scale, bool toggleItemInSelection );
void recalculateAxisExtents( RiuPlotAxis axis );