diff --git a/GUI/View/PlotSpecular/SpecularPlot.cpp b/GUI/View/PlotSpecular/SpecularPlot.cpp index ca6a8f8dbf0fc79ca56cb0877e659472d61e05c6..1b245b2cc98fcf56b062baba31783800ad7c80c9 100644 --- a/GUI/View/PlotSpecular/SpecularPlot.cpp +++ b/GUI/View/PlotSpecular/SpecularPlot.cpp @@ -14,6 +14,7 @@ #include "GUI/View/PlotSpecular/SpecularPlot.h" #include "Base/Axis/Frame.h" +#include "Base/Py/PyFmt.h" #include "Base/Util/Assert.h" #include "Device/Data/Datafield.h" #include "GUI/Model/Axis/AmplitudeAxisItem.h" @@ -92,6 +93,22 @@ PlotEventInfo SpecularPlot::eventInfo(double xpos, double ypos) const return result; } +QString SpecularPlot::infoString(QMouseEvent* event) const +{ + double x = m_plot->xAxis->pixelToCoord(event->pos().x()); + double y = m_plot->yAxis->pixelToCoord(event->pos().y()); + + int ix = bin(x, m_plot->graph()); + + QString intensityString = QString::fromStdString(Py::Fmt::printScientificDouble(y)); + + return QString(" [x: %1, y: %2] [binx: %3]") + .arg(QString::number(x, 'f', 4)) + .arg(intensityString) + .arg(ix, 2); +} + + void SpecularPlot::setLog() { if (!currentData1DItem()) diff --git a/GUI/View/PlotSpecular/SpecularPlot.h b/GUI/View/PlotSpecular/SpecularPlot.h index e60112f9c5a48b94f85c49727bb108c51a91d6f3..35551b2bd2ecd4cdf0ae7706e47223261606a74d 100644 --- a/GUI/View/PlotSpecular/SpecularPlot.h +++ b/GUI/View/PlotSpecular/SpecularPlot.h @@ -50,6 +50,8 @@ public: //! sets logarithmic scale void setLog(); + QString infoString(QMouseEvent* event) const override; + private: //! Propagate xmin, xmax back to Data2DItem void onXaxisRangeChanged(QCPRange range); diff --git a/GUI/View/PlotUtil/ColorMap.cpp b/GUI/View/PlotUtil/ColorMap.cpp index 4657cf9bec4fe2d4700e06ebbed775c8023d5826..e6064a352ab536b1430ccdaaca2176c6addc41ac 100644 --- a/GUI/View/PlotUtil/ColorMap.cpp +++ b/GUI/View/PlotUtil/ColorMap.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/View/PlotUtil/ColorMap.h" +#include "Base/Py/PyFmt.h" #include "Device/Data/Datafield.h" #include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Axis/BasicAxisItem.h" @@ -170,6 +171,26 @@ PlotEventInfo ColorMap::eventInfo(double xpos, double ypos) const return result; } +QString ColorMap::infoString(QMouseEvent* event) const +{ + double x = m_plot->xAxis->pixelToCoord(event->pos().x()); + double y = m_plot->yAxis->pixelToCoord(event->pos().y()); + + int ix, iy; + m_colorMap->data()->coordToCell(x, y, &ix, &iy); + + double intensity = m_colorMap->data()->cell(ix, iy); + QString intensityString = data2DItem()->isLog() + ? QString::fromStdString(Py::Fmt::printScientificDouble(intensity)) + : QString::number(intensity, 'f', 2); + return QString(" [x: %1, y: %2] [binx: %3, biny:%4] [value: %5]") + .arg(QString::number(x, 'f', 4)) + .arg(QString::number(y, 'f', 4), 2) + .arg(ix, 2) + .arg(iy, 2) + .arg(intensityString); +} + //! sets logarithmic scale void ColorMap::setLogz() { diff --git a/GUI/View/PlotUtil/ColorMap.h b/GUI/View/PlotUtil/ColorMap.h index 3a835f1c11bed3fbfeec7e23ee1f5e54959fd827..f670d74647c91e8068061cdab5698e30c44c98ae 100644 --- a/GUI/View/PlotUtil/ColorMap.h +++ b/GUI/View/PlotUtil/ColorMap.h @@ -47,6 +47,8 @@ public: //! Returns PlotEventInfo corresponding to given axes coordinates. PlotEventInfo eventInfo(double xpos, double ypos) const override; + QString infoString(QMouseEvent* event) const override; + signals: void marginsChanged(double left, double right); diff --git a/GUI/View/PlotUtil/PlotEventHelper.cpp b/GUI/View/PlotUtil/PlotEventHelper.cpp index ed32df775e8ac060038d4f8c3d549c5a09d7ca1e..1b766fec1aa79d0ad7ad50c18fd19aa41d2121af 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.cpp +++ b/GUI/View/PlotUtil/PlotEventHelper.cpp @@ -51,14 +51,14 @@ void PlotEventHelper::onCustomMouseMove(QMouseEvent* event) PlotEventInfo currentPos = m_plot->eventInfo(x, y); if (currentPos.inAxesRange()) { - m_plot->statusString(currentPos.infoString()); + m_plot->statusString(m_plot->infoString(event)); if (!m_prevPos.inAxesRange()) enteringPlot(); positionChanged(currentPos.x(), currentPos.y()); } else if (m_prevPos.inAxesRange()) { - m_plot->statusString(QString()); + m_plot->statusString(""); leavingPlot(); } diff --git a/GUI/View/PlotUtil/ScientificPlot.h b/GUI/View/PlotUtil/ScientificPlot.h index 53a5e15b9e554bae3ba8398a1c31f14f9b56e5d2..04e27c581d0f946dc0a119687b8dbfa053b7e5d2 100644 --- a/GUI/View/PlotUtil/ScientificPlot.h +++ b/GUI/View/PlotUtil/ScientificPlot.h @@ -20,6 +20,7 @@ class PlotEventHelper; class PlotEventInfo; class QCustomPlot; +class QMouseEvent; //! Common interface for plot-descriptor interaction @@ -48,6 +49,8 @@ public: //! Returns the type of current plot PLOT_TYPE plotType() const { return m_plot_type; } + virtual QString infoString(QMouseEvent* event) const = 0; + signals: void statusString(const QString& text);