52 QPainter painter(
this);
53 painter.setRenderHint(QPainter::Antialiasing,
true);
54 painter.setRenderHint(QPainter::TextAntialiasing,
true);
55 painter.fillRect(rect(), QColor(15, 18, 23));
57 const QRectF plotRect(62.0, 26.0,
58 std::max(10.0, width() - 84.0),
59 std::max(10.0, height() - 64.0));
61 painter.setPen(QPen(QColor(78, 86, 96), 1.0));
62 for (
int i = 0; i <= 4; ++i) {
63 const double u =
static_cast<double>(i) / 4.0;
64 painter.drawLine(QPointF(plotRect.left() + u * plotRect.width(), plotRect.top()),
65 QPointF(plotRect.left() + u * plotRect.width(), plotRect.bottom()));
66 painter.drawLine(QPointF(plotRect.left(), plotRect.top() + u * plotRect.height()),
67 QPointF(plotRect.right(), plotRect.top() + u * plotRect.height()));
69 painter.setPen(QPen(QColor(170, 180, 190), 1.0));
70 painter.drawRect(plotRect);
73 painter.setPen(QColor(190, 195, 205));
74 painter.drawText(plotRect, Qt::AlignCenter,
75 QStringLiteral(
"Compute bound states for a Y-invariant confining potential"));
84 yMin = std::min(yMin, state.
energy);
85 yMax = std::max(yMax, state.
energy);
88 const double yPad = 0.08 * std::max(1.0e-9, yMax - yMin);
92 const auto mapX = [plotRect, xMin, xMax](
double value) {
93 const double u = (value - xMin) / std::max(1.0e-30, xMax - xMin);
94 return plotRect.left() + u * plotRect.width();
96 const auto mapY = [plotRect, yMin, yMax](
double value) {
97 const double u = (value - yMin) / std::max(1.0e-30, yMax - yMin);
98 return plotRect.bottom() - u * plotRect.height();
102 QPainterPath potentialPath;
103 for (std::size_t i = 0u; i <
spectrum_.
x.size(); ++i) {
105 if (i == 0u) potentialPath.moveTo(p);
else potentialPath.lineTo(p);
107 painter.setPen(QPen(QColor(185, 190, 198), 2.0));
108 painter.drawPath(potentialPath);
112 painter.setPen(QPen(QColor(130, 140, 150), 1.0, Qt::DashLine));
113 painter.drawLine(QPointF(plotRect.left(), thresholdY), QPointF(plotRect.right(), thresholdY));
114 painter.setPen(QColor(145, 152, 162));
115 painter.drawText(QRectF(plotRect.right() - 150.0, thresholdY - 18.0, 146.0, 18.0),
116 Qt::AlignRight | Qt::AlignVCenter,
123 painter.setPen(QPen(selected ? QColor(255, 184, 70) : QColor(82, 190, 235),
124 selected ? 2.0 : 1.2,
125 selected ? Qt::SolidLine : Qt::DashLine));
126 const double y = mapY(state.
energy);
127 painter.drawLine(QPointF(plotRect.left(), y), QPointF(plotRect.right(), y));
128 painter.setPen(selected ? QColor(255, 205, 115) : QColor(130, 205, 235));
129 painter.drawText(QRectF(plotRect.left() + 5.0, y - 18.0, 130.0, 18.0),
130 Qt::AlignLeft | Qt::AlignVCenter,
131 QStringLiteral(
"n=%1 E=%2")
133 .arg(state.
energy, 0,
'g', 5));
141 maxAbs = std::max(maxAbs, std::abs(value));
145 const double energySpan = std::max(1.0e-9, yMax - yMin);
146 const double amplitudeEnergyScale = 0.075 * energySpan /
static_cast<double>(maxAbs);
147 QPainterPath statePath;
148 for (std::size_t i = 0u; i <
spectrum_.
x.size(); ++i) {
149 const double displayEnergy = state.
energy +
150 amplitudeEnergyScale *
static_cast<double>(state.
amplitude[i]);
151 const QPointF p(mapX(
spectrum_.
x[i]), mapY(displayEnergy));
152 if (i == 0u) statePath.moveTo(p);
else statePath.lineTo(p);
154 painter.setPen(QPen(QColor(255, 220, 120), 2.2));
155 painter.drawPath(statePath);
158 painter.setBrush(QColor(255, 115, 125));
159 painter.setPen(Qt::NoPen);
160 const float nodeThreshold = 0.015f * maxAbs;
161 for (std::size_t i = 1u; i < state.
amplitude.size(); ++i) {
164 if (std::max(std::abs(a), std::abs(b)) >= nodeThreshold &&
165 ((a < 0.0f && b > 0.0f) || (a > 0.0f && b < 0.0f))) {
166 const double t = std::abs(
static_cast<double>(a)) /
167 std::max(1.0e-30, std::abs(
static_cast<double>(a)) +
168 std::abs(
static_cast<double>(b)));
171 painter.drawEllipse(QPointF(mapX(x), mapY(state.
energy)), 3.2, 3.2);
177 painter.setPen(QColor(210, 215, 222));
178 painter.drawText(QRectF(plotRect.left(), 2.0, plotRect.width(), 20.0),
180 QStringLiteral(
"Bound-state ladder: V(x), E_n and selected eigenfunction"));
181 painter.setPen(QColor(160, 168, 178));
182 painter.drawText(QRectF(plotRect.left(), plotRect.bottom() + 5.0, plotRect.width(), 22.0),
183 Qt::AlignCenter, QStringLiteral(
"x"));
184 painter.drawText(QRectF(2.0, plotRect.top() - 6.0, 55.0, 18.0),
185 Qt::AlignRight | Qt::AlignVCenter,
186 QString::number(yMax,
'g', 4));
187 painter.drawText(QRectF(2.0, plotRect.bottom() - 10.0, 55.0, 18.0),
188 Qt::AlignRight | Qt::AlignVCenter,
189 QString::number(yMin,
'g', 4));