USGS

Isis 3.0 Object Programmers' Reference

Home

QnetPointRegistrationErrorFilter.cpp
2 
3 #include <QtGui>
4 
5 #include "QnetNavTool.h"
6 #include "ControlNet.h"
7 #include "ControlMeasure.h"
9 #include "ControlPoint.h"
10 #include "Statistics.h"
11 
12 namespace Isis {
30  QWidget *parent) : QnetFilter(navTool, parent) {
31  m_lessThanCB = NULL;
32  m_greaterThanCB = NULL;
33  m_lessErrorEdit = NULL;
34  m_greaterErrorEdit = NULL;
35 
36  // Create the components for the filter window
37  QLabel *label = new QLabel("Registration Pixel Errors");
38  m_lessThanCB = new QCheckBox("Less than");
39  m_lessErrorEdit = new QLineEdit();
40  m_greaterThanCB = new QCheckBox("Greater than");
41  m_greaterErrorEdit = new QLineEdit();
42  QLabel *pixels = new QLabel("pixels");
43  QLabel *pad = new QLabel();
44 
45  m_lessThanCB->setChecked(false);
46  m_lessErrorEdit->setEnabled(false);
47  m_greaterThanCB->setChecked(true);
48  m_greaterErrorEdit->setEnabled(true);
49 
50  connect(m_lessThanCB, SIGNAL(clicked()), this, SLOT(clearEdit()));
51  connect(m_greaterThanCB, SIGNAL(clicked()), this, SLOT(clearEdit()));
52 
53  // Create the layout and add the components to it
54  QGridLayout *gridLayout = new QGridLayout();
55  gridLayout->addWidget(label, 0, 0, 1, 2);
56  gridLayout->addWidget(m_lessThanCB, 1, 0, 1, 2);
57  gridLayout->addWidget(m_lessErrorEdit, 2, 0);
58  gridLayout->addWidget(pixels, 2, 1);
59  gridLayout->addWidget(m_greaterThanCB, 3, 0, 1, 2);
60  gridLayout->addWidget(m_greaterErrorEdit, 4, 0);
61  gridLayout->addWidget(pixels, 4, 1);
62  gridLayout->addWidget(pad, 5, 0);
63  gridLayout->setRowStretch(5, 50);
64  this->setLayout(gridLayout);
65  }
66 
88  // Make sure we have a list of control points to filter
89  if (controlNet() == NULL) {
90  QMessageBox::information((QWidget *)parent(),
91  "Error", "No points to filter");
92  return;
93  }
94 
95  // Make sure the user entered a value to use in the filtering
96  double lessNum = -1.;
97  if (m_lessThanCB->isChecked() && m_lessErrorEdit->text() == "") {
98  QMessageBox::information((QWidget *)parent(),
99  "Error", "Error value must be entered");
100  return;
101  }
102  double greaterNum = -1.;
103  if (m_greaterThanCB->isChecked() && m_greaterErrorEdit->text() == "") {
104  QMessageBox::information((QWidget *)parent(),
105  "Error", "Error value must be entered");
106  return;
107  }
108 
109  // Get the user entered filtering value
110  lessNum = m_lessErrorEdit->text().toDouble();
111  greaterNum = m_greaterErrorEdit->text().toDouble();
112 
113  QMultiMap <double, int> pointMap;
114  // Loop through each value of the filtered points list comparing the error
115  // of its corresponding point with error the user entered value and remove
116  // it from the filtered list if it is outside the filtering range Loop in
117  // reverse order since removal list of elements affects index number
118  for (int i = filteredPoints().size() - 1; i >= 0; i--) {
119  ControlPoint &cp = *(*controlNet())[filteredPoints()[i]];
120 // double maxPixelError = calculateMaxError(cp);
121  double maxPixelError =
122  cp.GetStatistic(&ControlMeasure::GetPixelShift).Maximum();
123  if (m_lessThanCB->isChecked() && m_greaterThanCB->isChecked()) {
124  if (maxPixelError < lessNum && maxPixelError > greaterNum) {
125  pointMap.insert(maxPixelError, filteredPoints()[i]);
126  continue;
127  }
128  else
129  filteredPoints().removeAt(i);
130  }
131  else if (m_lessThanCB->isChecked()) {
132  if (maxPixelError < lessNum) {
133  pointMap.insert(maxPixelError, filteredPoints()[i]);
134  continue;
135  }
136  else
137  filteredPoints().removeAt(i);
138  }
139  else if (m_greaterThanCB->isChecked()) {
140  if (maxPixelError > greaterNum) {
141  pointMap.insert(maxPixelError, filteredPoints()[i]);
142  continue;
143  }
144  else
145  filteredPoints().removeAt(i);
146  }
147  }
148 
149  int filteredIndex = 0;
150  QMultiMap<double, int>::const_iterator i = pointMap.constEnd();
151  while (i != pointMap.constBegin()) {
152  --i;
153  filteredPoints()[filteredIndex] = i.value();
154  filteredIndex++;
155  }
156  // Tell the navtool that a list has been filtered and it needs to update
157  emit filteredListModified();
158  return;
159  }
160 
161 
175 
176  if (m_lessThanCB->isChecked()) {
177  m_lessErrorEdit->setEnabled(true);
178  }
179  else {
180  m_lessErrorEdit->clear();
181  m_lessErrorEdit->setEnabled(false);
182  }
183  if (m_greaterThanCB->isChecked()) {
184  m_greaterErrorEdit->setEnabled(true);
185  }
186  else {
187  m_greaterErrorEdit->clear();
188  m_greaterErrorEdit->setEnabled(false);
189  }
190  }
191 }