MCPcopy Create free account
hub / github.com/MITK/MITK / OnListViewSelectionChanged

Method OnListViewSelectionChanged

Modules/QtWidgetsExt/src/QmitkPointListView.cpp:140–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140void 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
196void QmitkPointListView::keyPressEvent(QKeyEvent *e)
197{

Callers

nothing calls this directly

Calls 10

indexOfMethod · 0.80
SetSelectInfoMethod · 0.80
GetPointSetMethod · 0.45
BeginMethod · 0.45
GetTimeStepMethod · 0.45
EndMethod · 0.45
GetPointMethod · 0.45
SelectSliceByPointMethod · 0.45
RequestUpdateAllMethod · 0.45

Tested by

no test coverage detected