Isis 3.0 Programmer Reference
Back | Home
AdvancedTrackTool.cpp
1 #include "AdvancedTrackTool.h"
2 
3 #include <QAction>
4 #include <QApplication>
5 #include <QLabel>
6 #include <QMenu>
7 #include <QMenuBar>
8 #include <QMessageBox>
9 #include <QPushButton>
10 #include <QScrollArea>
11 #include <QSize>
12 #include <QTableWidget>
13 #include <QTableWidgetItem>
14 #include <QToolBar>
15 #include <QVBoxLayout>
16 
17 #include "Angle.h"
18 #include "Camera.h"
19 #include "CameraDistortionMap.h"
20 #include "CameraFocalPlaneMap.h"
21 #include "Distance.h"
22 #include "iTime.h"
23 #include "Longitude.h"
24 #include "MdiCubeViewport.h"
25 #include "Projection.h"
26 #include "RingPlaneProjection.h"
27 #include "SerialNumber.h"
28 #include "SpecialPixel.h"
29 #include "TableMainWindow.h"
30 #include "Target.h"
31 #include "TProjection.h"
32 
33 namespace Isis {
34 
35  // For mosaic tracking
36 #define FLOAT_MIN -16777215
37 #define TABLE_MOSAIC_SRC "InputImages"
38 
45  p_tableWin = new TableMainWindow("Advanced Tracking", parent);
47  connect(p_tableWin, SIGNAL(fileLoaded()), this, SLOT(updateID()));
48 
49  p_action = new QAction(parent);
50  p_action->setText("Tracking ...");
51  p_action->setIcon(QPixmap(toolIconDir() + "/goto.png"));
52  p_action->setShortcut(Qt::CTRL + Qt::Key_T);
53  p_action->setWhatsThis("<b>Function: </b> Opens the Advanced Tracking Tool \
54  window. This window will track sample/line positions,\
55  lat/lon positions, and many other pieces of \
56  information. All of the data in the window can be \
57  saved to a text file. <p><b>Shortcut: </b> Ctrl+T</p>");
58  connect(p_action, SIGNAL(triggered()), p_tableWin, SLOT(showTable()));
59  activate(true);
60  connect(p_action, SIGNAL(triggered()), p_tableWin, SLOT(raise()));
61  connect(p_action, SIGNAL(triggered()), p_tableWin, SLOT(syncColumns()));
62  p_tableWin->installEventFilter(this);
63 
64  p_tableWin->addToTable(false, "Id", "Id");
65  p_tableWin->addToTable(true, "Sample:Line", "Sample:Line", -1,
66  Qt::Horizontal, "Sample and Line");
67  p_tableWin->addToTable(false, "Band", "Band");
68  p_tableWin->addToTable(true, "Pixel", "Pixel");
69  p_tableWin->addToTable(true, "Planetocentric Latitude", "Planetocentric Lat");
70  p_tableWin->addToTable(false, "Planetographic Latitude", "Planetographic Lat");
71  p_tableWin->addToTable(true, "360 Positive East Longitude", "360 East Longitude");
72  p_tableWin->addToTable(false, "360 Positive West Longitude", "360 West Longitude");
73  p_tableWin->addToTable(true, "180 Positive East Longitude", "180 East Longitude");
74  p_tableWin->addToTable(false, "180 Positive West Longitude", "180 West Longitude");
75  p_tableWin->addToTable(false, "Projected X:Projected Y", "Projected X:Projected Y", -1,
76  Qt::Horizontal, "X and Y values for a projected image");
77  p_tableWin->addToTable(false, "Local Radius", "Radius");
78  p_tableWin->addToTable(false, "Point X:Point Y:Point Z", "XYZ", -1, Qt::Horizontal,
79  "The X, Y, and Z of surface intersection in body-fixed coordinates");
80  p_tableWin->addToTable(false, "Right Ascension:Declination", "Ra:Dec", -1, Qt::Horizontal,
81  "Right Ascension and Declination");
82  p_tableWin->addToTable(false, "Resolution", "Resolution");
83  p_tableWin->addToTable(false, "Phase", "Phase");
84  p_tableWin->addToTable(false, "Incidence", "Incidence");
85  p_tableWin->addToTable(false, "Emission", "Emission");
86  p_tableWin->addToTable(false, "LocalIncidence", "LocalIncidence");
87  p_tableWin->addToTable(false, "LocalEmission", "LocalEmission");
88  p_tableWin->addToTable(false, "North Azimuth", "North Azimuth");
89  p_tableWin->addToTable(false, "Sun Azimuth", "Sun Azimuth");
90  p_tableWin->addToTable(false, "Solar Longitude", "Solar Longitude");
91  p_tableWin->addToTable(false, "Spacecraft X:Spacecraft Y:Spacecraft Z", "Spacecraft Position",
92  -1, Qt::Horizontal, "The X, Y, and Z of the spacecraft position");
93  p_tableWin->addToTable(false, "Spacecraft Azimuth", "Spacecraft Azimuth");
94  p_tableWin->addToTable(false, "Slant Distance", "Slant Distance");
95  p_tableWin->addToTable(false, "Focal Plane X:Focal Plane Y", "Focal Plane X:Y");
96  p_tableWin->addToTable(false, "Undistorted Focal X:Undistorted Focal Y: Undistorted Focal Z",
97  "Undistorted Focal Plane X:Y:Z");
98  p_tableWin->addToTable(false, "Ephemeris Time", "Ephemeris iTime");
99  p_tableWin->addToTable(false, "Local Solar Time", "Local Solar iTime");
100  p_tableWin->addToTable(false, "UTC", "UTC", -1, Qt::Horizontal, "Internal time in UTC format");
101  p_tableWin->addToTable(false, "Path", "Path");
102  p_tableWin->addToTable(false, "FileName", "FileName");
103  p_tableWin->addToTable(false, "Serial Number", "Serial Number");
104  p_tableWin->addToTable(false, "Track Mosaic Index", "Track Mosaic Index");
105  p_tableWin->addToTable(false, "Track Mosaic FileName", "Track Mosaic FileName");
106  p_tableWin->addToTable(false, "Track Mosaic Serial Number", "Track Mosaic Serial Number");
107  p_tableWin->addToTable(false, "Notes", "Notes");
108  //This variable will keep track of how many times
109  // the user has issued the 'record' command.
110  p_id = 0;
111 
112  // Setup 10 blank rows in the table
113  for(int r = 0; r < 10; r++) {
114  p_tableWin->table()->insertRow(r);
115  for(int c = 0; c < p_tableWin->table()->columnCount(); c++) {
116  QTableWidgetItem *item = new QTableWidgetItem("");
117  p_tableWin->table()->setItem(r, c, item);
118  }
119  }
120 
121  // Create the action for recording points
122  QAction *recordAction = new QAction(parent);
123  recordAction->setShortcut(Qt::Key_R);
124  parent->addAction(recordAction);
125  connect(recordAction, SIGNAL(triggered()), this, SLOT(record()));
126  p_tableWin->setStatusMessage("To record press the R key"
127  " --- Double click on a cell to enable crtl+c (copy) and"
128  " ctrl+v (paste).");
129 
130  // Add a help menu to the menu bar
131  QMenuBar *menuBar = p_tableWin->menuBar();
132  QMenu *helpMenu = menuBar->addMenu("&Help");
133  QAction *help = new QAction(p_tableWin);
134  help->setText("&Tool Help");
135  help->setShortcut(Qt::CTRL + Qt::Key_H);
136  connect(help, SIGNAL(triggered()), this, SLOT(helpDialog()));
137  helpMenu->addAction(help);
138  p_tableWin->setMenuBar(menuBar);
139  installEventFilter(p_tableWin);
140 
141  m_showHelpOnStart = true;
142  readSettings();
143  }
144 
154  if(e->type() == QEvent::Show) {
155  activate(true);
156  if (m_showHelpOnStart) {
157  helpDialog();
158  m_showHelpOnStart = false;
159  writeSettings();
160  }
161  }
162  else if(e->type() == QEvent::Hide) {
163  activate(false);
164  }
165  return Tool::eventFilter(o, e);
166  }
167 
168 
174  void AdvancedTrackTool::addTo(QMenu *menu) {
175  menu->addAction(p_action);
176  }
177 
185  perm->addAction(p_action);
186  }
187 
195  updateRow(p);
196  }
197 
204 
205  if(cubeViewport()->isLinked()) {
206  for(int i = 0; i < p_numRows; i++) {
208  }
209  }
210  else {
212  }
213 
214  }
215 
222  MdiCubeViewport *cvp = cubeViewport();
223  if(cvp == NULL) {
225  return;
226  }
227 
228  if(!cubeViewport()->isLinked()) {
229  updateRow(cvp, p, p_tableWin->currentRow());
230  p_numRows = 1;
231  }
232  else {
233  p_numRows = 0;
234  for(int i = 0; i < (int)cubeViewportList()->size(); i++) {
235  MdiCubeViewport *d = (*(cubeViewportList()))[i];
236  if(d->isLinked()) {
238  p_numRows++;
239  }
240  }
241  }
242  }
243 
251  void AdvancedTrackTool::updateRow(MdiCubeViewport *cvp, QPoint p, int row) {
252  // Get the sample line position to report
253  double sample, line;
254  cvp->viewportToCube(p.x(), p.y(), sample, line);
255  int isample = int (sample + 0.5);
256  int iline = int (line + 0.5);
257 
258  /*if there are linked cvp's then we want to highlight (select)
259  the row of the active cvp.*/
260  if(cvp->isLinked()) {
261 
262  if(cvp == cubeViewport()) {
263  p_tableWin->table()->selectRow(row);
264  }
265 
266  }
267 
268 
269  // Do we need more rows?
270  if(row + 1 > p_tableWin->table()->rowCount()) {
271  p_tableWin->table()->insertRow(row);
272  for(int c = 0; c < p_tableWin->table()->columnCount(); c++) {
273  QTableWidgetItem *item = new QTableWidgetItem("");
274  p_tableWin->table()->setItem(row, c, item);
275  if(c == 0) p_tableWin->table()->scrollToItem(item);
276  }
277  }
278 
279  // Blank out the row to remove stuff left over from previous cvps
280  for(int c = 0; c < p_tableWin->table()->columnCount(); c++) {
281  p_tableWin->table()->item(row, c)->setText("");
282  }
283 
284  // Don't write anything if we are outside the cube
285  if(sample < 0.5) return;
286  if(line < 0.5) return;
287  if(sample > cvp->cubeSamples() + 0.5) return;
288  if(line > cvp->cubeLines() + 0.5) return;
289 
290  // Write cols 0-2 (id, sample, line)
291  p_tableWin->table()->item(row, ID)->setText(QString::number(p_id));
292  p_tableWin->table()->item(row, SAMPLE)->setText(QString::number(sample));
293  p_tableWin->table()->item(row, LINE)->setText(QString::number(line));
294 
295  // Write col 3 (band)
296  if(cvp->isGray()) {
297  p_tableWin->table()->item(row, BAND)->setText(QString::number(cvp->grayBand()));
298  }
299  else {
300  p_tableWin->table()->item(row, BAND)->setText(QString::number(cvp->redBand()));
301  }
302 
303  // Write out the path, filename, and serial number
304  FileName fname = FileName(cvp->cube()->fileName()).expanded();
305  QString fnamePath = fname.path();
306  QString fnameName = fname.name();
307  p_tableWin->table()->item(row, PATH)->setText(fnamePath);
308  p_tableWin->table()->item(row, FILENAME)->setText(fnameName);
309  //p_tableWin->table()->item(row,34)->setText(SerialNumber::Compose(*cvp->cube()).c_str());
310 
311  // If we are outside of the image then we are done
312  if((sample < 0.5) || (line < 0.5) ||
313  (sample > cvp->cubeSamples() + 0.5) ||
314  (line > cvp->cubeLines() + 0.5)) {
315  return;
316  }
317 
318  // Otherwise write out col 4 (Pixel value)
319  if(cvp->isGray()) {
320  QString grayPixel = PixelToString(cvp->grayPixel(isample, iline));
321  QString p = grayPixel;
322  p_tableWin->table()->item(row, PIXEL)->setText(p);
323  }
324  else {
325  QString redPixel = PixelToString(cvp->redPixel(isample, iline));
326  QString p = redPixel;
327  p_tableWin->table()->item(row, PIXEL)->setText(p);
328  }
329 
330  // Do we have a camera model?
331  if(cvp->camera() != NULL) {
332  if(cvp->camera()->SetImage(sample, line)) {
333  // Write columns ocentric lat/lon, and radius, only if set image succeeds
334  double lat = cvp->camera()->UniversalLatitude();
335  double lon = cvp->camera()->UniversalLongitude();
336 
337  double radius = cvp->camera()->LocalRadius().meters();
338  p_tableWin->table()->item(row, PLANETOCENTRIC_LAT)->setText(QString::number(lat, 'f', 15));
339  p_tableWin->table()->item(row, EAST_LON_360)->setText(QString::number(lon, 'f', 15));
340  p_tableWin->table()->item(row, RADIUS)->setText(QString::number(radius, 'f', 15));
341 
342  /* 180 Positive East Lon. */
343  p_tableWin->table()->item(row, EAST_LON_180)->
344  setText(QString::number(TProjection::To180Domain(lon), 'f', 15));
345 
346  // Write out the planetographic and positive west values, only if set image succeeds
347  lon = -lon;
348  while(lon < 0.0) lon += 360.0;
349  Distance radii[3];
350  cvp->camera()->radii(radii);
351  lat = TProjection::ToPlanetographic(lat, radii[0].meters(), radii[2].meters());
352  p_tableWin->table()->item(row, PLANETOGRAPHIC_LAT)->setText(QString::number(lat, 'f', 15));
353  p_tableWin->table()->item(row, WEST_LON_360)->setText(QString::number(lon, 'f', 15));
354 
355  /*180 Positive West Lon. */
356  p_tableWin->table()->item(row, WEST_LON_180)->setText(
357  QString::number(TProjection::To180Domain(lon), 'f', 15));
358 
359  // Next write out columns, the x/y/z position of the lat/lon, only if set image succeeds
360  double pos[3];
361  cvp->camera()->Coordinate(pos);
362  p_tableWin->table()->item(row, POINT_X)->setText(QString::number(pos[0]));
363  p_tableWin->table()->item(row, POINT_Y)->setText(QString::number(pos[1]));
364  p_tableWin->table()->item(row, POINT_Z)->setText(QString::number(pos[2]));
365 
366  // Write out columns resolution, only if set image succeeds
367  if (cvp->camera()->PixelResolution() != -1.0) {
368  double res = cvp->camera()->PixelResolution();
369  p_tableWin->table()->item(row, RESOLUTION)->setText(QString::number(res));
370  }
371  else {
372  p_tableWin->table()->item(row, RESOLUTION)->setText("");
373  }
374 
375  // Write out columns photometric angle values, only if set image succeeds
376  double phase = cvp->camera()->PhaseAngle();
377  p_tableWin->table()->item(row, PHASE)->setText(QString::number(phase));
378  double incidence = cvp->camera()->IncidenceAngle();
379  p_tableWin->table()->item(row, INCIDENCE)->setText(QString::number(incidence));
380  double emission = cvp->camera()->EmissionAngle();
381  p_tableWin->table()->item(row, EMISSION)->setText(QString::number(emission));
382 
383  // Write out columns local incidence and emission, only if set image
384  // succeeds. This might fail if there are holes in the DEM.
385  // Calculates the angles local to the slope for the DEMs, compare against
386  // the incidence and emission angles calculated for the sphere
387  Angle phaseAngle, incidenceAngle, emissionAngle;
388  bool bSuccess=false;
389  cvp->camera()->LocalPhotometricAngles(phaseAngle, incidenceAngle, emissionAngle, bSuccess);
390  if(bSuccess) {
391  p_tableWin->table()->item(row, LOCAL_INCIDENCE)->
392  setText(QString::number(incidenceAngle.degrees()));
393  p_tableWin->table()->item(row, LOCAL_EMISSION)->
394  setText(QString::number(emissionAngle.degrees()));
395  }
396  else {
397  p_tableWin->table()->item(row, LOCAL_INCIDENCE)->setText("");
398  p_tableWin->table()->item(row, LOCAL_EMISSION)->setText("");
399  }
400 
401  // If set image succeeds, write out columns north azimuth, sun azimuth, solar longitude
402  // north azimuth is meaningless for ring plane projections
403  if (cvp->camera()->target()->shape()->name() != "Plane"
404  && Isis::IsValidPixel(cvp->camera()->NorthAzimuth())) {
405  double northAzi = cvp->camera()->NorthAzimuth();
406  p_tableWin->table()->item(row, NORTH_AZIMUTH)->setText(QString::number(northAzi));
407  }
408  else { // north azimuth is meaningless for ring plane projections
409  p_tableWin->table()->item(row, NORTH_AZIMUTH)->setText("");
410  }
411  if (Isis::IsValidPixel(cvp->camera()->SunAzimuth())) {
412  double sunAzi = cvp->camera()->SunAzimuth();
413  p_tableWin->table()->item(row, SUN_AZIMUTH)->setText(QString::number(sunAzi));
414  }
415  else { // sun azimuth is null
416  p_tableWin->table()->item(row, SUN_AZIMUTH)->setText("");
417  }
419  double spacecraftAzi = cvp->camera()->SpacecraftAzimuth();
420  p_tableWin->table()->item(row, SPACECRAFT_AZIMUTH)->setText(QString::number(spacecraftAzi));
421  }
422  else { // spacecraft azimuth is null
423  p_tableWin->table()->item(row, SPACECRAFT_AZIMUTH)->setText("");
424  }
425 
426  // Write out columns solar lon, slant distance, local solar time
427  double solarLon = cvp->camera()->solarLongitude().degrees();
428  p_tableWin->table()->item(row, SOLAR_LON)->setText(QString::number(solarLon));
429  double slantDistance = cvp->camera()->SlantDistance();
430  p_tableWin->table()->item(row, SLANT)->setText(QString::number(slantDistance));
431  double lst = cvp->camera()->LocalSolarTime();
432  p_tableWin->table()->item(row, SOLAR_TIME)->setText(QString::number(lst));
433  } // end if set image succeeds
434 
435  // Always write out the x/y/z of the undistorted focal plane
436  CameraDistortionMap *distortedMap = cvp->camera()->DistortionMap();
437  double undistortedFocalPlaneX = distortedMap->UndistortedFocalPlaneX();
438  p_tableWin->table()->item(row, UNDISTORTED_FOCAL_X)->setText(QString::number(undistortedFocalPlaneX));
439  double undistortedFocalPlaneY = distortedMap->UndistortedFocalPlaneY();
440  p_tableWin->table()->item(row, UNDISTORTED_FOCAL_Y)->setText(QString::number(undistortedFocalPlaneY));
441  double undistortedFocalPlaneZ = distortedMap->UndistortedFocalPlaneZ();
442  p_tableWin->table()->item(row, UNDISTORTED_FOCAL_Z)->setText(QString::number(undistortedFocalPlaneZ));
443 
444  // Always write out the x/y of the distorted focal plane
445  CameraFocalPlaneMap *focalPlaneMap = cvp->camera()->FocalPlaneMap();
446  double distortedFocalPlaneX = focalPlaneMap->FocalPlaneX();
447  p_tableWin->table()->item(row, DISTORTED_FOCAL_X)->setText(QString::number(distortedFocalPlaneX));
448  double distortedFocalPlaneY = focalPlaneMap->FocalPlaneY();
449  p_tableWin->table()->item(row, DISTORTED_FOCAL_Y)->setText(QString::number(distortedFocalPlaneY));
450 
451  // Always write out columns ra/dec, regardless of whether set image succeeds
452  double ra = cvp->camera()->RightAscension();
453  p_tableWin->table()->item(row, RIGHT_ASCENSION)->setText(QString::number(ra));
454  double dec = cvp->camera()->Declination();
455  p_tableWin->table()->item(row, DECLINATION)->setText(QString::number(dec));
456 
457  // Always write out columns et and utc, regardless of whether set image succeeds
458  iTime time(cvp->camera()->time());
459  p_tableWin->table()->item(row, EPHEMERIS_TIME)->setText(QString::number(time.Et(), 'f', 15));
460  QString time_utc = time.UTC();
461  p_tableWin->table()->item(row, UTC)->setText(time_utc);
462 
463  // Always out columns spacecraft position, regardless of whether set image succeeds
464  double pos[3];
465  cvp->camera()->instrumentPosition(pos);
466  p_tableWin->table()->item(row, SPACECRAFT_X)->setText(QString::number(pos[0]));
467  p_tableWin->table()->item(row, SPACECRAFT_Y)->setText(QString::number(pos[1]));
468  p_tableWin->table()->item(row, SPACECRAFT_Z)->setText(QString::number(pos[2]));
469  }
470 
471  else if (cvp->projection() != NULL) {
472  // Determine the projection type
474 
475  if (cvp->projection()->SetWorld(sample, line)) {
476  if (projType == Projection::Triaxial) {
477  TProjection *tproj = (TProjection *) cvp->projection();
478  double lat = tproj->UniversalLatitude();
479  double lon = tproj->UniversalLongitude();
480 
481  double glat = tproj->ToPlanetographic(lat);
482  double wlon = -lon;
483  while(wlon < 0.0) wlon += 360.0;
484  if (tproj->IsSky()) {
485  lon = tproj->Longitude();
486  p_tableWin->table()->item(row, RIGHT_ASCENSION)->setText(QString::number(lon, 'f', 15));
487  p_tableWin->table()->item(row, DECLINATION)->setText(QString::number(lat, 'f', 15));
488  }
489  else {
490  double radius = tproj->LocalRadius();
491  p_tableWin->table()->item(row, PLANETOCENTRIC_LAT)->
492  setText(QString::number(lat, 'f', 15));
493  p_tableWin->table()->item(row, PLANETOGRAPHIC_LAT)->
494  setText(QString::number(glat, 'f', 15));
495  p_tableWin->table()->item(row, EAST_LON_360)->
496  setText(QString::number(lon, 'f', 15));
497  p_tableWin->table()->item(row, EAST_LON_180)->
498  setText(QString::number(TProjection::To180Domain(lon), 'f', 15));
499  p_tableWin->table()->item(row, WEST_LON_360)->setText(QString::number(wlon, 'f', 15));
500  p_tableWin->table()->item(row, WEST_LON_180)->
501  setText(QString::number(TProjection::To180Domain(wlon), 'f', 15));
502  p_tableWin->table()->item(row, RADIUS)->setText(QString::number(radius, 'f', 15));
503  }
504  }
505  else { // RingPlane
507  double lat = rproj->UniversalRingRadius();
508  double lon = rproj->UniversalRingLongitude();
509 
510  double wlon = -lon;
511  while(wlon < 0.0) wlon += 360.0;
512  double radius = lat;
513  p_tableWin->table()->item(row, PLANETOCENTRIC_LAT)->setText("0.0");
514  p_tableWin->table()->item(row, PLANETOGRAPHIC_LAT)->setText("0.0");
515  p_tableWin->table()->item(row, EAST_LON_360)->
516  setText(QString::number(lon, 'f', 15));
517  p_tableWin->table()->item(row, EAST_LON_180)->
518  setText(QString::number(RingPlaneProjection::To180Domain(lon), 'f', 15));
519  p_tableWin->table()->item(row, WEST_LON_360)->setText(QString::number(wlon, 'f', 15));
520  p_tableWin->table()->item(row, WEST_LON_180)->
521  setText(QString::number(RingPlaneProjection::To180Domain(wlon), 'f', 15));
522  p_tableWin->table()->item(row, RADIUS)->setText(QString::number(radius, 'f', 15));
523  }
524  }
525  }
526 
527  //If there is a projection add the Projected X and Y coords to the table
528  if(cvp->projection() != NULL) {
529  if(cvp->projection()->SetWorld(sample, line)) {
530  double projX = cvp->projection()->XCoord();
531  double projY = cvp->projection()->YCoord();
532  p_tableWin->table()->item(row, PROJECTED_X)->setText(QString::number(projX, 'f', 15));
533  p_tableWin->table()->item(row, PROJECTED_Y)->setText(QString::number(projY, 'f', 15));
534  }
535  }
536 
537  // Track the Mosaic Origin - Index (Zero based) and FileName
538  int iMosaicOrigin = -1;
539  QString sSrcFileName = "";
540  QString sSrcSerialNum = "";
541  TrackMosaicOrigin(cvp, iline, isample, iMosaicOrigin, sSrcFileName, sSrcSerialNum);
542  p_tableWin->table()->item(row, TRACK_MOSAIC_INDEX)->setText(QString::number(iMosaicOrigin));
543  p_tableWin->table()->item(row, TRACK_MOSAIC_FILENAME)->setText(QString(sSrcFileName));
544  p_tableWin->table()->item(row, TRACK_MOSAIC_SERIAL_NUM)->
545  setText(QString(sSrcSerialNum));
546  }
547 
548 
566  int piSample, int &piOrigin, QString &psSrcFileName,
567  QString &psSrcSerialNum) {
568  try {
569  Cube *cCube = cvp->cube();
570  int iTrackBand = -1;
571 
572  if(cCube->hasTable(TABLE_MOSAIC_SRC)) {
573  Pvl *cPvl = cCube->label();
574  PvlObject cObjIsisCube = cPvl->findObject("IsisCube");
575  PvlGroup cGrpBandBin = cObjIsisCube.findGroup("BandBin");
576  for(int i = 0; i < cGrpBandBin.keywords(); i++) {
577  PvlKeyword &cKeyTrackBand = cGrpBandBin[i];
578  for(int j = 0; j < cKeyTrackBand.size(); j++) {
579  if(cKeyTrackBand[j] == "TRACKING") {
580  iTrackBand = j;
581  break;
582  }
583  }
584  }
585 
586  if(iTrackBand > 0 && iTrackBand <= cCube->bandCount()) {
587  Portal cOrgPortal(cCube->sampleCount(), 1,
588  cCube->pixelType());
589  cOrgPortal.SetPosition(piSample, piLine, iTrackBand + 1); // 1 based
590  cCube->read(cOrgPortal);
591  piOrigin = (int)cOrgPortal[0];
592  switch(SizeOf(cCube->pixelType())) {
593  case 1:
594  piOrigin -= VALID_MIN1;
595  break;
596 
597  case 2:
598  piOrigin -= VALID_MIN2;
599  break;
600 
601  case 4:
602  piOrigin -= FLOAT_MIN;
603  break;
604  }
605 
606  // Get the input file name and serial number
607  Table cFileTable(TABLE_MOSAIC_SRC);
608  cCube->read(cFileTable);
609  int iRecs = cFileTable.Records();
610  if(piOrigin >= 0 && piOrigin < iRecs) {
611  psSrcFileName = QString(cFileTable[piOrigin][0]);
612  psSrcSerialNum = QString(cFileTable[piOrigin][1]);
613  }
614  }
615  }
616  }
617  catch (IException &e) {
618  QMessageBox::warning((QWidget *)parent(), "Warning", e.toString());
619  }
620 
621  }
622 
623 
630 
632 
633  QVBoxLayout *dialogLayout = new QVBoxLayout;
634  helpDialog->setLayout(dialogLayout);
635  QLabel *dialogTitle = new QLabel("<h3>Advanced Tracking Tool</h3>");
636  dialogLayout->addWidget(dialogTitle);
637 
638  QTabWidget *tabArea = new QTabWidget;
639  dialogLayout->addWidget(tabArea);
640 
641  QScrollArea *recordTab = new QScrollArea;
642  QWidget *recordContainer = new QWidget;
643  QVBoxLayout *recordLayout = new QVBoxLayout;
644  recordContainer->setLayout(recordLayout);
645  QLabel *recordText = new QLabel("To record, click on the viewport of interest and"
646  " press (r) while the mouse is hovering over the image.");
647  recordText->setWordWrap(true);
648  recordLayout->addWidget(recordText);
649  recordTab->setWidget(recordContainer);
650 
651  QScrollArea *helpTab = new QScrollArea;
652  QWidget *helpContainer = new QWidget;
653  QVBoxLayout *helpLayout = new QVBoxLayout;
654  helpContainer->setLayout(helpLayout);
655  QLabel *helpText = new QLabel("In order to use <i>ctrl+c</i> to copy and <i>ctrl+v</i> to"
656  " paste, you need to double click on the cell you are copying"
657  " from (the text should be highlighted). Then double click on"
658  " the cell you are pasting to (you should see a cursor if the"
659  " cell is blank). When a cell is in this editing mode, most"
660  " keyboard shortcuts work.");
661  helpText->setWordWrap(true);
662  recordText->setWordWrap(true);
663  helpLayout->addWidget(helpText);
664  helpTab->setWidget(helpContainer);
665 
666  tabArea->addTab(recordTab, "Record");
667  tabArea->addTab(helpTab, "Table Help");
668 
669  QPushButton *okButton = new QPushButton("OK");
670  dialogLayout->addStretch();
671  dialogLayout->addWidget(okButton);
672  helpDialog->show();
673  connect(okButton, SIGNAL(clicked()), helpDialog, SLOT(accept()));
674  }
675 
676 
682  if(p_tableWin->table()->isHidden()) return;
683  if(p_tableWin->table()->item(p_tableWin->currentRow(), 0)->text() == "") return;
684 
685  int row = 0;
688  while(p_tableWin->currentRow() >= p_tableWin->table()->rowCount()) {
689  row = p_tableWin->table()->rowCount();
690  p_tableWin->table()->insertRow(row);
691  for(int c = 0; c < p_tableWin->table()->columnCount(); c++) {
692  QTableWidgetItem *item = new QTableWidgetItem("");
693  p_tableWin->table()->setItem(row, c, item);
694  }
695  }
696 
697  QApplication::sendPostedEvents(p_tableWin->table(), 0);
698  p_tableWin->table()->scrollToItem(p_tableWin->table()->item(p_tableWin->currentRow(), 0),
699  QAbstractItemView::PositionAtBottom);
700 
701  //Keep track of number times user presses 'R' (record command)
702  p_id = p_tableWin->table()->item(p_tableWin->currentRow() - 1, 0)->text().toInt() + 1;
703  }
704 
705 
721  void AdvancedTrackTool::record(QPoint p) {
722  updateRow(p);
723  record();
725  }
726 
727 
733  //Check if the current row is 0
734  if(p_tableWin->currentRow() == 0)
735  p_id = 0;
736  else
737  p_id = p_tableWin->table()->item(p_tableWin->currentRow() - 1, ID)->text().toInt() + 1;
738  }
739 
740 
747 
748  QSettings settings(settingsFilePath() , QSettings::NativeFormat);
749 
750  m_showHelpOnStart = settings.value("showHelpOnStart", m_showHelpOnStart).toBool();
751  }
752 
753 
759 
760  QSettings settings(settingsFilePath(), QSettings::NativeFormat);
761 
762  settings.setValue("showHelpOnStart", m_showHelpOnStart);
763  }
764 
765 
772 
773  if (QApplication::applicationName() == "") {
774  throw IException(IException::Programmer, "You must set QApplication's "
775  "application name before using the Isis::MainWindow class. Window "
776  "state and geometry can not be saved and restored", _FILEINFO_);
777  }
778 
779  FileName config(FileName("$HOME/.Isis/" + QApplication::applicationName() + "/").path() + "/" +
780  "advancedTrackTool.config");
781 
782  return config.expanded();
783  }
784 }
Cube display widget for certain Isis MDI applications.
void LocalPhotometricAngles(Angle &phase, Angle &incidence, Angle &emission, bool &success)
Calculates LOCAL photometric angles using the DEM (not ellipsoid).
Definition: Camera.cpp:1717
The local solar time for this cube.
CubeViewportList * cubeViewportList() const
Return the list of cubeviewports.
Definition: Tool.cpp:390
The 180 east longitude for this point.
double RightAscension()
Returns the right ascension angle (sky longitude).
Definition: Sensor.cpp:553
The path for this cube.
int Records() const
Returns the number of records.
Definition: Table.cpp:224
The x of the distorted focal plane.
QTableWidget * table() const
Returns the table.
The planetocentric latitude for this point.
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:141
void setStatusMessage(QString message)
sets the status message in the lower lefthand corner of the window.
void updateRow(QPoint p)
This method updates the row with data from the point given.
bool IsSky() const
Returns true if projection is sky and false if it is land.
Definition: Projection.cpp:223
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
The declination for this point.
AdvancedTrackTool(QWidget *parent)
Constructs an AdvancedTrackTool object.
double SunAzimuth()
Returns the Sun Azimuth.
Definition: Camera.cpp:1995
void addTo(QMenu *menu)
This method adds the action to bring up the track tool to the menu.
void record()
This method records data to the current row.
PixelType pixelType() const
Definition: Cube.cpp:1355
double degrees() const
Get the angle in units of Degrees.
Definition: Angle.h:245
QString name() const
Gets the shape name.
Definition: ShapeModel.cpp:454
File name manipulation and expansion.
Definition: FileName.h:111
Parse and return pieces of a time string.
Definition: iTime.h:74
CameraDistortionMap * DistortionMap()
Returns a pointer to the CameraDistortionMap object.
Definition: Camera.cpp:2886
Projected X value for valid projections.
The x of the undistorted focal plane.
bool isGray() const
Is the viewport shown in gray / b&amp;w.
Definition: CubeViewport.h:158
double SlantDistance() const
Return the distance between the spacecraft and surface point in kmv.
Definition: Sensor.cpp:625
The phase for this point.
Buffer for containing a two dimensional section of an image.
Definition: Portal.h:52
int p_id
The record id.
Base class for Map TProjections.
Definition: TProjection.h:178
void clearRow(int row)
This method clears the text of the given row.
The UTC for this cube.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition: PvlObject.h:286
double SpacecraftAzimuth()
Return the Spacecraft Azimuth.
Definition: Camera.cpp:2009
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1298
int keywords() const
Returns the number of keywords contained in the PvlContainer.
Definition: PvlContainer.h:101
void radii(Distance r[3]) const
Returns the radii of the body in km.
Definition: Spice.cpp:850
The spacecraft z position for this cube.
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
Definition: PixelType.h:62
double ToPlanetographic(const double lat) const
This method converts a planetocentric latitude to a planetographic latitude.
The 180 west longitude for this point.
The emission for this point.
int cubeSamples() const
Return the number of samples in the cube.
The incidence for this point.
void writeSettings()
Write out this tool&#39;s preserved state between runs.
The solar longitude for this point.
double UniversalLatitude() const
Returns the planetocentric latitude, in degrees, at the surface intersection point in the body fixed ...
Definition: Sensor.cpp:225
void instrumentPosition(double p[3]) const
Returns the spacecraft position in body-fixed frame km units.
Definition: Spice.cpp:742
double XCoord() const
This returns the projection X provided SetGround, SetCoordinate, SetUniversalGround, or SetWorld returned with success.
Definition: Projection.cpp:402
double UndistortedFocalPlaneY() const
Return undistorted focal plane y.
double LocalRadius(double lat) const
This method returns the local radius in meters at the specified latitude position.
double UniversalLongitude()
This returns a universal longitude (positive east in 0 to 360 domain).
The filename for this cube.
int currentRow() const
Returns the current row.
int redBand() const
Return the red band currently viewed.
Definition: CubeViewport.h:168
Creates sequential IDs.
Definition: ID.h:44
Projection * projection() const
Return the projection associated with cube (NULL implies none)
Definition: CubeViewport.h:233
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
Definition: SpecialPixel.h:225
TableMainWindow * p_tableWin
The table window.
void read(Blob &blob) const
This method will read data from the specified Blob object.
Definition: Cube.cpp:686
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
bool m_showHelpOnStart
True to show dialog When tool is started.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:154
The radius for this point.
The y of the undistorted focal plane.
Distance measurement, usually in meters.
Definition: Distance.h:47
The local emission for this point.
The ephemeris time for this cube.
The spacecraft azimuth for this cube.
double UniversalLongitude() const
Returns the positive east, 0-360 domain longitude, in degrees, at the surface intersection point in t...
Definition: Sensor.cpp:248
double redPixel(int sample, int line)
Return the red pixel value at a sample/line.
void setTrackListItems(bool track=false)
If this property is true, the class will keep track of the checked/unchecked items in the dock area w...
bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
Definition: Camera.cpp:166
Projected Y value for valid projections.
double grayPixel(int sample, int line)
Return the gray pixel value at a sample/line.
Target * target() const
Returns a pointer to the target object.
Definition: Spice.cpp:1277
iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions...
Definition: Spice.cpp:804
Track the origin of the Mosaic, display file name.
int sampleCount() const
Definition: Cube.cpp:1404
bool eventFilter(QObject *o, QEvent *e)
An event filter that calls methods on certain events.
double meters() const
Get the distance in meters.
Definition: Distance.cpp:97
MdiCubeViewport * cubeViewport() const
Return the current cubeviewport.
Definition: Tool.h:211
Cube * cube() const
Return the cube associated with viewport.
Definition: CubeViewport.h:228
The y of the distorted focal plane.
Convert between distorted focal plane and detector coordinates.
int grayBand() const
Return the gray band currently viewed.
Definition: CubeViewport.h:163
static double To180Domain(const double lon)
This method converts a longitude into the -180 to 180 domain.
bool hasTable(const QString &name)
Check to see if the cube contains a pvl table by the provided name.
Definition: Cube.cpp:1610
double EmissionAngle() const
Returns the emission angle in degrees.
Definition: Sensor.cpp:339
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
double PhaseAngle() const
Returns the phase angle in degrees.
Definition: Sensor.cpp:327
Camera * camera() const
Return the camera associated with the cube (NULL implies none)
Definition: CubeViewport.h:238
A single keyword-value pair.
Definition: PvlKeyword.h:98
The sun azimuth for this cube.
void helpDialog()
This method creates a dialog box that shows help tips.
The local incidence for this point.
double UniversalRingRadius()
This returns a universal radius, which is just the radius in meters.
Track the origin of the Mosaic, display the zero based index.
bool isLinked() const
Is the viewport linked with other viewports.
Distort/undistort focal plane coordinates.
double NorthAzimuth()
Returns the North Azimuth.
Definition: Camera.cpp:1968
QAction * p_action
Action to bring up the track tool.
void viewportToCube(int x, int y, double &sample, double &line) const
Convert a viewport x/y to a cube sample/line (may be outside the cube)
Track the origin of the Mosaic, display file name.
The z value for this point.
virtual void mouseMove(QPoint p)
This method is called when the mouse has moved across the viewport and updates the row accordingly...
QString settingsFilePath() const
Generate the correct path for the config file.
The x value for this point.
Container for cube-like labels.
Definition: Pvl.h:135
The planetographic latitude for this point.
The 360 east longitude for this point.
void SetPosition(const double sample, const double line, const int band)
Sets the line and sample position of the buffer.
Definition: Portal.h:109
void setCurrentRow(int row)
Sets the current row to row.
double UniversalLatitude()
This returns a universal latitude (planetocentric).
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
Definition: Camera.cpp:2896
double UndistortedFocalPlaneZ() const
Return undistorted focal plane z.
a subclass of the qisis mainwindow, tablemainwindow handles all of the table tasks.
double YCoord() const
This returns the projection Y provided SetGround, SetCoordinate, SetUniversalGround, or SetWorld returned with success.
Definition: Projection.cpp:415
virtual void mouseLeave()
This method is called when the mouse leaves the viewport and clears any rows accordingly.
void Coordinate(double p[3]) const
Returns the x,y,z of the surface intersection in BodyFixed km.
Definition: Sensor.cpp:211
bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
Definition: Projection.cpp:483
Defines an angle and provides unit conversions.
Definition: Angle.h:58
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
int p_numRows
The number of rows in the table.
Distance LocalRadius() const
Returns the local radius at the intersection point.
Definition: Sensor.cpp:282
void readSettings()
Read this tool&#39;s preserved state.
The z of the undistorted focal plane.
The slant for this cube.
The right ascension for this point.
double Longitude() const
This returns a longitude with correct longitude direction and domain as specified in the label object...
The spacecraft y position for this cube.
Base class for Map Projections of plane shapes.
Class for storing Table blobs information.
Definition: Table.h:74
The spacecraft x position for this cube.
QString toString() const
Returns a string representation of this exception.
Definition: IException.cpp:553
double FocalPlaneY() const
Return distorted focal plane y.
QString PixelToString(double d)
Takes a double pixel value and returns the name of the pixel type as a string.
Definition: SpecialPixel.h:373
int currentIndex() const
Returns the current index.
double PixelResolution()
Returns the pixel resolution at the current position in meters/pixel.
Definition: Camera.cpp:744
Isis exception class.
Definition: IException.h:99
QString toolIconDir() const
returns the path to the icon directory.
Definition: Tool.h:127
The y value for this point.
Base class for the Qisis tools.
Definition: Tool.h:81
QString fileName() const
Returns the opened cube&#39;s filename.
Definition: Cube.cpp:1160
double FocalPlaneX() const
Return distorted focal plane x.
void addToTable(bool setOn, const QString &heading, const QString &menuText="", int insertAt=-1, Qt::Orientation o=Qt::Horizontal, QString toolTip="")
Adds a new column to the table when a new curve is added to the plot.
double LocalSolarTime()
Return the local solar time in hours.
Definition: Sensor.cpp:648
void TrackMosaicOrigin(MdiCubeViewport *cvp, int piLine, int piSample, int &piOrigin, QString &psSrcFileName, QString &psSrcSerialNum)
TrackMosaicOrigin - Given the pointer to Cube and line and sample index, finds the origin of the mosa...
ShapeModel * shape() const
Return the shape.
Definition: Target.cpp:592
void activate(bool)
Activates the tool.
Definition: Tool.cpp:131
ProjectionType projectionType() const
Returns an enum value for the projection type.
Definition: Projection.cpp:213
static double To180Domain(const double lon)
This method converts a ring longitude into the -180 to 180 domain.
void showTable()
This method checks to see if the table has been created.
int cubeLines() const
Return the number of lines in the cube.
double IncidenceAngle() const
Returns the incidence angle in degrees.
Definition: Sensor.cpp:350
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
void updateID()
This method updates the record ID.
QString path() const
Returns the path.
Definition: FileName.cpp:88
double UndistortedFocalPlaneX() const
Return undistorted focal plane x.
The north azimuth for this cube.
Longitude solarLongitude()
Returns the solar longitude.
Definition: Spice.cpp:1363
ProjectionType
This enum defines the subclasses of Projection supported in Isis.
Definition: Projection.h:180
The 360 west longitude for this point.
void addToPermanent(QToolBar *perm)
This method adds the action to bring up the track tool to the permanent tool bar. ...
double UniversalRingLongitude()
This returns a universal ring longitude (clockwise in 0 to 360 domain).
The resoultion for this point.
void setCurrentIndex(int currentIndex)
Sets the current index to currentIndex.
double Declination()
Returns the declination angle (sky latitude).
Definition: Sensor.cpp:564
These projections are used to map triaxial and irregular-shaped bodies.
Definition: Projection.h:180
IO Handler for Isis Cubes.
Definition: Cube.h:158

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:14:02