Isis 3 Programmer Reference
QnetPointRegistrationErrorFilter.cpp
2 
3 #include <QCheckBox>
4 #include <QGridLayout>
5 #include <QLabel>
6 #include <QLineEdit>
7 #include <QMessageBox>
8 #include <QtWidgets>
9 
10 #include "QnetNavTool.h"
11 #include "ControlNet.h"
12 #include "ControlMeasure.h"
13 #include "ControlMeasureLogData.h"
14 #include "ControlPoint.h"
15 #include "Statistics.h"
16 
17 namespace Isis {
35  QWidget *parent) : QnetFilter(navTool, parent) {
36  m_lessThanCB = NULL;
37  m_greaterThanCB = NULL;
38  m_lessErrorEdit = NULL;
39  m_greaterErrorEdit = NULL;
40 
41  // Create the components for the filter window
42  QLabel *label = new QLabel("Registration Pixel Errors");
43  m_lessThanCB = new QCheckBox("Less than");
44  m_lessErrorEdit = new QLineEdit();
45  m_greaterThanCB = new QCheckBox("Greater than");
46  m_greaterErrorEdit = new QLineEdit();
47  QLabel *pixels = new QLabel("pixels");
48  QLabel *pad = new QLabel();
49 
50  m_lessThanCB->setChecked(false);
51  m_lessErrorEdit->setEnabled(false);
52  m_greaterThanCB->setChecked(true);
53  m_greaterErrorEdit->setEnabled(true);
54 
55  connect(m_lessThanCB, SIGNAL(clicked()), this, SLOT(clearEdit()));
56  connect(m_greaterThanCB, SIGNAL(clicked()), this, SLOT(clearEdit()));
57 
58  // Create the layout and add the components to it
59  QGridLayout *gridLayout = new QGridLayout();
60  gridLayout->addWidget(label, 0, 0, 1, 2);
61  gridLayout->addWidget(m_lessThanCB, 1, 0, 1, 2);
62  gridLayout->addWidget(m_lessErrorEdit, 2, 0);
63  gridLayout->addWidget(pixels, 2, 1);
64  gridLayout->addWidget(m_greaterThanCB, 3, 0, 1, 2);
65  gridLayout->addWidget(m_greaterErrorEdit, 4, 0);
66  gridLayout->addWidget(pixels, 4, 1);
67  gridLayout->addWidget(pad, 5, 0);
68  gridLayout->setRowStretch(5, 50);
69  this->setLayout(gridLayout);
70  }
71 
93  // Make sure we have a list of control points to filter
94  if (controlNet() == NULL) {
95  QMessageBox::information((QWidget *)parent(),
96  "Error", "No points to filter");
97  return;
98  }
99 
100  // Make sure the user entered a value to use in the filtering
101  double lessNum = -1.;
102  if (m_lessThanCB->isChecked() && m_lessErrorEdit->text() == "") {
103  QMessageBox::information((QWidget *)parent(),
104  "Error", "Error value must be entered");
105  return;
106  }
107  double greaterNum = -1.;
108  if (m_greaterThanCB->isChecked() && m_greaterErrorEdit->text() == "") {
109  QMessageBox::information((QWidget *)parent(),
110  "Error", "Error value must be entered");
111  return;
112  }
113 
114  // Get the user entered filtering value
115  lessNum = m_lessErrorEdit->text().toDouble();
116  greaterNum = m_greaterErrorEdit->text().toDouble();
117 
118  QMultiMap <double, int> pointMap;
119  // Loop through each value of the filtered points list comparing the error
120  // of its corresponding point with error the user entered value and remove
121  // it from the filtered list if it is outside the filtering range Loop in
122  // reverse order since removal list of elements affects index number
123  for (int i = filteredPoints().size() - 1; i >= 0; i--) {
124  ControlPoint &cp = *(*controlNet())[filteredPoints()[i]];
125 // double maxPixelError = calculateMaxError(cp);
126  double maxPixelError =
127  cp.GetStatistic(&ControlMeasure::GetPixelShift).Maximum();
128  if (m_lessThanCB->isChecked() && m_greaterThanCB->isChecked()) {
129  if (maxPixelError < lessNum && maxPixelError > greaterNum) {
130  pointMap.insert(maxPixelError, filteredPoints()[i]);
131  continue;
132  }
133  else
134  filteredPoints().removeAt(i);
135  }
136  else if (m_lessThanCB->isChecked()) {
137  if (maxPixelError < lessNum) {
138  pointMap.insert(maxPixelError, filteredPoints()[i]);
139  continue;
140  }
141  else
142  filteredPoints().removeAt(i);
143  }
144  else if (m_greaterThanCB->isChecked()) {
145  if (maxPixelError > greaterNum) {
146  pointMap.insert(maxPixelError, filteredPoints()[i]);
147  continue;
148  }
149  else
150  filteredPoints().removeAt(i);
151  }
152  }
153 
154  int filteredIndex = 0;
155  QMultiMap<double, int>::const_iterator i = pointMap.constEnd();
156  while (i != pointMap.constBegin()) {
157  --i;
158  filteredPoints()[filteredIndex] = i.value();
159  filteredIndex++;
160  }
161  // Tell the navtool that a list has been filtered and it needs to update
162  emit filteredListModified();
163  return;
164  }
165 
166 
180 
181  if (m_lessThanCB->isChecked()) {
182  m_lessErrorEdit->setEnabled(true);
183  }
184  else {
185  m_lessErrorEdit->clear();
186  m_lessErrorEdit->setEnabled(false);
187  }
188  if (m_greaterThanCB->isChecked()) {
189  m_greaterErrorEdit->setEnabled(true);
190  }
191  else {
192  m_greaterErrorEdit->clear();
193  m_greaterErrorEdit->setEnabled(false);
194  }
195  }
196 }
void clearEdit()
Clears and disables the corresponding line edit if the "less than" or "greater than" checkBox is "unc...
Statistics GetStatistic(double(ControlMeasure::*statFunc)() const) const
This function will call a given method on every control measure that this point has.
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
Definition: Statistics.cpp:416
A single control point.
Definition: ControlPoint.h:369
Qnet Navigation Tool.
Definition: QnetNavTool.h:132
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
virtual void filter()
Filters a list of points for points that have less than or greater than the entered registration erro...
QnetPointRegistrationErrorFilter(QnetNavTool *navTool, QWidget *parent=0)
Contructor for the Point Registration Error filter.