22#include "MainWindow.h" 
   23#include "MdiCubeViewport.h" 
   24#include "Projection.h" 
   25#include "SurfacePoint.h" 
   28#include "UniversalGroundMap.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) {
 
  434      cvp->cubeToViewport(samp, line, x, y);
 
 
  453    activeViewport->viewportToCube(p.x(), p.y(), samp, line);
 
  461      if ( groundMap->
SetImage(samp, line) ) {
 
  462        if (activeViewport->camera() != NULL) {
 
  463          if (activeViewport->camera()->target()->isSky()) {
 
  464            p_lat = activeViewport->camera()->Declination();
 
  465            p_lon = activeViewport->camera()->RightAscension();
 
 
  504      double samp = p_samp;
 
  505      double line = p_line;
 
  509      if (p_lat != DBL_MAX && p_lon != DBL_MAX && groundMap) {
 
  511          samp = groundMap->
Sample();
 
  512          line = groundMap->
Line();
 
  516      if (samp != DBL_MAX && line != DBL_MAX) {
 
  519        vp->cubeToViewport(samp, line, x, y);
 
  524        pen.setStyle(Qt::SolidLine);
 
  525        painter->setPen(pen);
 
  526        painter->drawRoundRect(x - 2, y - 2, 4, 4);
 
 
  535    p_pointVisible = !p_pointVisible;
 
  538    if (p_pointVisible) {
 
  539      p_togglePointVisibleButton->setChecked(
true);
 
  540      p_togglePointVisibleButton->setToolTip(
"Hide red dot");
 
  543      p_togglePointVisibleButton->setChecked(
false);
 
  544      p_togglePointVisibleButton->setToolTip(
"Show red dot");
 
 
  569    bool syncScale = p_syncScale->isChecked();
 
  585      if ( viewport == activeViewport ||
 
  586           ( activeViewport->isLinked() && viewport->
isLinked() ) ) {
 
  588        double otherViewportZoomFactor = viewport->
scale();
 
  590        if ( groundMap && !
IsSpecial(p_lat) && p_lat != DBL_MAX &&
 
  593          double samp = groundMap->
Sample();
 
  594          double line = groundMap->
Line();
 
  596          if ( viewportResolutionToMatch.isValid() ) {
 
  599            otherViewportZoomFactor = activeViewport->scale() *
 
  600                (otherViewportResolution / viewportResolutionToMatch);
 
  603          if (p_lat != DBL_MAX && p_lon != DBL_MAX && groundMap) {
 
  604            viewport->
setScale(otherViewportZoomFactor, samp, line);
 
  608        if (p_line != DBL_MAX && p_samp != DBL_MAX) {
 
  609          viewport->
setScale(otherViewportZoomFactor, p_samp, p_line);
 
 
  633                                      double lat, 
double lon) {
 
  636    if (viewport->
camera() != NULL){
 
  644           lat != DBL_MAX && lon != DBL_MAX &&
 
  648        double samp = groundMap->
Sample();
 
  649        double line = groundMap->
Line();
 
  651        if ( groundMap->
SetImage(samp - 0.5, line - 0.5) ) {
 
  655          if ( groundMap->
SetImage(samp + 0.5, line + 0.5) ) {
 
  671            viewportResolution = point1.GetDistanceToPoint(point2);
 
  681      QMessageBox::warning((
QWidget *)parent(), 
"Warning", e.toString());
 
  684    return viewportResolution;
 
 
  694      if ( vp == activeVp || (activeVp->isLinked() && vp->isLinked() ) )
 
  695        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 setScale(double scale)
Change the scale of the cube to the given parameter value.
 
UniversalGroundMap * universalGroundMap() const
 
Distance measurement, usually in meters.
 
@ Meters
The distance is being specified in meters.
 
double meters() const
Get the distance 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.
 
Distance LocalRadius() const
Returns the local radius at the intersection point.
 
virtual Target * target() const
Returns a pointer to the target object.
 
This class defines a body-fixed surface point.
 
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.
 
bool HasProjection()
Returns whether the ground map has a projection or not.
 
bool SetUniversalGround(double lat, double lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
 
Isis::Projection * Projection() const
Return the projection associated with the ground map (NULL implies none)
 
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.
 
bool IsSpecial(const double d)
Returns if the input pixel is special.