///////////////////////////////////////////////////////////////////// PRIVATE /////////////////////////////////////////////////////////////////////
| 509 | // PRIVATE |
| 510 | ////////////////////////////////////////////////////////////////////////// |
| 511 | void QmitkMxNMultiWidget::SetLayoutImpl() |
| 512 | { |
| 513 | int requiredRenderWindowWidgets = this->GetRowCount() * this->GetColumnCount(); |
| 514 | int existingRenderWindowWidgets = this->GetRenderWindowWidgets().size(); |
| 515 | |
| 516 | int difference = requiredRenderWindowWidgets - existingRenderWindowWidgets; |
| 517 | while (0 < difference) |
| 518 | { |
| 519 | // more render window widgets needed |
| 520 | this->CreateRenderWindowWidget(); |
| 521 | --difference; |
| 522 | } |
| 523 | |
| 524 | while (0 > difference) |
| 525 | { |
| 526 | // Remove the highest 'widget<i>' that is registered. Routing through |
| 527 | // the name-keyed overload (rather than the no-arg lex-last variant) |
| 528 | // guarantees the right cell is removed once the editor crosses 10 cells: |
| 529 | // {widget0..widget11} sorts as widget0 < widget1 < widget10 < widget11 |
| 530 | // < widget2 < ..., so lex-last would otherwise pick widget9. |
| 531 | bool removed = false; |
| 532 | for (std::size_t i = this->GetNumberOfRenderWindowWidgets(); i-- > 0; ) |
| 533 | { |
| 534 | const auto id = this->GetMultiWidgetName() + NAMESPACE_DELIMITER + QStringLiteral("widget") + QString::number(i); |
| 535 | if (nullptr != this->GetRenderWindowWidget(id)) |
| 536 | { |
| 537 | this->RemoveRenderWindowWidget(id); |
| 538 | removed = true; |
| 539 | break; |
| 540 | } |
| 541 | } |
| 542 | if (!removed) |
| 543 | { |
| 544 | // No 'widget<i>' cell present - mixed with custom-named layout. Bail |
| 545 | // rather than spinning; the caller is expected to ApplyLayout/ |
| 546 | // RollBackToSingleDefaultCell when entering an inconsistent state. |
| 547 | MITK_WARN << "SetLayout: cannot shrink to " << requiredRenderWindowWidgets |
| 548 | << " cells - " << this->GetNumberOfRenderWindowWidgets() |
| 549 | << " custom-named cells remain. Layout dimensions (" |
| 550 | << this->GetRowCount() << "x" << this->GetColumnCount() |
| 551 | << ") are now out of sync with the cell count. Use ApplyLayout " |
| 552 | "or RollBackToSingleDefaultCell to recover a consistent state."; |
| 553 | break; |
| 554 | } |
| 555 | ++difference; |
| 556 | } |
| 557 | |
| 558 | auto firstRenderWindowWidget = this->GetFirstRenderWindowWidget(); |
| 559 | if (nullptr != firstRenderWindowWidget) |
| 560 | { |
| 561 | this->SetActiveRenderWindowWidget(firstRenderWindowWidget); |
| 562 | } |
| 563 | |
| 564 | this->GetMultiWidgetLayoutManager()->SetLayoutDesign(QmitkMultiWidgetLayoutManager::LayoutDesign::DEFAULT); |
| 565 | } |
| 566 | |
| 567 | QmitkAbstractMultiWidget::RenderWindowWidgetPointer QmitkMxNMultiWidget::CreateRenderWindowWidget() |
| 568 | { |
nothing calls this directly
no test coverage detected