Isis 3 Programmer Reference
QnetPointDistanceFilter.cpp
1#include "QnetPointDistanceFilter.h"
2
3#include <QGridLayout>
4#include <QLabel>
5#include <QLineEdit>
6#include <QList>
7#include <QMessageBox>
8
9#include "Camera.h"
10#include "ControlMeasure.h"
11#include "ControlNet.h"
12#include "ControlPoint.h"
13#include "Distance.h"
14#include "Latitude.h"
15#include "Longitude.h"
16#include "QnetNavTool.h"
17#include "SerialNumberList.h"
18#include "SurfacePoint.h"
19
20namespace Isis {
36 QWidget *parent) : QnetFilter(navTool, parent) {
37 m_lineEdit = NULL;
38
39 // Create the labels and widgets to be added to the main window
40 QLabel *label = new QLabel("Filter points that are within given distance of another point.");
41 QLabel *lessThan = new QLabel("Distance to another point is less than");
42 m_lineEdit = new QLineEdit;
43 QLabel *meters = new QLabel("meters");
44 QLabel *pad = new QLabel;
45
46 // Create the layout and add the widgets to the window
47 QGridLayout *gridLayout = new QGridLayout();
48 gridLayout->addWidget(label, 0, 0, 1, 2);
49 gridLayout->addWidget(lessThan, 1, 0);
50 gridLayout->addWidget(m_lineEdit, 1, 1);
51 gridLayout->addWidget(meters, 1, 2);
52 gridLayout->addWidget(pad, 2, 0);
53 gridLayout->setRowStretch(2, 50);
54 this->setLayout(gridLayout);
55 }
56
80 // Make sure we have a control network to filter through
81 if (controlNet() == NULL) {
82 QMessageBox::information((QWidget *)parent(),
83 "Error", "No points to filter");
84 return;
85 }
86
87 // Make sure the user entered a filtering value
88 if (m_lineEdit->text() == "") {
89 QMessageBox::information((QWidget *)parent(),
90 "Error", "Distance value must be entered");
91 return;
92 }
93 // Get the user entered value for filtering
94 double userEntered = m_lineEdit->text().toDouble();
95
96 // create temporary QList to contain new filtered images
97 QList <int> temp;
98 // Loop through each value of the filtered points list
99 // Loop in reverse order for consistency with other filter methods
100 for (int i = filteredPoints().size() - 1; i >= 0; i--) {
101 ControlPoint &cp1 = *(*controlNet())[filteredPoints()[i]];
102 // Get necessary info from the control point for later use
103 // First check if an adjusted point from jigsaw exists. If not, use
104 // the apriori values.
105
106 SurfacePoint sp1 = cp1.GetBestSurfacePoint();
107
108 // If no lat/lon for this point, use lat/lon of first measure
109 if (!sp1.Valid()) {
110 Camera *cam1;
111 ControlMeasure cm1;
112
113 cm1 = *cp1.GetRefMeasure();
114
115 int camIndex1 = serialNumberList()->serialNumberIndex(cm1.GetCubeSerialNumber());
116 cam1 = controlNet()->Camera(camIndex1);
117 cam1->SetImage(cm1.GetSample(), cm1.GetLine());
118 sp1 = cam1->GetSurfacePoint();
119 }
120 // Loop through each control point, comparing it to the initial point
121 // from the filtered list
122 for (int j = 0; j < controlNet()->GetNumPoints(); j++) {
123 if (j == filteredPoints()[i]) {
124 // cp1 = cp2, go to next value of j
125 continue;
126 }
127 ControlPoint cp2 = *(*controlNet())[j];
128 SurfacePoint sp2 = cp2.GetBestSurfacePoint();
129
130 // If no lat/lon for this point, use lat/lon of first measure
131 if (!sp2.Valid()) {
132 Camera *cam2;
133 ControlMeasure cm2;
134 cm2 = *cp2.GetRefMeasure();
135 int camIndex2 = serialNumberList()->serialNumberIndex(cm2.GetCubeSerialNumber());
136 cam2 = controlNet()->Camera(camIndex2);
137 cam2->SetImage(cm2.GetSample(), cm2.GetLine());
138 sp2 = cam2->GetSurfacePoint();
139 }
140 // Get the distance from the camera class
141 double dist = sp1.GetDistanceToPoint(sp2,sp1.GetLocalRadius()).meters();
142
143 // If the distance found is less than the input number, add the
144 // control points' indices to the new filtered points list
145 if (dist < userEntered) {
146 if (!temp.contains(filteredPoints()[i])) {
147 temp.push_back(filteredPoints()[i]);
148 }
149 break;
150 }
151 }
152 }
153
154 // Sort QList of filtered points before displaying list to user
155 qSort(temp.begin(), temp.end());
156 // replace existing filter list with this one
157 filteredPoints() = temp;
158
159 // Tell the nav tool that a list has been filtered and needs to be updated
160 emit filteredListModified();
161 return;
162 }
163}
virtual bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
Definition Camera.cpp:156
a control measurement
int GetNumPoints() const
Return the number of control points in the network.
Isis::Camera * Camera(int index)
Returns the camera list from the given image number.
A single control point.
Qnet Navigation Tool.
QnetPointDistanceFilter(QnetNavTool *navTool, QWidget *parent=0)
Contructor for the Point Distance filter.
virtual void filter()
Filters a list of points for points that are less than the user entered distance from another point i...
int serialNumberIndex(const QString &sn)
Return a list index given a serial number.
This class defines a body-fixed surface point.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16