11 #include "AbstractPointItem.h"
14 #include <QMessageBox>
18 #include "CnetDisplayProperties.h"
19 #include "ControlMeasure.h"
20 #include "ControlNet.h"
21 #include "ControlPoint.h"
22 #include "IException.h"
24 #include "Longitude.h"
25 #include "TableColumn.h"
26 #include "TableColumnList.h"
30 QString AbstractPointItem::getColumnName(Column col) {
37 return "Chooser Name";
47 return "Adjusted SP Lat";
49 return "Adjusted SP Lon";
50 case AdjustedSPRadius:
51 return "Adjusted SP Radius";
52 case AdjustedSPLatSigma:
53 return "Adjusted SP Lat Sigma";
54 case AdjustedSPLonSigma:
55 return "Adjusted SP Lon Sigma";
56 case AdjustedSPRadiusSigma:
57 return "Adjusted SP Radius Sigma";
59 return "A Priori SP Lat";
61 return "A Priori SP Lon";
63 return "A Priori SP Radius";
64 case APrioriSPLatSigma:
65 return "A Priori SP Lat Sigma";
66 case APrioriSPLonSigma:
67 return "A Priori SP Lon Sigma";
68 case APrioriSPRadiusSigma:
69 return "A Priori SP Radius Sigma";
71 return "A Priori SP Source";
72 case APrioriSPSourceFile:
73 return "A Priori SP Source File";
74 case APrioriRadiusSource:
75 return "A Priori Radius Source";
76 case APrioriRadiusSourceFile:
77 return "A Priori Radius Source File";
79 return "Jigsaw Rejected";
87 AbstractPointItem::Column AbstractPointItem::getColumn(QString columnTitle) {
88 for (
int i = 0; i < COLS; i++) {
89 if (columnTitle == getColumnName((Column)i))
93 QString msg =
"Column title [" + columnTitle +
"] does not match any of "
94 "the defined column types";
99 TableColumnList *AbstractPointItem::createColumns() {
100 TableColumnList *columnList =
new TableColumnList;
102 columnList->append(
new TableColumn(getColumnName(Id),
false,
false));
104 new TableColumn(getColumnName(PointType),
false,
false));
106 new TableColumn(getColumnName(ChooserName),
false,
false));
108 new TableColumn(getColumnName(DateTime),
true,
false));
110 new TableColumn(getColumnName(EditLock),
false,
false));
112 new TableColumn(getColumnName(Ignored),
false,
true));
114 new TableColumn(getColumnName(Reference),
false,
false));
116 new TableColumn(getColumnName(AdjustedSPLat),
true,
false));
118 new TableColumn(getColumnName(AdjustedSPLon),
true,
false));
120 new TableColumn(getColumnName(AdjustedSPRadius),
true,
false));
122 new TableColumn(getColumnName(AdjustedSPLatSigma),
true,
false));
124 new TableColumn(getColumnName(AdjustedSPLonSigma),
true,
false));
126 new TableColumn(getColumnName(AdjustedSPRadiusSigma),
true,
false));
128 new TableColumn(getColumnName(APrioriSPLat),
false,
false));
130 new TableColumn(getColumnName(APrioriSPLon),
false,
false));
132 new TableColumn(getColumnName(APrioriSPRadius),
false,
false));
134 new TableColumn(getColumnName(APrioriSPLatSigma),
false,
false));
136 new TableColumn(getColumnName(APrioriSPLonSigma),
false,
false));
138 new TableColumn(getColumnName(APrioriSPRadiusSigma),
false,
false));
140 new TableColumn(getColumnName(APrioriSPSource),
false,
false));
142 new TableColumn(getColumnName(APrioriSPSourceFile),
false,
false));
144 new TableColumn(getColumnName(APrioriRadiusSource),
false,
false));
145 columnList->append(
new TableColumn(
146 getColumnName(APrioriRadiusSourceFile),
false,
false));
148 new TableColumn(getColumnName(JigsawRejected),
true,
false));
154 AbstractPointItem::AbstractPointItem(ControlPoint *cp,
155 int avgCharWidth, AbstractTreeItem *parent)
156 : AbstractTreeItem(parent) {
159 calcDataWidth(avgCharWidth);
161 connect(m_point, SIGNAL(destroyed(
QObject *)),
this, SLOT(sourceDeleted()));
165 AbstractPointItem::~AbstractPointItem() {
170 QVariant AbstractPointItem::getData()
const {
171 return getData(getColumnName(Id));
175 QVariant AbstractPointItem::getData(QString columnTitle)
const {
177 Column column = getColumn(columnTitle);
179 switch ((Column) column) {
181 return QVariant((QString)m_point->
GetId());
185 return QVariant((QString)m_point->GetChooserName());
189 return QVariant((QString)m_point->GetDateTime());
191 if (m_point->IsEditLocked())
192 return QVariant(
"Yes");
194 return QVariant(
"No");
197 if (m_point->IsIgnored())
198 return QVariant(
"Yes");
200 return QVariant(
"No");
202 if (m_point->GetNumMeasures())
204 CnetDisplayProperties::getInstance()->getImageName(
214 case AdjustedSPRadius:
217 case AdjustedSPLatSigma:
219 m_point->GetAdjustedSurfacePoint().
220 GetLatSigmaDistance().meters());
221 case AdjustedSPLonSigma:
223 m_point->GetAdjustedSurfacePoint().
224 GetLonSigmaDistance().meters());
225 case AdjustedSPRadiusSigma:
227 m_point->GetAdjustedSurfacePoint().
228 GetLocalRadiusSigma().meters());
235 case APrioriSPRadius:
238 case APrioriSPLatSigma:
240 m_point->GetAprioriSurfacePoint().
241 GetLatSigmaDistance().meters());
242 case APrioriSPLonSigma:
244 m_point->GetAprioriSurfacePoint().
245 GetLonSigmaDistance().meters());
246 case APrioriSPRadiusSigma:
248 m_point->GetAprioriSurfacePoint().
249 GetLocalRadiusSigma().meters());
250 case APrioriSPSource:
252 case APrioriSPSourceFile:
253 return QVariant((QString)m_point->GetAprioriSurfacePointSourceFile());
254 case APrioriRadiusSource:
256 case APrioriRadiusSourceFile:
257 return QVariant((QString)m_point->GetAprioriRadiusSourceFile());
259 if (m_point->IsRejected())
260 return QVariant(
"Yes");
262 return QVariant(
"No");
270 void AbstractPointItem::setData(QString
const &columnTitle,
271 QString
const &newData) {
273 Column column = getColumn(columnTitle);
275 switch ((Column) column) {
277 m_point->
SetId(newData);
289 if (newData ==
"Yes")
313 case AdjustedSPRadius:
319 case AdjustedSPLatSigma: {
320 QString msg =
"Cannot set adjusted surface point latitude sigma";
324 case AdjustedSPLonSigma: {
325 QString msg =
"Cannot set adjusted surface point longitude sigma";
329 case AdjustedSPRadiusSigma: {
330 QString msg =
"Cannot set adjusted surface point radius sigma";
336 SurfacePoint newSurfacePoint(prepareSurfacePoint(newLat,
337 m_point->GetAprioriSurfacePoint()));
339 newSurfacePoint.SetSphericalCoordinates(newLat,
340 newSurfacePoint.GetLongitude(),
341 newSurfacePoint.GetLocalRadius());
347 SurfacePoint newSurfacePoint(prepareSurfacePoint(newLon,
348 m_point->GetAprioriSurfacePoint()));
350 newSurfacePoint.SetSphericalCoordinates(
351 newSurfacePoint.GetLatitude(),
353 newSurfacePoint.GetLocalRadius());
357 case APrioriSPRadius: {
359 SurfacePoint newSurfacePoint(prepareSurfacePoint(newRadius,
360 m_point->GetAprioriSurfacePoint()));
362 newSurfacePoint.SetSphericalCoordinates(
363 newSurfacePoint.GetLatitude(),
364 newSurfacePoint.GetLongitude(),
369 case APrioriSPLatSigma: {
371 SurfacePoint newSurfacePoint(prepareSigmas(newSigma,
372 m_point->GetAprioriSurfacePoint()));
374 newSurfacePoint.SetSphericalSigmasDistance(
375 newSigma, newSurfacePoint.GetLonSigmaDistance(),
376 newSurfacePoint.GetLocalRadiusSigma());
381 case APrioriSPLonSigma: {
383 SurfacePoint newSurfacePoint(prepareSigmas(newSigma,
384 m_point->GetAprioriSurfacePoint()));
386 newSurfacePoint.SetSphericalSigmasDistance(
387 newSurfacePoint.GetLatSigmaDistance(), newSigma,
388 newSurfacePoint.GetLocalRadiusSigma());
393 case APrioriSPRadiusSigma: {
395 SurfacePoint newSurfacePoint(prepareSigmas(newSigma,
396 m_point->GetAprioriSurfacePoint()));
398 newSurfacePoint.SetSphericalSigmasDistance(
399 newSurfacePoint.GetLatSigmaDistance(),
400 newSurfacePoint.GetLonSigmaDistance(),
406 case APrioriSPSource:
410 case APrioriSPSourceFile:
413 case APrioriRadiusSource:
417 case APrioriRadiusSourceFile:
431 bool AbstractPointItem::isDataEditable(QString columnTitle)
const {
433 if (m_point->IsEditLocked()) {
434 if (getColumn(columnTitle) == EditLock)
445 void AbstractPointItem::deleteSource() {
447 if (m_point->IsEditLocked()) {
448 QString msg =
"Point [" + getFormattedData() +
"] is edit locked and "
453 QString msg =
"Point [" + getFormattedData() +
"] has at least one "
454 "edit locked measure and cannot be deleted";
458 ControlPoint *tempPoint = m_point;
465 AbstractTreeItem::InternalPointerType AbstractPointItem::getPointerType()
const {
466 return AbstractTreeItem::Point;
470 void *AbstractPointItem::getPointer()
const {
475 bool AbstractPointItem::hasPoint(ControlPoint *p)
const {
479 void AbstractPointItem::sourceDeleted() {
484 SurfacePoint AbstractPointItem::prepareSigmas(Distance newSigma,
485 SurfacePoint surfacePoint) {
487 Distance latSigDist = surfacePoint.GetLatSigmaDistance();
488 Distance lonSigDist = surfacePoint.GetLonSigmaDistance();
489 Distance radiusSigDist = surfacePoint.GetLocalRadiusSigma();
491 if (newSigma.isValid()) {
492 if (!latSigDist.isValid())
494 if (!lonSigDist.isValid())
496 if (!radiusSigDist.isValid())
497 radiusSigDist = free;
500 latSigDist = Distance();
501 lonSigDist = Distance();
502 radiusSigDist = Distance();
505 surfacePoint.SetSphericalSigmasDistance(
506 latSigDist, lonSigDist, radiusSigDist);
511 SurfacePoint AbstractPointItem::prepareSurfacePoint(Latitude newLat,
512 SurfacePoint surfacePoint) {
513 if (newLat.isValid()) {
514 surfacePoint = prepareSurfacePoint(surfacePoint);
517 surfacePoint.SetSphericalCoordinates(Latitude(), Longitude(),
525 SurfacePoint AbstractPointItem::prepareSurfacePoint(Longitude newLon,
526 SurfacePoint surfacePoint) {
527 if (newLon.isValid()) {
528 surfacePoint = prepareSurfacePoint(surfacePoint);
531 surfacePoint.SetSphericalCoordinates(Latitude(), Longitude(),
539 SurfacePoint AbstractPointItem::prepareSurfacePoint(
540 Distance newRadius, SurfacePoint surfacePoint) {
541 if (newRadius.isValid()) {
542 surfacePoint = prepareSurfacePoint(surfacePoint);
545 surfacePoint.SetSphericalCoordinates(Latitude(), Longitude(),
553 SurfacePoint AbstractPointItem::prepareSurfacePoint(
554 SurfacePoint surfacePoint) {
555 Latitude lat = surfacePoint.GetLatitude();
556 Longitude lon = surfacePoint.GetLongitude();
557 Distance radius = surfacePoint.GetLocalRadius();
563 if (!radius.isValid())
566 surfacePoint.SetSphericalCoordinates(lat, lon, radius);