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

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:25:49