Isis 3 Programmer Reference
QnetCubePointsFilter.cpp
1#include "QnetCubePointsFilter.h"
2
3#include <QGridLayout>
4#include <QLabel>
5#include <QLineEdit>
6#include <QMessageBox>
7#include <QRadioButton>
8#include <QtWidgets>
9
10#include "QnetNavTool.h"
11#include "ControlNet.h"
12#include "ControlPoint.h"
13#include "ControlMeasure.h"
14#include "SerialNumberList.h"
15
16namespace Isis {
30 QnetFilter(navTool, parent) {
31 m_lessThanRB = NULL;
32 m_greaterThanRB = NULL;
33 m_pointEdit = NULL;
34
35 // Create the components for the filter window
36 QLabel *label = new QLabel("Filter by number of points in cube");
37 m_lessThanRB = new QRadioButton("Less than (undercontrolled)");
38 m_greaterThanRB = new QRadioButton("Greater than (overcontrolled)");
39 m_pointEdit = new QLineEdit();
40 QLabel *units = new QLabel("points");
41 m_lessThanRB->setChecked(true);
42 QLabel *pad = new QLabel();
43
44 // Create the layout and add the components to it
45 QGridLayout *gridLayout = new QGridLayout();
46 gridLayout->addWidget(label, 0, 0, 1, 2);
47 gridLayout->addWidget(m_lessThanRB, 1, 0, 1, 2);
48 gridLayout->addWidget(m_greaterThanRB, 2, 0, 1, 2);
49 gridLayout->addWidget(m_pointEdit, 3, 0);
50 gridLayout->addWidget(units, 3, 1);
51 gridLayout->addWidget(pad, 4, 0);
52 gridLayout->setRowStretch(4, 50);
53 this->setLayout(gridLayout);
54 }
55
70 // Make sure we have a list of images to filter
71 if (serialNumberList() == NULL) {
72 QMessageBox::information((QWidget *)parent(),
73 "Error", "No cubes to filter");
74 return;
75 }
76
77 // Make sure the user has entered a value for filtering
78 int num = -1;
79 if (m_pointEdit->text() == "") {
80 QMessageBox::information((QWidget *)parent(),
81 "Error", "Point value must be entered");
82 return;
83 }
84
85 // Get the value the user entered for filtering
86 num = m_pointEdit->text().toInt();
87
88 // Loop through each image in the list
89 // Loop in reverse order since removal of list elements affects index number
90 for (int i = filteredImages().size() - 1; i >= 0; i--) {
91
92 // Set up a counter parameter
93 int count = 0;
94
95 // Loop through each control point in the network
96 for (int c = 0; c < controlNet()->GetNumPoints(); c++) {
97 ControlPoint &cp = *(*controlNet())[c];
98
99 // Check to see if it has a measure on the current image
100 for (int cm = 0; cm < cp.GetNumMeasures(); cm++) {
101 // Increment the count if it does
102 if ((cp[cm]->GetCubeSerialNumber()) == ((*serialNumberList()).serialNumber(filteredImages()[i]))) {
103 count++;
104 break;
105 }
106 }
107 }
108
109 // If the count is greater than the number the user entered and the
110 // greater than option was selected, add the image to the filtered list
111 if (m_greaterThanRB->isChecked()) {
112 if (count > num)
113 continue;
114 else
115 filteredImages().removeAt(i);
116 }
117 // If the count is less than the number the user entered and the less than
118 // option was selected, add the image to the filtered list
119 else if (m_lessThanRB->isChecked()) {
120 if (count < num)
121 continue;
122 else
123 filteredImages().removeAt(i);
124 }
125 }
126 // Tell the navtool a list has been filtered and it needs to update
127 emit filteredListModified();
128 return;
129 }
130}
int GetNumPoints() const
Return the number of control points in the network.
A single control point.
QnetCubePointsFilter(QnetNavTool *navTool, QWidget *parent=0)
Contructor for the Cube Points filter.
virtual void filter()
Filters a list of images for images that have more or less than the user entered number of points.
Qnet Navigation Tool.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16