74 p.setRenderHint(QPainter::Antialiasing,
true);
75 p.fillRect(rect(), QColor(11, 16, 22));
77 p.setPen(QColor(220, 232, 241));
81 p.drawText(QRect(12, 8, width() - 24, 24), Qt::AlignLeft | Qt::AlignVCenter,
82 QStringLiteral(
"Moshinsky shutter — diffraction in time"));
86 p.setPen(QColor(150, 166, 180));
87 p.drawText(QRect(20, 52, width() - 40, height() - 72),
88 Qt::AlignCenter | Qt::TextWordWrap,
89 QStringLiteral(
"Load Moshinsky Shutter / Diffraction in Time and press Play"));
93 const std::vector<qpe::QuantumMoshinskySample2D> &samples =
history_->
samples();
100 const int traceH = std::max(120, height() / 3);
101 const int heatBottom = height() - traceH - gap;
102 QRect heat(left, top, std::max(10, width() - left - right), std::max(80, heatBottom - top));
103 QRect trace(left, heat.bottom() + gap, heat.width(), height() - (heat.bottom() + gap) - 28);
105 p.setPen(QColor(60, 76, 90));
106 p.setBrush(QColor(6, 11, 16));
110 double maxMarginal = 0.0;
111 double maxSignal = 0.0;
113 maxSignal = std::max(maxSignal, s.detectorSignal);
114 for (
float v : s.marginalX) maxMarginal = std::max(maxMarginal,
static_cast<double>(v));
116 maxMarginal = std::max(maxMarginal, 1.0e-12);
117 maxSignal = std::max(maxSignal, 1.0e-12);
121 for (std::size_t si = 0; si < samples.size(); ++si) {
123 const int y0 = heat.top() +
static_cast<int>(
124 (
static_cast<double>(si) /
static_cast<double>(samples.size())) * heat.height());
125 const int y1 = heat.top() +
static_cast<int>(
126 (
static_cast<double>(si + 1u) /
static_cast<double>(samples.size())) * heat.height());
127 const int hh = std::max(1, y1 - y0 + 1);
128 for (std::size_t xi = 0; xi < nx && xi < s.
marginalX.size(); ++xi) {
129 const int x0 = heat.left() +
static_cast<int>(
130 (
static_cast<double>(xi) /
static_cast<double>(nx)) * heat.width());
131 const int x1 = heat.left() +
static_cast<int>(
132 (
static_cast<double>(xi + 1u) /
static_cast<double>(nx)) * heat.width());
133 const int ww = std::max(1, x1 - x0 + 1);
134 const double intensity = std::sqrt(
135 std::max(0.0,
static_cast<double>(s.
marginalX[xi])) / maxMarginal);
136 p.fillRect(QRect(x0, y0, ww, hh), heatColor(intensity));
143 const auto mapX = [&](
double x) {
144 const double u = (x - xMin) / std::max(1.0e-12, xMax - xMin);
145 return heat.left() + u * heat.width();
147 const double tMax = std::max(config.
analysisEndTime, samples.back().time);
148 const auto mapTHeat = [&](
double t) {
149 return heat.top() + (t / std::max(1.0e-12, tMax)) * heat.height();
152 p.setPen(QPen(QColor(255, 198, 73), 1.3, Qt::DashLine));
153 p.drawLine(QPointF(mapX(geometry.
shutterX), heat.top()),
154 QPointF(mapX(geometry.
shutterX), heat.bottom()));
155 p.setPen(QPen(QColor(255, 110, 110), 1.3, Qt::DashLine));
156 p.drawLine(QPointF(mapX(config.
detectorX), heat.top()),
157 QPointF(mapX(config.
detectorX), heat.bottom()));
158 p.setPen(QPen(QColor(240, 240, 240, 140), 1.0, Qt::DashLine));
159 p.drawLine(QPointF(heat.left(), mapTHeat(config.
openTime)),
160 QPointF(heat.right(), mapTHeat(config.
openTime)));
163 p.setPen(QColor(180, 197, 210));
164 p.drawText(QRect(4, heat.top(), left - 10, 20), Qt::AlignRight | Qt::AlignVCenter,
165 QStringLiteral(
"t=0"));
166 p.drawText(QRect(4, heat.bottom() - 20, left - 10, 20), Qt::AlignRight | Qt::AlignVCenter,
167 QStringLiteral(
"%1").arg(tMax, 0,
'f', 2));
168 p.drawText(QRect(heat.left(), heat.bottom() + 4, heat.width(), 20), Qt::AlignCenter,
169 QStringLiteral(
"x | gold=shutter red=detector"));
171 const auto mapTraceX = [&](
double t) {
172 return trace.left() + (t / std::max(1.0e-12, tMax)) * trace.width();
174 const auto mapTraceY = [&](
double v) {
175 return trace.bottom() - (v / maxSignal) * trace.height();
179 for (std::size_t i = 0; i < samples.size(); ++i) {
180 const QPointF pt(mapTraceX(samples[i].time), mapTraceY(samples[i].detectorSignal));
181 if (i == 0u) path.moveTo(pt);
else path.lineTo(pt);
183 p.setPen(QPen(QColor(98, 220, 255), 2.0));
186 p.setPen(QPen(QColor(240, 240, 240, 110), 1.0, Qt::DashLine));
187 p.drawLine(QPointF(mapTraceX(config.
openTime), trace.top()),
188 QPointF(mapTraceX(config.
openTime), trace.bottom()));
190 p.setPen(QColor(180, 197, 210));
191 p.drawText(QRect(4, trace.top(), left - 10, 20), Qt::AlignRight | Qt::AlignVCenter,
192 QStringLiteral(
"Imax"));
193 p.drawText(QRect(trace.left(), trace.bottom() + 4, trace.width(), 20), Qt::AlignCenter,
194 QStringLiteral(
"time — detector line density I(xd,t)"));
197 p.setPen(QColor(225, 235, 242));
198 p.drawText(QRect(trace.left() + 8, trace.top() + 6, trace.width() - 16, 20),
199 Qt::AlignLeft | Qt::AlignVCenter,
200 QStringLiteral(
"samples=%1 t=%2 I_det=%3 P(x>shutter)=%4")
201 .arg(
static_cast<qulonglong
>(samples.size()))
202 .arg(last.
time, 0,
'f', 3)