1#include "ControlNetGraphicsItem.h"
7#include <QGraphicsScene>
10#include "ControlMeasure.h"
11#include "ControlNet.h"
12#include "ControlPoint.h"
13#include "ControlPointGraphicsItem.h"
15#include "IException.h"
18#include "MosaicGraphicsView.h"
19#include "MosaicSceneWidget.h"
20#include "ProgressBar.h"
21#include "Projection.h"
23#include "SerialNumberList.h"
24#include "SurfacePoint.h"
25#include "UniversalGroundMap.h"
30 ControlNetGraphicsItem::ControlNetGraphicsItem(
ControlNet *controlNet,
32 m_controlNet = controlNet;
33 m_mosaicScene = mosaicScene;
36 m_serialNumbers = NULL;
37 mosaicScene->getScene()->addItem(
this);
41 connect(mosaicScene, SIGNAL(projectionChanged(Projection *)),
42 this, SLOT(buildChildren()));
43 connect(mosaicScene, SIGNAL(cubesChanged()),
44 this, SLOT(buildChildren()));
50 ControlNetGraphicsItem::~ControlNetGraphicsItem() {
52 delete m_pointToScene;
53 m_pointToScene = NULL;
56 if (m_cubeToGroundMap) {
57 QMapIterator<QString, UniversalGroundMap *> it(*m_cubeToGroundMap);
66 delete m_cubeToGroundMap;
67 m_cubeToGroundMap = NULL;
72 QRectF ControlNetGraphicsItem::boundingRect()
const {
77 void ControlNetGraphicsItem::paint(QPainter *painter,
78 const QStyleOptionGraphicsItem *style,
QWidget * widget) {
83 Projection *proj = m_mosaicScene->getProjection();
88 QPointF initialLatLon;
89 QPointF adjustedLatLon;
93 if (!rememberedLoc.second.isNull()) {
95 proj->SetUniversalGround(rememberedLoc.second.y(),
96 rememberedLoc.second.x());
97 adjusted = QPointF(proj->XCoord(), -1 * proj->YCoord());
98 adjustedLatLon = rememberedLoc.second;
100 if (!rememberedLoc.first.isNull()) {
101 proj->SetUniversalGround(rememberedLoc.first.y(),
102 rememberedLoc.first.x());
103 initial = QPointF(proj->XCoord(), -1 * proj->YCoord());
104 initialLatLon = rememberedLoc.first;
110 SurfacePoint adjSurfacePoint(cp->GetAdjustedSurfacePoint());
111 if (adjSurfacePoint.Valid()) {
113 if (proj->SetUniversalGround(adjSurfacePoint.GetLatitude().degrees(),
114 adjSurfacePoint.GetLongitude().degrees())) {
115 adjusted = QPointF(proj->XCoord(), -1 * proj->YCoord());
116 adjustedLatLon = QPointF(adjSurfacePoint.GetLongitude().degrees(),
117 adjSurfacePoint.GetLatitude().degrees());
121 SurfacePoint apriSurfacePoint(cp->GetAprioriSurfacePoint());
122 if (apriSurfacePoint.Valid()) {
124 if (proj->SetUniversalGround(apriSurfacePoint.GetLatitude().degrees(),
125 apriSurfacePoint.GetLongitude().degrees())) {
126 initial = QPointF(proj->XCoord(), -1 * proj->YCoord());
127 initialLatLon = QPointF(apriSurfacePoint.GetLongitude().degrees(),
128 apriSurfacePoint.GetLatitude().degrees());
135 if ((!adjusted.isNull() && initial.isNull()) ||
136 (adjusted.isNull() && initial.isNull())) {
139 QString sn = cp->GetReferenceSN();
140 QString filename = snToFileName(sn);
142 if (filename.size() > 0) {
143 if ((*m_cubeToGroundMap)[filename] == NULL) {
144 Cube cube(FileName(filename).expanded(),
"r");
145 UniversalGroundMap *groundMap =
new UniversalGroundMap(cube);
146 (*m_cubeToGroundMap)[filename] = groundMap;
149 if ((*m_cubeToGroundMap)[filename]->SetImage(
150 cp->GetRefMeasure()->GetSample(),
151 cp->GetRefMeasure()->GetLine())) {
152 double lat = (*m_cubeToGroundMap)[filename]->UniversalLatitude();
153 double lon = (*m_cubeToGroundMap)[filename]->UniversalLongitude();
155 if (proj->SetUniversalGround(lat, lon)) {
156 initial = QPointF(proj->XCoord(), -1 * proj->YCoord());
157 initialLatLon = QPointF(lon, lat);
162 catch(IException &) {
169 if (!adjusted.isNull() && adjusted != initial) {
171 result.second = adjusted;
172 result.first = initial;
173 latLonResult.second = adjustedLatLon;
174 latLonResult.first = initialLatLon;
178 result.second = initial;
179 latLonResult.second = initialLatLon;
182 (*m_pointToScene)[cp] = latLonResult;
188 void ControlNetGraphicsItem::clearControlPointGraphicsItem(QString pointId) {
193 m_pointToScene->clear();
203 QString ControlNetGraphicsItem::snToFileName(QString sn) {
206 if (m_serialNumbers && m_serialNumbers->size()) {
208 result = m_serialNumbers->fileName(sn);
210 catch(IException &) {
225 bool colorByMeasureCount,
int maxMeasureCount,
226 bool colorByJigsawError,
double maxResidualMagnitude) {
230 visible, colorByMeasureCount, maxMeasureCount, colorByJigsawError, maxResidualMagnitude);
243 foreach (child, children) {
245 child->scene()->removeItem(child);
252 const int numCp = m_controlNet->GetNumPoints();
254 if (m_serialNumbers) {
255 delete m_serialNumbers;
260 QStringList cubeFiles(m_mosaicScene->cubeFileNames());
263 foreach (filename, cubeFiles) {
265 m_serialNumbers->add(filename);
272 p->
setText(
"Calculating CP Locations");
273 p->setRange(0, numCp - 1);
277 for (
int cpIndex = 0; cpIndex < numCp; cpIndex ++) {
285 cp, m_serialNumbers, m_mosaicScene,
this);
286 p->setValue(cpIndex);
289 p->setVisible(
false);
305 QPoint viewPoint = m_mosaicScene->getView()->mapFromScene(locationPoint);
306 cpItem = (
QGraphicsItem *) m_mosaicScene->getView()->itemAt(viewPoint);
ControlPoint * findClosestControlPoint(QPointF locationPoint)
Return the closest control point to the pointLocation.
void setArrowsVisible(bool visible, bool colorByMeasureCount, int measureCount, bool colorByJigsawError, double residualMagnitude)
Enable/disable and configure movement arrows for all CP displays in the network.
void buildChildren()
Call this to re-calculate where control points ought to lie.
The visual display of a single control point.
void setText(QString text)
Set custom text for this progress bar.
Serial Number list generator.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.
This is free and unencumbered software released into the public domain.