3 #include <QApplication> 11 #include <QMessageBox> 12 #include <QPushButton> 13 #include <QToolButton> 22 #include "MainWindow.h" 41 p_showDialogButton = NULL;
42 p_linkViewportsButton = NULL;
53 p_pointVisible =
true;
59 p_findPoint =
new QAction(parent);
60 p_findPoint->setShortcut(Qt::CTRL + Qt::Key_F);
61 p_findPoint->setText(
"&Find Point");
62 p_findPoint->setIcon( QPixmap(
toolIconDir() +
"/find.png") );
64 "<b>Function:</b> Centers all linked viewports to the selected lat/lon. \ 65 The user can click anywhere on the image to have that point centered, or \ 66 they can use the shortcut or button to bring up a window that they can \ 67 enter a specific lat/lon position into. \ 68 <p><b>Shortcut: </b> Ctrl+F </p> \ 69 <p><b>Hint: </b> This option will only work if the image has a camera \ 70 model or is projected, and will only center the point on images \ 71 where the selected lat/lon position exists.</p>";
72 p_findPoint->setWhatsThis(text);
73 p_findPoint->setEnabled(
false);
74 connect( p_findPoint, SIGNAL( triggered() ),
75 p_dialog, SLOT( show() ) );
78 FindTool::~FindTool() {
91 p_tabWidget =
new QTabWidget(p_dialog);
92 p_dialog->setWindowTitle(
"Find Latitude/Longitude Coordinate");
96 p_tabWidget->addTab(p_imageTab,
"Image");
97 p_tabWidget->addTab(p_groundTab,
"Ground");
100 QPushButton *okButton =
new QPushButton(
"Ok");
101 connect( okButton, SIGNAL( clicked() ),
104 QPushButton *recordButton =
new QPushButton(
"Record Point");
105 connect( recordButton, SIGNAL( clicked() ),
108 QPushButton *closeButton =
new QPushButton(
"Close");
109 connect( closeButton, SIGNAL( clicked() ),
110 p_dialog, SLOT( hide() ) );
113 QHBoxLayout *actionLayout =
new QHBoxLayout();
114 actionLayout->addWidget(okButton);
115 actionLayout->addWidget(recordButton);
116 actionLayout->addWidget(closeButton);
118 QVBoxLayout *dialogLayout =
new QVBoxLayout;
119 dialogLayout->addWidget(p_tabWidget);
120 dialogLayout->addLayout(actionLayout);
121 p_dialog->setLayout(dialogLayout);
133 p_latLineEdit->setValidator(
new QDoubleValidator(-90.0, 90.0, 99, parent) );
137 QLabel *latLabel =
new QLabel(
"Latitude");
138 QLabel *lonLabel =
new QLabel(
"Longitude");
141 QGridLayout *gridLayout =
new QGridLayout();
142 gridLayout->addWidget(latLabel, 0, 0);
144 gridLayout->addWidget(lonLabel, 1, 0);
146 setLayout(gridLayout);
160 QLabel *sampleLabel =
new QLabel(
"Sample");
161 QLabel *lineLabel =
new QLabel(
"Line");
164 QGridLayout *gridLayout =
new QGridLayout();
165 gridLayout->addWidget(sampleLabel, 0, 0);
167 gridLayout->addWidget(lineLabel, 1, 0);
169 setLayout(gridLayout);
182 action->setIcon( QPixmap(
toolIconDir() +
"/find.png") );
183 action->setToolTip(
"Find (F)");
184 action->setShortcut(Qt::Key_F);
186 "<b>Function:</b> Find a lat/lon or line/sample coordinate in this cube. \ 187 <p><b>Shortcut:</b>F</p> ";
188 action->setWhatsThis(text);
199 menu->addAction(p_findPoint);
213 p_showDialogButton =
new QToolButton(hbox);
214 p_showDialogButton->setIcon( QPixmap(
toolIconDir() +
"/find.png") );
215 p_showDialogButton->setToolTip(
"Find Point");
217 "<b>Function:</b> Centers all linked viewports to the selected lat/lon. \ 218 The user can click anywhere on the image to have that point centered, or \ 219 they can use the shortcut or button to bring up a window that they can \ 220 enter a specific lat/lon position into. \ 221 <p><b>Shortcut: </b> Ctrl+F </p> \ 222 <p><b>Hint: </b> This option will only work if the image has a camera \ 223 model or is projected, and will only center the point on images \ 224 where the selected lat/lon position exists.</p>";
225 p_showDialogButton->setWhatsThis(text);
226 connect( p_showDialogButton, SIGNAL( clicked() ),
227 p_dialog, SLOT( show() ) );
228 p_showDialogButton->setAutoRaise(
true);
229 p_showDialogButton->setIconSize( QSize(22, 22) );
231 p_syncScale =
new QCheckBox(
"Sync Scale");
232 p_syncScale->setChecked(
true);
233 p_syncScale->setToolTip(
"Synchronize Scale");
234 text =
"<b>Function:</b> Syncronizes the scale of all linked viewports.";
235 p_syncScale->setWhatsThis(text);
237 p_linkViewportsButton =
new QToolButton(hbox);
238 p_linkViewportsButton->setIcon( QPixmap(
toolIconDir() +
"/link_valid.png") );
239 p_linkViewportsButton->setToolTip(
"Link Georeferenced Images");
240 p_linkViewportsButton->setWhatsThis(
"<b>Function: </b> Links all open images that have\ 241 a camera model or are map projections");
242 connect( p_linkViewportsButton, SIGNAL( clicked() ),
244 p_linkViewportsButton->setAutoRaise(
true);
245 p_linkViewportsButton->setIconSize( QSize(22, 22) );
247 p_togglePointVisibleButton =
new QToolButton(hbox);
248 p_togglePointVisibleButton->setIcon( QPixmap(
toolIconDir() +
"/redDot.png") );
249 p_togglePointVisibleButton->setToolTip(
"Hide red dot");
250 p_togglePointVisibleButton->setCheckable(
true);
251 p_togglePointVisibleButton->setChecked(
true);
252 connect( p_togglePointVisibleButton, SIGNAL( clicked() ),
255 p_statusEdit =
new QLineEdit();
256 p_statusEdit->setReadOnly(
true);
257 p_statusEdit->setToolTip(
"Cube Type");
258 p_statusEdit->setWhatsThis(
"<b>Function: </b> Displays whether the active cube \ 259 is a camera model, projection, both, or none. <p> \ 260 <b>Hint: </b> If the cube is 'None' the find tool \ 261 will not be active</p>");
263 QHBoxLayout *layout =
new QHBoxLayout(hbox);
264 layout->setMargin(0);
265 layout->addWidget(p_statusEdit);
266 layout->addWidget(p_showDialogButton);
267 layout->addWidget(p_linkViewportsButton);
268 layout->addWidget(p_togglePointVisibleButton);
269 layout->addWidget(p_syncScale);
270 layout->addStretch(1);
271 hbox->setLayout(layout);
291 if (activeViewport == NULL) {
292 p_linkViewportsButton->setEnabled(
false);
293 p_findPoint->setEnabled(
false);
294 p_showDialogButton->setEnabled(
false);
295 p_syncScale->setEnabled(
false);
296 p_statusEdit->setText(
"None");
297 if ( p_dialog->isVisible() ) {
302 p_findPoint->setEnabled(
true);
303 p_showDialogButton->setEnabled(
true);
304 p_statusEdit->setText(
"None");
307 p_linkViewportsButton->setEnabled(
true);
308 p_syncScale->setEnabled(
true);
311 p_linkViewportsButton->setEnabled(
false);
312 p_syncScale->setEnabled(
false);
315 if (activeViewport->
camera() != NULL) {
316 p_statusEdit->setText(
"Camera");
318 p_statusEdit->setText(
"Both");
321 else if (activeViewport->
projection() != NULL) {
322 p_statusEdit->setText(
"Projection");
330 if (p_samp != DBL_MAX && p_line != DBL_MAX) {
331 if ( groundMap && groundMap->
SetImage(p_samp, p_line) ) {
345 else if (p_lat != DBL_MAX && p_lon != DBL_MAX) {
348 QString lineStr = QString::number( groundMap->
Line() );
349 QString sampStr = QString::number( groundMap->
Sample() );
358 p_groundTab->
p_latLineEdit->setText( QString::number(p_lat) );
359 p_groundTab->
p_lonLineEdit->setText( QString::number(p_lon) );
378 if (p_tabWidget->tabText( p_tabWidget->currentIndex() ) ==
"Ground") {
381 if (p_lat > 90 || p_lat < -90) {
382 QString mess = QString::number(p_lat) +
" is an invalid latitude value. " 383 +
"Please enter a latitude between -90 and 90.";
384 QMessageBox::warning((
QWidget *)parent(),
"Warning", mess);
389 else if (p_tabWidget->tabText( p_tabWidget->currentIndex() ) ==
"Image") {
416 double line = p_line;
417 double samp = p_samp;
419 if (p_lat != DBL_MAX && p_lon != DBL_MAX) {
425 line = groundMap->
Line();
426 samp = groundMap->
Sample();
431 if (line != DBL_MAX && samp != DBL_MAX) {
461 if ( groundMap->
SetImage(samp, line) ) {
492 double samp = p_samp;
493 double line = p_line;
497 if (p_lat != DBL_MAX && p_lon != DBL_MAX && groundMap) {
499 samp = groundMap->
Sample();
500 line = groundMap->
Line();
504 if (samp != DBL_MAX && line != DBL_MAX) {
512 pen.setStyle(Qt::SolidLine);
513 painter->setPen(pen);
514 painter->drawRoundRect(x - 2, y - 2, 4, 4);
523 p_pointVisible = !p_pointVisible;
526 if (p_pointVisible) {
527 p_togglePointVisibleButton->setChecked(
true);
528 p_togglePointVisibleButton->setToolTip(
"Hide red dot");
531 p_togglePointVisibleButton->setChecked(
false);
532 p_togglePointVisibleButton->setToolTip(
"Show red dot");
557 bool syncScale = p_syncScale->isChecked();
573 if ( viewport == activeViewport ||
576 double otherViewportZoomFactor = viewport->
scale();
578 if ( groundMap && !
IsSpecial(p_lat) && p_lat != DBL_MAX &&
581 double samp = groundMap->
Sample();
582 double line = groundMap->
Line();
584 if ( viewportResolutionToMatch.
isValid() ) {
587 otherViewportZoomFactor = activeViewport->
scale() *
588 (otherViewportResolution / viewportResolutionToMatch);
591 if (p_lat != DBL_MAX && p_lon != DBL_MAX && groundMap) {
592 viewport->
setScale(otherViewportZoomFactor, samp, line);
596 if (p_line != DBL_MAX && p_samp != DBL_MAX) {
597 viewport->
setScale(otherViewportZoomFactor, p_samp, p_line);
621 double lat,
double lon) {
627 lat != DBL_MAX && lon != DBL_MAX &&
631 double samp = groundMap->
Sample();
632 double line = groundMap->
Line();
634 if ( groundMap->
SetImage(samp - 0.5, line - 0.5) ) {
638 if ( groundMap->
SetImage(samp + 0.5, line + 0.5) ) {
667 return viewportResolution;
678 vp->viewport()->repaint();
This class defines a body-fixed surface point.
Cube display widget for certain Isis MDI applications.
double meters() const
Get the distance in meters.
ImageTab(QWidget *parent=0)
The image tab used by the dialog in the FindTool.
double Line() const
Returns the current line value of the camera model or projection.
Distance GetDistanceToPoint(const SurfacePoint &other) const
Computes and returns the distance between two surface points.
QLineEdit * p_lineLineEdit
Input for line.
void setScale(double scale)
Change the scale of the cube to the given parameter value.
This class is designed to encapsulate the concept of a Latitude.
QLineEdit * p_sampLineEdit
Input for sample.
void cubeToViewport(double sample, double line, int &x, int &y) const
Turns a cube into a viewport.
QLineEdit * p_latLineEdit
Input for latitude.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Distance measurement, usually in meters.
void setLinked(bool b)
Change the linked state of the viewport.
Distance LocalRadius() const
Returns the local radius at the intersection point.
This class is designed to encapsulate the concept of a Longitude.
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
UniversalGroundMap * universalGroundMap() const
Isis::Projection * Projection() const
Return the projection associated with the ground map (NULL implies none)
double UniversalLatitude() const
Returns the universal latitude of the camera model or projection.
bool IsSpecial(const double d)
Returns if the input pixel is special.
bool isLinked() const
Is the viewport linked with other viewports.
bool isValid() const
Test if this distance has been initialized or not.
GroundTab(QWidget *parent=0)
The ground tab used by the dialog in the FindTool.
QLineEdit * p_lonLineEdit
Input for longitude.
bool SetImage(double sample, double line)
Returns whether the sample/line postion was set successfully in the camera model or projection...
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
QString toString() const
Returns a string representation of this exception.
Namespace for ISIS/Bullet specific routines.
Isis::Camera * Camera() const
Return the camera associated with the ground map (NULL implies none)
Projection * projection() const
bool SetUniversalGround(double lat, double lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
The distance is being specified in meters.
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.
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
double Resolution() const
Returns the resolution of the camera model or projection.
bool HasProjection()
Returns whether the ground map has a projection or not.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.