9#include "ControlNetTool.h"
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"
33#include "IException.h"
34#include "MdiCubeViewport.h"
36#include "SerialNumber.h"
40#include "UniversalGroundMap.h"
41#include "ViewportMainWindow.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);
148 cvp->viewportToCube(p.x(),p.y(),samp,line);
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::MiddleButton) {
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) {
215 if (!gmap->SetImage(samp,line)) {
216 QString message =
"Invalid latitude or longitude at this point. ";
217 QMessageBox::critical(NULL,
"Error", message);
220 double lat = gmap->UniversalLatitude();
221 double lon = gmap->UniversalLongitude();
222 emit createControlPoint(lat, lon, cvp->cube(), isGroundSource);
257 vp->viewport()->update();
292 if (m_controlNet == 0 || m_controlNet->GetNumPoints() == 0)
return;
301 QList<ShapeList *> projectShapes = m_directory->
project()->shapes();
302 foreach (
ShapeList *shapeList, projectShapes) {
303 foreach (
Shape *shape, *shapeList) {
305 if (serialNumber == shapeSn) {
317 if (!m_controlNet->GetCubeSerials().contains(
318 serialNumber))
return;
320 QList<ControlMeasure *> measures =
321 m_controlNet->GetMeasuresInCube(serialNumber);
323 for (
int i = 0; i < measures.count(); i++) {
326 double samp = m->GetSample();
327 double line = m->GetLine();
329 vp->cubeToViewport(samp, line, x, y);
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())) {
357 if (currentEditPoint->HasSerialNumber(serialNumber)) {
359 double samp = (*currentEditPoint)[serialNumber]->GetSample();
360 double line = (*currentEditPoint)[serialNumber]->GetLine();
362 vp->cubeToViewport(samp, line, x, y);
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;
410 if (groundMap->
SetGround(p.GetAprioriSurfacePoint().GetLatitude(),
411 p.GetAprioriSurfacePoint().GetLongitude())) {
412 double samp = groundMap->
Sample();
413 double line = groundMap->
Line();
415 vp->cubeToViewport(samp, line, x, y);
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);
ControlNet * controlNet()
Open and return a pointer to the ControlNet for this Control.
ControlPointEditWidget * controlPointEditWidget()
Returns the ControlPointEditWidget.
@ Free
A Free point is a Control Point that identifies common measurements between two or more cubes.
Project * project() const
Gets the Project for this directory.
ControlPointEditView * controlPointEditView()
Gets the ControlPointEditWidget associated with the Directory.
Cube display widget for certain Isis MDI applications.
QList< ControlList * > controls()
Return controls in project.
Control * activeControl()
Return the Active Control (control network)
static QString Compose(Pvl &label, bool def2filename=false)
Compose a SerialNumber from a PVL.
This represents a shape in a project-based GUI interface.
QString serialNumber()
Get the serial number.
Cube * cube()
Get the Cube * associated with this display property.
Internalizes a list of shapes and allows for operations on the entire list.
double Sample() const
Returns the current line value of the camera model or projection.
double Line() const
Returns the current line value of the camera model or projection.
bool SetGround(Latitude lat, Longitude lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.