Isis 3 Programmer Reference
ControlPointList.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "ControlPointList.h"
10 
11 #include <QList>
12 
13 #include "IException.h"
14 #include "FileList.h"
15 #include "FileName.h"
16 #include "IString.h"
17 
18 namespace Isis {
25  try {
26  QList<QString> qList;
27  FileList list(psListFile);
28  int size = list.size();
29  for(int i = 0; i < size; i++) {
30  qList.insert(i, list[i].toString());
31  mbFound.push_back(false);
32  }
33  mqCpList = QStringList(qList);
34 
35  //sort the list for faster searches - internally uses qsort()
36  mqCpList.sort();
37  }
38  catch(IException &e) {
39  QString msg = "Can't open or invalid file list [" +
40  psListFile.expanded() + "]";
41  throw IException(e, IException::User, msg, _FILEINFO_);
42  }
43  }
44 
49  }
50 
51 
60  bool ControlPointList::HasControlPoint(const QString &psCpId) {
61  int index = mqCpList.indexOf(QString(psCpId));
62 
63  if(index == -1 || index >= Size())
64  return false;
65 
66  mbFound[index] = true;
67  return true;
68  }
69 
70 
76  int ControlPointList::Size() const {
77  return mqCpList.size();
78  }
79 
80 
88  QString ControlPointList::ControlPointId(int piIndex) {
89  int size = Size();
90  if(piIndex >= 0 && piIndex < size) {
91  return (mqCpList.value(piIndex));
92  }
93  else {
94  QString num = toString(piIndex);
95  QString msg = "Index [" + num + "] is invalid";
96  throw IException(IException::Programmer, msg, _FILEINFO_);
97  }
98  }
99 
107  int ControlPointList::ControlPointIndex(const QString &psCpId) {
108  if(HasControlPoint(psCpId)) {
109  return mqCpList.indexOf(QString(psCpId));
110  }
111  else {
112  QString msg = "Requested control point id [" + psCpId + "] ";
113  msg += "does not exist in the list";
114  throw IException(IException::Programmer, msg, _FILEINFO_);
115  }
116  }
117 
125  int size = Size();
126  int iNotFound = 0;
127  QString sPointsNotFound = "";
128 
129  for(int i = 0; i < size; i++) {
130  if(!mbFound[i]) {
131  if(iNotFound) {
132  sPointsNotFound += ", ";
133  }
134  sPointsNotFound += mqCpList.value(i);
135  iNotFound++;
136  }
137  }
138 
139  pcPvlLog += Isis::PvlKeyword("TotalPoints", toString(size));
140  pcPvlLog += Isis::PvlKeyword("ValidPoints", toString(size - iNotFound));
141  pcPvlLog += Isis::PvlKeyword("InvalidPoints", toString(iNotFound));
142  pcPvlLog += Isis::PvlKeyword("InvalidPointIds", sPointsNotFound);
143  }
144 }
Isis::ControlPointList::RegisterStatistics
void RegisterStatistics(Pvl &pcPvlLog)
Register invalid control point and calculate the valid & invalid point count.
Definition: ControlPointList.cpp:124
Isis::ControlPointList::mbFound
QVector< bool > mbFound
holds one to one correspondence with "mqCpList" on whether the point was valid
Definition: ControlPointList.h:57
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
QList< QString >
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::ControlPointList::ControlPointId
QString ControlPointId(int piIndex)
Return a control point id given an index.
Definition: ControlPointList.cpp:88
QStringList
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::ControlPointList::Size
int Size() const
How many control points in the list.
Definition: ControlPointList.cpp:76
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::ControlPointList::~ControlPointList
virtual ~ControlPointList()
Destructor.
Definition: ControlPointList.cpp:48
Isis::ControlPointList::HasControlPoint
bool HasControlPoint(const QString &psCpId)
Determines whether or not the requested control point id exists in the list.
Definition: ControlPointList.cpp:60
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::ControlPointList::ControlPointIndex
int ControlPointIndex(const QString &psCpId)
return a list index given a control point id
Definition: ControlPointList.cpp:107
Isis::ControlPointList::ControlPointList
ControlPointList(const FileName &psFileName)
Creates a ControlPointList from a list of control point ids'.
Definition: ControlPointList.cpp:24
Isis::FileList
Internalizes a list of files.
Definition: FileList.h:54
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126