Skip to content

Commit

Permalink
Started added tooltip for x array on integrated spec widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Nov 12, 2024
1 parent 6438fa7 commit 80fc624
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/mvc/SpectraWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <QIntValidator>
#include "preferences/Preferences.h"
#include <math.h>
#include <QToolTip>


//---------------------------------------------------------------------------
Expand Down Expand Up @@ -297,6 +298,8 @@ void SpectraWidget::append_spectra(QString name, const data_struct::ArrayTr<doub
{
_int_spec_max_x = energy->maxCoeff();
_int_spec_max_y = spectra->maxCoeff();
disconnect(series, &QLineSeries::hovered, this, &SpectraWidget::showIntSpecTooltip);
connect(series, &QLineSeries::hovered, this, &SpectraWidget::showIntSpecTooltip);
}

if(series == nullptr)
Expand Down Expand Up @@ -740,4 +743,19 @@ void SpectraWidget::set_top_axis(std::map < float, std::string> elements)
}
}

//---------------------------------------------------------------------------

void SpectraWidget::showIntSpecTooltip(const QPointF &point, bool state)
{
if (state)
{
const QRect r = {};
QToolTip::showText(QCursor::pos(), QString::number(point.x(), 'f', 2), nullptr, r, 100000);
}
else
{
QToolTip::hideText();
}
}

//---------------------------------------------------------------------------
1 change: 1 addition & 0 deletions src/mvc/SpectraWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public slots:

void set_log10(bool val);

void showIntSpecTooltip(const QPointF &point, bool state);
protected:

/**
Expand Down

0 comments on commit 80fc624

Please sign in to comment.