9 #include "ControlNetTool.h"
18 #include <QMessageBox>
24 #include "Application.h"
25 #include "ControlList.h"
26 #include "ControlMeasure.h"
27 #include "ControlNet.h"
28 #include "ControlPoint.h"
29 #include "ControlPointEditView.h"
30 #include "ControlPointEditWidget.h"
31 #include "CubeDnView.h"
32 #include "Directory.h"
33 #include "IException.h"
34 #include "MdiCubeViewport.h"
36 #include "SerialNumber.h"
38 #include "ShapeList.h"
40 #include "UniversalGroundMap.h"
41 #include "ViewportMainWindow.h"
42 #include "Workspace.h"
60 m_directory = directory;
61 m_view = qobject_cast<CubeDnView *>(parent);
65 ControlNetTool::~ControlNetTool () {
85 action->setIcon(QPixmap(
toolIconDir()+
"/HILLBLU_molecola.png"));
86 action->setToolTip(
"Control Point Editor (T)");
87 action->setStatusTip(
"If tool disabled, make sure you have a control net in your project and "
88 "it is set to the active control.");
89 action->setShortcut(Qt::Key_T);
93 action->setObjectName(
"ControlNetTool");
99 if (cnets.isEmpty()) {
100 action->setDisabled(
true);
123 void ControlNetTool::loadNetwork() {
141 if (m_controlNet == NULL || cvp == NULL)
return;
145 bool isGroundSource = m_view->viewportContainsShape(cvp);
151 if (s == Qt::LeftButton) {
153 if (isGroundSource) {
154 QString message =
"Cannot select point for editing on ground source. Select ";
155 message +=
"point using un-projected images or the Cnet Editor View (choose \"View Network\" ";
156 message +=
"from the context menu for control nets on the project tree).";
157 QMessageBox::critical(m_ControlNetTool,
"Error", message);
164 ControlPoint *point = m_controlNet->FindClosest(sn, samp, line);
165 emit modifyControlPoint(point, sn);
168 QString message =
"No points exist for editing. Create points using the right mouse";
169 message +=
" button.";
170 QMessageBox::warning(m_ControlNetTool,
"Warning", message);
175 else if (s == Qt::MidButton) {
177 if (!m_controlNet || m_controlNet->GetNumPoints() == 0) {
178 QString message =
"No points exist for deleting. Create points ";
179 message +=
"using the right mouse button.";
180 QMessageBox::warning(m_ControlNetTool,
"Warning", message);
184 if (isGroundSource) {
185 QString message =
"Cannot select point for deleting on ground source. Select ";
186 message +=
"point using un-projected images or the Cnet Editor View (choose \"View Network\" ";
187 message +=
"from the context menu for control nets on the project tree).";
188 QMessageBox::critical(m_ControlNetTool,
"Error", message);
195 point = m_controlNet->FindClosest(sn, samp, line);
198 QString message =
"No points exist for deleting. Create points ";
199 message +=
"using the right mouse button.";
200 QMessageBox::warning(m_ControlNetTool,
"Warning", message);
205 QString message =
"Cannot find point on this image for deleting.";
206 QMessageBox::critical(m_ControlNetTool,
"Error", message);
210 emit deleteControlPoint(point);
212 else if (s == Qt::RightButton) {
216 QString message =
"Invalid latitude or longitude at this point. ";
217 QMessageBox::critical(NULL,
"Error", message);
222 emit createControlPoint(lat, lon, cvp->
cube(), isGroundSource);
257 vp->viewport()->update();
292 if (m_controlNet == 0 || m_controlNet->GetNumPoints() == 0)
return;
302 foreach (
ShapeList *shapeList, projectShapes) {
303 foreach (
Shape *shape, *shapeList) {
305 if (serialNumber == shapeSn) {
317 if (!m_controlNet->GetCubeSerials().contains(
318 serialNumber))
return;
321 m_controlNet->GetMeasuresInCube(serialNumber);
323 for (
int i = 0; i < measures.count(); i++) {
326 double samp = m->GetSample();
327 double line = m->GetLine();
331 if (m->Parent()->IsIgnored()) {
332 painter->setPen(QColor(255, 255, 0));
335 else if (m->IsIgnored()) {
336 painter->setPen(QColor(255, 255, 0));
340 painter->setPen(Qt::magenta);
343 painter->setPen(Qt::green);
346 painter->drawLine(x - 5, y, x + 5, y);
347 painter->drawLine(x, y - 5, x, y + 5);
355 if (currentEditPoint && m_controlNet->ContainsPoint(currentEditPoint->
GetId())) {
359 double samp = (*currentEditPoint)[serialNumber]->GetSample();
360 double line = (*currentEditPoint)[serialNumber]->GetLine();
366 path.addEllipse(QPointF(x,y), 5., 5.);
373 QPen pen(QPen(Qt::red, 0.0));
375 painter->setPen(pen);
376 painter->drawPath(path);
404 for (
int i = 0; i < m_controlNet->GetNumPoints(); i++) {
407 if (!p.HasAprioriCoordinates())
continue;
412 double samp = groundMap->
Sample();
413 double line = groundMap->
Line();
419 painter->setPen(QColor(255, 255, 0));
421 painter->drawLine(x - 5, y, x + 5, y);
422 painter->drawLine(x, y - 5, x, y + 5);
425 else if (currentEditPoint != NULL && p.
GetId() == currentEditPoint->
GetId()) {
428 path.addEllipse(QPointF(x,y), 5., 5.);
434 QBrush brush(Qt::red);
437 painter->setPen(pen);
438 painter->drawPath(path);
442 painter->setPen(Qt::magenta);
444 painter->drawLine(x - 5, y, x + 5, y);
445 painter->drawLine(x, y - 5, x, y + 5);