55 p.setRenderHint(QPainter::Antialiasing,
true);
56 p.setRenderHint(QPainter::TextAntialiasing,
true);
57 p.fillRect(rect(), QColor(13, 17, 23));
59 const QColor text(210, 220, 230);
60 const QColor frame(70, 82, 94);
61 const QColor watched(80, 220, 235);
62 const QColor control(245, 170, 70);
63 const QColor boundary(235, 90, 105);
66 p.drawText(QRect(8, 2, width() - 16, 20), Qt::AlignCenter,
67 QStringLiteral(
"Quantum Zeno effect: unmeasured escape vs repeatedly watched survival"));
69 const int marginL = 58;
70 const int marginR = 20;
73 const int bottom = 30;
74 const int panelH = std::max(95, (height() - top - bottom - gap) / 2);
75 const QRect survivalRect(marginL, top,
76 std::max(20, width() - marginL - marginR), panelH);
77 const QRect profileRect(marginL, top + panelH + gap,
78 std::max(20, width() - marginL - marginR), panelH);
80 auto drawFrame = [&](
const QRect &r,
const QString &title) {
84 p.drawText(QRect(r.left(), r.top() - 20, r.width(), 18), Qt::AlignLeft, title);
86 drawFrame(survivalRect, QStringLiteral(
"Survival probability"));
87 drawFrame(profileRect, QStringLiteral(
"Current X profile (each lane normalized for shape)"));
91 p.drawText(rect(), Qt::AlignCenter,
92 QStringLiteral(
"Run the Quantum Zeno / Watched Escape preset"));
96 const std::vector<qpe::QuantumZenoSample2D> &samples =
history_->
samples();
99 const double tMax = std::max(1.0e-9, samples.back().time);
101 auto mapT = [&](
double t) {
102 return survivalRect.left() + t / tMax * survivalRect.width();
104 auto mapSurvival = [&](
double v) {
105 const double clamped = std::max(0.0, std::min(1.0, v));
106 return survivalRect.bottom() - clamped * survivalRect.height();
109 p.setPen(QPen(frame, 1, Qt::DotLine));
110 for (
int i = 1; i < 4; ++i) {
111 const double level = 0.25 *
static_cast<double>(i);
112 const int yy =
static_cast<int>(std::lround(mapSurvival(level)));
113 p.drawLine(survivalRect.left(), yy, survivalRect.right(), yy);
116 auto drawSurvival = [&](
bool watchedSeries,
const QColor &color) {
118 bool started =
false;
120 const double value = watchedSeries
121 ? sample.watchedCumulativeSurvival
122 : sample.controlSurvival;
123 const QPointF q(mapT(sample.time), mapSurvival(value));
124 if (!started) { path.moveTo(q); started =
true; }
127 p.setPen(QPen(color, 2.2));
130 drawSurvival(
false, control);
131 drawSurvival(
true, watched);
134 p.drawText(survivalRect.adjusted(8, 6, -8, -6),
135 Qt::AlignTop | Qt::AlignLeft,
136 QStringLiteral(
"upper control: no measurements"));
138 p.drawText(survivalRect.adjusted(8, 6, -8, -6),
139 Qt::AlignTop | Qt::AlignRight,
140 QStringLiteral(
"lower watched: repeated YES projections"));
142 p.drawText(QRect(4, survivalRect.top(), 48, 18), Qt::AlignRight,
143 QStringLiteral(
"1.0"));
144 p.drawText(QRect(4, survivalRect.bottom() - 16, 48, 18), Qt::AlignRight,
145 QStringLiteral(
"0.0"));
146 p.drawText(QRect(survivalRect.left(), survivalRect.bottom() + 4,
147 survivalRect.width(), 20),
149 QStringLiteral(
"t=%1 measurements=%2")
150 .arg(tMax, 0,
'f', 1)
159 for (
float v :
profile_.
control) maxP = std::max(maxP,
static_cast<double>(v));
160 for (
float v :
profile_.
watched) maxP = std::max(maxP,
static_cast<double>(v));
161 maxP = std::max(maxP, 1.0e-12);
163 auto mapX = [&](
double x) {
164 return profileRect.left() + (x - xMin) / (xMax - xMin) * profileRect.width();
166 auto mapP = [&](
double value) {
167 return profileRect.bottom() - value / maxP * profileRect.height();
171 if (bx >= profileRect.left() && bx <= profileRect.right()) {
172 p.setPen(QPen(boundary, 1.5, Qt::DashLine));
173 p.drawLine(bx, profileRect.top(), bx, profileRect.bottom());
174 p.drawText(QRect(bx + 4, profileRect.top() + 4, 120, 18),
175 Qt::AlignLeft, QStringLiteral(
"measurement edge"));
178 auto drawProfile = [&](
const std::vector<float> &values,
const QColor &color) {
180 bool started =
false;
181 for (std::size_t i = 0u; i < values.size(); ++i) {
182 const double x = xMin +
static_cast<double>(i) *
profile_.
dx;
183 const QPointF q(mapX(x), mapP(values[i]));
184 if (!started) { path.moveTo(q); started =
true; }
187 p.setPen(QPen(color, 2.0));
194 p.drawText(profileRect.adjusted(8, 6, -8, -6),
195 Qt::AlignBottom | Qt::AlignLeft,
196 QStringLiteral(
"orange control cyan watched"));
197 p.drawText(QRect(profileRect.left(), profileRect.bottom() + 4,
198 profileRect.width(), 20),
200 QStringLiteral(
"x=%1").arg(xMin, 0,
'f', 1));
201 p.drawText(QRect(profileRect.left(), profileRect.bottom() + 4,
202 profileRect.width(), 20),
204 QStringLiteral(
"x=%1").arg(xMax, 0,
'f', 1));