9#include "AdvancedTrackTool.h"
12#include <QApplication>
14#include <QListIterator>
21#include <QTableWidget>
22#include <QTableWidgetItem>
28#include "CameraDistortionMap.h"
29#include "CameraFocalPlaneMap.h"
33#include "MdiCubeViewport.h"
34#include "Projection.h"
35#include "RingPlaneProjection.h"
36#include "SerialNumber.h"
37#include "SpecialPixel.h"
38#include "TableMainWindow.h"
40#include "TProjection.h"
41#include "TrackingTable.h"
46#define FLOAT_MIN -16777215
61 p_action->setShortcut(Qt::CTRL + Qt::Key_T);
62 p_action->setWhatsThis(
"<b>Function: </b> Opens the Advanced Tracking Tool \
63 window. This window will track sample/line positions,\
64 lat/lon positions, and many other pieces of \
65 information. All of the data in the window can be \
66 saved to a text file. <p><b>Shortcut: </b> Ctrl+T</p>");
77 for (iter = checkBoxItems.begin(); iter != checkBoxItems.end(); ++iter) {
79 QString header = currentList[0];
80 QString menuText = currentList[2];
81 QString toolTip = currentList[3];
83 if (currentList[1] == QString(
"true")) {
90 if (toolTip != QString(
"")) {
91 p_tableWin->addToTable(onByDefault, header, menuText,
92 -1, Qt::Horizontal, toolTip);
95 p_tableWin->addToTable(onByDefault, header, menuText);
104 for(
int r = 0; r < 10; r++) {
106 for(
int c = 0; c <
p_tableWin->table()->columnCount(); c++) {
107 QTableWidgetItem *item =
new QTableWidgetItem(
"");
114 recordAction->setShortcut(Qt::Key_R);
115 parent->addAction(recordAction);
116 connect(recordAction, SIGNAL(triggered()),
this, SLOT(
record()));
117 p_tableWin->setStatusMessage(
"To record press the R key"
118 " --- Double click on a cell to enable crtl+c (copy) and"
123 QMenu *helpMenu = menuBar->addMenu(
"&Help");
125 help->setText(
"&Tool Help");
126 help->setShortcut(Qt::CTRL + Qt::Key_H);
127 connect(help, SIGNAL(triggered()),
this, SLOT(
helpDialog()));
128 helpMenu->addAction(help);
145 if(e->type() == QEvent::Show) {
153 else if(e->type() == QEvent::Hide) {
156 return Tool::eventFilter(o, e);
247 for (iter = checkBoxItems.begin(); iter != checkBoxItems.end(); ++iter) {
251 for (headerIter = splitHeader.begin(); headerIter != splitHeader.end(); ++headerIter) {
252 QString header = *headerIter;
253 if (header.toLower() == keyword.toLower()) {
259 IString msg =
"Header [" + keyword +
"] not found; make sure spelling is correct";
274 int isample = int (sample + 0.5);
275 int iline = int (line + 0.5);
289 if(row + 1 >
p_tableWin->table()->rowCount()) {
291 for(
int c = 0; c <
p_tableWin->table()->columnCount(); c++) {
292 QTableWidgetItem *item =
new QTableWidgetItem(
"");
294 if(c == 0)
p_tableWin->table()->scrollToItem(item);
299 for(
int c = 0; c <
p_tableWin->table()->columnCount(); c++) {
300 p_tableWin->table()->item(row, c)->setText(
"");
304 if(sample < 0.5)
return;
305 if(line < 0.5)
return;
307 if(line > cvp->
cubeLines() + 0.5)
return;
324 QString fnamePath = fname.
path();
325 QString fnameName = fname.
name();
333 if((sample < 0.5) || (line < 0.5) ||
350 if(cvp->
camera() != NULL) {
356 setText(QString::number(ra,
'f', 15));
358 setText(QString::number(dec,
'f', 15));
367 setText(QString::number(lat,
'f', 15));
369 setText(QString::number(lon,
'f', 15));
371 setText(QString::number(radius,
'f', 15));
379 while(lon < 0.0) lon += 360.0;
384 setText(QString::number(lat,
'f', 15));
386 setText(QString::number(lon,
'f', 15));
395 p_tableWin->table()->item(row,
getIndex(
"Point X"))->setText(QString::number(pos[0]));
396 p_tableWin->table()->item(row,
getIndex(
"Point Y"))->setText(QString::number(pos[1]));
397 p_tableWin->table()->item(row,
getIndex(
"Point Z"))->setText(QString::number(pos[2]));
402 p_tableWin->table()->item(row,
getIndex(
"Resolution"))->setText(QString::number(res));
412 setText(QString::number(obliquePRes));
422 p_tableWin->table()->item(row,
getIndex(
"Incidence"))->setText(QString::number(incidence));
424 p_tableWin->table()->item(row,
getIndex(
"Emission"))->setText(QString::number(emission));
430 Angle phaseAngle, incidenceAngle, emissionAngle;
431 bool bSuccess =
false;
435 setText(QString::number(incidenceAngle.
degrees()));
437 setText(QString::number(emissionAngle.
degrees()));
450 setText(QString::number(northAzi));
461 setText(QString::number(sunAzi));
475 setText(QString::number(spacecraftAzi));
485 setText(QString::number(solarLon));
494 setText(QString::number(slantDistance));
498 setText(QString::number(lst));
513 setText(QString::number(undistortedFocalPlaneX));
516 setText(QString::number(undistortedFocalPlaneY));
519 setText(QString::number(undistortedFocalPlaneZ));
533 double distortedFocalPlaneX = focalPlaneMap->
FocalPlaneX();
535 setText(QString::number(distortedFocalPlaneX));
536 double distortedFocalPlaneY = focalPlaneMap->
FocalPlaneY();
538 setText(QString::number(distortedFocalPlaneY));
550 p_tableWin->table()->item(row,
getIndex(
"Right Ascension"))->setText(QString::number(ra));
552 p_tableWin->table()->item(row,
getIndex(
"Declination"))->setText(QString::number(dec));
557 setText(QString::number(time.
Et(),
'f', 15));
558 QString time_utc = time.
UTC();
564 p_tableWin->table()->item(row,
getIndex(
"Spacecraft X"))->setText(QString::number(pos[0]));
565 p_tableWin->table()->item(row,
getIndex(
"Spacecraft Y"))->setText(QString::number(pos[1]));
566 p_tableWin->table()->item(row,
getIndex(
"Spacecraft Z"))->setText(QString::number(pos[2]));
581 while(wlon < 0.0) wlon += 360.0;
582 if (tproj->
IsSky()) {
585 setText(QString::number(lon,
'f', 15));
587 setText(QString::number(lat,
'f', 15));
592 setText(QString::number(lat,
'f', 15));
594 setText(QString::number(glat,
'f', 15));
596 setText(QString::number(lon,
'f', 15));
600 setText(QString::number(wlon,
'f', 15));
603 p_tableWin->table()->item(row,
getIndex(
"Local Radius"))->setText(QString::number(radius,
'f', 15));
612 while(wlon < 0.0) wlon += 360.0;
617 setText(QString::number(lon,
'f', 15));
621 setText(QString::number(wlon,
'f', 15));
625 setText(QString::number(radius,
'f', 15));
636 setText(QString::number(projX,
'f', 15));
638 setText(QString::number(projY,
'f', 15));
644 int iMosaicOrigin = -1;
645 QString sSrcFileName =
"";
646 QString sSrcSerialNum =
"";
647 TrackMosaicOrigin(cvp, iline, isample, iMosaicOrigin, sSrcFileName, sSrcSerialNum);
649 setText(QString::number(iMosaicOrigin));
651 setText(QString(sSrcFileName));
653 setText(QString(sSrcSerialNum));
675 int piSample,
int &piOrigin, QString &psSrcFileName,
676 QString &psSrcSerialNum) {
689 trackingCube = cCube;
695 trackingCube->
read(trackingPortal);
697 unsigned int currentPixel = trackingPortal[0];
698 if (currentPixel != NULLUI4) {
703 psSrcFileName = trackingFileName.
name();
704 psSrcSerialNum = trackingTable.
pixelToSN(currentPixel);
705 piOrigin = trackingTable.
fileNameToIndex(trackingFileName, psSrcSerialNum);
709 else if(cCube->
hasTable(trackingTableName)) {
713 for(
int i = 0; i < cGrpBandBin.
keywords(); i++) {
715 for(
int j = 0; j < cKeyTrackBand.
size(); j++) {
716 if(cKeyTrackBand[j] ==
"TRACKING") {
723 if(iTrackBand > 0 && iTrackBand <= cCube->bandCount()) {
726 cOrgPortal.
SetPosition(piSample, piLine, iTrackBand + 1);
727 cCube->
read(cOrgPortal);
728 piOrigin = (int)cOrgPortal[0];
731 piOrigin -= VALID_MIN1;
735 piOrigin -= VALID_MIN2;
739 piOrigin -= FLOAT_MIN;
745 int iRecs = cFileTable.
Records();
746 if(piOrigin >= 0 && piOrigin < iRecs) {
747 psSrcFileName = QString(cFileTable[piOrigin][0]);
748 psSrcSerialNum = QString(cFileTable[piOrigin][1]);
760 if (piOrigin == -1) {
761 psSrcFileName =
"N/A";
762 psSrcSerialNum =
"N/A";
776 QVBoxLayout *dialogLayout =
new QVBoxLayout;
778 QLabel *dialogTitle =
new QLabel(
"<h3>Advanced Tracking Tool</h3>");
779 dialogLayout->addWidget(dialogTitle);
781 QTabWidget *tabArea =
new QTabWidget;
782 dialogLayout->addWidget(tabArea);
784 QScrollArea *recordTab =
new QScrollArea;
786 QVBoxLayout *recordLayout =
new QVBoxLayout;
787 recordContainer->setLayout(recordLayout);
788 QLabel *recordText =
new QLabel(
"To record, click on the viewport of interest and"
789 " press (r) while the mouse is hovering over the image.");
790 recordText->setWordWrap(
true);
791 recordLayout->addWidget(recordText);
792 recordTab->setWidget(recordContainer);
794 QScrollArea *helpTab =
new QScrollArea;
796 QVBoxLayout *helpLayout =
new QVBoxLayout;
797 helpContainer->setLayout(helpLayout);
798 QLabel *helpText =
new QLabel(
"In order to use <i>ctrl+c</i> to copy and <i>ctrl+v</i> to"
799 " paste, you need to double click on the cell you are copying"
800 " from (the text should be highlighted). Then double click on"
801 " the cell you are pasting to (you should see a cursor if the"
802 " cell is blank). When a cell is in this editing mode, most"
803 " keyboard shortcuts work.");
804 helpText->setWordWrap(
true);
805 recordText->setWordWrap(
true);
806 helpLayout->addWidget(helpText);
807 helpTab->setWidget(helpContainer);
809 tabArea->addTab(recordTab,
"Record");
810 tabArea->addTab(helpTab,
"Table Help");
812 QPushButton *okButton =
new QPushButton(
"OK");
813 dialogLayout->addStretch();
814 dialogLayout->addWidget(okButton);
816 connect(okButton, SIGNAL(clicked()),
helpDialog, SLOT(accept()));
836 for(
int c = 0; c <
p_tableWin->table()->columnCount(); c++) {
837 QTableWidgetItem *item =
new QTableWidgetItem(
"");
842 QApplication::sendPostedEvents(
p_tableWin->table(), 0);
844 QAbstractItemView::PositionAtBottom);
921 if (QApplication::applicationName() ==
"") {
923 "application name before using the Isis::MainWindow class. Window "
924 "state and geometry can not be saved and restored", _FILEINFO_);
927 FileName config(
FileName(
"$HOME/.Isis/" + QApplication::applicationName() +
"/").path() +
"/" +
928 "advancedTrackTool.config");
Defines an angle and provides unit conversions.
double degrees() const
Get the angle in units of Degrees.
Distort/undistort focal plane coordinates.
double UndistortedFocalPlaneX() const
Gets the x-value in the undistorted focal plane coordinate system.
double UndistortedFocalPlaneZ() const
Gets the z-value in the undistorted focal plane coordinate system.
double UndistortedFocalPlaneY() const
Gets the y-value in the undistorted focal plane coordinate system.
Convert between distorted focal plane and detector coordinates.
double FocalPlaneY() const
double FocalPlaneX() const
double NorthAzimuth()
Returns the North Azimuth.
double SpacecraftAzimuth()
Return the Spacecraft Azimuth.
double SunAzimuth()
Returns the Sun Azimuth.
virtual double ObliquePixelResolution(bool useLocal=true)
Returns the oblique pixel resolution at the current position in meters/pixel.
virtual double PixelResolution()
Returns the pixel resolution at the current position in meters/pixel.
virtual bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
void LocalPhotometricAngles(Angle &phase, Angle &incidence, Angle &emission, bool &success)
Calculates LOCAL photometric angles using the DEM (not ellipsoid).
CameraDistortionMap * DistortionMap()
Returns a pointer to the CameraDistortionMap object.
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
IO Handler for Isis Cubes.
bool hasTable(const QString &name)
Check to see if the cube contains a pvl table by the provided name.
PixelType pixelType() const
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
Table readTable(const QString &name)
Read a Table from the cube.
bool hasGroup(const QString &group) const
Return if the cube has a specified group in the labels.
virtual QString fileName() const
Returns the opened cube's filename.
virtual int bandCount() const
Returns the number of virtual bands for the cube.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
int cubeLines() const
Return the number of lines in the cube.
int cubeSamples() const
Return the number of samples in the cube.
double grayPixel(int sample, int line)
Gets the gray pixel.
Cube * trackingCube() const
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
double redPixel(int sample, int line)
Gets the red pixel.
Projection * projection() const
Distance measurement, usually in meters.
double meters() const
Get the distance in meters.
File name manipulation and expansion.
QString path() const
Returns the path of the file name.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
@ Programmer
This error is for when a programmer made an API call that was illegal.
@ Io
A type of error that occurred when performing an actual I/O operation.
Adds specific functionality to C++ strings.
Cube display widget for certain Isis MDI applications.
bool isLinked() const
Is the viewport linked with other viewports.
Buffer for containing a two dimensional section of an image.
void SetPosition(const double sample, const double line, const int band)
Sets the line and sample position of the buffer.
ProjectionType
This enum defines the subclasses of Projection supported in Isis.
@ Triaxial
These projections are used to map triaxial and irregular-shaped bodies.
double XCoord() const
This returns the projection X provided SetGround, SetCoordinate, SetUniversalGround,...
virtual bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
bool IsSky() const
Returns true if projection is sky and false if it is land.
double YCoord() const
This returns the projection Y provided SetGround, SetCoordinate, SetUniversalGround,...
ProjectionType projectionType() const
Returns an enum value for the projection type.
int keywords() const
Returns the number of keywords contained in the PvlContainer.
Contains multiple PvlContainers.
Container for cube-like labels.
A single keyword-value pair.
int size() const
Returns the number of values stored in this keyword.
Contains Pvl Groups and Pvl Objects.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Base class for Map Projections of plane shapes.
double UniversalRingLongitude()
This returns a universal ring longitude (clockwise in 0 to 360 domain).
double UniversalRingRadius()
This returns a universal radius, which is just the radius in meters.
static double To180Domain(const double lon)
This method converts a ring longitude into the -180 to 180 domain.
double LocalSolarTime()
Return the local solar time in hours.
virtual double UniversalLatitude() const
Returns the planetocentric latitude, in degrees, at the surface intersection point in the body fixed ...
virtual double RightAscension()
Returns the right ascension angle (sky longitude).
virtual double SlantDistance() const
Return the distance between the spacecraft and surface point in kmv.
virtual double PhaseAngle() const
Returns the phase angle in degrees.
virtual double IncidenceAngle() const
Returns the incidence angle in degrees.
virtual double UniversalLongitude() const
Returns the positive east, 0-360 domain longitude, in degrees, at the surface intersection point in t...
void Coordinate(double p[3]) const
Returns the x,y,z of the surface intersection in BodyFixed km.
Distance LocalRadius() const
Returns the local radius at the intersection point.
virtual double Declination()
Returns the declination angle (sky latitude).
virtual double EmissionAngle() const
Returns the emission angle in degrees.
static QString Compose(Pvl &label, bool def2filename=false)
Compose a SerialNumber from a PVL.
QString name() const
Gets the shape name.
virtual Longitude solarLongitude()
Returns the solar longitude.
void radii(Distance r[3]) const
Returns the radii of the body in km.
void instrumentPosition(double p[3]) const
Returns the spacecraft position in body-fixed frame km units.
virtual Target * target() const
Returns a pointer to the target object.
virtual iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Base class for Map TProjections.
static double To180Domain(const double lon)
This method converts a longitude into the -180 to 180 domain.
double LocalRadius(double lat) const
This method returns the local radius in meters at the specified latitude position.
virtual double UniversalLongitude()
This returns a universal longitude (positive east in 0 to 360 domain).
virtual double UniversalLatitude()
This returns a universal latitude (planetocentric).
virtual double Longitude() const
This returns a longitude with correct longitude direction and domain as specified in the label object...
double ToPlanetographic(const double lat) const
This method converts a planetocentric latitude to a planetographic latitude.
Class for storing Table blobs information.
int Records() const
Returns the number of records.
a subclass of the qisis mainwindow, tablemainwindow handles all of the table tasks.
ShapeModel * shape() const
Return the shape.
bool isSky() const
Return if our target is the sky.
Table to store tracking information for a mosaic.
QString pixelToSN(unsigned int pixel)
Returns the serial number that corresponds to a pixel value.
FileName pixelToFileName(unsigned int pixel)
Returns the FileName that corresponds to a pixel value.
int fileNameToIndex(FileName file, QString serialNumber)
Returns the index of the filename/serialnumber combination.
Parse and return pieces of a time string.
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
QString UTC(int precision=8) const
Returns the internally stored time, formatted as a UTC time.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
const double Null
Value for an Isis Null pixel.
QString PixelToString(double d, double precision=8)
Takes a double pixel value and returns the name of the pixel type as a string.