USGS

Isis 3.0 Application Source Code Reference

Home

QnetCubePointsFilter.cpp

Go to the documentation of this file.
00001 #include <QGridLayout>
00002 #include <QMessageBox>
00003 #include "QnetCubePointsFilter.h"
00004 #include "QnetNavTool.h"
00005 #include "ControlPoint.h"
00006 #include "ControlMeasure.h"
00007 #include "SerialNumberList.h"
00008 
00009 #include "qnet.h"
00010 
00011 using namespace Isis::Qnet;
00012 
00013 namespace Isis {
00014   /**
00015    * Contructor for the Cube Points filter.  It
00016    * creates the Points filter window found in
00017    * the navtool
00018    *
00019    * @param parent The parent widget for the
00020    *               cube points filter
00021    * @internal
00022    *   @history 2010-06-03 Jeannie Walldren - Initialized pointers
00023    *                          to null.
00024    *
00025    */
00026   QnetCubePointsFilter::QnetCubePointsFilter(QWidget *parent) : QnetFilter(parent) {
00027     p_lessThanRB = NULL;
00028     p_greaterThanRB = NULL;
00029     p_pointEdit = NULL;
00030 
00031     // Create the components for the filter window
00032     QLabel *label = new QLabel("Filter by number of points in cube");
00033     p_lessThanRB = new QRadioButton("Less than (undercontrolled)");
00034     p_greaterThanRB = new QRadioButton("Greater than (overcontrolled)");
00035     p_pointEdit = new QLineEdit();
00036     QLabel *units = new QLabel("points");
00037     p_lessThanRB->setChecked(true);
00038     QLabel *pad = new QLabel();
00039 
00040     // Create the layout and add the components to it
00041     QGridLayout *gridLayout = new QGridLayout();
00042     gridLayout->addWidget(label, 0, 0, 1, 2);
00043     gridLayout->addWidget(p_lessThanRB, 1, 0, 1, 2);
00044     gridLayout->addWidget(p_greaterThanRB, 2, 0, 1, 2);
00045     gridLayout->addWidget(p_pointEdit, 3, 0);
00046     gridLayout->addWidget(units, 3, 1);
00047     gridLayout->addWidget(pad, 4, 0);
00048     gridLayout->setRowStretch(4, 50);
00049     this->setLayout(gridLayout);
00050   }
00051 
00052   /**
00053    * Filters a list of images for images that have more or less
00054    * than the user entered number of points. The filtered list
00055    * will appear in the navtools cube list display.
00056    *
00057    * @internal
00058    *   @history 2009-01-08 Jeannie Walldren - Modified to create
00059    *                          new filtered list from images in the
00060    *                          existing filtered list. Previously,
00061    *                          a new filtered list was created from
00062    *                          the entire serial number list each
00063    *                          time.
00064    */
00065   void QnetCubePointsFilter::filter() {
00066     // Make sure we have a list of images to filter
00067     if (g_serialNumberList == NULL) {
00068       QMessageBox::information((QWidget *)parent(),
00069           "Error", "No cubes to filter");
00070       return;
00071     }
00072 
00073     // Make sure the user has entered a value for filtering
00074     int num = -1;
00075     if (p_pointEdit->text() == "") {
00076       QMessageBox::information((QWidget *)parent(),
00077           "Error", "Point value must be entered");
00078       return;
00079     }
00080 
00081     // Get the value the user entered for filtering
00082     num = p_pointEdit->text().toInt();
00083 
00084     // Loop through each image in the list
00085     // Loop in reverse order since removal of list elements affects index number
00086     for (int i = g_filteredImages.size() - 1; i >= 0; i--) {
00087 
00088       // Set up a counter parameter
00089       int count = 0;
00090 
00091       // Loop through each control point in the network
00092       for (int c = 0; c < g_controlNetwork->GetNumPoints(); c++) {
00093         ControlPoint &cp = *(*g_controlNetwork)[c];
00094 
00095         // Check to see if it has a measure on the current image
00096         for (int cm = 0; cm < cp.GetNumMeasures(); cm++) {
00097           // Increment the count if it does
00098           if ((cp[cm]->GetCubeSerialNumber()) == ((*g_serialNumberList).SerialNumber(g_filteredImages[i]))) {
00099             count++;
00100             break;
00101           }
00102         }
00103       }
00104 
00105       //  If the count is greater than the number the user entered and the
00106       // greater than option was selected, add the image to the filtered list
00107       if (p_greaterThanRB->isChecked()) {
00108         if (count > num)
00109           continue;
00110         else
00111           g_filteredImages.removeAt(i);
00112       }
00113       // If the count is less than the number the user entered and the less than
00114       // option was selected, add the image to the filtered list
00115       else if (p_lessThanRB->isChecked()) {
00116         if (count < num)
00117           continue;
00118         else
00119           g_filteredImages.removeAt(i);
00120       }
00121     }
00122     // Tell the navtool a list has been filtered and it needs to update
00123     emit filteredListModified();
00124     return;
00125   }
00126 }