Added panel impact size based severity circles with impact value

This commit is contained in:
Jon ESA
2026-04-02 09:54:37 +01:00
parent d4ad6f4258
commit bea6c7c885
2 changed files with 29 additions and 17 deletions

View File

@@ -57,6 +57,14 @@ void PanelsPanel::reset()
update();
}
// Returns a circle radius multiplier (0.0-1.0) based on 3 power tiers
static double bubbleScale(int power)
{
if (power < 50) return 0.18; // small
if (power < 100) return 0.30; // medium
return 0.85; // large
}
void PanelsPanel::paintEvent(QPaintEvent *)
{
if (m_count <= 0) return;
@@ -78,6 +86,10 @@ void PanelsPanel::paintEvent(QPaintEvent *)
const double gapDeg = (m_count > 1) ? 3.0 : 0.0;
const double segSpan = (360.0 - m_count * gapDeg) / m_count;
// Max bubble radius constrained to fit inside the segment band
const double maxCircR = qMin((outerR - innerR) * 0.48,
(outerR + innerR) / 2.0 * qSin(qDegreesToRadians(segSpan / 2.0)) * 0.88);
static const QColor kDefault(100, 140, 180);
static const QColor kHit(220, 40, 40);
@@ -93,8 +105,7 @@ void PanelsPanel::paintEvent(QPaintEvent *)
path.arcTo(innerRect, startAngle + sweep, -sweep);
path.closeSubpath();
QColor segColor = isHit ? kHit : m_colors.value(i, kDefault);
p.setBrush(segColor);
p.setBrush(isHit ? kHit : m_colors.value(i, kDefault));
p.setPen(QPen(Qt::white, isHit ? 3 : 2));
p.drawPath(path);
@@ -106,39 +117,40 @@ void PanelsPanel::paintEvent(QPaintEvent *)
cy - midR * qSin(midAngleRad));
if (isHit) {
// ---- Red glow halo ring around segment ----
QPen haloPen(QColor(255, 80, 80, 120), 6);
const int power = m_hits[i];
const double circR = maxCircR * bubbleScale(power);
// Tier label for legend (small/medium/large)
// Glow halo
p.setBrush(Qt::NoBrush);
p.setPen(haloPen);
p.setPen(QPen(QColor(255, 80, 80, 110), 5));
p.drawPath(path);
// ---- Red filled circle centred on segment ----
const double circR = qMin(outerR - innerR, midR * 0.38) * 0.9;
// Drop shadow
const QRectF circRect(mid.x() - circR, mid.y() - circR, circR * 2, circR * 2);
// drop shadow
p.setBrush(QColor(0, 0, 0, 60));
p.setBrush(QColor(0, 0, 0, 55));
p.setPen(Qt::NoPen);
p.drawEllipse(circRect.adjusted(2, 3, 2, 3));
// circle fill: radial gradient (bright centre → dark red)
QRadialGradient grad(mid, circR, QPointF(mid.x() - circR*0.3, mid.y() - circR*0.3));
// Radial gradient fill
QRadialGradient grad(mid, circR,
QPointF(mid.x() - circR * 0.3, mid.y() - circR * 0.3));
grad.setColorAt(0.0, QColor(255, 100, 100));
grad.setColorAt(1.0, QColor(160, 10, 10));
p.setBrush(grad);
p.setPen(QPen(QColor(255, 200, 200), 1.5));
p.drawEllipse(circRect);
// power value text
// Power value text — scale font to circle size
QFont pf = p.font();
pf.setBold(true);
pf.setPointSize(qMax(6, qMin(11, static_cast<int>(circR * 0.72))));
pf.setPointSize(qMax(6, qMin(12, static_cast<int>(circR * 0.68))));
p.setFont(pf);
p.setPen(Qt::white);
p.drawText(circRect, Qt::AlignCenter, QString::number(m_hits[i]));
p.drawText(circRect, Qt::AlignCenter, QString::number(power));
} else {
// ---- Normal index label ----
// Normal index label
QFont font = p.font();
font.setBold(true);
font.setPointSize(qMax(7, qMin(12, static_cast<int>(outerR / (m_count * 0.55 + 2)))));

View File

@@ -374,7 +374,7 @@ int main(int argc, char *argv[])
tabs->addTab(makeSettingsTab(ctrl, &window), "Settings");
tabs->addTab(makePowerTab (ctrl, &window), "Power");
tabs->addTab(makeLogsTab (ctrl, &window), "Logs");
tabs->addTab(makePanelsTab (ctrl, &window), "Panels");
tabs->addTab(makePanelsTab (ctrl, &window), "Panels Impacts");
mainLayout->addWidget(tabs, 1);
// --- Shutdown inline confirm ---