Isis 3 Programmer Reference
QnetPointCubeNameFilter.cpp
1#include "QnetPointCubeNameFilter.h"
2
3#include <QApplication>
4#include <QGridLayout>
5#include <QLabel>
6#include <QListWidget>
7#include <QMessageBox>
8
9#include "ControlMeasure.h"
10#include "ControlNet.h"
11#include "ControlPoint.h"
12#include "FileName.h"
13#include "QnetNavTool.h"
14#include "SerialNumberList.h"
15
16using namespace std;
17
18namespace Isis {
31 : QnetFilter(navTool, parent) {
32 p_listBox = NULL;
33
34 QLabel *label = new QLabel("Select cube(s) from the list:");
35 p_listBox = new QListWidget;
36 p_listBox->setSelectionMode(QAbstractItemView::ExtendedSelection);
37 //connect (p_listBox,SIGNAL(itemDoubleClicked(QListWidgetItem *)),
38 // this,SLOT(editPoint(QListWidgetItem *)));
39
40 // Create the layout and add the components to it
41 QGridLayout *gridLayout = new QGridLayout;
42 gridLayout->addWidget(label, 0, 0);
43 gridLayout->addWidget(p_listBox, 1, 0);
44 this->setLayout(gridLayout);
45 //if (g_serialNumberList != NULL) createCubeList();
46 return;
47 }
48
59 // Make sure there is a control net loaded
60 if (controlNet() == NULL) {
61 QMessageBox::information((QWidget *)parent(),
62 "Error", "No points to filter");
63 return;
64 }
65
66 if (serialNumberList() == NULL) {
67 QMessageBox::information((QWidget *)parent(),
68 "Error", "No cubes to filter");
69 return;
70 }
71
72 // load???
73 int index = p_listBox->currentRow();
74 if (index < 0) {
75 QApplication::restoreOverrideCursor();
76 QMessageBox::information((QWidget *)parent(),
77 "Error", "No file selected to filter");
78 return;
79 }
80
81 QList<QListWidgetItem *> selected = p_listBox->selectedItems();
82
83 for (int i = 0; i < selected.size(); i++) {
84 int index = p_listBox->row(selected[i]);
85 QString selectedCubeSerNum = serialNumberList()->serialNumber(index);
86
87 // Loop through each value of the filtered points list
88 // checking the types of each control measure for each
89 // of the control points. If no measures match, we remove
90 // it from the filtered list
91 // Loop in reverse order since removal list of elements affects index number
92 for (int i = filteredPoints().size() - 1; i >= 0; i--) {
93 ControlPoint &cp = *(*controlNet())[filteredPoints()[i]];
94 int numMeasNotMatching = 0;
95 for (int j = 0; j < cp.GetNumMeasures(); j++) {
96 // if the point contains a measure that matches a checked type,
97 // keep this point in the list and go on to the next point
98 if (cp[j]->GetCubeSerialNumber() == selectedCubeSerNum) {
99 break;
100 }
101 // if this measure doesn't match any of the checked values, increment
102 else
103 numMeasNotMatching++;
104 }
105 // if no measures match the checked values,
106 // remove this point from the filter list
107 if (cp.GetNumMeasures() == numMeasNotMatching) {
108 filteredPoints().removeAt(i);
109 }
110 }
111 }
112 // Tell the navtool that a list has been filtered and it needs to update
113 emit filteredListModified();
114 return;
115 }
116
124 // Clear the old list and update with the entire list
125 p_listBox->setCurrentRow(-1);
126 p_listBox->clear();
127
128 SerialNumberList *snList = serialNumberList();
129 for (int i = 0; i < snList->size(); i++) {
130 FileName filename = FileName(snList->fileName(i));
131 QString tempFileName = filename.name();
132 p_listBox->insertItem(i, tempFileName);
133 }
134 }
135}
136
137
138
139
140
A single control point.
File name manipulation and expansion.
Definition FileName.h:100
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
Definition FileName.cpp:162
Qnet Navigation Tool.
QnetPointCubeNameFilter(QnetNavTool *navTool, QWidget *parent=0)
Contructor for the Point Cube Name filter.
virtual void filter()
Method overwrites parent method.
void createCubeList()
Fills the list box with the cube name list.
Serial Number list generator.
QString serialNumber(const QString &filename)
Return a serial number given a filename.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.