Isis 3 Programmer Reference
PointTableModel.cpp
1 #include "IsisDebug.h"
2 
3 #include "PointTableModel.h"
4 
5 #include <iostream>
6 
7 #include <QDebug>
8 #include <QList>
9 #include <QMessageBox>
10 #include <QStringList>
11 #include <QVariant>
12 
13 #include "ControlMeasure.h"
14 #include "ControlPoint.h"
15 #include "Distance.h"
16 #include "IException.h"
17 #include "IString.h"
18 #include "Latitude.h"
19 #include "Longitude.h"
20 #include "SpecialPixel.h"
21 
22 #include "AbstractTableDelegate.h"
23 #include "AbstractPointItem.h"
24 #include "TableColumn.h"
25 #include "TableColumnList.h"
26 #include "PointTableDelegate.h"
27 #include "AbstractTreeModel.h"
28 
29 
30 namespace Isis {
31  PointTableModel::PointTableModel(AbstractTreeModel *model) :
32  AbstractTableModel(model, new PointTableDelegate) {
33  connect(model, SIGNAL(filterCountsChanged(int, int)),
34  this, SIGNAL(filterCountsChanged(int, int)));
35  connect(model,
36  SIGNAL(treeSelectionChanged(QList< AbstractTreeItem * >)),
37  this,
38  SLOT(handleTreeSelectionChanged(QList< AbstractTreeItem * >)));
39  }
40 
41 
42  PointTableModel::~PointTableModel() {
43  }
44 
45 
46  QList< AbstractTreeItem * > PointTableModel::getItems(
47  int start, int end) {
48  return getSortedItems(start, end, AbstractTreeModel::PointItems);
49  }
50 
51 
52  QList< AbstractTreeItem * > PointTableModel::getItems(
53  AbstractTreeItem *item1, AbstractTreeItem *item2) {
54  return getSortedItems(item1, item2, AbstractTreeModel::PointItems);
55  }
56 
57 
58  int PointTableModel::getVisibleRowCount() const {
59  return getDataModel()->getVisibleItemCount(AbstractTreeModel::PointItems,
60  true);
61  }
62 
63 
64  QList< AbstractTreeItem * > PointTableModel::getSelectedItems() {
65  return getDataModel()->getSelectedItems(AbstractTreeModel::PointItems,
66  true);
67  }
68 
69 
70  QString PointTableModel::getWarningMessage(AbstractTreeItem const *row,
71  TableColumn const *column, QString valueToSave) const {
72  return getPointWarningMessage(row, column, valueToSave);
73  }
74 
75 
76  void PointTableModel::setGlobalSelection(bool selected) {
77  return getDataModel()->setGlobalSelection(selected,
78  AbstractTreeModel::AllItems);
79  }
80 
81 
82  int PointTableModel::indexOfVisibleItem(
83  AbstractTreeItem const *item) const {
84  return getDataModel()->indexOfVisibleItem(item,
85  AbstractTreeModel::PointItems,
86  true);
87  }
88 
89 
90  QString PointTableModel::getPointWarningMessage(
91  AbstractTreeItem const *row, TableColumn const *column,
92  QString valueToSave) {
93  QString colTitle = column->getTitle();
94  AbstractPointItem::Column colType =
95  AbstractPointItem::getColumn(colTitle);
96 
97  QString warningText;
98 
99  switch (colType) {
100  case AbstractPointItem::EditLock:
101  if (valueToSave.toLower() == "no" &&
102  row->getFormattedData(colTitle).toLower() == "yes") {
103  warningText = "Are you sure you want to unlock control point [" +
104  row->getFormattedData() + "] for editing?";
105  }
106  break;
107  case AbstractPointItem::APrioriSPLatSigma:
108  case AbstractPointItem::APrioriSPLonSigma:
109  case AbstractPointItem::APrioriSPRadiusSigma: {
110  ASSERT(row->getPointerType() == AbstractTreeItem::Point);
111  ControlPoint *point = (ControlPoint *) row->getPointer();
112 
113  // Check to see if any of the sigma values are null.
114  bool latSigmaValid = (point->GetAprioriSurfacePoint().
115  GetLatSigmaDistance().isValid());
116  bool lonSigmaValid = (point->GetAprioriSurfacePoint().
117  GetLonSigmaDistance().isValid());
118  bool radiusSigmaValid = (point->GetAprioriSurfacePoint().
119  GetLocalRadiusSigma().isValid());
120 
121  if (!latSigmaValid && !lonSigmaValid && !radiusSigmaValid &&
122  valueToSave.toLower() != "null") {
123  warningText = "The sigma values are currently null. The other "
124  "sigmas will be set to 10,000, which currently represents "
125  "'free'. Is this okay?";
126  }
127  break;
128  }
129  case AbstractPointItem::APrioriSPLat:
130  case AbstractPointItem::APrioriSPLon:
131  case AbstractPointItem::APrioriSPRadius: {
132  ASSERT(row->getPointerType() == AbstractTreeItem::Point);
133  ControlPoint *point = (ControlPoint *) row->getPointer();
134 
135  // Check to see if any of the surface point values are null.
136  bool latValid = (point->GetAprioriSurfacePoint().
137  GetLatitude().isValid());
138  bool lonValid = (point->GetAprioriSurfacePoint().
139  GetLongitude().isValid());
140  bool radiusValid = (point->GetAprioriSurfacePoint().
141  GetLocalRadius().isValid());
142 
143  if (!latValid && !lonValid && !radiusValid &&
144  valueToSave.toLower() != "null") {
145  warningText = "Some of the a priori surface point values are "
146  "currently null. The surface point lat and lon will be set "
147  "to 0 if they are null, and the radius will be set to "
148  "10,000 if it is null. Is this okay?";
149  }
150  break;
151  }
152 
153  default:
154  break;
155  }
156 
157  return warningText;
158  }
159 
160 
161  void PointTableModel::handleTreeSelectionChanged(
162  QList< AbstractTreeItem * > newlySelectedItems) {
163  AbstractTableModel::handleTreeSelectionChanged(
164  newlySelectedItems, AbstractTreeItem::Point);
165 
166  QList<AbstractTreeItem *> measureParentItems;
167  foreach (AbstractTreeItem * item, newlySelectedItems) {
168  if (item->getPointerType() == AbstractTreeItem::Measure) {
169  measureParentItems.append(item->parent());
170  }
171  }
172 
173  if (measureParentItems.size()) {
174  AbstractTableModel::handleTreeSelectionChanged(
175  measureParentItems, AbstractTreeItem::Point);
176  }
177  }
178 
179 
180  TableColumnList *PointTableModel::createColumns() {
181  return AbstractPointItem::createColumns();
182  }
183 }
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Unless noted otherwise, the portions of Isis written by the USGS are public domain.