diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7b7cbbdf9..26f766366 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -13,6 +13,8 @@ * The viewer's file manager lists CBF frames beside HDF5 datasets. * The viewer's image statistics state the collection time, detector distance, beam centre and wavelength as entries of their own rather than in a tooltip, and no longer report a B-factor. * The viewer plots spot count and background together on one plot, which is what a connection to a live source now shows by default. +* The viewer's combined spots + background plot scales each quantity on its own axis - background on the left, spot count on the right, each axis coloured like its curve - and keeps the two curves in separate halves of the plot. +* The viewer's per-image plot selector no longer offers the X-ray fluorescence spectrum. * The viewer's reprocessing panel is called Processing, and the jobs panel it shared that name with is called Jobs. * Expanding the viewer's powder-calibration section no longer widens the left-hand panel past the space it has, which used to push half of it out of sight. * No section of the viewer's processing panel asks for more width than the panel has: geometry, unit cell, goniometer, spot finding and indexing all used to widen it when opened. diff --git a/viewer/JFJochViewerDatasetInfo.cpp b/viewer/JFJochViewerDatasetInfo.cpp index 4cf0e3150..03f1722ce 100644 --- a/viewer/JFJochViewerDatasetInfo.cpp +++ b/viewer/JFJochViewerDatasetInfo.cpp @@ -329,7 +329,8 @@ void JFJochViewerDatasetInfo::UpdatePlot() { RunColor(static_cast(runs_.size())), XForRun(*live_run_)}); } - // "Spots + background": one plot, two quantities, the background on its own right-hand axis. + // "Spots + background": one plot, two quantities — the background on its own left-hand axis, + // the spot count on the right. std::optional secondary; if (val == SPOTS_PLUS_BACKGROUND) { secondary = JFJochDatasetInfoChartView::NamedSeries{ diff --git a/viewer/charts/JFJochDatasetInfoChartView.cpp b/viewer/charts/JFJochDatasetInfoChartView.cpp index ad7eee442..7f35229b6 100644 --- a/viewer/charts/JFJochDatasetInfoChartView.cpp +++ b/viewer/charts/JFJochDatasetInfoChartView.cpp @@ -431,9 +431,10 @@ void JFJochDatasetInfoChartView::buildTimeDomainChart() { chart()->setMargins(m); } } else { - // Normal numeric labels, axis on the LEFT + // Normal numeric labels, axis on the LEFT — unless a secondary quantity takes the + // left side, in which case the primary reads on the RIGHT. chart()->removeAxis(axisY); - chart()->addAxis(axisY, Qt::AlignLeft); + chart()->addAxis(axisY, secondary_.has_value() ? Qt::AlignRight : Qt::AlignLeft); series->attachAxis(axisY); currentSeries->attachAxis(axisY); @@ -450,9 +451,12 @@ void JFJochDatasetInfoChartView::buildTimeDomainChart() { line->attachAxis(ax); } - // Secondary quantity: same x, its own Y axis on the right, so a small background value is - // not flattened by a spot count three orders of magnitude larger. The 1/d^2 layout already - // owns the right-hand side, so the two never combine. + // Secondary quantity: same x, its own Y axis on the LEFT (the primary then reads on the + // RIGHT), so a small background value is not flattened by a spot count three orders of + // magnitude larger. Each axis is ranged from its own series alone; on top of that the + // secondary's max and the primary's min are each inflated by that series' own span, so the + // secondary curve occupies the lower half of the plot and the primary the upper half. A + // secondary never combines with the 1/d^2 layout. if (secondary_.has_value() && !m_yOneOverD) { auto *line = new QLineSeries(this); line->setName(secondary_->name); @@ -466,18 +470,27 @@ void JFJochDatasetInfoChartView::buildTimeDomainChart() { auto *axisY2 = new QValueAxis(); if (std::isfinite(secMin) && std::isfinite(secMax)) { const double lo = m_minYZeroEnabled ? 0.0 : secMin; - axisY2->setRange(lo, (secMax > lo) ? secMax : (lo + 1.0)); + const double hi = (secMax > lo) ? secMax : (lo + 1.0); + axisY2->setRange(lo, lo + 2.0 * (hi - lo)); // lower half } - if (secondary_->color.isValid()) - axisY2->setLabelsColor(secondary_->color); - chart()->addAxis(axisY2, Qt::AlignRight); + chart()->addAxis(axisY2, Qt::AlignLeft); line->attachAxis(axisY2); for (auto *ax: finalAxes) if (ax->orientation() == Qt::Horizontal) line->attachAxis(ax); - // Colour the left labels to match the primary, so it is clear which axis reads which. - if (axisY && primary_color_.isValid()) + if (axisY) + axisY->setRange(axisY->max() - 2.0 * (axisY->max() - axisY->min()), + axisY->max()); // upper half + // Each axis carries its series' colour on labels and axis line, so it is clear at a + // glance which axis reads which curve. + if (secondary_->color.isValid()) { + axisY2->setLabelsColor(secondary_->color); + axisY2->setLinePenColor(secondary_->color); + } + if (axisY && primary_color_.isValid()) { axisY->setLabelsColor(primary_color_); + axisY->setLinePenColor(primary_color_); + } } // The current-image marker is not a run - keep it out of the legend. diff --git a/viewer/charts/JFJochDatasetInfoChartView.h b/viewer/charts/JFJochDatasetInfoChartView.h index 403aa0cf8..26a6bba06 100644 --- a/viewer/charts/JFJochDatasetInfoChartView.h +++ b/viewer/charts/JFJochDatasetInfoChartView.h @@ -53,8 +53,9 @@ public: struct NamedSeries { QString name; std::vector values; QColor color; std::vector x; }; private: std::vector overlays_; - // A second quantity plotted against the same x but on its own right-hand Y axis, for a metric - // pair whose units are unrelated (spot count vs background per pixel). Never 1/d^2-transformed. + // A second quantity plotted against the same x but on its own left-hand Y axis (the primary + // then moves to the right), for a metric pair whose units are unrelated (spot count vs + // background per pixel). Never 1/d^2-transformed. std::optional secondary_; QColor primary_color_; // colour of the active (primary) run, if assigned std::vector primary_x_; // x (image numbers) for the primary series; empty => index diff --git a/viewer/widgets/JFJochViewerSidePanelChart.cpp b/viewer/widgets/JFJochViewerSidePanelChart.cpp index a4cb3c795..e7ace480f 100644 --- a/viewer/widgets/JFJochViewerSidePanelChart.cpp +++ b/viewer/widgets/JFJochViewerSidePanelChart.cpp @@ -23,7 +23,6 @@ QList> JFJochViewerSidePanelChart::PlotTypes() { {"I/sigma", 2}, {"Spots (count)", 5}, {"Spots (intensity)", 6}, - {"X-ray fluorescence spectrum", 4}, }; } @@ -53,13 +52,6 @@ void JFJochViewerSidePanelChart::redrawPlot() { y = image->ImageData().integration_Isigma; azint_plot->UpdateData(x, y, "d [Å]", "I/sigma", true); break; - case 4: - x = image->Dataset().experiment.GetFluorescenceSpectrum().GetEnergy_eV(); - y = image->Dataset().experiment.GetFluorescenceSpectrum().GetData(); - for (auto &iter: x) - iter /= 1000.0; // Convert eV to keV - azint_plot->UpdateData(x, y, "E [keV]", "", false); - break; case 5: x = image->ImageData().spot_plot_one_over_d_square; y = image->ImageData().spot_plot_count; diff --git a/viewer/widgets/JFJochViewerSidePanelChart.h b/viewer/widgets/JFJochViewerSidePanelChart.h index 74141bd29..61d736b62 100644 --- a/viewer/widgets/JFJochViewerSidePanelChart.h +++ b/viewer/widgets/JFJochViewerSidePanelChart.h @@ -11,7 +11,7 @@ #include "../../reader/JFJochReaderImage.h" #include "../charts/JFJochSimpleChartView.h" -// Per-image profile plot (azimuthal 1D, Wilson, I/sigma, spots, fluorescence). It has no selector +// Per-image profile plot (azimuthal 1D, Wilson, I/sigma, spots). It has no selector // of its own — the host (dataset-info dock) drives the plot type via setPlotType, reusing its one // combo box. class JFJochViewerSidePanelChart : public QWidget {