57 QPainter painter(
this);
58 painter.setRenderHint(QPainter::Antialiasing,
true);
59 painter.setRenderHint(QPainter::TextAntialiasing,
true);
60 painter.fillRect(rect(), QColor(15, 18, 23));
62 const QRectF plotRect(58.0, 26.0,
63 std::max(10.0, width() - 78.0),
64 std::max(10.0, height() - 64.0));
65 painter.setPen(QPen(QColor(78, 86, 96), 1.0));
66 for (
int i = 0; i <= 4; ++i) {
67 const double u =
static_cast<double>(i) / 4.0;
68 painter.drawLine(QPointF(plotRect.left() + u * plotRect.width(), plotRect.top()),
69 QPointF(plotRect.left() + u * plotRect.width(), plotRect.bottom()));
70 painter.drawLine(QPointF(plotRect.left(), plotRect.top() + u * plotRect.height()),
71 QPointF(plotRect.right(), plotRect.top() + u * plotRect.height()));
73 painter.setPen(QPen(QColor(170, 180, 190), 1.0));
74 painter.drawRect(plotRect);
78 double sigmaMin = std::numeric_limits<double>::infinity();
79 double sigmaMax = -std::numeric_limits<double>::infinity();
80 double energyMin = std::numeric_limits<double>::infinity();
81 double energyMax = -std::numeric_limits<double>::infinity();
83 tMax = std::max(tMax, sample.time);
84 if (std::isfinite(sample.sigmaX)) {
85 sigmaMin = std::min(sigmaMin, sample.sigmaX);
86 sigmaMax = std::max(sigmaMax, sample.sigmaX);
88 if (std::isfinite(sample.totalEnergy)) {
89 energyMin = std::min(energyMin, sample.totalEnergy);
90 energyMax = std::max(energyMax, sample.totalEnergy);
93 if (!(tMax > tMin)) tMax = tMin + 1.0;
94 if (!(sigmaMax > sigmaMin)) { sigmaMin = 0.0; sigmaMax = std::max(1.0, sigmaMax); }
95 if (!(energyMax > energyMin)) { energyMin -= 0.5; energyMax += 0.5; }
96 const double sigmaPad = 0.10 * std::max(1.0e-6, sigmaMax - sigmaMin);
97 sigmaMin = std::max(0.0, sigmaMin - sigmaPad);
99 const double energyPad = 0.10 * std::max(1.0e-6, energyMax - energyMin);
100 energyMin -= energyPad;
101 energyMax += energyPad;
103 const auto mapX = [plotRect, tMin, tMax](
double t) {
104 return plotRect.left() + (t - tMin) / (tMax - tMin) * plotRect.width();
106 const auto mapSigma = [plotRect, sigmaMin, sigmaMax](
double v) {
107 return plotRect.bottom() - (v - sigmaMin) / (sigmaMax - sigmaMin) * plotRect.height();
109 const auto mapEnergy = [plotRect, energyMin, energyMax](
double v) {
110 return plotRect.bottom() - (v - energyMin) / (energyMax - energyMin) * plotRect.height();
114 painter.setPen(QPen(QColor(255, 220, 100), 1.5, Qt::DashLine));
115 painter.drawLine(QPointF(mapX(
quenchTime_), plotRect.top()),
117 painter.drawText(QRectF(mapX(
quenchTime_) + 4.0, plotRect.top() + 2.0, 80.0, 18.0),
118 Qt::AlignLeft, QStringLiteral(
"quench"));
121 QPainterPath sigmaPath;
122 QPainterPath energyPath;
125 const QPointF ps(mapX(sample.time), mapSigma(sample.sigmaX));
126 const QPointF pe(mapX(sample.time), mapEnergy(sample.totalEnergy));
128 sigmaPath.moveTo(ps);
129 energyPath.moveTo(pe);
132 sigmaPath.lineTo(ps);
133 energyPath.lineTo(pe);
138 painter.setPen(QPen(QColor(100, 220, 255), 2.2));
139 painter.drawPath(sigmaPath);
140 painter.setPen(QPen(QColor(255, 170, 105), 1.8));
141 painter.drawPath(energyPath);
143 painter.setPen(QColor(190, 195, 205));
144 painter.drawText(plotRect, Qt::AlignCenter,
145 QStringLiteral(
"Load Quantum Quench and press Play"));
148 painter.setPen(QColor(210, 215, 222));
149 painter.drawText(QRectF(plotRect.left(), 2.0, plotRect.width(), 20.0),
151 QStringLiteral(
"Quantum quench: width and total energy"));
152 painter.setPen(QColor(100, 220, 255));
153 painter.drawText(QRectF(plotRect.left() + 8.0, plotRect.top() + 5.0, 110.0, 18.0),
154 Qt::AlignLeft, QStringLiteral(
"sigmaX"));
155 painter.setPen(QColor(255, 170, 105));
156 painter.drawText(QRectF(plotRect.left() + 80.0, plotRect.top() + 5.0, 110.0, 18.0),
157 Qt::AlignLeft, QStringLiteral(
"<H>"));
158 painter.setPen(QColor(160, 168, 178));
159 painter.drawText(QRectF(plotRect.left(), plotRect.bottom() + 5.0,
160 plotRect.width(), 22.0),
161 Qt::AlignCenter, QStringLiteral(
"simulation time"));