Commit a4968297 authored by Ken Edmundson's avatar Ken Edmundson
Browse files

project update

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@5922 41f8697f-d340-4b68-9986-7bafba869bb8
parent e67452f2
Loading
Loading
Loading
Loading
+175 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ namespace Isis {

    m_idToControlMap = new QMap<QString, Control *>;
    m_idToImageMap = new QMap<QString, Image *>;
    m_idToBundleResultsMap = new QMap<QString, BundleResults *>;

    m_name = "Project";

@@ -161,10 +162,17 @@ namespace Isis {
    m_images = new QList<ImageList *>;

    m_controls = new QList<ControlList *>;

    m_bundleResults = new QList<BundleResults *>;

    m_warnings = new QStringList;
    m_workOrderHistory = new QList< QPointer<WorkOrder> >;

    m_imageReadingMutex = new QMutex;

    // TODO: ken testing
//    m_bundleSettings = NULL;
//    m_bundleSettings = new BundleSettings();
  }


@@ -219,12 +227,24 @@ namespace Isis {
      m_controls = NULL;
    }

    if (m_bundleResults) {
      foreach (BundleResults *bundleResults, *m_bundleResults) {
        delete bundleResults;
      }

      delete m_bundleResults;
      m_bundleResults = NULL;
    }

    delete m_idToControlMap;
    m_idToControlMap = NULL;

    delete m_idToImageMap;
    m_idToImageMap = NULL;

    delete m_idToBundleResultsMap;
    m_idToBundleResultsMap = NULL;

    m_directory = NULL;

    delete m_projectRoot;
@@ -240,6 +260,9 @@ namespace Isis {

    delete m_workOrderHistory;
    m_workOrderHistory = NULL;

    delete m_bundleSettings;
    m_bundleSettings = NULL;
  }


@@ -270,6 +293,19 @@ namespace Isis {
        warn(msg);
        throw IException(IException::Io, msg, _FILEINFO_);
      }

      if ( !dir.mkdir( resultsRoot() ) ) {
        QString msg = QString("Unable to create folder [%1] when trying to initialize project")
                        .arg( resultsRoot() );
        warn(msg);
        throw IException(IException::Io, msg, _FILEINFO_);
      }
      if ( !dir.mkdir( bundleResultsRoot() ) ) {
        QString msg = QString("Unable to create folder [%1] when trying to initialize project")
                        .arg( bundleResultsRoot() );
        warn(msg);
        throw IException(IException::Io, msg, _FILEINFO_);
      }
    }
    catch (...) {
      warn("Failed to create project directory structure");
@@ -335,6 +371,24 @@ namespace Isis {
      stream.writeEndElement();
    }

    if ( !m_bundleResults->isEmpty() ) {
      stream.writeStartElement("bundleResults");

      for (int i = 0; i < m_bundleResults->count(); i++) {
        m_bundleResults->at(i)->save(stream, this, newProjectRoot);
      }

      stream.writeEndElement();
    }

    if ( m_bundleSettings ) {
      stream.writeStartElement("bundleSettings");

//      m_bundleSettings->save(stream, this, newProjectRoot);

      stream.writeEndElement();
    }

    stream.writeEndElement();
  }

@@ -424,6 +478,28 @@ namespace Isis {
  }


  /**
   * Create and return the name of a folder for placing BundleResults.
   *
   * TODO: don't know if sentence below is accurate.
   * This can be called from multiple threads, but should only be called by one thread at a time.
   */
  QDir Project::addBundleResultsFolder(QString folder) {
    QDir bundleResultsFolder = bundleResultsRoot();

    if ( !bundleResultsFolder.mkpath(folder) ) {
      throw IException(IException::Io,
          tr("Could not create bundle results directory [%1] in [%2].")
            .arg(folder).arg( bundleResultsFolder.absolutePath() ),
          _FILEINFO_);
    }

    bundleResultsFolder.cd(folder);

    return bundleResultsFolder;
  }


  /**
   * Create and return the name of a folder for placing control networks.
   *
@@ -549,6 +625,28 @@ namespace Isis {
    return (*m_idToControlMap)[id];
  }

  /**
   * Add the given BundleResults to the current project. This will cause the BundleResults to be
   *   saved/restored from disk, Project-related GUIs to display the BundleResults, and enable
   *   access to the BundleResults given access to the project.
   */
  void Project::addBundleResults(BundleResults *bundleResults) {

    connect( bundleResults, SIGNAL( destroyed(QObject *) ),
             this, SLOT( bundleResultsClosed(QObject *) ) );
    connect( this, SIGNAL( projectRelocated(Project *) ),
             bundleResults, SLOT( updateFileName(Project *) ) );

    // create bundle results folder
    addBundleResultsFolder(bundleResults->runTime());

    m_bundleResults->append(bundleResults);

    (*m_idToBundleResultsMap)[bundleResults->id()] = bundleResults;

    emit bundleResultsAdded(bundleResults);
  }


  /**
   * Returns the directory associated with this Project. The directory is not part of the project
@@ -887,6 +985,51 @@ namespace Isis {
  }


  /**
   * Appends the root directory name 'results' to the project.
   *
   * @return The path to the root directory of bundleresults data.
   */
  QString Project::resultsRoot(QString projectRoot) {
    return projectRoot + "/results";
  }


  /**
   * Accessor for the root directory of the results data.
   *
   * @return The path to the root directory of the results data.
   */
  QString Project::resultsRoot() const {
    return resultsRoot( m_projectRoot->path() );
  }


  QList<BundleResults *> Project::bundleResults() {
    return *m_bundleResults;
  }


  /**
   * Appends the root directory name 'bundle' to the project results directory.
   *
   * @return The path to the root directory of bundle results data.
   */
  QString Project::bundleResultsRoot(QString projectRoot) {
    return projectRoot + "/results/bundle";
  }


  /**
   * Accessor for the root directory of the results data.
   *
   * @return The path to the root directory of the results data.
   */
  QString Project::bundleResultsRoot() const {
    return bundleResultsRoot( m_projectRoot->path() );
  }


  /**
   * Delete all of the files, that this project stores, from disk.
   */
