From f53bf8615d8a38cd07925f80ef7eefebd4f416ac Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 14:23:18 +0100 Subject: [PATCH 01/18] rm decimal dots --- GUI/View/Shape/EllipseDisplay.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GUI/View/Shape/EllipseDisplay.cpp b/GUI/View/Shape/EllipseDisplay.cpp index b88fb9d7b47..cecdd6fb5d0 100644 --- a/GUI/View/Shape/EllipseDisplay.cpp +++ b/GUI/View/Shape/EllipseDisplay.cpp @@ -114,13 +114,13 @@ void EllipseDisplay::update_position() connect(this, &EllipseDisplay::xChanged, this, &EllipseDisplay::onChangedX); connect(this, &EllipseDisplay::yChanged, this, &EllipseDisplay::onChangedY); - if (m_item->angle() != 0.0) - setTransform(QTransform().rotate(-1.0 * m_item->angle())); + if (m_item->angle() != 0) + setTransform(QTransform().rotate(-1 * m_item->angle())); } QRectF EllipseDisplay::mask_rectangle() { - return QRectF(-width() / 2., -height() / 2., width(), height()); + return QRectF(-width() / 2, -height() / 2, width(), height()); } //! Returns the x-coordinate of the rectangle's left edge -- GitLab From 01bace61e640a99504962985223509ceeca7d32d Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 14:42:06 +0100 Subject: [PATCH 02/18] don't show generic plot properties in MaskEditorPropertyPanel --- GUI/View/Mask/MaskEditorPropertyPanel.cpp | 15 ++------------- GUI/View/Mask/MaskEditorPropertyPanel.h | 1 - 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/GUI/View/Mask/MaskEditorPropertyPanel.cpp b/GUI/View/Mask/MaskEditorPropertyPanel.cpp index 25eec0e75da..403ccdf8439 100644 --- a/GUI/View/Mask/MaskEditorPropertyPanel.cpp +++ b/GUI/View/Mask/MaskEditorPropertyPanel.cpp @@ -19,7 +19,6 @@ #include "GUI/Model/Mask/MaskItems.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Support/Tool/LayoutUtil.h" -#include "GUI/View/Data/IntensityDataPropertyWidget.h" #include "GUI/View/Numeric/DoubleSpinBox.h" #include "GUI/View/Numeric/NumberUtil.h" #include "GUI/View/Widget/GroupBoxes.h" @@ -31,7 +30,6 @@ using std::function; MaskEditorPropertyPanel::MaskEditorPropertyPanel(QWidget* parent) : DataAccessWidget(parent) , m_listView(new QListView) - , m_propertyPanel(new IntensityDataPropertyWidget) , m_maskContainerModel(nullptr) , m_data2DItem(nullptr) , m_currentMaskItem(nullptr) @@ -47,14 +45,6 @@ MaskEditorPropertyPanel::MaskEditorPropertyPanel(QWidget* parent) auto* layout = new QVBoxLayout; layout->setSpacing(8); - // -- plot properties - auto* g1 = new StaticGroupBox("Plot properties", this); - layout->addWidget(g1); - auto* l1 = new QVBoxLayout; - g1->body()->setLayout(l1); - m_propertyPanel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); - l1->addWidget(m_propertyPanel); - // -- mask stack auto* g2 = new StaticGroupBox("Mask stack", this); layout->addWidget(g2); @@ -76,17 +66,16 @@ MaskEditorPropertyPanel::MaskEditorPropertyPanel(QWidget* parent) void MaskEditorPropertyPanel::setJobOrRealItem(QObject* job_or_real_item) { setBaseItem(job_or_real_item); - m_propertyPanel->setJobOrRealItem(job_or_real_item); } QSize MaskEditorPropertyPanel::sizeHint() const { - return QSize(128, 128); + return {128, 128}; } QSize MaskEditorPropertyPanel::minimumSizeHint() const { - return QSize(128, 128); + return {128, 128}; } void MaskEditorPropertyPanel::setContextMPP(MaskContainerModel* containerModel) diff --git a/GUI/View/Mask/MaskEditorPropertyPanel.h b/GUI/View/Mask/MaskEditorPropertyPanel.h index 65ac231eb17..f6074e7cd7b 100644 --- a/GUI/View/Mask/MaskEditorPropertyPanel.h +++ b/GUI/View/Mask/MaskEditorPropertyPanel.h @@ -72,7 +72,6 @@ private: void createMaskEditorUI(); QListView* m_listView; - IntensityDataPropertyWidget* m_propertyPanel; MaskContainerModel* m_maskContainerModel; Data2DItem* m_data2DItem; QFormLayout* m_maskPropertiesLayout; -- GitLab From 0ffc499496a63f701ea9a4a79a74e387c24ea3a3 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 14:46:43 +0100 Subject: [PATCH 03/18] .. --- GUI/View/PlotUtil/PlotEventInfo.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/GUI/View/PlotUtil/PlotEventInfo.cpp b/GUI/View/PlotUtil/PlotEventInfo.cpp index ba17563c23f..43a207d7e75 100644 --- a/GUI/View/PlotUtil/PlotEventInfo.cpp +++ b/GUI/View/PlotUtil/PlotEventInfo.cpp @@ -29,20 +29,18 @@ PlotEventInfo::PlotEventInfo(PLOT_TYPE type) QString PlotEventInfo::statusString() const { - QString result; - result = m_info_type == PLOT_TYPE::Plot1D - ? QString(" [x: %1, y: %2] [binx: %3]") - .arg(QString::number(x(), 'f', 4)) - .arg(valueToString()) - .arg(m_nx, 2) - : 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(m_nx, 2) - .arg(m_ny, 2) - .arg(valueToString()); - - return result; + if (m_info_type == PLOT_TYPE::Plot1D) + return QString(" [x: %1, y: %2] [binx: %3]") + .arg(QString::number(x(), 'f', 4)) + .arg(valueToString()) + .arg(m_nx, 2); + else + 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(m_nx, 2) + .arg(m_ny, 2) + .arg(valueToString()); } QString PlotEventInfo::valueToString() const -- GitLab From 850aa2bffcb5a4759f7e959dea87a820fe0b3e82 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 15:06:04 +0100 Subject: [PATCH 04/18] shorter name --- GUI/View/Mask/MaskGraphicsScene.cpp | 2 +- GUI/View/Shape/IShapeDisplay.cpp | 2 +- GUI/View/Shape/IShapeDisplay.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GUI/View/Mask/MaskGraphicsScene.cpp b/GUI/View/Mask/MaskGraphicsScene.cpp index 0411246e8d1..329e55e4792 100644 --- a/GUI/View/Mask/MaskGraphicsScene.cpp +++ b/GUI/View/Mask/MaskGraphicsScene.cpp @@ -411,7 +411,7 @@ IShapeDisplay* MaskGraphicsScene::addViewForItem(MaskRoot* item) IShapeDisplay* view = m_ItemToView[item]; if (!view) { view = MaskViewFactory::createMaskView(item); - view->setViewSceneAdaptor(m_adaptor.get()); + view->setSceneAdaptor (m_adaptor.get()); m_ItemToView[item] = view; addItem(view); } diff --git a/GUI/View/Shape/IShapeDisplay.cpp b/GUI/View/Shape/IShapeDisplay.cpp index da93252473e..ff0994e4b7c 100644 --- a/GUI/View/Shape/IShapeDisplay.cpp +++ b/GUI/View/Shape/IShapeDisplay.cpp @@ -52,7 +52,7 @@ QRectF IShapeDisplay::boundingRect() const return m_bounding_rect; } -void IShapeDisplay::setViewSceneAdaptor(const SceneAdaptor* adaptor) +void IShapeDisplay::setSceneAdaptor (const SceneAdaptor* adaptor) { ASSERT(adaptor); if (m_adaptor == adaptor) diff --git a/GUI/View/Shape/IShapeDisplay.h b/GUI/View/Shape/IShapeDisplay.h index f1a49797cb9..a83d07442f5 100644 --- a/GUI/View/Shape/IShapeDisplay.h +++ b/GUI/View/Shape/IShapeDisplay.h @@ -33,7 +33,7 @@ public: virtual MaskRoot* parameterizedItem() const = 0; - void setViewSceneAdaptor(const SceneAdaptor* adaptor); + void setSceneAdaptor (const SceneAdaptor* adaptor); virtual void addView(IShapeDisplay* childView); -- GitLab From 82637a9388dcaa01b682d4952294ee1e912c5419 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 15:06:15 +0100 Subject: [PATCH 05/18] clang-format --- GUI/View/Mask/MaskGraphicsScene.cpp | 2 +- GUI/View/PlotUtil/PlotEventInfo.cpp | 20 ++++++++++---------- GUI/View/Shape/IShapeDisplay.cpp | 2 +- GUI/View/Shape/IShapeDisplay.h | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/GUI/View/Mask/MaskGraphicsScene.cpp b/GUI/View/Mask/MaskGraphicsScene.cpp index 329e55e4792..7d4cbb138b4 100644 --- a/GUI/View/Mask/MaskGraphicsScene.cpp +++ b/GUI/View/Mask/MaskGraphicsScene.cpp @@ -411,7 +411,7 @@ IShapeDisplay* MaskGraphicsScene::addViewForItem(MaskRoot* item) IShapeDisplay* view = m_ItemToView[item]; if (!view) { view = MaskViewFactory::createMaskView(item); - view->setSceneAdaptor (m_adaptor.get()); + view->setSceneAdaptor(m_adaptor.get()); m_ItemToView[item] = view; addItem(view); } diff --git a/GUI/View/PlotUtil/PlotEventInfo.cpp b/GUI/View/PlotUtil/PlotEventInfo.cpp index 43a207d7e75..8132264a00f 100644 --- a/GUI/View/PlotUtil/PlotEventInfo.cpp +++ b/GUI/View/PlotUtil/PlotEventInfo.cpp @@ -30,17 +30,17 @@ PlotEventInfo::PlotEventInfo(PLOT_TYPE type) QString PlotEventInfo::statusString() const { if (m_info_type == PLOT_TYPE::Plot1D) - return QString(" [x: %1, y: %2] [binx: %3]") - .arg(QString::number(x(), 'f', 4)) - .arg(valueToString()) - .arg(m_nx, 2); + return QString(" [x: %1, y: %2] [binx: %3]") + .arg(QString::number(x(), 'f', 4)) + .arg(valueToString()) + .arg(m_nx, 2); else - 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(m_nx, 2) - .arg(m_ny, 2) - .arg(valueToString()); + 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(m_nx, 2) + .arg(m_ny, 2) + .arg(valueToString()); } QString PlotEventInfo::valueToString() const diff --git a/GUI/View/Shape/IShapeDisplay.cpp b/GUI/View/Shape/IShapeDisplay.cpp index ff0994e4b7c..17662ec50cb 100644 --- a/GUI/View/Shape/IShapeDisplay.cpp +++ b/GUI/View/Shape/IShapeDisplay.cpp @@ -52,7 +52,7 @@ QRectF IShapeDisplay::boundingRect() const return m_bounding_rect; } -void IShapeDisplay::setSceneAdaptor (const SceneAdaptor* adaptor) +void IShapeDisplay::setSceneAdaptor(const SceneAdaptor* adaptor) { ASSERT(adaptor); if (m_adaptor == adaptor) diff --git a/GUI/View/Shape/IShapeDisplay.h b/GUI/View/Shape/IShapeDisplay.h index a83d07442f5..242d9bc2d8d 100644 --- a/GUI/View/Shape/IShapeDisplay.h +++ b/GUI/View/Shape/IShapeDisplay.h @@ -33,7 +33,7 @@ public: virtual MaskRoot* parameterizedItem() const = 0; - void setSceneAdaptor (const SceneAdaptor* adaptor); + void setSceneAdaptor(const SceneAdaptor* adaptor); virtual void addView(IShapeDisplay* childView); -- GitLab From ff6f7c553b2f2e5c782791fb8be965e845546702 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 15:08:55 +0100 Subject: [PATCH 06/18] . --- GUI/View/Mask/MaskEditorPropertyPanel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/GUI/View/Mask/MaskEditorPropertyPanel.h b/GUI/View/Mask/MaskEditorPropertyPanel.h index f6074e7cd7b..5bb134ccfc7 100644 --- a/GUI/View/Mask/MaskEditorPropertyPanel.h +++ b/GUI/View/Mask/MaskEditorPropertyPanel.h @@ -23,7 +23,6 @@ #include <functional> class Data2DItem; -class IntensityDataPropertyWidget; class MaskContainerModel; class MaskItem; class RealLimits; -- GitLab From 0a759a374445a1974346fa82e7cfe3c9b8822d54 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 15:11:29 +0100 Subject: [PATCH 07/18] shorter name --- GUI/View/Mask/MaskGraphicsScene.cpp | 18 +++++++++--------- GUI/View/Mask/MaskGraphicsScene.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/GUI/View/Mask/MaskGraphicsScene.cpp b/GUI/View/Mask/MaskGraphicsScene.cpp index 7d4cbb138b4..906e0704cf2 100644 --- a/GUI/View/Mask/MaskGraphicsScene.cpp +++ b/GUI/View/Mask/MaskGraphicsScene.cpp @@ -282,7 +282,7 @@ void MaskGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) if ((m_drawing_in_progress && m_activity == MaskEditorFlags::POLYGON_MODE) || ::isLineMode(m_activity)) { - m_currentMousePosition = event->scenePos(); + m_mouse_position = event->scenePos(); invalidate(); } } @@ -316,27 +316,27 @@ void MaskGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) void MaskGraphicsScene::drawForeground(QPainter* painter, const QRectF&) { - if (m_currentMousePosition == QPointF()) + if (m_mouse_position == QPointF()) return; if (PolygonDisplay* polygon = currentPolygon()) { painter->setPen(QPen(Qt::black, 1, Qt::DashLine)); - painter->drawLine(QLineF(polygon->lastAddedPoint(), m_currentMousePosition)); + painter->drawLine(QLineF(polygon->lastAddedPoint(), m_mouse_position)); } else { if (::isLineMode(m_activity)) { const QRectF& plot_scene_rectangle = m_adaptor->viewportRectangle(); - if (!plot_scene_rectangle.contains(m_currentMousePosition)) + if (!plot_scene_rectangle.contains(m_mouse_position)) return; painter->setPen(QPen(Qt::black, 1, Qt::DashLine)); if (m_activity == MaskEditorFlags::VERTICAL_LINE_MODE) { - QPointF p1(m_currentMousePosition.x(), plot_scene_rectangle.bottom()); - QPointF p2(m_currentMousePosition.x(), plot_scene_rectangle.top()); + QPointF p1(m_mouse_position.x(), plot_scene_rectangle.bottom()); + QPointF p2(m_mouse_position.x(), plot_scene_rectangle.top()); painter->drawLine(QLineF(p1, p2)); } if (m_activity == MaskEditorFlags::HORIZONTAL_LINE_MODE) { - QPointF p1(plot_scene_rectangle.left(), m_currentMousePosition.y()); - QPointF p2(plot_scene_rectangle.right(), m_currentMousePosition.y()); + QPointF p1(plot_scene_rectangle.left(), m_mouse_position.y()); + QPointF p2(plot_scene_rectangle.right(), m_mouse_position.y()); painter->drawLine(QLineF(p1, p2)); } } @@ -697,7 +697,7 @@ void MaskGraphicsScene::processPolygonItem(QGraphicsSceneMouseEvent* event) if (PolygonDisplay* polygon = currentPolygon()) { if (polygon->closePolygonIfNecessary()) { m_drawing_in_progress = false; - m_currentMousePosition = {}; + m_mouse_position = {}; return; } } diff --git a/GUI/View/Mask/MaskGraphicsScene.h b/GUI/View/Mask/MaskGraphicsScene.h index dbd41d1c2e6..c0876fb8e4b 100644 --- a/GUI/View/Mask/MaskGraphicsScene.h +++ b/GUI/View/Mask/MaskGraphicsScene.h @@ -123,7 +123,7 @@ private: bool m_mouse_is_pressed = false; Data2DItem* m_data2DItem = nullptr; MaskRoot* m_currentItem = nullptr; - QPointF m_currentMousePosition; + QPointF m_mouse_position; bool m_drawing_in_progress; MaskEditorFlags::MaskValue m_mask_value; MaskEditorFlags::Activity m_activity; -- GitLab From aacf892f2cf69be74d214d4f4b9eb4181fa911dc Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 15:34:59 +0100 Subject: [PATCH 08/18] rm private fct --- GUI/View/PlotUtil/PlotEventInfo.cpp | 20 +++++++++----------- GUI/View/PlotUtil/PlotEventInfo.h | 2 -- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/GUI/View/PlotUtil/PlotEventInfo.cpp b/GUI/View/PlotUtil/PlotEventInfo.cpp index 8132264a00f..fe12f5fa7a1 100644 --- a/GUI/View/PlotUtil/PlotEventInfo.cpp +++ b/GUI/View/PlotUtil/PlotEventInfo.cpp @@ -29,23 +29,21 @@ PlotEventInfo::PlotEventInfo(PLOT_TYPE type) QString PlotEventInfo::statusString() const { - if (m_info_type == PLOT_TYPE::Plot1D) + if (m_info_type == PLOT_TYPE::Plot1D) { + QString intensityString = QString::fromStdString(Py::Fmt::printScientificDouble(m_value)); return QString(" [x: %1, y: %2] [binx: %3]") .arg(QString::number(x(), 'f', 4)) - .arg(valueToString()) + .arg(intensityString) .arg(m_nx, 2); - else + } else { + QString intensityString = m_log_valued_axis + ? QString::fromStdString(Py::Fmt::printScientificDouble(m_value)) + : QString::number(m_value, '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(m_nx, 2) .arg(m_ny, 2) - .arg(valueToString()); -} - -QString PlotEventInfo::valueToString() const -{ - return m_info_type == PLOT_TYPE::Plot1D || m_log_valued_axis - ? QString::fromStdString(Py::Fmt::printScientificDouble(m_value)) - : QString::number(m_value, 'f', 2); + .arg(intensityString); + } } diff --git a/GUI/View/PlotUtil/PlotEventInfo.h b/GUI/View/PlotUtil/PlotEventInfo.h index 2f364914d20..fd3e9b95c4d 100644 --- a/GUI/View/PlotUtil/PlotEventInfo.h +++ b/GUI/View/PlotUtil/PlotEventInfo.h @@ -49,8 +49,6 @@ public: int ny() const { return m_ny; } private: - QString valueToString() const; - bool m_in_axes_range, m_log_valued_axis; double m_x, m_y, m_value; int m_nx, m_ny; -- GitLab From 6bb8e47b8be48647cdde4028c04bef210bf9f96b Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 15:36:47 +0100 Subject: [PATCH 09/18] disambiguate fct names --- GUI/View/PlotUtil/PlotEventHelper.cpp | 2 +- GUI/View/PlotUtil/PlotEventInfo.cpp | 2 +- GUI/View/PlotUtil/PlotEventInfo.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GUI/View/PlotUtil/PlotEventHelper.cpp b/GUI/View/PlotUtil/PlotEventHelper.cpp index 92f9ffac53f..5ceb02dd64a 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.cpp +++ b/GUI/View/PlotUtil/PlotEventHelper.cpp @@ -49,7 +49,7 @@ void PlotEventHelper::onCustomMouseMove(QMouseEvent* event) auto currentPos = currentPlotDescriptor(event); if (currentPos.inAxesRange()) { - m_plot->statusString(currentPos.statusString()); + m_plot->statusString(currentPos.infoString()); if (!m_prevPos.inAxesRange()) enteringPlot(); diff --git a/GUI/View/PlotUtil/PlotEventInfo.cpp b/GUI/View/PlotUtil/PlotEventInfo.cpp index fe12f5fa7a1..2f6eb95cec0 100644 --- a/GUI/View/PlotUtil/PlotEventInfo.cpp +++ b/GUI/View/PlotUtil/PlotEventInfo.cpp @@ -27,7 +27,7 @@ PlotEventInfo::PlotEventInfo(PLOT_TYPE type) { } -QString PlotEventInfo::statusString() const +QString PlotEventInfo::infoString() const { if (m_info_type == PLOT_TYPE::Plot1D) { QString intensityString = QString::fromStdString(Py::Fmt::printScientificDouble(m_value)); diff --git a/GUI/View/PlotUtil/PlotEventInfo.h b/GUI/View/PlotUtil/PlotEventInfo.h index fd3e9b95c4d..c7ce59dbf2c 100644 --- a/GUI/View/PlotUtil/PlotEventInfo.h +++ b/GUI/View/PlotUtil/PlotEventInfo.h @@ -26,7 +26,7 @@ class PlotEventInfo { public: PlotEventInfo(PLOT_TYPE type); - QString statusString() const; + QString infoString() const; // setters, getters void setInAxesRange(bool flag) { m_in_axes_range = flag; } -- GitLab From 3b174d36eb9c035baae5bb9de6d20cd80f2d320b Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 15:39:01 +0100 Subject: [PATCH 10/18] rm private fct --- GUI/View/PlotUtil/PlotEventHelper.cpp | 13 +++---------- GUI/View/PlotUtil/PlotEventHelper.h | 2 -- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/GUI/View/PlotUtil/PlotEventHelper.cpp b/GUI/View/PlotUtil/PlotEventHelper.cpp index 5ceb02dd64a..ed32df775e8 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.cpp +++ b/GUI/View/PlotUtil/PlotEventHelper.cpp @@ -46,7 +46,9 @@ void PlotEventHelper::setMouseTrackingEnabled(bool enable) void PlotEventHelper::onCustomMouseMove(QMouseEvent* event) { - auto currentPos = currentPlotDescriptor(event); + double x = m_plot->customPlot()->xAxis->pixelToCoord(event->pos().x()); + double y = m_plot->customPlot()->yAxis->pixelToCoord(event->pos().y()); + PlotEventInfo currentPos = m_plot->eventInfo(x, y); if (currentPos.inAxesRange()) { m_plot->statusString(currentPos.infoString()); @@ -62,12 +64,3 @@ void PlotEventHelper::onCustomMouseMove(QMouseEvent* event) m_prevPos = currentPos; } - -//! Constructs current position of the data. - -PlotEventInfo PlotEventHelper::currentPlotDescriptor(QMouseEvent* event) const -{ - double x = m_plot->customPlot()->xAxis->pixelToCoord(event->pos().x()); - double y = m_plot->customPlot()->yAxis->pixelToCoord(event->pos().y()); - return m_plot->eventInfo(x, y); -} diff --git a/GUI/View/PlotUtil/PlotEventHelper.h b/GUI/View/PlotUtil/PlotEventHelper.h index e27f615be93..a4ae27cff82 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.h +++ b/GUI/View/PlotUtil/PlotEventHelper.h @@ -43,8 +43,6 @@ public slots: void onCustomMouseMove(QMouseEvent* event); private: - PlotEventInfo currentPlotDescriptor(QMouseEvent* event) const; - ScientificPlot* m_plot; PlotEventInfo m_prevPos; }; -- GitLab From cd2683e695487e194a20e7c1cb88c496d83a4c84 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 17:06:36 +0100 Subject: [PATCH 11/18] infoString (x,y values and bin indices) now computed more directly --- GUI/View/PlotSpecular/SpecularPlot.cpp | 17 +++++++++++++++++ GUI/View/PlotSpecular/SpecularPlot.h | 2 ++ GUI/View/PlotUtil/ColorMap.cpp | 21 +++++++++++++++++++++ GUI/View/PlotUtil/ColorMap.h | 2 ++ GUI/View/PlotUtil/PlotEventHelper.cpp | 4 ++-- GUI/View/PlotUtil/ScientificPlot.h | 3 +++ 6 files changed, 47 insertions(+), 2 deletions(-) diff --git a/GUI/View/PlotSpecular/SpecularPlot.cpp b/GUI/View/PlotSpecular/SpecularPlot.cpp index ca6a8f8dbf0..1b245b2cc98 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 e60112f9c5a..35551b2bd2e 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 4657cf9bec4..e6064a352ab 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 3a835f1c11b..f670d74647c 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 ed32df775e8..1b766fec1aa 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 53a5e15b9e5..04e27c581d0 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); -- GitLab From d00cb7964fe264cf9492751b6ab84159d46d54fb Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 17:07:41 +0100 Subject: [PATCH 12/18] rm PlotEventInfo::infoString --- GUI/View/PlotUtil/PlotEventInfo.cpp | 21 --------------------- GUI/View/PlotUtil/PlotEventInfo.h | 2 -- 2 files changed, 23 deletions(-) diff --git a/GUI/View/PlotUtil/PlotEventInfo.cpp b/GUI/View/PlotUtil/PlotEventInfo.cpp index 2f6eb95cec0..45d1e0a71ff 100644 --- a/GUI/View/PlotUtil/PlotEventInfo.cpp +++ b/GUI/View/PlotUtil/PlotEventInfo.cpp @@ -26,24 +26,3 @@ PlotEventInfo::PlotEventInfo(PLOT_TYPE type) , m_info_type(type) { } - -QString PlotEventInfo::infoString() const -{ - if (m_info_type == PLOT_TYPE::Plot1D) { - QString intensityString = QString::fromStdString(Py::Fmt::printScientificDouble(m_value)); - return QString(" [x: %1, y: %2] [binx: %3]") - .arg(QString::number(x(), 'f', 4)) - .arg(intensityString) - .arg(m_nx, 2); - } else { - QString intensityString = m_log_valued_axis - ? QString::fromStdString(Py::Fmt::printScientificDouble(m_value)) - : QString::number(m_value, '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(m_nx, 2) - .arg(m_ny, 2) - .arg(intensityString); - } -} diff --git a/GUI/View/PlotUtil/PlotEventInfo.h b/GUI/View/PlotUtil/PlotEventInfo.h index c7ce59dbf2c..841410d76dd 100644 --- a/GUI/View/PlotUtil/PlotEventInfo.h +++ b/GUI/View/PlotUtil/PlotEventInfo.h @@ -26,8 +26,6 @@ class PlotEventInfo { public: PlotEventInfo(PLOT_TYPE type); - QString infoString() const; - // setters, getters void setInAxesRange(bool flag) { m_in_axes_range = flag; } bool inAxesRange() const { return m_in_axes_range; } -- GitLab From 3edea0e40a24a99a4f131462323485f4400b9adf Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 17:15:14 +0100 Subject: [PATCH 13/18] save only bool m_was_inside --- GUI/View/PlotUtil/PlotEventHelper.cpp | 19 ++++++++++--------- GUI/View/PlotUtil/PlotEventHelper.h | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/GUI/View/PlotUtil/PlotEventHelper.cpp b/GUI/View/PlotUtil/PlotEventHelper.cpp index 1b766fec1aa..2b31154330a 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.cpp +++ b/GUI/View/PlotUtil/PlotEventHelper.cpp @@ -19,7 +19,6 @@ PlotEventHelper::PlotEventHelper(ScientificPlot* scientific_plot) : QObject(scientific_plot) , m_plot(scientific_plot) - , m_prevPos(scientific_plot->plotType()) { } @@ -52,15 +51,17 @@ void PlotEventHelper::onCustomMouseMove(QMouseEvent* event) if (currentPos.inAxesRange()) { m_plot->statusString(m_plot->infoString(event)); - - if (!m_prevPos.inAxesRange()) + if (!m_was_inside) { enteringPlot(); + m_was_inside = true; + } + positionChanged(x, y); - positionChanged(currentPos.x(), currentPos.y()); - } else if (m_prevPos.inAxesRange()) { - m_plot->statusString(""); - leavingPlot(); + } else { + if (m_was_inside) { + m_plot->statusString(""); + leavingPlot(); + m_was_inside = false; + } } - - m_prevPos = currentPos; } diff --git a/GUI/View/PlotUtil/PlotEventHelper.h b/GUI/View/PlotUtil/PlotEventHelper.h index a4ae27cff82..278b7488c2c 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.h +++ b/GUI/View/PlotUtil/PlotEventHelper.h @@ -44,7 +44,7 @@ public slots: private: ScientificPlot* m_plot; - PlotEventInfo m_prevPos; + bool m_was_inside = false; }; #endif // BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTHELPER_H -- GitLab From 1b7b84d53d8f0770ce785d19c3574c84c3d99f54 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 17:21:06 +0100 Subject: [PATCH 14/18] pass only pos --- GUI/View/PlotSpecular/SpecularPlot.cpp | 6 +++--- GUI/View/PlotSpecular/SpecularPlot.h | 2 +- GUI/View/PlotUtil/ColorMap.cpp | 6 +++--- GUI/View/PlotUtil/ColorMap.h | 2 +- GUI/View/PlotUtil/PlotEventHelper.cpp | 2 +- GUI/View/PlotUtil/ScientificPlot.h | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/GUI/View/PlotSpecular/SpecularPlot.cpp b/GUI/View/PlotSpecular/SpecularPlot.cpp index 1b245b2cc98..64b66c6d181 100644 --- a/GUI/View/PlotSpecular/SpecularPlot.cpp +++ b/GUI/View/PlotSpecular/SpecularPlot.cpp @@ -93,10 +93,10 @@ PlotEventInfo SpecularPlot::eventInfo(double xpos, double ypos) const return result; } -QString SpecularPlot::infoString(QMouseEvent* event) const +QString SpecularPlot::infoString(const QPointF& pos) const { - double x = m_plot->xAxis->pixelToCoord(event->pos().x()); - double y = m_plot->yAxis->pixelToCoord(event->pos().y()); + double x = m_plot->xAxis->pixelToCoord(pos.x()); + double y = m_plot->yAxis->pixelToCoord(pos.y()); int ix = bin(x, m_plot->graph()); diff --git a/GUI/View/PlotSpecular/SpecularPlot.h b/GUI/View/PlotSpecular/SpecularPlot.h index 35551b2bd2e..6c477405b7c 100644 --- a/GUI/View/PlotSpecular/SpecularPlot.h +++ b/GUI/View/PlotSpecular/SpecularPlot.h @@ -50,7 +50,7 @@ public: //! sets logarithmic scale void setLog(); - QString infoString(QMouseEvent* event) const override; + QString infoString(const QPointF& pos) const override; private: //! Propagate xmin, xmax back to Data2DItem diff --git a/GUI/View/PlotUtil/ColorMap.cpp b/GUI/View/PlotUtil/ColorMap.cpp index e6064a352ab..4e7b2f44c72 100644 --- a/GUI/View/PlotUtil/ColorMap.cpp +++ b/GUI/View/PlotUtil/ColorMap.cpp @@ -171,10 +171,10 @@ PlotEventInfo ColorMap::eventInfo(double xpos, double ypos) const return result; } -QString ColorMap::infoString(QMouseEvent* event) const +QString ColorMap::infoString(const QPointF& pos) const { - double x = m_plot->xAxis->pixelToCoord(event->pos().x()); - double y = m_plot->yAxis->pixelToCoord(event->pos().y()); + double x = m_plot->xAxis->pixelToCoord(pos.x()); + double y = m_plot->yAxis->pixelToCoord(pos.y()); int ix, iy; m_colorMap->data()->coordToCell(x, y, &ix, &iy); diff --git a/GUI/View/PlotUtil/ColorMap.h b/GUI/View/PlotUtil/ColorMap.h index f670d74647c..ffd628cd50b 100644 --- a/GUI/View/PlotUtil/ColorMap.h +++ b/GUI/View/PlotUtil/ColorMap.h @@ -47,7 +47,7 @@ public: //! Returns PlotEventInfo corresponding to given axes coordinates. PlotEventInfo eventInfo(double xpos, double ypos) const override; - QString infoString(QMouseEvent* event) const override; + QString infoString(const QPointF& pos) const override; signals: void marginsChanged(double left, double right); diff --git a/GUI/View/PlotUtil/PlotEventHelper.cpp b/GUI/View/PlotUtil/PlotEventHelper.cpp index 2b31154330a..78e62052c01 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.cpp +++ b/GUI/View/PlotUtil/PlotEventHelper.cpp @@ -50,7 +50,7 @@ void PlotEventHelper::onCustomMouseMove(QMouseEvent* event) PlotEventInfo currentPos = m_plot->eventInfo(x, y); if (currentPos.inAxesRange()) { - m_plot->statusString(m_plot->infoString(event)); + m_plot->statusString(m_plot->infoString(event->pos())); if (!m_was_inside) { enteringPlot(); m_was_inside = true; diff --git a/GUI/View/PlotUtil/ScientificPlot.h b/GUI/View/PlotUtil/ScientificPlot.h index 04e27c581d0..cc98d84c758 100644 --- a/GUI/View/PlotUtil/ScientificPlot.h +++ b/GUI/View/PlotUtil/ScientificPlot.h @@ -49,7 +49,7 @@ public: //! Returns the type of current plot PLOT_TYPE plotType() const { return m_plot_type; } - virtual QString infoString(QMouseEvent* event) const = 0; + virtual QString infoString(const QPointF& pos) const = 0; signals: void statusString(const QString& text); -- GitLab From 545cd6732e0aff7bcb8a2886eca828186c4d01b6 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 17:29:34 +0100 Subject: [PATCH 15/18] PlotEventHelper::onCustomMouseMove w/o PlotEventInfo --- GUI/View/PlotUtil/PlotEventHelper.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/GUI/View/PlotUtil/PlotEventHelper.cpp b/GUI/View/PlotUtil/PlotEventHelper.cpp index 78e62052c01..a0ea89f35bb 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.cpp +++ b/GUI/View/PlotUtil/PlotEventHelper.cpp @@ -47,9 +47,8 @@ void PlotEventHelper::onCustomMouseMove(QMouseEvent* event) { double x = m_plot->customPlot()->xAxis->pixelToCoord(event->pos().x()); double y = m_plot->customPlot()->yAxis->pixelToCoord(event->pos().y()); - PlotEventInfo currentPos = m_plot->eventInfo(x, y); - if (currentPos.inAxesRange()) { + if (m_plot->axesRangeContains(x, y)) { m_plot->statusString(m_plot->infoString(event->pos())); if (!m_was_inside) { enteringPlot(); -- GitLab From 3b52780316caf7cf1cd80e9dfddea9357c89ff00 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 17:32:01 +0100 Subject: [PATCH 16/18] rm includes --- GUI/View/PlotUtil/PlotEventHelper.cpp | 1 + GUI/View/PlotUtil/PlotEventHelper.h | 1 - GUI/View/PlotUtil/ScientificPlot.cpp | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/GUI/View/PlotUtil/PlotEventHelper.cpp b/GUI/View/PlotUtil/PlotEventHelper.cpp index a0ea89f35bb..8304620c8e6 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.cpp +++ b/GUI/View/PlotUtil/PlotEventHelper.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/View/PlotUtil/PlotEventHelper.h" +#include "GUI/View/PlotUtil/ScientificPlot.h" #include <QMouseEvent> #include <qcustomplot.h> diff --git a/GUI/View/PlotUtil/PlotEventHelper.h b/GUI/View/PlotUtil/PlotEventHelper.h index 278b7488c2c..a52d8c9b4e5 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.h +++ b/GUI/View/PlotUtil/PlotEventHelper.h @@ -15,7 +15,6 @@ #ifndef BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTHELPER_H #define BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTHELPER_H -#include "GUI/View/PlotUtil/PlotEventInfo.h" #include <QObject> #include <memory> diff --git a/GUI/View/PlotUtil/ScientificPlot.cpp b/GUI/View/PlotUtil/ScientificPlot.cpp index 68a0223906c..a78ce23e256 100644 --- a/GUI/View/PlotUtil/ScientificPlot.cpp +++ b/GUI/View/PlotUtil/ScientificPlot.cpp @@ -12,6 +12,7 @@ // // ************************************************************************************************ +#include "GUI/View/PlotUtil/ScientificPlot.h" #include "GUI/View/PlotUtil/PlotEventHelper.h" #include <qcustomplot.h> -- GitLab From 203d4a2abdda0a52ae04c173a7515025caf8668c Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 17:33:47 +0100 Subject: [PATCH 17/18] rm PlotEventInfo --- GUI/View/PlotSpecular/SpecularPlot.cpp | 15 ------- GUI/View/PlotSpecular/SpecularPlot.h | 3 -- GUI/View/PlotUtil/ColorMap.cpp | 23 ----------- GUI/View/PlotUtil/ColorMap.h | 3 -- GUI/View/PlotUtil/PlotEventInfo.cpp | 28 ------------- GUI/View/PlotUtil/PlotEventInfo.h | 56 -------------------------- GUI/View/PlotUtil/ScientificPlot.h | 4 -- 7 files changed, 132 deletions(-) delete mode 100644 GUI/View/PlotUtil/PlotEventInfo.cpp delete mode 100644 GUI/View/PlotUtil/PlotEventInfo.h diff --git a/GUI/View/PlotSpecular/SpecularPlot.cpp b/GUI/View/PlotSpecular/SpecularPlot.cpp index 64b66c6d181..0fd2fe26cde 100644 --- a/GUI/View/PlotSpecular/SpecularPlot.cpp +++ b/GUI/View/PlotSpecular/SpecularPlot.cpp @@ -24,7 +24,6 @@ #include "GUI/Support/Tool/UpdateTimer.h" #include "GUI/Support/Util/QCP_Util.h" #include "GUI/View/PlotUtil/PlotConstants.h" -#include "GUI/View/PlotUtil/PlotEventInfo.h" namespace { @@ -80,19 +79,6 @@ Data1DItem* SpecularPlot::currentData1DItem() const return data1DItems().first(); } -PlotEventInfo SpecularPlot::eventInfo(double xpos, double ypos) const -{ - PlotEventInfo result(plotType()); - - result.setX(xpos); - result.setValue(ypos); - - result.setInAxesRange(axesRangeContains(xpos, ypos)); - result.setNx(bin(result.x(), m_plot->graph())); - - return result; -} - QString SpecularPlot::infoString(const QPointF& pos) const { double x = m_plot->xAxis->pixelToCoord(pos.x()); @@ -108,7 +94,6 @@ QString SpecularPlot::infoString(const QPointF& pos) const .arg(ix, 2); } - void SpecularPlot::setLog() { if (!currentData1DItem()) diff --git a/GUI/View/PlotSpecular/SpecularPlot.h b/GUI/View/PlotSpecular/SpecularPlot.h index 6c477405b7c..fcf448dcfe6 100644 --- a/GUI/View/PlotSpecular/SpecularPlot.h +++ b/GUI/View/PlotSpecular/SpecularPlot.h @@ -44,9 +44,6 @@ public: QSize sizeHint() const override { return QSize(500, 400); } QSize minimumSizeHint() const override { return QSize(128, 128); } - //! Returns PlotEventInfo corresponding to given axes coordinates. - PlotEventInfo eventInfo(double xpos, double ypos) const override; - //! sets logarithmic scale void setLog(); diff --git a/GUI/View/PlotUtil/ColorMap.cpp b/GUI/View/PlotUtil/ColorMap.cpp index 4e7b2f44c72..640ed9cc73c 100644 --- a/GUI/View/PlotUtil/ColorMap.cpp +++ b/GUI/View/PlotUtil/ColorMap.cpp @@ -22,7 +22,6 @@ #include "GUI/Support/Tool/UpdateTimer.h" #include "GUI/Support/Util/QCP_Util.h" #include "GUI/View/PlotUtil/PlotConstants.h" -#include "GUI/View/PlotUtil/PlotEventInfo.h" #include <qcustomplot.h> namespace { @@ -149,28 +148,6 @@ QRectF ColorMap::viewportRectangleInWidgetCoordinates() // only used by Mask/Sce return {left, top, right - left, bottom - top}; } -PlotEventInfo ColorMap::eventInfo(double xpos, double ypos) const -{ - PlotEventInfo result(plotType()); - const Data2DItem* ii = data2DItem(); - if (!ii) - return result; - - int nx(0), ny(0); - m_colorMap->data()->coordToCell(xpos, ypos, &nx, &ny); - - result.setX(xpos); - result.setY(ypos); - result.setNx(nx); - result.setNy(ny); - - result.setInAxesRange(axesRangeContains(xpos, ypos)); - result.setValue(m_colorMap->data()->cell(result.nx(), result.ny())); - result.setLogValueAxis(ii->isLog()); - - return result; -} - QString ColorMap::infoString(const QPointF& pos) const { double x = m_plot->xAxis->pixelToCoord(pos.x()); diff --git a/GUI/View/PlotUtil/ColorMap.h b/GUI/View/PlotUtil/ColorMap.h index ffd628cd50b..ba1ac38d2d9 100644 --- a/GUI/View/PlotUtil/ColorMap.h +++ b/GUI/View/PlotUtil/ColorMap.h @@ -44,9 +44,6 @@ public: //! Returns rectangle representing current axes zoom state in widget coordinates QRectF viewportRectangleInWidgetCoordinates(); - //! Returns PlotEventInfo corresponding to given axes coordinates. - PlotEventInfo eventInfo(double xpos, double ypos) const override; - QString infoString(const QPointF& pos) const override; signals: diff --git a/GUI/View/PlotUtil/PlotEventInfo.cpp b/GUI/View/PlotUtil/PlotEventInfo.cpp deleted file mode 100644 index 45d1e0a71ff..00000000000 --- a/GUI/View/PlotUtil/PlotEventInfo.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/PlotUtil/PlotEventInfo.cpp -//! @brief Implementation of the class PlotEventInfo -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/View/PlotUtil/PlotEventInfo.h" -#include "Base/Py/PyFmt.h" - -PlotEventInfo::PlotEventInfo(PLOT_TYPE type) - : m_in_axes_range(false) - , m_log_valued_axis(false) - , m_x(0.0) - , m_y(0.0) - , m_value(0.0) - , m_nx(0) - , m_ny(0) - , m_info_type(type) -{ -} diff --git a/GUI/View/PlotUtil/PlotEventInfo.h b/GUI/View/PlotUtil/PlotEventInfo.h deleted file mode 100644 index 841410d76dd..00000000000 --- a/GUI/View/PlotUtil/PlotEventInfo.h +++ /dev/null @@ -1,56 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/PlotUtil/PlotEventInfo.h -//! @brief Defines the class PlotEventInfo -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTINFO_H -#define BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTINFO_H - -#include "GUI/View/PlotUtil/ScientificPlot.h" -#include <QString> - -//! Contains parameters of mouse position in 1D or 2D plot. - -class PlotEventInfo { - using PLOT_TYPE = ScientificPlot::PLOT_TYPE; - -public: - PlotEventInfo(PLOT_TYPE type); - - // setters, getters - void setInAxesRange(bool flag) { m_in_axes_range = flag; } - bool inAxesRange() const { return m_in_axes_range; } - - void setLogValueAxis(bool flag) { m_log_valued_axis = flag; } - bool isLogValueAxis() const { return m_log_valued_axis; } - - void setX(double x) { m_x = x; } - double x() const { return m_x; } - void setY(double y) { m_y = y; } - double y() const { return m_y; } - - void setValue(double value) { m_value = value; } - double value() const { return m_value; } - - void setNx(int nx) { m_nx = nx; } - int nx() const { return m_nx; } - void setNy(int ny) { m_ny = ny; } - int ny() const { return m_ny; } - -private: - bool m_in_axes_range, m_log_valued_axis; - double m_x, m_y, m_value; - int m_nx, m_ny; - PLOT_TYPE m_info_type; -}; - -#endif // BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTINFO_H diff --git a/GUI/View/PlotUtil/ScientificPlot.h b/GUI/View/PlotUtil/ScientificPlot.h index cc98d84c758..2211f4ab28b 100644 --- a/GUI/View/PlotUtil/ScientificPlot.h +++ b/GUI/View/PlotUtil/ScientificPlot.h @@ -18,7 +18,6 @@ #include <QWidget> class PlotEventHelper; -class PlotEventInfo; class QCustomPlot; class QMouseEvent; @@ -32,9 +31,6 @@ public: explicit ScientificPlot(QWidget* parent, PLOT_TYPE plot_type); ~ScientificPlot() override; - //! Returns plot descriptor corresponding to given axes coordinates. - virtual PlotEventInfo eventInfo(double xpos, double ypos) const = 0; - QCustomPlot* customPlot() { return m_plot; } const QCustomPlot* customPlot() const { return m_plot; } -- GitLab From 4ac342fbe074f42a515949381555228474a4ce8f Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Fri, 10 Nov 2023 17:34:02 +0100 Subject: [PATCH 18/18] clang-format --- GUI/View/PlotSpecular/SpecularPlot.cpp | 6 +++--- GUI/View/PlotUtil/ColorMap.cpp | 16 ++++++++-------- GUI/View/PlotUtil/PlotEventHelper.cpp | 14 +++++++------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/GUI/View/PlotSpecular/SpecularPlot.cpp b/GUI/View/PlotSpecular/SpecularPlot.cpp index 0fd2fe26cde..82fe45803bf 100644 --- a/GUI/View/PlotSpecular/SpecularPlot.cpp +++ b/GUI/View/PlotSpecular/SpecularPlot.cpp @@ -89,9 +89,9 @@ QString SpecularPlot::infoString(const QPointF& pos) const 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); + .arg(QString::number(x, 'f', 4)) + .arg(intensityString) + .arg(ix, 2); } void SpecularPlot::setLog() diff --git a/GUI/View/PlotUtil/ColorMap.cpp b/GUI/View/PlotUtil/ColorMap.cpp index 640ed9cc73c..fb1fec298cd 100644 --- a/GUI/View/PlotUtil/ColorMap.cpp +++ b/GUI/View/PlotUtil/ColorMap.cpp @@ -157,15 +157,15 @@ QString ColorMap::infoString(const QPointF& pos) const 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); + 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); + .arg(QString::number(x, 'f', 4)) + .arg(QString::number(y, 'f', 4), 2) + .arg(ix, 2) + .arg(iy, 2) + .arg(intensityString); } //! sets logarithmic scale diff --git a/GUI/View/PlotUtil/PlotEventHelper.cpp b/GUI/View/PlotUtil/PlotEventHelper.cpp index 8304620c8e6..1e1d7546a40 100644 --- a/GUI/View/PlotUtil/PlotEventHelper.cpp +++ b/GUI/View/PlotUtil/PlotEventHelper.cpp @@ -53,15 +53,15 @@ void PlotEventHelper::onCustomMouseMove(QMouseEvent* event) m_plot->statusString(m_plot->infoString(event->pos())); if (!m_was_inside) { enteringPlot(); - m_was_inside = true; - } + m_was_inside = true; + } positionChanged(x, y); } else { - if (m_was_inside) { - m_plot->statusString(""); - leavingPlot(); - m_was_inside = false; - } + if (m_was_inside) { + m_plot->statusString(""); + leavingPlot(); + m_was_inside = false; + } } } -- GitLab