63 QPainter painter(
this);
64 painter.setRenderHint(QPainter::Antialiasing,
true);
65 painter.setRenderHint(QPainter::TextAntialiasing,
true);
66 painter.fillRect(rect(), QColor(15, 18, 23));
68 const QRectF probRect(58.0, 28.0,
69 std::max(10.0, width() - 80.0),
70 std::max(80.0, height() - 108.0));
71 const QRectF biasRect(probRect.left(), probRect.bottom() + 18.0,
72 probRect.width(), 34.0);
76 bool haveSamples =
false;
78 if (!sample.hasLandauZener)
continue;
79 if (!haveSamples) tMin = std::min(0.0, sample.time);
80 tMax = std::max(tMax, sample.time);
83 if (!(tMax > tMin)) tMax = tMin + 1.0;
85 const auto mapX = [probRect, tMin, tMax](
double t) {
86 return probRect.left() + (t - tMin) / (tMax - tMin) * probRect.width();
88 const auto mapP = [probRect](
double p) {
89 const double q = std::max(0.0, std::min(1.0, p));
90 return probRect.bottom() - q * probRect.height();
93 painter.setPen(QPen(QColor(75, 84, 94), 1.0));
94 for (
int i = 0; i <= 4; ++i) {
95 const double u =
static_cast<double>(i) / 4.0;
96 painter.drawLine(QPointF(probRect.left() + u * probRect.width(), probRect.top()),
97 QPointF(probRect.left() + u * probRect.width(), probRect.bottom()));
98 painter.drawLine(QPointF(probRect.left(), probRect.top() + u * probRect.height()),
99 QPointF(probRect.right(), probRect.top() + u * probRect.height()));
101 painter.setPen(QPen(QColor(170, 180, 190), 1.0));
102 painter.drawRect(probRect);
105 painter.setPen(QPen(QColor(210, 210, 220, 120), 1.0, Qt::DashDotLine));
110 QPainterPath lowerPath;
111 QPainterPath upperPath;
112 QPainterPath leftPath;
113 QPainterPath rightPath;
114 QPainterPath capturedPath;
117 if (!sample.hasLandauZener)
continue;
118 const QPointF lower(mapX(sample.time), mapP(sample.landauZenerLowerPopulation));
119 const QPointF upper(mapX(sample.time), mapP(sample.landauZenerUpperPopulation));
120 const QPointF left(mapX(sample.time), mapP(sample.landauZenerLeftPopulation));
121 const QPointF right(mapX(sample.time), mapP(sample.landauZenerRightPopulation));
122 const QPointF captured(mapX(sample.time), mapP(sample.landauZenerCapturedPopulation));
124 lowerPath.moveTo(lower);
125 upperPath.moveTo(upper);
126 leftPath.moveTo(left);
127 rightPath.moveTo(right);
128 capturedPath.moveTo(captured);
131 lowerPath.lineTo(lower);
132 upperPath.lineTo(upper);
133 leftPath.lineTo(left);
134 rightPath.lineTo(right);
135 capturedPath.lineTo(captured);
140 painter.setPen(QPen(QColor(105, 220, 255), 2.3));
141 painter.drawPath(lowerPath);
142 painter.setPen(QPen(QColor(255, 165, 100), 2.1));
143 painter.drawPath(upperPath);
144 painter.setPen(QPen(QColor(120, 235, 150, 180), 1.5, Qt::DashLine));
145 painter.drawPath(leftPath);
146 painter.setPen(QPen(QColor(225, 135, 245, 180), 1.5, Qt::DashLine));
147 painter.drawPath(rightPath);
148 painter.setPen(QPen(QColor(185, 190, 200), 1.0, Qt::DotLine));
149 painter.drawPath(capturedPath);
151 painter.setPen(QColor(190, 195, 205));
152 painter.drawText(probRect, Qt::AlignCenter,
153 QStringLiteral(
"Load a Landau-Zener sweep preset and press Play"));
156 painter.setPen(QPen(QColor(80, 88, 98), 1.0));
157 painter.drawRect(biasRect);
158 const double maxBias = std::max(1.0e-12,
160 const auto mapBiasY = [biasRect, maxBias](
double value) {
161 const double q = std::max(-1.0, std::min(1.0, value / maxBias));
162 return biasRect.center().y() - 0.45 * q * biasRect.height();
164 painter.setPen(QPen(QColor(105, 115, 125), 1.0, Qt::DashLine));
165 painter.drawLine(QPointF(biasRect.left(), biasRect.center().y()),
166 QPointF(biasRect.right(), biasRect.center().y()));
168 QPainterPath biasPath;
169 const int segments = 240;
170 for (
int i = 0; i <= segments; ++i) {
171 const double t = tMin + (tMax - tMin) *
static_cast<double>(i) /
172 static_cast<double>(segments);
174 const QPointF point(mapX(t), mapBiasY(value));
175 if (i == 0) biasPath.moveTo(point);
else biasPath.lineTo(point);
177 painter.setPen(QPen(QColor(240, 215, 105), 1.8));
178 painter.drawPath(biasPath);
181 painter.setPen(QColor(210, 215, 222));
182 painter.drawText(QRectF(probRect.left(), 2.0, probRect.width(), 22.0),
184 QStringLiteral(
"Landau-Zener sweep: adiabatic and localized populations"));
185 painter.setPen(QColor(160, 168, 178));
186 painter.drawText(QRectF(2.0, probRect.top() - 8.0, 52.0, 18.0),
187 Qt::AlignRight | Qt::AlignVCenter, QStringLiteral(
"1.0"));
188 painter.drawText(QRectF(2.0, probRect.bottom() - 10.0, 52.0, 18.0),
189 Qt::AlignRight | Qt::AlignVCenter, QStringLiteral(
"0.0"));
190 painter.drawText(QRectF(2.0, biasRect.top() + 6.0, 52.0, 18.0),
191 Qt::AlignRight | Qt::AlignVCenter, QStringLiteral(
"bias"));
192 painter.drawText(QRectF(probRect.left(), biasRect.bottom() + 3.0,
193 probRect.width(), 18.0),
194 Qt::AlignCenter, QStringLiteral(
"simulation time"));
196 painter.setPen(QColor(105, 220, 255));
197 painter.drawText(QRectF(probRect.left() + 8.0, probRect.top() + 4.0, 105.0, 18.0),
198 Qt::AlignLeft, QStringLiteral(
"P(lower)"));
199 painter.setPen(QColor(255, 165, 100));
200 painter.drawText(QRectF(probRect.left() + 92.0, probRect.top() + 4.0, 105.0, 18.0),
201 Qt::AlignLeft, QStringLiteral(
"P(upper)"));
202 painter.setPen(QColor(120, 235, 150));
203 painter.drawText(QRectF(probRect.left() + 176.0, probRect.top() + 4.0, 90.0, 18.0),
204 Qt::AlignLeft, QStringLiteral(
"P(left)"));
205 painter.setPen(QColor(225, 135, 245));
206 painter.drawText(QRectF(probRect.left() + 246.0, probRect.top() + 4.0, 95.0, 18.0),
207 Qt::AlignLeft, QStringLiteral(
"P(right)"));