| 138 | } |
| 139 | |
| 140 | void QmitkPointListView::OnListViewSelectionChanged(const QItemSelection &selected, |
| 141 | const QItemSelection & /*deselected*/) |
| 142 | { |
| 143 | if (m_SelfCall) |
| 144 | return; |
| 145 | |
| 146 | mitk::PointSet *pointSet = const_cast<mitk::PointSet *>(m_PointListModel->GetPointSet()); |
| 147 | |
| 148 | if (pointSet == nullptr) |
| 149 | return; |
| 150 | |
| 151 | // (take care that this widget doesn't react to self-induced changes by setting m_SelfCall) |
| 152 | m_SelfCall = true; |
| 153 | |
| 154 | // update selection of all points in pointset: select the one(s) that are selected in the view, deselect all others |
| 155 | QModelIndexList selectedIndexes = selected.indexes(); |
| 156 | |
| 157 | // only call setSelectInfo on a point set with 'selected = true' if you deselected the other entries |
| 158 | int indexToSelect = -1; |
| 159 | |
| 160 | for (mitk::PointSet::PointsContainer::Iterator it = |
| 161 | pointSet->GetPointSet(m_PointListModel->GetTimeStep())->GetPoints()->Begin(); |
| 162 | it != pointSet->GetPointSet(m_PointListModel->GetTimeStep())->GetPoints()->End(); |
| 163 | ++it) |
| 164 | { |
| 165 | QModelIndex index; |
| 166 | if (m_PointListModel->GetModelIndexForPointID(it->Index(), index)) |
| 167 | { |
| 168 | if (selectedIndexes.indexOf(index) != -1) // index is found in the selected indices list |
| 169 | { |
| 170 | indexToSelect = it->Index(); |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | pointSet->SetSelectInfo(it->Index(), false, m_PointListModel->GetTimeStep()); |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // force selection of only one index after deselecting the others |
| 180 | if (indexToSelect > -1) { |
| 181 | pointSet->SetSelectInfo(indexToSelect, true, m_PointListModel->GetTimeStep()); |
| 182 | |
| 183 | mitk::Point3D p = pointSet->GetPoint(indexToSelect, m_PointListModel->GetTimeStep()); |
| 184 | |
| 185 | for (auto snc : m_Sncs) |
| 186 | snc->SelectSliceByPoint(p); |
| 187 | } |
| 188 | |
| 189 | m_SelfCall = false; |
| 190 | |
| 191 | emit SignalPointSelectionChanged(); |
| 192 | |
| 193 | mitk::RenderingManager::GetInstance()->RequestUpdateAll(); |
| 194 | } |
| 195 | |
| 196 | void QmitkPointListView::keyPressEvent(QKeyEvent *e) |
| 197 | { |
nothing calls this directly
no test coverage detected