Commit 3b160ed2 authored by Kaitlyn Lee's avatar Kaitlyn Lee
Browse files

Moved tracking cube code to CubeViewport.

parent 9fb7022d
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -571,22 +571,16 @@ namespace Isis {
        int iTrackBand = -1;

        if(cCube->hasGroup("Tracking")) {
          PvlGroup trackingGroup = cCube->group("Tracking");
          //Because the tracking group does not have a path, get the path from the main cube
          FileName cCubeName(cCube->fileName());
          QString trackingCubeName = trackingGroup.findKeyword("Filename")[0];
          FileName trackingCubeFileName(cCubeName.path() + "/" + trackingCubeName);
          Cube trackingCube(trackingCubeFileName);

          Cube *trackingCube = cvp->trackingCube();
          // Read the cube DN value from TRACKING cube at location (piLine, piSample)
          Portal trackingPortal(trackingCube.sampleCount(), 1, trackingCube.pixelType());
          Portal trackingPortal(trackingCube->sampleCount(), 1, trackingCube->pixelType());
          trackingPortal.SetPosition(piSample, piLine, 1);
          trackingCube.read(trackingPortal);
          trackingCube->read(trackingPortal);

          unsigned int currentPixel = trackingPortal[0];
          if (currentPixel != NULLUI4) {  // If from an image
            Table table(m_tableMosaicSrc);
            trackingCube.read(table);
            trackingCube->read(table);
            TrackingTable trackingTable(table);

            FileName trackingFileName = trackingTable.pixelToFileName(currentPixel);
+2 −1
Original line number Diff line number Diff line
@@ -86,7 +86,8 @@ namespace Isis {
   *                          an external tracking cube.
   *  @history 2018-07-31 Kaitlyn Lee - Updated TrackMosaicOrigin to use a TrackingTable object
   *                          to get the file name, serial number, and index of the image associated
   *                          with the current pixel.
   *                          with the current pixel. Moved code opening the tracking cube to
   *                          CubeViewport.
   */
  class AdvancedTrackTool : public Tool {
      Q_OBJECT
+28 −2
Original line number Diff line number Diff line
@@ -97,6 +97,13 @@ namespace Isis {
      p_cubeId = p_cubeData->AddCube(p_cube);
    }

    if(p_cube->hasGroup("Tracking")) {
      setTrackingCube();
    }
    else {
      p_trackingCube = NULL;
    }


    connect(p_cubeData, SIGNAL(BrickChanged(int, const Isis::Brick *)),
            this, SLOT(cubeDataChanged(int, const Isis::Brick *)));
@@ -370,6 +377,9 @@ namespace Isis {

    p_cube = NULL;
    
    delete p_trackingCube;
    p_trackingCube = NULL;

    if(p_progressTimer) {
      delete p_progressTimer;
      p_progressTimer = NULL;
@@ -2359,6 +2369,22 @@ namespace Isis {
  }


/**
 * Finds the Tracking group from p_cube and stores the tracking cube name
 * so that we can grab it in AdvancedTrackTool and get mosaic information.
 * This way, we are not opening the tracking cube every time the cursor is moved.
 */
  void CubeViewport::setTrackingCube() {
    PvlGroup trackingGroup = p_cube->group("Tracking");
    //Because the tracking group does not have a path, get the path from the main cube
    FileName cubeName(p_cube->fileName());
    QString trackingCubeName = trackingGroup.findKeyword("Filename")[0];
    FileName trackingCubeFileName(cubeName.path() + "/" + trackingCubeName);
    Cube *trackingCube = new Cube(trackingCubeFileName);
    p_trackingCube = trackingCube;
  }


  /**
   * Allows users to change the cursor type on the viewport.
   *
+34 −23
Original line number Diff line number Diff line
@@ -125,6 +125,9 @@ namespace Isis {
   *  @history 2017-08-11 Adam Goins - Added the ability to ctrl + c to copy the filename
   *                          of the current cube into the system's clipboard.
   *                          Fixes #5098.
   *  @history 2018-07-31 Kaitlyn Lee - Added setTrackingCube() and trackingCube() so that a
   *                          tracking cube is stored when needed and we do not have to open it in
   *                          AdvancedTrackTool every time the cursor is moved.
   */
  class CubeViewport : public QAbstractScrollArea {
      Q_OBJECT
@@ -361,6 +364,11 @@ namespace Isis {
        return p_groundMap;
      };

      //! @return The tracking cube associated with p_cube (if it has one)
      Cube *trackingCube() const {
        return p_trackingCube;
      };

      void moveCursor(int x, int y);
      bool cursorInside() const;
      QPoint cursorPosition() const;
@@ -512,6 +520,8 @@ namespace Isis {

      bool confirmClose();

      void setTrackingCube();

    signals:
      void viewportUpdated();//!< Emitted when viewport updated.
      void viewportClosed(CubeViewport *);//!< Emitted when viewport is closed.
@@ -628,6 +638,7 @@ namespace Isis {
      Camera *p_camera;  //!< The camera from the cube.
      Projection *p_projection;  //!< The projection from the cube.
      UniversalGroundMap *p_groundMap;  //!< The universal ground map from the cube.
      Cube *p_trackingCube; //<! The tracking cube associated with p_cube

      //! Activated to update progress bar
      QTimer *p_progressTimer;