Isis 3 Programmer Reference
QnetPointTypeFilter.cpp
1 #include "QnetPointTypeFilter.h"
2 
3 #include <QCheckBox>
4 #include <QHBoxLayout>
5 #include <QGroupBox>
6 #include <QMessageBox>
7 #include <QRadioButton>
8 #include <QtWidgets>
9 #include <QVBoxLayout>
10 
11 
12 #include "ControlMeasure.h"
13 #include "ControlNet.h"
14 #include "ControlPoint.h"
15 #include "QnetNavTool.h"
16 #include "SerialNumberList.h"
17 
18 namespace Isis {
35  QnetFilter(navTool, parent) {
36  m_pointType = NULL;
37  m_free = NULL;
38  m_constrained = NULL;
39  m_fixed = NULL;
40  m_ignoreStatus = NULL;
41  m_ignored = NULL;
42  m_notIgnored = NULL;
43  m_editLockStatus = NULL;
44  m_editLocked = NULL;
45  m_notEditLocked = NULL;
46 
47  // Create the components for the filter window
48  m_pointType = new QGroupBox("Filter by Point Type(s)");
49  m_pointType->setCheckable(true);
50  m_free = new QCheckBox("Free");
51  m_constrained = new QCheckBox("Constrained");
52  m_fixed = new QCheckBox("Fixed");
53 
54  m_free->setChecked(true);
55 
56  QVBoxLayout *typeLayout = new QVBoxLayout();
57  typeLayout->addWidget(m_free);
58  typeLayout->addWidget(m_constrained);
59  typeLayout->addWidget(m_fixed);
60  typeLayout->addStretch(1);
61  m_pointType->setLayout(typeLayout);
62 
63  m_ignoreStatus = new QGroupBox("Filter by Ignore Status");
64  m_ignoreStatus->setCheckable(true);
65  m_ignoreStatus->setChecked(false);
66  m_ignored = new QRadioButton("Ignored");
67  m_notIgnored = new QRadioButton("Not Ignored");
68 
69  m_ignored->setChecked(true);
70 
71  QVBoxLayout *ignoreLayout = new QVBoxLayout();
72  ignoreLayout->addWidget(m_ignored);
73  ignoreLayout->addWidget(m_notIgnored);
74  m_ignoreStatus->setLayout(ignoreLayout);
75 
76  m_editLockStatus = new QGroupBox("Filter by Edit Lock Status");
77  m_editLockStatus->setCheckable(true);
78  m_editLockStatus->setChecked(false);
79  m_editLocked = new QRadioButton("Edit Locked");
80  m_notEditLocked = new QRadioButton("Not Edit Locked");
81 
82  m_editLocked->setChecked(true);
83 
84  QVBoxLayout *lockLayout = new QVBoxLayout();
85  lockLayout->addWidget(m_editLocked);
86  lockLayout->addWidget(m_notEditLocked);
87  m_editLockStatus->setLayout(lockLayout);
88 
89  //QLabel *pad = new QLabel();
90 
91  // Create the layout and add the components to it
92 
93 
94  QVBoxLayout *statusLayout = new QVBoxLayout();
95  statusLayout->addWidget(m_ignoreStatus);
96  statusLayout->addWidget(m_editLockStatus);
97 
98  QHBoxLayout *layout = new QHBoxLayout();
99  layout->addWidget(m_pointType);
100  layout->addLayout(statusLayout);
101 
102  this->setLayout(layout);
103  }
104 
132  // Make sure there is a control net loaded
133  if (controlNet() == NULL) {
134  QMessageBox::information((QWidget *)parent(),
135  "Error", "No points to filter");
136  return;
137  }
138 
139  // Make sure something is selected for filtering
140  if (!m_pointType->isChecked() && !m_ignoreStatus->isChecked() &&
141  !m_editLockStatus->isChecked()) {
142  QMessageBox::information((QWidget *)parent(),"Input Error",
143  "You must select something to filter.");
144  return;
145  }
146 
147  // if Filter by Measure Type is selected but no Measure Type is checked, throw error
148  if ((m_pointType->isChecked()) &&
149  !(m_fixed->isChecked() || m_constrained->isChecked() ||
150  m_free->isChecked())) {
151  QMessageBox::information((QWidget *)parent(), "Input Error",
152  "Filter by Point Type is selected. You must choose at least one "
153  "Point Type to filter");
154  return;
155  }
156 
157  // Loop through each value of the filtered points list checking the types of
158  // each control point Loop in reverse order since removal list of elements
159  // affects index number
160  for (int i = filteredPoints().size() - 1; i >= 0; i--) {
161  ControlPoint &cp = *(*controlNet())[filteredPoints()[i]];
162  // While keep is true, keep testing for next filter option
163  bool keep = true;
164  if (m_pointType->isChecked()) {
165  if (!PointTypeMatched(cp.GetType())) keep = false;
166  }
167 
168  if (keep && m_ignoreStatus->isChecked()) {
169 
170  // First check all measures in point. if all measures are ignored,
171  // point is considered ignored.
172  bool allMeasuresIgnored = true;
173  for (int j = 0; j < cp.GetNumMeasures(); j++) {
174  if (!cp[j]->IsIgnored()) {
175  allMeasuresIgnored = false;
176  break;
177  }
178  }
179  if (m_ignored->isChecked() && !cp.IsIgnored() && !allMeasuresIgnored) {
180  keep = false;
181  }
182  else if (m_notIgnored->isChecked() &&
183  (cp.IsIgnored() || allMeasuresIgnored)) {
184  keep = false;
185  }
186  }
187 
188  if (keep && m_editLockStatus->isChecked()) {
189  if (m_editLocked->isChecked() && !cp.IsEditLocked()) {
190  keep = false;
191  }
192  else if (m_notEditLocked->isChecked() && cp.IsEditLocked()) {
193  keep = false;
194  }
195  }
196 
197  if (!keep) filteredPoints().removeAt(i);
198  }
199 
200  // Tell the navtool that a list has been filtered and it needs to update
201  emit filteredListModified();
202  return;
203  }
204 
205 
206 
220  if (m_fixed->isChecked() && pointType == ControlPoint::Fixed) {
221  return true;;
222  }
223  if (m_constrained->isChecked() && pointType == ControlPoint::Constrained) {
224  return true;;
225  }
226  if (m_free->isChecked() && pointType == ControlPoint::Free) {
227  return true;;
228  }
229  return false;
230  }
231 
232 
233 }
bool PointTypeMatched(int pointType)
Returns whether the point type passed in matches a type selected by the user.
A Constrained point is a Control Point whose lat/lon/radius is somewhat established and should not be...
Definition: ControlPoint.h:391
A Fixed point is a Control Point whose lat/lon is well established and should not be changed...
Definition: ControlPoint.h:386
virtual void filter()
Filters a list of points and keeps points that have the selected property or in the given range...
A Free point is a Control Point that identifies common measurements between two or more cubes...
Definition: ControlPoint.h:399
A single control point.
Definition: ControlPoint.h:369
Qnet Navigation Tool.
Definition: QnetNavTool.h:132
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
PointType GetType() const
QnetPointTypeFilter(QnetNavTool *navTool, QWidget *parent=0)
Contructor for the Point Type filter.