Isis 3 Programmer Reference
ControlPointList.cpp
1 #include "ControlPointList.h"
2 
3 #include <QList>
4 
5 #include "IException.h"
6 #include "FileList.h"
7 #include "FileName.h"
8 #include "IString.h"
9 
10 namespace Isis {
17  try {
18  QList<QString> qList;
19  FileList list(psListFile);
20  int size = list.size();
21  for(int i = 0; i < size; i++) {
22  qList.insert(i, list[i].toString());
23  mbFound.push_back(false);
24  }
25  mqCpList = QStringList(qList);
26 
27  //sort the list for faster searches - internally uses qsort()
28  mqCpList.sort();
29  }
30  catch(IException &e) {
31  QString msg = "Can't open or invalid file list [" +
32  psListFile.expanded() + "]";
33  throw IException(e, IException::User, msg, _FILEINFO_);
34  }
35  }
36 
41  }
42 
43 
52  bool ControlPointList::HasControlPoint(const QString &psCpId) {
53  int index = mqCpList.indexOf(QString(psCpId));
54 
55  if(index == -1 || index >= Size())
56  return false;
57 
58  mbFound[index] = true;
59  return true;
60  }
61 
62 
68  int ControlPointList::Size() const {
69  return mqCpList.size();
70  }
71 
72 
80  QString ControlPointList::ControlPointId(int piIndex) {
81  int size = Size();
82  if(piIndex >= 0 && piIndex < size) {
83  return (mqCpList.value(piIndex));
84  }
85  else {
86  QString num = toString(piIndex);
87  QString msg = "Index [" + num + "] is invalid";
89  }
90  }
91 
99  int ControlPointList::ControlPointIndex(const QString &psCpId) {
100  if(HasControlPoint(psCpId)) {
101  return mqCpList.indexOf(QString(psCpId));
102  }
103  else {
104  QString msg = "Requested control point id [" + psCpId + "] ";
105  msg += "does not exist in the list";
107  }
108  }
109 
117  int size = Size();
118  int iNotFound = 0;
119  QString sPointsNotFound = "";
120 
121  for(int i = 0; i < size; i++) {
122  if(!mbFound[i]) {
123  if(iNotFound) {
124  sPointsNotFound += ", ";
125  }
126  sPointsNotFound += mqCpList.value(i);
127  iNotFound++;
128  }
129  }
130 
131  pcPvlLog += Isis::PvlKeyword("TotalPoints", toString(size));
132  pcPvlLog += Isis::PvlKeyword("ValidPoints", toString(size - iNotFound));
133  pcPvlLog += Isis::PvlKeyword("InvalidPoints", toString(iNotFound));
134  pcPvlLog += Isis::PvlKeyword("InvalidPointIds", sPointsNotFound);
135  }
136 }
137 
QVector< bool > mbFound
holds one to one correspondence with "mqCpList" on whether the point was valid
void RegisterStatistics(Pvl &pcPvlLog)
Register invalid control point and calculate the valid & invalid point count.
File name manipulation and expansion.
Definition: FileName.h:116
QString ControlPointId(int piIndex)
Return a control point id given an index.
Internalizes a list of files.
Definition: FileList.h:70
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
ControlPointList(const FileName &psFileName)
Creates a ControlPointList from a list of control point ids&#39;.
virtual ~ControlPointList()
Destructor.
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
A single keyword-value pair.
Definition: PvlKeyword.h:98
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:212
Container for cube-like labels.
Definition: Pvl.h:135
int Size() const
How many control points in the list.
bool HasControlPoint(const QString &psCpId)
Determines whether or not the requested control point id exists in the list.
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
int ControlPointIndex(const QString &psCpId)
return a list index given a control point id