| 398 | } |
| 399 | |
| 400 | void QmitkMultiLabelInspector::OnChangeModelSelection(const QItemSelection& /*selected*/, const QItemSelection& /*deselected*/) |
| 401 | { |
| 402 | if (!m_ModelManipulationOngoing) |
| 403 | { |
| 404 | if(!m_Model->GetModelUpdateOngoing()) |
| 405 | { |
| 406 | auto internallySelectedLabels = this->GetSelectedLabelsFromSelectionModel(); |
| 407 | auto validLabels = FilterValidLabels(internallySelectedLabels, this->GetMultiLabelSegmentation()); |
| 408 | |
| 409 | if (internallySelectedLabels.size() == validLabels.size()) |
| 410 | { //all labels selected by the selection model are valid |
| 411 | //set the state of this instance accordingly |
| 412 | m_LastValidSelectedLabels = validLabels; |
| 413 | emit CurrentSelectionChanged(GetSelectedLabels()); |
| 414 | } |
| 415 | else if (!validLabels.empty()) |
| 416 | { //only a part of the selection model is valid. Update it accordingly, this will |
| 417 | //lead to a re-triggering of this function |
| 418 | UpdateSelectionModel(validLabels); |
| 419 | } |
| 420 | else |
| 421 | { |
| 422 | //empty selections are not allowed by UI interactions, there should always be at least one valid label selected. |
| 423 | //but selections are e.g. also cleared if the model is updated (e.g. due to addition of labels). |
| 424 | //In this case all valid elements of m_LastValidSelectedLabels should be used. |
| 425 | validLabels = FilterValidLabels(m_LastValidSelectedLabels, this->GetMultiLabelSegmentation()); |
| 426 | |
| 427 | if (validLabels.empty() && m_Model->GetNearestLabelValueToLastChange() != mitk::MultiLabelSegmentation::UNLABELED_VALUE) |
| 428 | { |
| 429 | //we use the nearest existing label as valid value, like we do it in DeletLabelInternal |
| 430 | validLabels = { m_Model->GetNearestLabelValueToLastChange() }; |
| 431 | } |
| 432 | |
| 433 | if (!validLabels.empty()) |
| 434 | { |
| 435 | UpdateSelectionModel(validLabels); |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | m_LastValidSelectedLabels = {}; |
| 440 | emit CurrentSelectionChanged(GetSelectedLabels()); |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | else |
| 445 | { //the model is changed by an external source (not by this instance; e.g. an undo operation or another instance) |
| 446 | //need to check the selection after the model change is needed |
| 447 | m_CheckSelectionDueToExternalModelChange = true; |
| 448 | } |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | void QmitkMultiLabelInspector::WaitCursorOn() const |
| 453 | { |
nothing calls this directly
no test coverage detected