1 #include "MosaicFindTool.h"     4 #include <QDoubleValidator>     5 #include <QGraphicsEllipseItem>     6 #include <QGraphicsScene>    11 #include <QMessageBox>    12 #include <QPushButton>    15 #include "FindSpotGraphicsItem.h"    16 #include "MosaicGraphicsView.h"    17 #include "MosaicSceneWidget.h"    40   void MosaicFindTool::getUserGroundPoint() {
    45     QValidator::State validLat =
    47     if(validLat != QValidator::Acceptable) {
    48       QMessageBox::warning(getWidget(), 
"Error",
    49                            "Latitude value must be in the range -90 to 90",
    50                            QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
    56     QValidator::State validLon =
    58     if(validLon != QValidator::Acceptable) {
    59       QMessageBox::warning(getWidget(), 
"Error",
    60                            "Longitude value must be a double",
    61                            QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
    65     double lat = IString(latitude.toStdString()).
ToDouble();
    66     double lon = IString(longitude.toStdString()).
ToDouble();
    68     Projection *projection = getWidget()->getProjection();
    72       TProjection *tproj = (TProjection *) projection;
    73       if (tproj->SetGround(lat, lon)) {
    74         QPointF scenePos(projection->XCoord(), -1 * projection->YCoord());
    75         QRectF sceneRect(getWidget()->getView()->sceneRect());
    77         if (sceneRect.contains(scenePos)) {
    78           if(p_findSpot != NULL) {
    82           p_findSpot = 
new FindSpotGraphicsItem(scenePos, getWidget());
    84           getWidget()->getScene()->addItem(p_findSpot);
    85           getWidget()->getView()->centerOn(scenePos);
    88           QString message = 
"Lat/Lon not within this view.";
    89           QMessageBox::information(getWidget(), 
"Point Not Found",
    90                                    message, QMessageBox::Ok);
   107     p_action->setIcon(
getIcon(
"find.png"));
   108     p_action->setToolTip(
"Find (f)");
   109     p_action->setShortcut(Qt::Key_F);
   111       "<b>Function:</b>  Find a specific latitude/longitude on the mosaic "   113       "This tool allows you to type in a latitude and longitude, in the "   114       "projection's native units, and that point will be centered and given "   115       "a red dot on the mosaic scene. Alternatively, you can <b>click</b> on "   116       "the mosaic scene and it will give you the latitude and longitude values "   117       "along with drawing the red dot."   118       "<p><b>Shortcut:</b>  f</p> ";
   119     p_action->setWhatsThis(text);
   126     p_latLineEdit->setValidator(
new QDoubleValidator(-90.0, 90.0, 99, 
this));
   131     QLabel *latLabel = 
new QLabel(
"Latitude");
   132     QLabel *lonLabel = 
new QLabel(
"Longitude");
   135     QPushButton *okButton = 
new QPushButton(
"Go to Point");
   136     connect(okButton, SIGNAL(clicked()), 
this, SLOT(getUserGroundPoint()));
   138     QPushButton *clearButton = 
new QPushButton(
"Clear Point");
   139     connect(clearButton, SIGNAL(clicked()), 
this, SLOT(clearPoint()));
   142     QHBoxLayout *actionLayout = 
new QHBoxLayout();
   143     actionLayout->addWidget(latLabel);
   145     actionLayout->addWidget(lonLabel);
   147     actionLayout->addWidget(okButton);
   148     actionLayout->addWidget(clearButton);
   149     actionLayout->addStretch(1);
   150     actionLayout->setMargin(0);
   153     toolBarWidget->setLayout(actionLayout);
   155     return toolBarWidget;
   170   PvlObject MosaicFindTool::toPvl()
 const {
   181   void MosaicFindTool::fromPvl(
const PvlObject &obj) {
   184     if(
toBool(obj[
"Visible"][0])) {
   185       getUserGroundPoint();
   190   QString MosaicFindTool::projectPvlObjectName()
 const {
   191     return "MosaicFindTool";
   209   void MosaicFindTool::mouseButtonRelease(QPointF mouseLoc, Qt::MouseButton s) {
   213     if(s == Qt::LeftButton) {
   214       Projection *proj = getWidget()->getProjection();
   219         if (tproj && getWidget()->getView()->sceneRect().contains(mouseLoc)) {
   221             if (p_findSpot != NULL) {
   225             p_findSpot = 
new FindSpotGraphicsItem(mouseLoc, getWidget());
   227             getWidget()->getScene()->addItem(p_findSpot);
   242   void MosaicFindTool::clearPoint() {
   243     if(p_findSpot != NULL) {
   244       getWidget()->getScene()->removeItem(p_findSpot);
 
ProjectionType projectionType() const
Returns an enum value for the projection type. 
 
Base class for Map TProjections. 
 
QString toString(bool boolToConvert)
Global function to convert a boolean to a string. 
 
Base class for Map Projections. 
 
double Longitude() const
This returns a longitude with correct longitude direction and domain as specified in the label object...
 
A single keyword-value pair. 
 
double ToDouble(const T &value)
Helper function to convert values to doubles. 
 
virtual bool SetCoordinate(const double x, const double y)
This method is used to set the projection x/y. 
 
bool toBool(const QString &string)
Global function to convert from a string to a boolean. 
 
double Latitude() const
This returns a latitude with correct latitude type as specified in the label object. 
 
Namespace for ISIS/Bullet specific routines. 
 
Contains Pvl Groups and Pvl Objects. 
 
ProjectionType
This enum defines the subclasses of Projection supported in Isis. 
 
These projections are used to map triaxial and irregular-shaped bodies.