| 1309 | } |
| 1310 | |
| 1311 | LineWidth PlotWidget::lineWidthFromPixels(double pixels) { |
| 1312 | // Older layouts stored the line width per-curve as a raw pen width, which could be |
| 1313 | // either the rendered lineWidthValue() or the raw toolbar value (lineWidthValue is |
| 1314 | // `scale` times the raw value). Pick the LineWidth closest across both scales, |
| 1315 | // deriving every candidate from lineWidthValue() so the width ladder lives in one place. |
| 1316 | const double scale = lineWidthValue(LineWidth::kPoints10); // raw == lineWidthValue / scale |
| 1317 | int best = 0; |
| 1318 | double best_dist = std::numeric_limits<double>::max(); |
| 1319 | for (int i = static_cast<int>(LineWidth::kPoints10); i <= static_cast<int>(LineWidth::kPoints30); ++i) { |
| 1320 | const double scaled = lineWidthValue(static_cast<LineWidth>(i)); |
| 1321 | const double dist = std::min(std::abs(pixels - scaled), std::abs(pixels - scaled / scale)); |
| 1322 | if (dist < best_dist) { |
| 1323 | best_dist = dist; |
| 1324 | best = i; |
| 1325 | } |
| 1326 | } |
| 1327 | return static_cast<LineWidth>(best); |
| 1328 | } |
| 1329 | |
| 1330 | QString PlotWidget::curveStyleToString(CurveStyle style) { |
| 1331 | switch (style) { |
nothing calls this directly
no test coverage detected