1 #include "ControlNetTool.h" 10 #include <QMessageBox> 17 #include "ControlList.h" 22 #include "ControlPointEditWidget.h" 30 #include "ShapeList.h" 33 #include "ViewportMainWindow.h" 52 m_directory = directory;
57 ControlNetTool::~ControlNetTool () {
77 action->setIcon(QPixmap(
toolIconDir()+
"/HILLBLU_molecola.png"));
78 action->setToolTip(
"Control Point Editor (T)");
79 action->setStatusTip(
"If tool disabled, make sure you have a control net in your project and " 80 "it is set to the active control.");
81 action->setShortcut(Qt::Key_T);
85 action->setObjectName(
"ControlNetTool");
91 if (cnets.isEmpty()) {
92 action->setDisabled(
true);
115 void ControlNetTool::loadNetwork() {
133 if (m_controlNet == NULL || cvp == NULL)
return;
137 bool isGroundSource = m_view->viewportContainsShape(cvp);
143 if (s == Qt::LeftButton) {
145 if (isGroundSource) {
146 QString message =
"Cannot select point for editing on ground source. Select ";
147 message +=
"point using un-projected images or the Cnet Editor View (choose \"View Network\" ";
148 message +=
"from the context menu for control nets on the project tree).";
149 QMessageBox::critical(m_ControlNetTool,
"Error", message);
156 ControlPoint *point = m_controlNet->FindClosest(sn, samp, line);
157 emit modifyControlPoint(point, sn);
160 QString message =
"No points exist for editing. Create points using the right mouse";
161 message +=
" button.";
162 QMessageBox::warning(m_ControlNetTool,
"Warning", message);
167 else if (s == Qt::MidButton) {
169 if (!m_controlNet || m_controlNet->GetNumPoints() == 0) {
170 QString message =
"No points exist for deleting. Create points ";
171 message +=
"using the right mouse button.";
172 QMessageBox::warning(m_ControlNetTool,
"Warning", message);
176 if (isGroundSource) {
177 QString message =
"Cannot select point for deleting on ground source. Select ";
178 message +=
"point using un-projected images or the Cnet Editor View (choose \"View Network\" ";
179 message +=
"from the context menu for control nets on the project tree).";
180 QMessageBox::critical(m_ControlNetTool,
"Error", message);
187 point = m_controlNet->FindClosest(sn, samp, line);
190 QString message =
"No points exist for deleting. Create points ";
191 message +=
"using the right mouse button.";
192 QMessageBox::warning(m_ControlNetTool,
"Warning", message);
197 QString message =
"Cannot find point on this image for deleting.";
198 QMessageBox::critical(m_ControlNetTool,
"Error", message);
202 emit deleteControlPoint(point);
204 else if (s == Qt::RightButton) {
208 QString message =
"Invalid latitude or longitude at this point. ";
209 QMessageBox::critical(NULL,
"Error", message);
214 emit createControlPoint(lat, lon, cvp->
cube(), isGroundSource);
249 vp->viewport()->update();
284 if (m_controlNet == 0 || m_controlNet->GetNumPoints() == 0)
return;
294 foreach (
ShapeList *shapeList, projectShapes) {
295 foreach (
Shape *shape, *shapeList) {
297 if (serialNumber == shapeSn) {
309 if (!m_controlNet->GetCubeSerials().contains(
310 serialNumber))
return;
313 m_controlNet->GetMeasuresInCube(serialNumber);
315 for (
int i = 0; i < measures.count(); i++) {
318 double samp = m->GetSample();
319 double line = m->GetLine();
323 if (m->Parent()->IsIgnored()) {
324 painter->setPen(QColor(255, 255, 0));
327 else if (m->IsIgnored()) {
328 painter->setPen(QColor(255, 255, 0));
332 painter->setPen(Qt::magenta);
335 painter->setPen(Qt::green);
338 painter->drawLine(x - 5, y, x + 5, y);
339 painter->drawLine(x, y - 5, x, y + 5);
347 if (currentEditPoint && m_controlNet->ContainsPoint(currentEditPoint->
GetId())) {
351 double samp = (*currentEditPoint)[serialNumber]->GetSample();
352 double line = (*currentEditPoint)[serialNumber]->GetLine();
358 path.addEllipse(QPointF(x,y), 5., 5.);
365 QPen pen(QPen(Qt::red, 0.0));
367 painter->setPen(pen);
368 painter->drawPath(path);
396 for (
int i = 0; i < m_controlNet->GetNumPoints(); i++) {
399 if (!p.HasAprioriCoordinates())
continue;
404 double samp = groundMap->
Sample();
405 double line = groundMap->
Line();
411 painter->setPen(QColor(255, 255, 0));
413 painter->drawLine(x - 5, y, x + 5, y);
414 painter->drawLine(x, y - 5, x, y + 5);
417 else if (currentEditPoint != NULL && p.
GetId() == currentEditPoint->
GetId()) {
420 path.addEllipse(QPointF(x,y), 5., 5.);
426 QBrush brush(Qt::red);
429 painter->setPen(pen);
430 painter->drawPath(path);
434 painter->setPen(Qt::magenta);
436 painter->drawLine(x - 5, y, x + 5, y);
437 painter->drawLine(x, y - 5, x, y + 5);
Cube display widget for certain Isis MDI applications.
Internalizes a list of shapes and allows for operations on the entire list.
bool HasSerialNumber(QString serialNumber) const
Return true if given serial number exists in point.
double Line() const
Returns the current line value of the camera model or projection.
ControlPointEditWidget * controlPointEditWidget()
Returns the ControlPointEditWidget.
Namespace for the standard library.
ControlPointEditView * controlPointEditView()
Gets the ControlPointEditWidget associated with the Directory.
void cubeToViewport(double sample, double line, int &x, int &y) const
Turns a cube into a viewport.
Control * activeControl()
Return the Active Control (control network)
Latitude GetLatitude() const
Return the body-fixed latitude for the surface point.
A Free point is a Control Point that identifies common measurements between two or more cubes...
static QString Compose(Pvl &label, bool def2filename=false)
Compose a SerialNumber from a PVL.
QString GetId() const
Return the Id of the control point.
bool SetGround(Latitude lat, Longitude lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
Cube * cube()
Get the Cube * associated with this display property.
UniversalGroundMap * universalGroundMap() const
QString serialNumber()
Get the serial number.
double UniversalLatitude() const
Returns the universal latitude of the camera model or projection.
ControlNet * controlNet()
Open and return a pointer to the ControlNet for this Control.
QList< ControlList * > controls()
Return controls in project.
bool SetImage(double sample, double line)
Returns whether the sample/line postion was set successfully in the camera model or projection...
Longitude GetLongitude() const
Return the body-fixed longitude for the surface point.
This represents a shape in a project-based GUI interface.
View that displays cubes in a QView-like way.
virtual QString fileName() const
Returns the opened cube's filename.
Namespace for ISIS/Bullet specific routines.
Project * project() const
Gets the Project for this directory.
double Sample() const
Returns the current line value of the camera model or projection.
PointType GetType() const
double UniversalLongitude() const
Returns the universal longitude of the camera model or projection.
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.