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