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

Method GetPointForModelIndex

Modules/QtWidgetsExt/src/QmitkPointListModel.cpp:204–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204bool QmitkPointListModel::GetPointForModelIndex(const QModelIndex &index,
205 mitk::PointSet::PointType &p,
206 mitk::PointSet::PointIdentifier &id) const
207{
208 mitk::PointSet::Pointer pointSet = this->CheckForPointSetInNode(m_PointSetNode);
209 if (pointSet.IsNull())
210 return false;
211
212 if ((index.row() < 0) || (index.row() >= (int)pointSet->GetPointSet(m_TimeStep)->GetPoints()->Size()))
213 return false;
214
215 // get the nth. element, if it exists.
216 // we can not use the index directly, because PointSet uses a map container,
217 // where the index is not necessarily the same as the key.
218 // Therefore we have to count the elements
219 mitk::PointSet::PointsContainer::Iterator it = pointSet->GetPointSet(m_TimeStep)->GetPoints()->Begin();
220 for (int i = 0; i < index.row(); ++i)
221 {
222 ++it;
223
224 if (it == pointSet->GetPointSet(m_TimeStep)->GetPoints()->End())
225 return false;
226 }
227
228 if (it != pointSet->GetPointSet(m_TimeStep)->GetPoints()->End()) // not at the end,
229 {
230 p = it->Value();
231 id = it->Index();
232 return true;
233 }
234
235 return false;
236}
237
238bool QmitkPointListModel::GetModelIndexForPointID(mitk::PointSet::PointIdentifier id, QModelIndex &index) const
239{

Callers 2

dataMethod · 0.95
OnPointDoubleClickedMethod · 0.80

Calls 8

ValueMethod · 0.80
IsNullMethod · 0.45
rowMethod · 0.45
SizeMethod · 0.45
GetPointSetMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45

Tested by

no test coverage detected