|
Isis 3.0 Application Source Code Reference |
Home |
00001 #include <QGridLayout> 00002 #include <QMessageBox> 00003 00004 #include "QnetPointGoodnessFilter.h" 00005 #include "QnetNavTool.h" 00006 00007 #include "ControlMeasure.h" 00008 #include "ControlMeasureLogData.h" 00009 #include "ControlNet.h" 00010 #include "SerialNumberList.h" 00011 #include "SpecialPixel.h" 00012 #include "qnet.h" 00013 00014 using namespace Isis::Qnet; 00015 using namespace std; 00016 00017 namespace Isis { 00018 /** 00019 * Contructor for the Point Goodness of Fit filter. It creates 00020 * the Goodness of Fit filter window found in the navtool 00021 * 00022 * @param parent The parent widget for the point type 00023 * filter 00024 * @internal 00025 * @history 2010-06-02 Jeannie Walldren - Modify default 00026 * settings of checkboxes and line edits 00027 * @history 2010-06-03 Jeannie Walldren - Initialized pointers 00028 * to null in constructor. 00029 * 00030 */ 00031 QnetPointGoodnessFilter::QnetPointGoodnessFilter (QWidget *parent) : QnetFilter(parent) { 00032 p_lessThanCB = NULL; 00033 p_greaterThanCB = NULL; 00034 p_maxValueEdit = NULL; 00035 p_minValueEdit = NULL; 00036 00037 // Create the components for the filter window 00038 p_lessThanCB = new QCheckBox("Less than "); 00039 p_maxValueEdit = new QLineEdit(); 00040 p_greaterThanCB = new QCheckBox("Greater than "); 00041 p_minValueEdit = new QLineEdit(); 00042 QLabel *pad = new QLabel(); 00043 00044 p_lessThanCB->setChecked(false); 00045 p_maxValueEdit->setEnabled(false); 00046 p_greaterThanCB->setChecked(false); 00047 p_minValueEdit->setEnabled(false); 00048 00049 connect(p_lessThanCB,SIGNAL(clicked()),this,SLOT(clearEdit())); 00050 connect(p_greaterThanCB,SIGNAL(clicked()),this,SLOT(clearEdit())); 00051 00052 // Create the layout and add the components to it 00053 QGridLayout *gridLayout = new QGridLayout(); 00054 //gridLayout->addWidget(label,0,0,1,2); 00055 gridLayout->addWidget(p_lessThanCB,1,0,1,2); 00056 gridLayout->addWidget(p_maxValueEdit,2,0); 00057 gridLayout->addWidget(p_greaterThanCB,3,0,1,2); 00058 gridLayout->addWidget(p_minValueEdit,4,0); 00059 gridLayout->addWidget(pad,5,0); 00060 gridLayout->setRowStretch(5,50); 00061 this->setLayout(gridLayout); 00062 } 00063 00064 /** 00065 * @brief Method overwrites parent method. 00066 * This method keeps all points that contain at least one 00067 * measure whose Goodness of Fit is within the range specified 00068 * by the user. 00069 * 00070 * @internal 00071 * @history 2008-11-26 Jeannie Walldren - Original Version 00072 * @history 2009-01-08 Jeannie Walldren - Modified to remove 00073 * new filter points from the existing 00074 * filtered list. Previously, a new 00075 * filtered list was created from the 00076 * entire control net each time. 00077 */ 00078 void QnetPointGoodnessFilter::filter() { 00079 // Make sure there is a control net loaded 00080 if (g_controlNetwork == NULL) { 00081 QMessageBox::information((QWidget *)parent(), 00082 "Error","No points to filter"); 00083 return; 00084 } 00085 00086 // Make sure the user entered a value to use in the filtering 00087 if (p_lessThanCB->isChecked() && p_maxValueEdit->text() == "") { 00088 QMessageBox::information((QWidget *)parent(), 00089 "Error","Maximum Goodness of Fit value must be entered"); 00090 return; 00091 } 00092 if (p_greaterThanCB->isChecked() && p_minValueEdit->text() == "") { 00093 QMessageBox::information((QWidget *)parent(), 00094 "Error","Minimum Goodness of Fit value must be entered"); 00095 return; 00096 } 00097 00098 // Get the user entered filtering value 00099 double maxValue = p_maxValueEdit->text().toDouble(); 00100 double minValue = p_minValueEdit->text().toDouble(); 00101 00102 // Loop through each value of the filtered points list 00103 // Loop in reverse order since removal list of elements affects index number 00104 for (int i = g_filteredPoints.size()-1; i >= 0; i--) { 00105 ControlPoint &cp = *(*g_controlNetwork)[g_filteredPoints[i]]; 00106 int numMeasOutsideRange = 0; 00107 // Loop through each measure of the point at this index of the control net 00108 for (int j = 0; j < cp.GetNumMeasures(); j++) { 00109 00110 double goodnessOfFit = cp[j]->GetLogData( 00111 ControlMeasureLogData::GoodnessOfFit).GetNumericalValue(); 00112 if (goodnessOfFit == Null) { 00113 numMeasOutsideRange++; 00114 } 00115 else if (p_lessThanCB->isChecked() && p_greaterThanCB->isChecked()) { 00116 if (goodnessOfFit < maxValue && goodnessOfFit > minValue) break; 00117 else numMeasOutsideRange++; 00118 } 00119 else if (p_lessThanCB->isChecked()) { 00120 if (goodnessOfFit < maxValue) break; 00121 else numMeasOutsideRange++; 00122 } 00123 else if (p_greaterThanCB->isChecked()) { 00124 if (goodnessOfFit > minValue) break; 00125 else numMeasOutsideRange++; 00126 } 00127 } 00128 // if no measures are within the range, remove from filter list 00129 if (cp.GetNumMeasures() == numMeasOutsideRange) { 00130 g_filteredPoints.removeAt(i); 00131 } 00132 } 00133 00134 // Tell the navtool that a list has been filtered and it needs to update 00135 emit filteredListModified(); 00136 return; 00137 } 00138 /** 00139 * Clears and disables the corresponding line edit if the "less 00140 * than" or "greater than" checkBox is "unchecked". Method 00141 * overrides parent method. 00142 * 00143 * @internal 00144 * @history 2010-06-02 Jeannie Walldren - Disable the line 00145 * edit so the user can not enter a value unless the 00146 * corresponding box is checked. 00147 * 00148 */ 00149 void QnetPointGoodnessFilter::clearEdit() { 00150 00151 if (p_lessThanCB->isChecked()) { 00152 p_maxValueEdit->setEnabled(true); 00153 } 00154 else { 00155 p_maxValueEdit->clear(); 00156 p_maxValueEdit->setEnabled(false); 00157 } 00158 if (p_greaterThanCB->isChecked()) { 00159 p_minValueEdit->setEnabled(true); 00160 } 00161 else { 00162 p_minValueEdit->clear(); 00163 p_minValueEdit->setEnabled(false); 00164 } 00165 } 00166 }