Isis 3 Programmer Reference
QnetPointRangeFilter.cpp
1 #include "QnetPointRangeFilter.h"
2 
3 #include <QGridLayout>
4 #include <QLabel>
5 #include <QLineEdit>
6 #include <QMessageBox>
7 
8 #include "ControlNet.h"
9 #include "ControlPoint.h"
10 #include "Latitude.h"
11 #include "Longitude.h"
12 #include "SerialNumberList.h"
13 #include "SurfacePoint.h"
14 
15 using namespace std;
16 
17 namespace Isis {
29  QnetPointRangeFilter::QnetPointRangeFilter(QnetNavTool *navTool, QWidget *parent) :
30  QnetFilter(navTool, parent) {
31  m_minlat = NULL;
32  m_maxlat = NULL;
33  m_minlon = NULL;
34  m_maxlon = NULL;
35 
36  // Create the components for the filter window
37  m_minlat = new QLineEdit;
38  m_maxlat = new QLineEdit;
39  m_minlon = new QLineEdit;
40  m_maxlon = new QLineEdit;
41 
42  // Disable all range line edits since the lat/lon range is not selected
43  // m_minlat->setEnabled(false);
44  // m_maxlat->setEnabled(false);
45  // m_minlon->setEnabled(false);
46  // m_maxlon->setEnabled(false);
47 
48  // Create labels for the latitude range values
49  QLabel *minlatLabel = new QLabel("Minimum Latitude");
50  QLabel *maxlatLabel = new QLabel("Maximum Latitude");
51  QLabel *minlonLabel = new QLabel("Minimum Longitude");
52  QLabel *maxlonLabel = new QLabel("Maximum Longitude");
53  QLabel *pad = new QLabel();
54 
55  // Create the layout and add the components to it
56  QGridLayout *gridLayout = new QGridLayout();
57  gridLayout->addWidget(minlatLabel, 0, 0, 1, 1);
58  gridLayout->addWidget(m_minlat, 0, 1, 1, 1);
59  gridLayout->addWidget(maxlatLabel, 1, 0, 1, 1);
60  gridLayout->addWidget(m_maxlat, 1, 1, 1, 1);
61  gridLayout->addWidget(minlonLabel, 2, 0, 1, 1);
62  gridLayout->addWidget(m_minlon, 2, 1, 1, 1);
63  gridLayout->addWidget(maxlonLabel, 3, 0, 1, 1);
64  gridLayout->addWidget(m_maxlon, 3, 1, 1, 1);
65  gridLayout->addWidget(pad, 4, 0);
66  gridLayout->setRowStretch(4, 50);
67  this->setLayout(gridLayout);
68  }
69 
85  // Make sure there is a control net loaded
86  if (controlNet() == NULL) {
87  QMessageBox::information((QWidget *)parent(),
88  "Error", "No points to filter");
89  return;
90  }
91 
92  // Make sure all the values we need have been entered by the user
93  if ((m_minlat->text() == "") || (m_maxlat->text() == "") ||
94  (m_minlon->text() == "") || (m_maxlon->text() == "")) {
95  QMessageBox::information((QWidget *)parent(),
96  "Error", "All lat/lon range values must be entered");
97  return;
98  }
99  else {
100  // Get the user entered values for the range
101  double minlat = m_minlat->text().toDouble();
102  double maxlat = m_maxlat->text().toDouble();
103  double minlon = m_minlon->text().toDouble();
104  double maxlon = m_maxlon->text().toDouble();
105 
106  // Make sure the lat values are in order
107  if (minlat > maxlat) {
108  QString msg = "The minimum latitude value must be less than the maximum latitude value";
109  QMessageBox::information((QWidget *)parent(), "Error", msg);
110  return;
111  }
112  // Make sure the lon values are in order
113  else if (minlon > maxlon) {
114  QString msg = "The minimum longitude value must be less than the maximum longitude value";
115  QMessageBox::information((QWidget *)parent(), "Error", msg);
116  return;
117  }
118 
119  // Loop through each value of the filtered points list
120  // checking to see if each point falls within the rangee
121  // Loop in reverse order since removal list of elements affects index number
122  for (int i = filteredPoints().size() - 1; i >= 0; i--) {
123  // Get the current control point
124  ControlPoint &cp = *(*controlNet())[filteredPoints()[i]];
125 
128  if (lat.inRange(Latitude(minlat,Angle::Degrees),Latitude(maxlat,Angle::Degrees)) &&
130  continue;
131  }
132  else {
133  filteredPoints().removeAt(i);
134  }
135 
136  }
137  }
138 
139  // Tell the navtool that a list has been filtered and it needs to update
140  emit filteredListModified();
141  return;
142  }
143 }
Namespace for the standard library.
This class is designed to encapsulate the concept of a Latitude.
Definition: Latitude.h:63
SurfacePoint GetBestSurfacePoint() const
Returns the adjusted surface point if it exists, otherwise returns the a priori surface point...
Latitude GetLatitude() const
Return the body-fixed latitude for the surface point.
This class is designed to encapsulate the concept of a Longitude.
Definition: Longitude.h:52
bool inRange(Latitude min, Latitude max) const
Checks if this latitude value is within the given range.
Definition: Latitude.cpp:452
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
Definition: Angle.h:73
A single control point.
Definition: ControlPoint.h:369
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Longitude GetLongitude() const
Return the body-fixed longitude for the surface point.
virtual void filter()
Filters a list of points for points that are of the selected Range or in the given range...
Qnet Navigation Tool.
Definition: QnetNavTool.h:132
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
bool inRange(Longitude min, Longitude max) const
Checks if this longitude value is within the given range.
Definition: Longitude.cpp:332
Unless noted otherwise, the portions of Isis written by the USGS are public domain.