| 202 | } |
| 203 | |
| 204 | bool 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 | |
| 238 | bool QmitkPointListModel::GetModelIndexForPointID(mitk::PointSet::PointIdentifier id, QModelIndex &index) const |
| 239 | { |
no test coverage detected