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