! called when legend's current vertical position relative to its parent (top, center, bottom, custom) is changed. */
| 378 | called when legend's current vertical position relative to its parent (top, center, bottom, custom) is changed. |
| 379 | */ |
| 380 | void CartesianPlotLegendDock::positionYChanged(int index) { |
| 381 | CONDITIONAL_LOCK_RETURN; |
| 382 | |
| 383 | CartesianPlotLegend::PositionWrapper position = m_legend->position(); |
| 384 | auto oldVerticalPosition = position.verticalPosition; |
| 385 | position.verticalPosition = CartesianPlotLegend::VerticalPosition(index); |
| 386 | double y = 0.; |
| 387 | if (position.verticalPosition == WorksheetElement::VerticalPosition::Relative) { |
| 388 | switch (oldVerticalPosition) { |
| 389 | case WorksheetElement::VerticalPosition::Top: |
| 390 | case WorksheetElement::VerticalPosition::Relative: |
| 391 | break; |
| 392 | case WorksheetElement::VerticalPosition::Center: |
| 393 | y = 0.5; |
| 394 | break; |
| 395 | case WorksheetElement::VerticalPosition::Bottom: |
| 396 | y = 1.0; |
| 397 | } |
| 398 | ui.sbPositionY->setSuffix(QStringLiteral(" %")); |
| 399 | } else { |
| 400 | if (m_units == Units::Metric) |
| 401 | ui.sbPositionY->setSuffix(QStringLiteral(" cm")); |
| 402 | else |
| 403 | ui.sbPositionY->setSuffix(QStringLiteral(" in")); |
| 404 | } |
| 405 | |
| 406 | position.point.setY(y); |
| 407 | ui.sbPositionY->setValue(std::round(100. * y)); |
| 408 | |
| 409 | for (auto* legend : m_legendList) |
| 410 | legend->setPosition(position); |
| 411 | } |
| 412 | |
| 413 | void CartesianPlotLegendDock::customPositionXChanged(double value) { |
| 414 | CONDITIONAL_RETURN_NO_LOCK; |
nothing calls this directly
no test coverage detected