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

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 USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:17:01