@@ -904,6 +1047,11 @@ namespace Isis {
             .arg( cnetRoot() ) );
    }

    if ( !m_projectRoot->rmdir( resultsRoot() ) ) {
      warn( tr("Did not properly clean up results folder [%1] in project")
             .arg( resultsRoot() ) );
    }

    if ( !m_projectRoot->rmpath( m_projectRoot->path() ) ) {
      warn( tr("Did not properly clean up project in [%1]").arg( m_projectRoot->path() ) );
    }
@@ -1201,6 +1349,25 @@ namespace Isis {
  }

  
  /**
   * A BundleResults object is being deleted from the project
   */
  void Project::bundleResultsClosed(QObject *bundleResultsObj) {
    QMutableListIterator<BundleResults *> it(*m_bundleResults);
    while ( it.hasNext() ) {
      BundleResults *bundleResults = it.next();

      int foundElement = m_bundleResults->indexOf( (BundleResults *)bundleResultsObj );

      if (foundElement != -1) {
        m_bundleResults->removeAt(foundElement);
      }
    }

    m_idToBundleResultsMap->remove(m_idToBundleResultsMap->key((BundleResults *)bundleResultsObj));
  }



  Project::XmlHandler::XmlHandler(Project *project) {
    m_project = project;
@@ -1248,6 +1415,11 @@ namespace Isis {
      else if (localName == "directory") {
        m_project->directory()->load( reader() );
      }

      else if (localName == "bundleSettings") {
        BundleSettings *bundleSettings = m_project->bundleSettings();
//        bundleSettings = new BundleSettings(m_project, reader());
      }
    }

    return true;
@@ -1275,6 +1447,9 @@ namespace Isis {
      }
      m_controls.clear();
    }
    else if (localName == "bundleSettings") {
      // TODO: what to do here????
    }

    return XmlStackedHandler::endElement(namespaceURI, localName, qName);
  }
+20 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ class QXmlStreamWriter;
#include "XmlStackedHandler.h"

namespace Isis {
  class BundleResults;
  class BundleSettings;
  class Control;
  class ControlList;
  class CorrelationMatrix;
@@ -88,11 +90,13 @@ namespace Isis {
//      static QStringList verifyCNets(QStringList);

      QList<QAction *> userPreferenceActions();
      QDir addBundleResultsFolder(QString folder);
      QDir addCnetFolder(QString prefix);
      void addControl(Control *control);
      QDir addImageFolder(QString prefix);
      void addImages(QStringList imageFiles);
      void addImages(ImageList newImages);
      void addBundleResults(BundleResults *bundleResults);
      Control *control(QString id);
      Directory *directory() const;
      Image *image(QString id);
@@ -118,9 +122,17 @@ namespace Isis {
      QString imageDataRoot() const;
      QList<ImageList *> images();

      static QString resultsRoot(QString projectRoot);
      QString resultsRoot() const;
      static QString bundleResultsRoot(QString projectRoot);
      QString bundleResultsRoot() const;
      QList<BundleResults *> bundleResults();

      void deleteAllProjectFiles();
      void relocateProjectRoot(QString newRoot);

      BundleSettings *bundleSettings() {return m_bundleSettings;}

      QProgressBar *progress();

//       void removeImages(ImageList &imageList);
@@ -140,6 +152,7 @@ namespace Isis {
      void controlAdded(Control *control);
      // Emitted when new images are available.
      void imagesAdded(ImageList *images);
      void bundleResultsAdded(BundleResults *bundleResults);
      void nameChanged(QString newName);
      void projectLoaded(Project *);
      void projectRelocated(Project *);
@@ -155,6 +168,7 @@ namespace Isis {
      void imagesReady(ImageList);
      void imageClosed(QObject *image);
      void imageListDeleted(QObject *imageList);
      void bundleResultsClosed(QObject *bundleResults);

    private:
      Project(const Project &other);
@@ -205,6 +219,10 @@ namespace Isis {
      QPointer<Directory> m_directory;
      QList<ImageList *> *m_images;
      QList<ControlList *> *m_controls;
      QList<BundleResults *> *m_bundleResults;

      // TODO: kle testing - this will almost certainly be changed
      BundleSettings *m_bundleSettings;
      /**
       * This variable will probably go away when we add the bundle results object because it will
       *  be under:
@@ -216,6 +234,8 @@ namespace Isis {

      QMap<QString, Control *> *m_idToControlMap;
      QMap<QString, Image *> *m_idToImageMap;
      QMap<QString, BundleResults *> *m_idToBundleResultsMap;

      QString m_name;
      QStringList *m_warnings;
      QList< QPointer<WorkOrder> > *m_workOrderHistory;