USGS

Isis 3.0 Application Source Code Reference

Home

QnetPointJigsawErrorFilter.cpp

Go to the documentation of this file.
00001 #include <QGridLayout>
00002 #include <QMessageBox>
00003 #include "QnetPointJigsawErrorFilter.h"
00004 #include "QnetNavTool.h"
00005 #include "ControlNet.h"
00006 #include "ControlMeasure.h"
00007 #include "SerialNumberList.h"
00008 #include "Statistics.h"
00009 
00010 #include "qnet.h"
00011 
00012 using namespace Isis::Qnet;
00013 
00014 namespace Isis {
00015   /**
00016   * Contructor for the Point Error filter.  It
00017   * creates the Error filter window found in the
00018   * navtool
00019   *
00020   * @param parent The parent widget for the point
00021   *               error filter
00022   *
00023   * @internal
00024   *  @history  2008-08-06 Tracie Sucharski - Added functionality
00025   *                          of filtering range of errors.
00026   *  @history  2010-06-02 Jeannie Walldren - Modify default
00027   *                          settings of checkboxes and line edits
00028   *   @history 2010-06-03 Jeannie Walldren - Initialized pointers
00029   *                          to null.
00030   *
00031   */
00032   QnetPointJigsawErrorFilter::QnetPointJigsawErrorFilter(QWidget *parent) : QnetFilter(parent) {
00033     p_lessThanCB = NULL;
00034     p_greaterThanCB = NULL;
00035     p_lessErrorEdit = NULL;
00036     p_greaterErrorEdit = NULL;
00037 
00038     // Create the components for the filter window
00039     QLabel *label = new QLabel("Filter bundle-adjustment error");
00040     p_lessThanCB = new QCheckBox("Less than (undercontrolled)");
00041     p_lessErrorEdit = new QLineEdit();
00042     p_greaterThanCB = new QCheckBox("Greater than (overcontrolled)");
00043     p_greaterErrorEdit = new QLineEdit();
00044     QLabel *pixels = new QLabel("pixels");
00045     QLabel *pad = new QLabel();
00046 
00047     p_lessThanCB->setChecked(false);
00048     p_lessErrorEdit->setEnabled(false);
00049     p_greaterThanCB->setChecked(true);
00050     p_greaterErrorEdit->setEnabled(true);
00051 
00052     connect(p_lessThanCB, SIGNAL(clicked()), this, SLOT(clearEdit()));
00053     connect(p_greaterThanCB, SIGNAL(clicked()), this, SLOT(clearEdit()));
00054 
00055     // Create the layout and add the components to it
00056     QGridLayout *gridLayout = new QGridLayout();
00057     gridLayout->addWidget(label, 0, 0, 1, 2);
00058     gridLayout->addWidget(p_lessThanCB, 1, 0, 1, 2);
00059     gridLayout->addWidget(p_lessErrorEdit, 2, 0);
00060     gridLayout->addWidget(pixels, 2, 1);
00061     gridLayout->addWidget(p_greaterThanCB, 3, 0, 1, 2);
00062     gridLayout->addWidget(p_greaterErrorEdit, 4, 0);
00063     gridLayout->addWidget(pixels, 4, 1);
00064     gridLayout->addWidget(pad, 5, 0);
00065     gridLayout->setRowStretch(5, 50);
00066     this->setLayout(gridLayout);
00067   }
00068 
00069   /**
00070    * Filters a list of points for points that have less than or greater
00071    * than the entered bundle adjust error values.  The filtered list will
00072    * appear in the navtools point list display.
00073    *
00074    * @internal
00075    *   @history  2007-06-05 Tracie Sucharski - Look at ControlPoint::MaximumError
00076    *                           instead of ControlPoint::AverageError
00077    *   @history  2008-08-06 Tracie Sucharski - Added functionality of filtering
00078    *                           range of errors.
00079    *   @history  2009-01-08 Jeannie Walldren - Modified to remove
00080    *                           new filter points from the existing
00081    *                           filtered list. Previously, a new
00082    *                           filtered list was created from the
00083    *                           entire control net each time.
00084    *   @history  2010-07-14 Tracie Sucharski - ControlPoint::MaximumError
00085    *                           renamed to MaximumResidual.
00086    *   @history  2011-04-28 Tracie Sucharski - Sort points in decsending order
00087    *                           of max residual.
00088    */
00089   void QnetPointJigsawErrorFilter::filter() {
00090     // Make sure we have a list of control points to filter
00091     if (g_controlNetwork == NULL) {
00092       QMessageBox::information((QWidget *)parent(),
00093           "Error", "No points to filter");
00094       return;
00095     }
00096 
00097     // Make sure the user entered a value to use in the filtering
00098     double lessNum = -1.;
00099     if (p_lessThanCB->isChecked() && p_lessErrorEdit->text() == "") {
00100       QMessageBox::information((QWidget *)parent(),
00101           "Error", "Error value must be entered");
00102       return;
00103     }
00104     double greaterNum = -1.;
00105     if (p_greaterThanCB->isChecked() && p_greaterErrorEdit->text() == "") {
00106       QMessageBox::information((QWidget *)parent(),
00107           "Error", "Error value must be entered");
00108       return;
00109     }
00110 
00111     // Get the user entered filtering value
00112     lessNum = p_lessErrorEdit->text().toDouble();
00113     greaterNum = p_greaterErrorEdit->text().toDouble();
00114 
00115     QMultiMap <double, int> pointMap;
00116     // Loop through each value of the filtered points list comparing the error of its
00117     // corresponding point with error with the user entered value and remove it from
00118     // the filtered list if it is outside the filtering range
00119     // Loop in reverse order since removal list of elements affects index number
00120     for (int i = g_filteredPoints.size() - 1; i >= 0; i--) {
00121       ControlPoint &cp = *(*g_controlNetwork)[g_filteredPoints[i]];
00122       double maxResidual = cp.GetStatistic(&ControlMeasure::GetResidualMagnitude).Maximum();
00123       if (p_lessThanCB->isChecked() && p_greaterThanCB->isChecked()) {
00124         if (maxResidual < lessNum && maxResidual > greaterNum) {
00125           pointMap.insert(maxResidual, g_filteredPoints[i]);
00126           continue;
00127         }
00128         else
00129           g_filteredPoints.removeAt(i);
00130       }
00131       else if (p_lessThanCB->isChecked()) {
00132         if (maxResidual < lessNum) {
00133           pointMap.insert(maxResidual, g_filteredPoints[i]);
00134           continue;
00135         }
00136         else
00137           g_filteredPoints.removeAt(i);
00138       }
00139       else if (p_greaterThanCB->isChecked()) {
00140         if (maxResidual > greaterNum) {
00141           pointMap.insert(maxResidual, g_filteredPoints[i]);
00142           continue;
00143         }
00144         else
00145           g_filteredPoints.removeAt(i);
00146       }
00147     }
00148 
00149     int filteredIndex = 0;
00150     QMultiMap<double, int>::const_iterator i = pointMap.constEnd();
00151     while (i != pointMap.constBegin()) {
00152       --i;
00153       g_filteredPoints[filteredIndex] = i.value();
00154       filteredIndex++;
00155     }
00156     // Tell the navtool that a list has been filtered and it needs to update
00157     emit filteredListModified();
00158     return;
00159   }
00160 
00161 
00162   /**
00163    * Clears and disables the corresponding line edit if the "less
00164    * than" or "greater than" checkBox is "unchecked".
00165    *
00166    * @internal
00167    *   @history 2008-08-06 Tracie Sucharski - New method for
00168    *                         added functionality filtering range
00169    *                         of errors.
00170    *   @history 2010-06-02 Jeannie Walldren - Disable the line
00171    *            edit so the user can not enter a value unless the
00172    *            corresponding box is checked.
00173    */
00174   void QnetPointJigsawErrorFilter::clearEdit() {
00175 
00176     if (p_lessThanCB->isChecked()) {
00177       p_lessErrorEdit->setEnabled(true);
00178     }
00179     else {
00180       p_lessErrorEdit->clear();
00181       p_lessErrorEdit->setEnabled(false);
00182     }
00183     if (p_greaterThanCB->isChecked()) {
00184       p_greaterErrorEdit->setEnabled(true);
00185     }
00186     else {
00187       p_greaterErrorEdit->clear();
00188       p_greaterErrorEdit->setEnabled(false);
00189     }
00190   }
00191 }