23#include "MainWindow.h"
24#include "MdiCubeViewport.h"
25#include "Projection.h"
26#include "SurfacePoint.h"
29#include "UniversalGroundMap.h"
42 p_showDialogButton = NULL;
43 p_linkViewportsButton = NULL;
54 p_pointVisible =
true;
60 p_findPoint =
new QAction(parent);
61 p_findPoint->setShortcut(Qt::CTRL + Qt::Key_F);
62 p_findPoint->setText(
"&Find Point");
63 p_findPoint->setIcon( QPixmap(
toolIconDir() +
"/find.png") );
65 "<b>Function:</b> Centers all linked viewports to the selected lat/lon. \
66 The user can click anywhere on the image to have that point centered, or \
67 they can use the shortcut or button to bring up a window that they can \
68 enter a specific lat/lon position into. \
69 <p><b>Shortcut: </b> Ctrl+F </p> \
70 <p><b>Hint: </b> This option will only work if the image has a camera \
71 model or is projected, and will only center the point on images \
72 where the selected lat/lon position exists.</p>";
73 p_findPoint->setWhatsThis(text);
74 p_findPoint->setEnabled(
false);
75 connect( p_findPoint, SIGNAL( triggered() ),
76 p_dialog, SLOT( show() ) );
79 FindTool::~FindTool() {
92 p_tabWidget =
new QTabWidget(p_dialog);
93 p_dialog->setWindowTitle(
"Find Latitude/Longitude Coordinate");
97 p_tabWidget->addTab(p_imageTab,
"Image");
98 p_tabWidget->addTab(p_groundTab,
"Ground");
101 QPushButton *okButton =
new QPushButton(
"Ok");
102 connect( okButton, SIGNAL( clicked() ),
105 QPushButton *recordButton =
new QPushButton(
"Record Point");
106 connect( recordButton, SIGNAL( clicked() ),
109 QPushButton *closeButton =
new QPushButton(
"Close");
110 connect( closeButton, SIGNAL( clicked() ),
111 p_dialog, SLOT( hide() ) );
114 QHBoxLayout *actionLayout =
new QHBoxLayout();
115 actionLayout->addWidget(okButton);
116 actionLayout->addWidget(recordButton);
117 actionLayout->addWidget(closeButton);
119 QVBoxLayout *dialogLayout =
new QVBoxLayout;
120 dialogLayout->addWidget(p_tabWidget);
121 dialogLayout->addLayout(actionLayout);
122 p_dialog->setLayout(dialogLayout);
134 p_latLineEdit->setValidator(
new QDoubleValidator(-90.0, 90.0, 99, parent) );
138 QLabel *latLabel =
new QLabel(
"Latitude");
139 QLabel *lonLabel =
new QLabel(
"Longitude");
142 QGridLayout *gridLayout =
new QGridLayout();
143 gridLayout->addWidget(latLabel, 0, 0);
145 gridLayout->addWidget(lonLabel, 1, 0);
147 setLayout(gridLayout);
161 QLabel *sampleLabel =
new QLabel(
"Sample");
162 QLabel *lineLabel =
new QLabel(
"Line");
165 QGridLayout *gridLayout =
new QGridLayout();
166 gridLayout->addWidget(sampleLabel, 0, 0);
168 gridLayout->addWidget(lineLabel, 1, 0);
170 setLayout(gridLayout);
183 action->setIcon( QPixmap(
toolIconDir() +
"/find.png") );
184 action->setToolTip(
"Find (F)");
185 action->setShortcut(Qt::Key_F);
187 "<b>Function:</b> Find a lat/lon or line/sample coordinate in this cube. \
188 <p><b>Shortcut:</b>F</p> ";
189 action->setWhatsThis(text);
200 menu->addAction(p_findPoint);
214 p_showDialogButton =
new QToolButton(hbox);
215 p_showDialogButton->setIcon( QPixmap(
toolIconDir() +
"/find.png") );
216 p_showDialogButton->setToolTip(
"Find Point");
218 "<b>Function:</b> Centers all linked viewports to the selected lat/lon. \
219 The user can click anywhere on the image to have that point centered, or \
220 they can use the shortcut or button to bring up a window that they can \
221 enter a specific lat/lon position into. \
222 <p><b>Shortcut: </b> Ctrl+F </p> \
223 <p><b>Hint: </b> This option will only work if the image has a camera \
224 model or is projected, and will only center the point on images \
225 where the selected lat/lon position exists.</p>";
226 p_showDialogButton->setWhatsThis(text);
227 connect( p_showDialogButton, SIGNAL( clicked() ),
228 p_dialog, SLOT( show() ) );
229 p_showDialogButton->setAutoRaise(
true);
230 p_showDialogButton->setIconSize( QSize(22, 22) );
232 p_syncScale =
new QCheckBox(
"Sync Scale");
233 p_syncScale->setChecked(
true);
234 p_syncScale->setToolTip(
"Synchronize Scale");
235 text =
"<b>Function:</b> Syncronizes the scale of all linked viewports.";
236 p_syncScale->setWhatsThis(text);
238 p_linkViewportsButton =
new QToolButton(hbox);
239 p_linkViewportsButton->setIcon( QPixmap(
toolIconDir() +
"/link_valid.png") );
240 p_linkViewportsButton->setToolTip(
"Link Georeferenced Images");
241 p_linkViewportsButton->setWhatsThis(
"<b>Function: </b> Links all open images that have\
242 a camera model or are map projections");
243 connect( p_linkViewportsButton, SIGNAL( clicked() ),
245 p_linkViewportsButton->setAutoRaise(
true);
246 p_linkViewportsButton->setIconSize( QSize(22, 22) );
248 p_togglePointVisibleButton =
new QToolButton(hbox);
249 p_togglePointVisibleButton->setIcon( QPixmap(
toolIconDir() +
"/redDot.png") );
250 p_togglePointVisibleButton->setToolTip(
"Hide red dot");
251 p_togglePointVisibleButton->setCheckable(
true);
252 p_togglePointVisibleButton->setChecked(
true);
253 connect( p_togglePointVisibleButton, SIGNAL( clicked() ),
256 p_statusEdit =
new QLineEdit();
257 p_statusEdit->setReadOnly(
true);
258 p_statusEdit->setToolTip(
"Cube Type");
259 p_statusEdit->setWhatsThis(
"<b>Function: </b> Displays whether the active cube \
260 is a camera model, projection, both, or none. <p> \
261 <b>Hint: </b> If the cube is 'None' the find tool \
262 will not be active</p>");
265 p_groundEngine->setEditable(
true);
266 p_groundEngine->setToolTip(
"Ground Engine Priority");
267 p_groundEngine->setWhatsThis(
"<b>Function: </b> Set priority use of the projection \
268 or the camera to determine ground coordinates. If both are available, \
269 the selected option takes priority. If only one is available, it will \
270 be used by default.");
271 p_groundEngine->insertItem(0,
"Camera");
272 p_groundEngine->insertItem(1,
"Projection");
273 p_groundEngine->setCurrentIndex(0);
274 connect( p_groundEngine, SIGNAL( currentIndexChanged(
int) ),
277 QHBoxLayout *layout =
new QHBoxLayout(hbox);
278 layout->setContentsMargins(0, 0, 0, 0);
279 layout->addWidget(p_statusEdit);
280 layout->addWidget(p_groundEngine);
281 layout->addWidget(p_showDialogButton);
282 layout->addWidget(p_linkViewportsButton);
283 layout->addWidget(p_togglePointVisibleButton);
284 layout->addWidget(p_syncScale);
285 layout->addStretch(1);
286 hbox->setLayout(layout);
306 if (activeViewport == NULL) {
307 p_linkViewportsButton->setEnabled(
false);
308 p_findPoint->setEnabled(
false);
309 p_showDialogButton->setEnabled(
false);
310 p_syncScale->setEnabled(
false);
311 p_statusEdit->setText(
"None");
312 if ( p_dialog->isVisible() ) {
317 p_findPoint->setEnabled(
true);
318 p_showDialogButton->setEnabled(
true);
319 p_statusEdit->setText(
"None");
322 p_linkViewportsButton->setEnabled(
true);
323 p_syncScale->setEnabled(
true);
326 p_linkViewportsButton->setEnabled(
false);
327 p_syncScale->setEnabled(
false);
330 if (activeViewport->
camera() != NULL) {
331 p_statusEdit->setText(
"Camera");
333 p_statusEdit->setText(
"Both");
336 else if (activeViewport->
projection() != NULL) {
337 p_statusEdit->setText(
"Projection");
345 if (p_samp != DBL_MAX && p_line != DBL_MAX) {
346 if ( groundMap && groundMap->
SetImage(p_samp, p_line) ) {
349 p_groundTab->p_latLineEdit->setText(latStr);
350 p_groundTab->p_lonLineEdit->setText(lonStr);
353 p_groundTab->p_latLineEdit->setText(
"");
354 p_groundTab->p_lonLineEdit->setText(
"");
357 p_imageTab->p_sampLineEdit->setText( QString::number(p_samp) );
358 p_imageTab->p_lineLineEdit->setText( QString::number(p_line) );
360 else if (p_lat != DBL_MAX && p_lon != DBL_MAX) {
363 QString lineStr = QString::number( groundMap->
Line() );
364 QString sampStr = QString::number( groundMap->
Sample() );
365 p_imageTab->p_lineLineEdit->setText(lineStr);
366 p_imageTab->p_sampLineEdit->setText(sampStr);
369 p_imageTab->p_lineLineEdit->setText(
"");
370 p_imageTab->p_sampLineEdit->setText(
"");
373 p_groundTab->p_latLineEdit->setText( QString::number(p_lat) );
374 p_groundTab->p_lonLineEdit->setText( QString::number(p_lon) );
393 if (p_tabWidget->tabText( p_tabWidget->currentIndex() ) ==
"Ground") {
394 p_lat = p_groundTab->p_latLineEdit->text().toDouble();
395 p_lon = p_groundTab->p_lonLineEdit->text().toDouble();
396 if (p_lat > 90 || p_lat < -90) {
397 QString mess = QString::number(p_lat) +
" is an invalid latitude value. "
398 +
"Please enter a latitude between -90 and 90.";
399 QMessageBox::warning((
QWidget *)parent(),
"Warning", mess);
404 else if (p_tabWidget->tabText( p_tabWidget->currentIndex() ) ==
"Image") {
405 p_line = p_imageTab->p_lineLineEdit->text().toDouble();
406 p_samp = p_imageTab->p_sampLineEdit->text().toDouble();
431 double line = p_line;
432 double samp = p_samp;
434 if (p_lat != DBL_MAX && p_lon != DBL_MAX) {
440 line = groundMap->
Line();
441 samp = groundMap->
Sample();
446 if (line != DBL_MAX && samp != DBL_MAX) {
476 if ( groundMap->
SetImage(samp, line) ) {
477 if (activeViewport->
camera() != NULL) {
519 double samp = p_samp;
520 double line = p_line;
524 if (p_lat != DBL_MAX && p_lon != DBL_MAX && groundMap) {
526 samp = groundMap->
Sample();
527 line = groundMap->
Line();
531 if (samp != DBL_MAX && line != DBL_MAX) {
539 pen.setStyle(Qt::SolidLine);
540 painter->setPen(pen);
541 painter->drawRoundedRect(x - 2, y - 2, 4, 4, 1, 1, Qt::RelativeSize);
550 p_pointVisible = !p_pointVisible;
553 if (p_pointVisible) {
554 p_togglePointVisibleButton->setChecked(
true);
555 p_togglePointVisibleButton->setToolTip(
"Hide red dot");
558 p_togglePointVisibleButton->setChecked(
false);
559 p_togglePointVisibleButton->setToolTip(
"Show red dot");
573 groundMap->setPriority(index);
597 bool syncScale = p_syncScale->isChecked();
613 if ( viewport == activeViewport ||
616 double otherViewportZoomFactor = viewport->
scale();
618 if ( groundMap && !IsSpecial(p_lat) && p_lat != DBL_MAX &&
619 !IsSpecial(p_lon) && p_lon != DBL_MAX &&
621 double samp = groundMap->
Sample();
622 double line = groundMap->
Line();
624 if ( viewportResolutionToMatch.
isValid() ) {
627 otherViewportZoomFactor = activeViewport->
scale() *
628 (otherViewportResolution / viewportResolutionToMatch);
631 if (p_lat != DBL_MAX && p_lon != DBL_MAX && groundMap) {
632 viewport->
setScale(otherViewportZoomFactor, samp, line);
636 if (p_line != DBL_MAX && p_samp != DBL_MAX) {
637 viewport->
setScale(otherViewportZoomFactor, p_samp, p_line);
661 double lat,
double lon) {
666 if (groundMap->
Camera() != NULL) {
674 if ( groundMap && !IsSpecial(lat) && !IsSpecial(lon) &&
675 lat != DBL_MAX && lon != DBL_MAX &&
679 double samp = groundMap->
Sample();
680 double line = groundMap->
Line();
682 if ( groundMap->
SetImage(samp - 0.5, line - 0.5) ) {
687 if ( groundMap->
SetImage(samp + 0.5, line + 0.5) ) {
705 catch (IException &e) {
710 QMessageBox::warning((
QWidget *)parent(),
"Warning", e.toString());
713 return viewportResolution;
724 vp->viewport()->repaint();
@ Degrees
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
double RaDecResolution()
Returns the RaDec resolution.
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
void cubeToViewport(double sample, double line, int &x, int &y) const
Turns a cube into a viewport.
void setScale(double scale)
Change the scale of the cube to the given parameter value.
UniversalGroundMap * universalGroundMap() const
Projection * projection() const
Distance measurement, usually in meters.
bool isValid() const
Test if this distance has been initialized or not.
@ Meters
The distance is being specified in meters.
QLineEdit * p_lonLineEdit
Input for longitude.
GroundTab(QWidget *parent=0)
The ground tab used by the dialog in the FindTool.
QLineEdit * p_latLineEdit
Input for latitude.
QLineEdit * p_sampLineEdit
Input for sample.
QLineEdit * p_lineLineEdit
Input for line.
ImageTab(QWidget *parent=0)
The image tab used by the dialog in the FindTool.
This class is designed to encapsulate the concept of a Latitude.
This class is designed to encapsulate the concept of a Longitude.
Cube display widget for certain Isis MDI applications.
void setLinked(bool b)
Change the linked state of the viewport.
bool isLinked() const
Is the viewport linked with other viewports.
virtual double RightAscension()
Returns the right ascension angle (sky longitude).
virtual double Declination()
Returns the declination angle (sky latitude).
virtual Target * target() const
Returns a pointer to the target object.
This class defines a body-fixed surface point.
Distance GetDistanceToPoint(const SurfacePoint &other) const
Computes and returns the distance between two surface points.
bool isSky() const
Return if our target is the sky.
double Sample() const
Returns the current line value of the camera model or projection.
double UniversalLongitude() const
Returns the universal longitude of the camera model or projection.
bool SetImage(double sample, double line)
Returns whether the sample/line postion was set successfully in the camera model or projection.
double Resolution() const
Returns the resolution of the camera model or projection.
double UniversalLatitude() const
Returns the universal latitude of the camera model or projection.
double Line() const
Returns the current line value of the camera model or projection.
double LocalRadius() const
Returns the radius of the camera model or projection.
bool SetUniversalGround(double lat, double lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
Isis::Camera * Camera() const
Return the camera associated with the ground map (NULL implies none)
This is free and unencumbered software released into the public domain.