3 #include <QApplication>
10 #include <QMessageBox>
11 #include <QPushButton>
20 #include "MainWindow.h"
39 p_showDialogButton = NULL;
40 p_linkViewportsButton = NULL;
51 p_pointVisible =
true;
57 p_findPoint =
new QAction(parent);
58 p_findPoint->setShortcut(Qt::CTRL + Qt::Key_F);
59 p_findPoint->setText(
"&Find Point");
60 p_findPoint->setIcon( QPixmap(
toolIconDir() +
"/find.png") );
62 "<b>Function:</b> Centers all linked viewports to the selected lat/lon. \
63 The user can click anywhere on the image to have that point centered, or \
64 they can use the shortcut or button to bring up a window that they can \
65 enter a specific lat/lon position into. \
66 <p><b>Shortcut: </b> Ctrl+F </p> \
67 <p><b>Hint: </b> This option will only work if the image has a camera \
68 model or is projected, and will only center the point on images \
69 where the selected lat/lon position exists.</p>";
70 p_findPoint->setWhatsThis(text);
71 p_findPoint->setEnabled(
false);
72 connect( p_findPoint, SIGNAL( triggered() ),
73 p_dialog, SLOT( show() ) );
76 FindTool::~FindTool() {
89 p_tabWidget =
new QTabWidget(p_dialog);
90 p_dialog->setWindowTitle(
"Find Latitude/Longitude Coordinate");
94 p_tabWidget->addTab(p_imageTab,
"Image");
95 p_tabWidget->addTab(p_groundTab,
"Ground");
98 QPushButton *okButton =
new QPushButton(
"Ok");
99 connect( okButton, SIGNAL( clicked() ),
102 QPushButton *recordButton =
new QPushButton(
"Record Point");
103 connect( recordButton, SIGNAL( clicked() ),
106 QPushButton *closeButton =
new QPushButton(
"Close");
107 connect( closeButton, SIGNAL( clicked() ),
108 p_dialog, SLOT( hide() ) );
111 QHBoxLayout *actionLayout =
new QHBoxLayout();
112 actionLayout->addWidget(okButton);
113 actionLayout->addWidget(recordButton);
114 actionLayout->addWidget(closeButton);
116 QVBoxLayout *dialogLayout =
new QVBoxLayout;
117 dialogLayout->addWidget(p_tabWidget);
118 dialogLayout->addLayout(actionLayout);
119 p_dialog->setLayout(dialogLayout);
131 p_latLineEdit->setValidator(
new QDoubleValidator(-90.0, 90.0, 99, parent) );
135 QLabel *latLabel =
new QLabel(
"Latitude");
136 QLabel *lonLabel =
new QLabel(
"Longitude");
139 QGridLayout *gridLayout =
new QGridLayout();
140 gridLayout->addWidget(latLabel, 0, 0);
142 gridLayout->addWidget(lonLabel, 1, 0);
144 setLayout(gridLayout);
158 QLabel *sampleLabel =
new QLabel(
"Sample");
159 QLabel *lineLabel =
new QLabel(
"Line");
162 QGridLayout *gridLayout =
new QGridLayout();
163 gridLayout->addWidget(sampleLabel, 0, 0);
165 gridLayout->addWidget(lineLabel, 1, 0);
167 setLayout(gridLayout);
180 action->setIcon( QPixmap(
toolIconDir() +
"/find.png") );
181 action->setToolTip(
"Find (F)");
182 action->setShortcut(Qt::Key_F);
184 "<b>Function:</b> Find a lat/lon or line/sample coordinate in this cube. \
185 <p><b>Shortcut:</b>F</p> ";
186 action->setWhatsThis(text);
197 menu->addAction(p_findPoint);
211 p_showDialogButton =
new QToolButton(hbox);
212 p_showDialogButton->setIcon( QPixmap(
toolIconDir() +
"/find.png") );
213 p_showDialogButton->setToolTip(
"Find Point");
215 "<b>Function:</b> Centers all linked viewports to the selected lat/lon. \
216 The user can click anywhere on the image to have that point centered, or \
217 they can use the shortcut or button to bring up a window that they can \
218 enter a specific lat/lon position into. \
219 <p><b>Shortcut: </b> Ctrl+F </p> \
220 <p><b>Hint: </b> This option will only work if the image has a camera \
221 model or is projected, and will only center the point on images \
222 where the selected lat/lon position exists.</p>";
223 p_showDialogButton->setWhatsThis(text);
224 connect( p_showDialogButton, SIGNAL( clicked() ),
225 p_dialog, SLOT( show() ) );
226 p_showDialogButton->setAutoRaise(
true);
227 p_showDialogButton->setIconSize( QSize(22, 22) );
229 p_syncScale =
new QCheckBox(
"Sync Scale");
230 p_syncScale->setChecked(
true);
231 p_syncScale->setToolTip(
"Synchronize Scale");
232 text =
"<b>Function:</b> Syncronizes the scale of all linked viewports.";
233 p_syncScale->setWhatsThis(text);
235 p_linkViewportsButton =
new QToolButton(hbox);
236 p_linkViewportsButton->setIcon( QPixmap(
toolIconDir() +
"/link_valid.png") );
237 p_linkViewportsButton->setToolTip(
"Link Georeferenced Images");
238 p_linkViewportsButton->setWhatsThis(
"<b>Function: </b> Links all open images that have\
239 a camera model or are map projections");
240 connect( p_linkViewportsButton, SIGNAL( clicked() ),
242 p_linkViewportsButton->setAutoRaise(
true);
243 p_linkViewportsButton->setIconSize( QSize(22, 22) );
245 p_togglePointVisibleButton =
new QToolButton(hbox);
246 p_togglePointVisibleButton->setIcon( QPixmap(
toolIconDir() +
"/redDot.png") );
247 p_togglePointVisibleButton->setToolTip(
"Hide red dot");
248 p_togglePointVisibleButton->setCheckable(
true);
249 p_togglePointVisibleButton->setChecked(
true);
250 connect( p_togglePointVisibleButton, SIGNAL( clicked() ),
253 p_statusEdit =
new QLineEdit();
254 p_statusEdit->setReadOnly(
true);
255 p_statusEdit->setToolTip(
"Cube Type");
256 p_statusEdit->setWhatsThis(
"<b>Function: </b> Displays whether the active cube \
257 is a camera model, projection, both, or none. <p> \
258 <b>Hint: </b> If the cube is 'None' the find tool \
259 will not be active</p>");
261 QHBoxLayout *layout =
new QHBoxLayout(hbox);
262 layout->setMargin(0);
263 layout->addWidget(p_statusEdit);
264 layout->addWidget(p_showDialogButton);
265 layout->addWidget(p_linkViewportsButton);
266 layout->addWidget(p_togglePointVisibleButton);
267 layout->addWidget(p_syncScale);
268 layout->addStretch(1);
269 hbox->setLayout(layout);
289 if (activeViewport == NULL) {
290 p_linkViewportsButton->setEnabled(
false);
291 p_findPoint->setEnabled(
false);
292 p_showDialogButton->setEnabled(
false);
293 p_syncScale->setEnabled(
false);
294 p_statusEdit->setText(
"None");
295 if ( p_dialog->isVisible() ) {
300 p_findPoint->setEnabled(
true);
301 p_showDialogButton->setEnabled(
true);
302 p_statusEdit->setText(
"None");
305 p_linkViewportsButton->setEnabled(
true);
306 p_syncScale->setEnabled(
true);
309 p_linkViewportsButton->setEnabled(
false);
310 p_syncScale->setEnabled(
false);
313 if (activeViewport->
camera() != NULL) {
314 p_statusEdit->setText(
"Camera");
316 p_statusEdit->setText(
"Both");
319 else if (activeViewport->
projection() != NULL) {
320 p_statusEdit->setText(
"Projection");
328 if (p_samp != DBL_MAX && p_line != DBL_MAX) {
329 if ( groundMap && groundMap->
SetImage(p_samp, p_line) ) {
343 else if (p_lat != DBL_MAX && p_lon != DBL_MAX) {
346 QString lineStr = QString::number( groundMap->
Line() );
347 QString sampStr = QString::number( groundMap->
Sample() );
356 p_groundTab->
p_latLineEdit->setText( QString::number(p_lat) );
357 p_groundTab->
p_lonLineEdit->setText( QString::number(p_lon) );
376 if (p_tabWidget->tabText( p_tabWidget->currentIndex() ) ==
"Ground") {
380 else if (p_tabWidget->tabText( p_tabWidget->currentIndex() ) ==
"Image") {
407 double line = p_line;
408 double samp = p_samp;
410 if (p_lat != DBL_MAX && p_lon != DBL_MAX) {
416 line = groundMap->
Line();
417 samp = groundMap->
Sample();
422 if (line != DBL_MAX && samp != DBL_MAX) {
452 if ( groundMap->
SetImage(samp, line) ) {
483 double samp = p_samp;
484 double line = p_line;
488 if (p_lat != DBL_MAX && p_lon != DBL_MAX && groundMap) {
490 samp = groundMap->
Sample();
491 line = groundMap->
Line();
495 if (samp != DBL_MAX && line != DBL_MAX) {
503 pen.setStyle(Qt::SolidLine);
504 painter->setPen(pen);
505 painter->drawRoundRect(x - 2, y - 2, 4, 4);
514 p_pointVisible = !p_pointVisible;
517 if (p_pointVisible) {
518 p_togglePointVisibleButton->setChecked(
true);
519 p_togglePointVisibleButton->setToolTip(
"Hide red dot");
522 p_togglePointVisibleButton->setChecked(
false);
523 p_togglePointVisibleButton->setToolTip(
"Show red dot");
548 bool syncScale = p_syncScale->isChecked();
564 if ( viewport == activeViewport ||
567 double otherViewportZoomFactor = viewport->
scale();
569 if ( groundMap && !
IsSpecial(p_lat) && p_lat != DBL_MAX &&
572 double samp = groundMap->
Sample();
573 double line = groundMap->
Line();
575 if ( viewportResolutionToMatch.
isValid() ) {
578 otherViewportZoomFactor = activeViewport->
scale() *
579 (otherViewportResolution / viewportResolutionToMatch);
582 if (p_lat != DBL_MAX && p_lon != DBL_MAX && groundMap) {
583 viewport->
setScale(otherViewportZoomFactor, samp, line);
587 if (p_line != DBL_MAX && p_samp != DBL_MAX) {
588 viewport->
setScale(otherViewportZoomFactor, p_samp, p_line);
612 double lat,
double lon)
const {
617 lat != DBL_MAX && lon != DBL_MAX &&
621 double samp = groundMap->
Sample();
622 double line = groundMap->
Line();
624 if ( groundMap->
SetImage(samp - 0.5, line - 0.5) ) {
628 if ( groundMap->
SetImage(samp + 0.5, line + 0.5) ) {
649 return viewportResolution;
660 vp->viewport()->repaint();