24 #include "IsisDebug.h"
29 #include <QApplication>
31 #include <QFileDialog>
33 #include <QFutureWatcher>
34 #include <QMessageBox>
36 #include <QMutexLocker>
37 #include <QProgressBar>
38 #include <QStringList>
40 #include <QXmlStreamWriter>
46 #include "ControlList.h"
53 #include "GuiCameraList.h"
55 #include "ImageList.h"
56 #include "ImageReader.h"
58 #include "ProgressBar.h"
60 #include "ShapeList.h"
61 #include "ShapeReader.h"
63 #include "TargetBodyList.h"
66 #include "XmlStackedHandlerReader.h"
76 m_bundleSettings = NULL;
81 m_idToImageMap = NULL;
82 m_idToShapeMap = NULL;
83 m_idToTargetBodyMap = NULL;
84 m_idToGuiCameraMap = NULL;
90 m_workOrderHistory = NULL;
91 m_isTemporaryProject =
true;
92 m_activeControl = NULL;
93 m_activeImageList = NULL;
95 m_numImagesCurrentlyReading = 0;
98 m_imageReadingMutex = NULL;
100 m_numShapesCurrentlyReading = 0;
102 m_shapeReadingMutex = NULL;
114 QDir tempDir = QDir::temp();
117 QApplication::applicationName() +
"_*");
118 tempDir.setNameFilters(nameFilters);
120 QStringList existingProjects = tempDir.entryList();
121 bool crashedPreviously =
false;
123 foreach (QString existingProject, existingProjects) {
124 FileName existingProjectFileName(tempDir.absolutePath() +
"/" + existingProject);
125 QString pidString = QString(existingProject).replace(QRegExp(
".*_"),
"");
126 int otherPid = pidString.toInt();
129 if ( !QFile::exists(
"/proc/" + pidString) ) {
130 crashedPreviously =
true;
131 int status = system( (
"rm -rf '" +
132 existingProjectFileName.expanded() +
"' &").toLatin1().data() );
134 QString msg =
"Executing command [rm -rf" + existingProjectFileName.expanded() +
135 "' &] failed with return status [" +
toString(status) +
"]";
142 if (crashedPreviously &&
false) {
143 QMessageBox::information( NULL,
144 QObject::tr(
"Crashed"),
145 QObject::tr(
"It appears %1 crashed. We're sorry.").
146 arg( QApplication::applicationName() ) );
151 QString tmpFolder = QDir::temp().absolutePath() +
"/"
153 + QApplication::applicationName() +
"_" + QString::number( getpid() );
154 QDir temp(tmpFolder +
"/tmpProject");
155 m_projectRoot =
new QDir(temp);
162 catch (std::exception &e) {
165 tr(
"Error creating project folders [%1]").arg( e.what() ),
_FILEINFO_);
169 m_mutex =
new QMutex;
174 connect( m_imageReader, SIGNAL( imagesReady(
ImageList) ),
178 this, SLOT(addTargetsFromImportedImagesToProject(
ImageList *) ) );
181 this, SLOT(addCamerasFromImportedImagesToProject(
ImageList *) ) );
186 m_shapeMutex =
new QMutex;
188 m_shapeReader =
new ShapeReader(m_shapeMutex,
false);
190 connect( m_shapeReader, SIGNAL( shapesReady(
ShapeList) ),
206 m_imageReadingMutex =
new QMutex;
208 m_shapeReadingMutex =
new QMutex;
220 if (m_isTemporaryProject) {
224 int undoStackIndex = m_undoStack.index();
225 int undoStackCleanIndex = m_undoStack.cleanIndex();
227 int undoNeededToRestoreDiskState = undoStackIndex;
229 for (
int i = undoStackIndex - 1; i >= undoStackCleanIndex; i--) {
231 dynamic_cast<const WorkOrder *
>( m_undoStack.command(i) );
233 undoNeededToRestoreDiskState = i;
237 if (undoNeededToRestoreDiskState != undoStackIndex) {
238 m_undoStack.setIndex(undoNeededToRestoreDiskState);
243 foreach (
ImageList *imageList, *m_images) {
244 foreach (
Image *image, *imageList) {
256 foreach (
ShapeList *shapeList, *m_shapes) {
257 foreach (
Shape *shape, *shapeList) {
270 foreach (
Control *control, *controlList) {
280 m_activeControl = NULL;
281 m_activeImageList = NULL;
283 if (m_bundleSolutionInfo) {
285 delete bundleSolutionInfo;
288 delete m_bundleSolutionInfo;
289 m_bundleSolutionInfo = NULL;
295 delete m_idToImageMap;
296 m_idToImageMap = NULL;
298 delete m_idToShapeMap;
299 m_idToShapeMap = NULL;
301 delete m_idToTargetBodyMap;
302 m_idToTargetBodyMap = NULL;
304 delete m_idToGuiCameraMap;
305 m_idToGuiCameraMap = NULL;
307 delete m_idToBundleSolutionInfoMap;
308 m_idToBundleSolutionInfoMap = NULL;
312 delete m_projectRoot;
313 m_projectRoot = NULL;
318 delete m_imageReader;
319 delete m_shapeReader;
324 delete m_workOrderHistory;
325 m_workOrderHistory = NULL;
327 delete m_bundleSettings;
328 m_bundleSettings = NULL;
337 if ( !dir.mkpath( m_projectRoot->path() ) ) {
338 warn(
"Cannot create project directory.");
340 tr(
"Unable to create folder [%1] when trying to initialize project")
341 .arg(m_projectRoot->path() ),
347 QString msg = QString(
"Unable to create folder [%1] when trying to initialize project")
354 QString msg = QString(
"Unable to create folder [%1] when trying to initialize project")
361 QString msg = QString(
"Unable to create folder [%1] when trying to initialize project")
368 QString msg = QString(
"Unable to create folder [%1] when trying to initialize project")
374 QString msg = QString(
"Unable to create folder [%1] when trying to initialize project")
381 warn(
"Failed to create project directory structure");
387 ImageList *Project::createOrRetrieveImageList(QString name) {
395 connect( result, SIGNAL( destroyed(
QObject *) ),
399 m_images->append(result);
405 ShapeList *Project::createOrRetrieveShapeList(QString name) {
413 connect( result, SIGNAL( destroyed(
QObject *) ),
415 m_shapes->append(result);
434 void Project::save(QXmlStreamWriter &stream,
FileName newProjectRoot)
const {
435 stream.writeStartElement(
"project");
437 stream.writeAttribute(
"name", m_name);
439 if ( !m_controls->isEmpty() ) {
440 stream.writeStartElement(
"controlNets");
442 for (
int i = 0; i < m_controls->count(); i++) {
443 m_controls->at(i)->save(stream,
this, newProjectRoot);
446 stream.writeEndElement();
449 if ( !m_images->isEmpty() ) {
450 stream.writeStartElement(
"imageLists");
452 for (
int i = 0; i < m_images->count(); i++) {
453 m_images->at(i)->save(stream,
this, newProjectRoot);
456 stream.writeEndElement();
459 if ( !m_shapes->isEmpty() ) {
460 stream.writeStartElement(
"shapeLists");
462 for (
int i = 0; i < m_shapes->count(); i++) {
463 m_shapes->at(i)->save(stream,
this, newProjectRoot);
466 stream.writeEndElement();
489 if (!m_bundleSolutionInfo->isEmpty()) {
490 stream.writeStartElement(
"bundleRuns");
492 for (
int i = 0; i < m_bundleSolutionInfo->count(); i++) {
493 m_bundleSolutionInfo->at(i)->runTime();
496 stream.writeEndElement();
499 stream.writeEndElement();
519 stream.writeStartElement(
"history");
521 foreach (
WorkOrder *workOrder, *m_workOrderHistory) {
523 workOrder->
save(stream);
527 stream.writeEndElement();
542 stream.writeStartElement(
"warnings");
544 foreach (QString warning, *m_warnings) {
545 stream.writeStartElement(
"warning");
546 stream.writeAttribute(
"text", warning);
547 stream.writeEndElement();
550 stream.writeEndElement();
565 foreach (QString fileName, fileNames) {
568 result.append(fileName);
597 if (!bundleSolutionInfoFolder.mkpath(folder)) {
599 tr(
"Could not create bundle results directory [%1] in [%2].")
600 .arg(folder).arg(bundleSolutionInfoFolder.absolutePath()),
604 bundleSolutionInfoFolder.cd(folder);
605 return bundleSolutionInfoFolder;
617 int prefixCounter = 0;
619 QString numberedPrefix;
622 numberedPrefix = prefix.arg( QString::number(prefixCounter) );
624 while ( cnetFolder.exists(numberedPrefix) );
626 if ( !cnetFolder.mkpath(numberedPrefix) ) {
628 tr(
"Could not create control network directory [%1] in [%2].")
629 .arg(numberedPrefix).arg( cnetFolder.absolutePath() ),
633 cnetFolder.cd(numberedPrefix);
635 m_currentCnetFolder = cnetFolder;
648 connect( control, SIGNAL( destroyed(
QObject *) ),
651 control, SLOT( updateFileName(
Project *) ) );
653 createOrRetrieveControlList(
FileName( control->
fileName() ).dir().dirName() )->append(control);
655 (*m_idToControlMap)[control->
id()] = control;
661 ControlList *Project::createOrRetrieveControlList(QString name) {
670 connect( result, SIGNAL( destroyed(
QObject *) ),
674 m_controls->append(result);
689 int prefixCounter = 0;
691 QString numberedPrefix;
694 numberedPrefix = prefix.arg( QString::number(prefixCounter) );
696 while ( imageFolder.exists(numberedPrefix) );
698 if ( !imageFolder.mkpath(numberedPrefix) ) {
700 tr(
"Could not create image directory [%1] in [%2].")
701 .arg(numberedPrefix).arg( imageFolder.absolutePath() ),
705 imageFolder.cd(numberedPrefix);
716 if (m_numImagesCurrentlyReading == 0) {
717 m_imageReadingMutex->lock();
720 m_numImagesCurrentlyReading += imageFiles.count();
721 m_imageReader->read(imageFiles);
727 imagesReady(newImages);
739 int prefixCounter = 0;
741 QString numberedPrefix;
744 numberedPrefix = prefix.arg( QString::number(prefixCounter) );
746 while ( shapeFolder.exists(numberedPrefix) );
748 if ( !shapeFolder.mkpath(numberedPrefix) ) {
750 tr(
"Could not create shape directory [%1] in [%2].")
751 .arg(numberedPrefix).arg( shapeFolder.absolutePath() ),
755 shapeFolder.cd(numberedPrefix);
765 if (m_numShapesCurrentlyReading == 0) {
766 m_shapeReadingMutex->lock();
769 m_numShapesCurrentlyReading += shapeFiles.count();
770 m_shapeReader->read(shapeFiles);
775 shapesReady(newShapes);
779 Control *Project::control(QString
id) {
791 connect(bundleSolutionInfo, SIGNAL(destroyed(
QObject *)),
794 bundleSolutionInfo, SLOT(updateFileName(
Project *)));
797 QString runTime = bundleSolutionInfo->
runTime();
800 QString bundleFileName = bundleDir.absolutePath() +
"/" +
"BundleSolutionInfo.hdf";
802 bundleSolutionInfo->
bundleSettings()->setOutputFilePrefix(bundleDir.absolutePath() +
"/");
805 loadBundleSolutionInfo(bundleSolutionInfo);
810 m_bundleSolutionInfo->append(bundleSolutionInfo);
812 (*m_idToBundleSolutionInfoMap)[bundleSolutionInfo->
id()] = bundleSolutionInfo;
840 m_isTemporaryProject =
false;
842 FileName projectPath(projectPathStr);
846 reader.pushContentHandler(&handler);
847 reader.setErrorHandler(&handler);
849 QString projectXmlPath = projectPath.toString() +
"/project.xml";
850 QFile file(projectXmlPath);
851 if ( !file.open(QFile::ReadOnly) ) {
853 QString(
"Unable to open [%1] with read access")
854 .arg(projectXmlPath),
858 QDir oldProjectRoot(*m_projectRoot);
859 *m_projectRoot = projectPath.expanded();
861 QXmlInputSource xmlInputSource(&file);
867 reader.parse(xmlInputSource);
871 .arg(projectPath.original()));
874 catch (std::exception &e) {
876 .arg(projectPath.original()));
880 QString projectXmlHistoryPath = projectPath.toString() +
"/history.xml";
881 QFile historyFile(projectXmlHistoryPath);
883 if ( !historyFile.open(QFile::ReadOnly) ) {
885 QString(
"Unable to open [%1] with read access")
886 .arg(projectXmlHistoryPath),
890 reader.pushContentHandler(&handler);
891 QXmlInputSource xmlHistoryInputSource(&historyFile);
894 reader.parse(xmlHistoryInputSource);
899 .arg(projectPath.original()));
902 catch (std::exception &e) {
904 .arg(projectPath.original()));
908 QString projectXmlWarningsPath = projectPath.toString() +
"/warnings.xml";
909 QFile warningsFile(projectXmlWarningsPath);
911 if (!warningsFile.open(QFile::ReadOnly)) {
913 QString(
"Unable to open [%1] with read access")
914 .arg(projectXmlWarningsPath),
918 reader.pushContentHandler(&handler);
920 QXmlInputSource xmlWarningsInputSource(&warningsFile);
921 if (!reader.parse(xmlWarningsInputSource)) {
922 warn(tr(
"Failed to read warnings from project [%1]").arg(projectPath.original()));
925 QString directoryXmlPath = projectPath.toString() +
"/directory.xml";
926 QFile directoryFile(directoryXmlPath);
929 if (!directoryFile.open(QFile::ReadOnly)) {
931 QString(
"Unable to open [%1] with read access")
932 .arg(directoryXmlPath),
936 reader.pushContentHandler(&handler);
938 QXmlInputSource xmlDirectoryInputSource(&directoryFile);
941 reader.parse(xmlDirectoryInputSource);
945 .arg(projectPath.original()));
949 catch (std::exception &e) {
951 .arg(projectPath.original()));
956 if (bundleRoot.exists()) {
958 bundleRoot.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
960 QFileInfoList bundleDirs = bundleRoot.entryInfoList();
961 for (
int dirListIndex = 0; dirListIndex < bundleDirs.size(); dirListIndex++) {
963 QDir bundleSolutionDir(bundleDirs[dirListIndex].absoluteFilePath());
964 bundleSolutionDir.setFilter(QDir::Files | QDir::NoSymLinks);
966 QFileInfoList bundleSolutionFiles = bundleSolutionDir.entryInfoList();
967 for (
int fileListIndex = 0; fileListIndex < bundleSolutionFiles.size(); fileListIndex++) {
969 if (bundleSolutionFiles[fileListIndex].fileName().contains(
"_BundleSolutionInfo.hdf")) {
970 QString absoluteFileName = bundleSolutionFiles[fileListIndex].absoluteFilePath();
971 FileName solutionFile(bundleSolutionFiles[fileListIndex].absoluteFilePath());
983 return m_imageReader->progress();
987 Image *Project::image(QString
id) {
988 return (*m_idToImageMap)[id];
992 ImageList *Project::imageList(QString name) {
993 QListIterator<ImageList *> it(*m_images);
996 while (it.hasNext() && !result) {
999 if (list->
name() ==
name) result = list;
1006 Shape *Project::shape(QString
id) {
1007 return (*m_idToShapeMap)[id];
1011 ShapeList *Project::shapeList(QString name) {
1012 QListIterator<ShapeList *> it(*m_shapes);
1015 while (it.hasNext() && !result) {
1018 if (list->
name() ==
name) result = list;
1025 bool Project::isTemporaryProject()
const {
1026 return m_isTemporaryProject;
1030 WorkOrder *Project::lastNotUndoneWorkOrder() {
1032 QListIterator< QPointer<WorkOrder> > it(*m_workOrderHistory);
1035 while ( !result && it.hasPrevious() ) {
1055 const WorkOrder *Project::lastNotUndoneWorkOrder()
const {
1057 QListIterator< QPointer<WorkOrder> > it(*m_workOrderHistory);
1060 while ( !result && it.hasPrevious() ) {
1088 return m_projectRoot->path();
1101 QUndoStack *Project::undoStack() {
1102 return &m_undoStack;
1106 QString Project::nextImageListGroupName() {
1107 int numLists = m_images->size();
1108 QString maxName =
"";
1109 QString newGroupName =
"Group";
1111 foreach (
ImageList *imageList, *m_images) {
1112 QString name = imageList->
name();
1113 if ( !name.contains(
"Group") )
continue;
1114 if ( maxName.isEmpty() ) {
1117 else if (name > maxName) {
1122 if ( maxName.isEmpty() ) {
1123 newGroupName += QString::number(numLists+1);
1126 int maxNum = maxName.remove(
"Group").toInt();
1129 newGroupName += QString::number(maxNum);
1131 return newGroupName;
1136 void Project::waitForImageReaderFinished() {
1137 QMutexLocker locker(m_imageReadingMutex);
1141 void Project::waitForShapeReaderFinished() {
1142 QMutexLocker locker(m_shapeReadingMutex);
1151 foreach (
WorkOrder *workOrder, *m_workOrderHistory) {
1152 result.append(workOrder);
1169 m_activeControl = control;
1183 return m_activeControl;
1197 m_activeImageList = imageList;
1211 return m_activeImageList;
1221 return projectRoot +
"/cnets";
1231 return cnetRoot( m_projectRoot->path() );
1242 QListIterator< ControlList * > it(*m_controls);
1245 while (it.hasNext() && !result) {
1248 if (list->
name() ==
name) result = list;
1261 return projectRoot +
"/images";
1281 return projectRoot +
"/shapes";
1311 return projectRoot +
"/targets";
1336 return projectRoot +
"/results";
1351 return *m_bundleSolutionInfo;
1361 return projectRoot +
"/results/bundle";
1379 foreach (
ImageList *imagesInAFolder, *m_images) {
1384 warn( tr(
"Did not properly clean up images folder [%1] in project").arg(
imageDataRoot() ) );
1388 warn( tr(
"Did not properly clean up shapes folder [%1] in project").
1392 if ( !m_projectRoot->rmdir(
cnetRoot() ) ) {
1393 warn( tr(
"Did not properly clean up control network folder [%1] in project")
1398 warn( tr(
"Did not properly clean up results folder [%1] in project")
1402 if ( !m_projectRoot->rmpath( m_projectRoot->path() ) ) {
1403 warn( tr(
"Did not properly clean up project in [%1]").arg( m_projectRoot->path() ) );
1414 *m_projectRoot = newProjectRoot;
1419 void Project::save() {
1420 if (m_isTemporaryProject) {
1421 QString newDestination = QFileDialog::getSaveFileName(NULL,
1422 QString(
"Project Location"),
1425 if ( !newDestination.isEmpty() ) {
1426 save( QFileInfo(newDestination +
"/").absolutePath() );
1431 m_isTemporaryProject =
false;
1435 save(m_projectRoot->absolutePath(),
false);
1440 void Project::save(
FileName newPath,
bool verifyPathDoesntExist) {
1441 if ( verifyPathDoesntExist && QFile::exists( newPath.toString() ) ) {
1443 QString(
"Projects may not be saved to an existing path [%1]; "
1444 "please select a new path or delete the current folder")
1445 .arg(newPath.original()),
1450 if (!dir.mkpath(newPath.toString())) {
1452 QString(
"Unable to save project at [%1] "
1453 "because we could not create the folder")
1454 .arg(newPath.original()),
1458 QFile projectSettingsFile(newPath.toString() +
"/project.xml");
1459 if (!projectSettingsFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
1461 QString(
"Unable to save project at [%1] because the file [%2] "
1462 "could not be opened for writing")
1463 .arg(newPath.original()).arg(projectSettingsFile.fileName()),
1467 QXmlStreamWriter writer(&projectSettingsFile);
1468 writer.setAutoFormatting(
true);
1470 writer.writeStartDocument();
1473 save(writer, newPath);
1475 writer.writeEndDocument();
1477 QFile projectHistoryFile(newPath.toString() +
"/history.xml");
1478 if (!projectHistoryFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
1480 QString(
"Unable to save project at [%1] because the file [%2] "
1481 "could not be opened for writing")
1482 .arg(newPath.original()).arg(projectHistoryFile.fileName()),
1486 QXmlStreamWriter historyWriter(&projectHistoryFile);
1487 historyWriter.setAutoFormatting(
true);
1489 historyWriter.writeStartDocument();
1491 historyWriter.writeEndDocument();
1493 QFile projectWarningsFile(newPath.toString() +
"/warnings.xml");
1494 if (!projectWarningsFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
1496 QString(
"Unable to save project at [%1] because the file [%2] could not be "
1497 "opened for writing")
1498 .arg(newPath.original()).arg(projectWarningsFile.fileName()),
1502 QXmlStreamWriter warningsWriter(&projectWarningsFile);
1503 warningsWriter.setAutoFormatting(
true);
1505 warningsWriter.writeStartDocument();
1507 warningsWriter.writeEndDocument();
1509 QFile directoryStateFile(newPath.toString() +
"/directory.xml");
1510 if (!directoryStateFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
1512 QString(
"Unable to save project at [%1] because the file [%2] could not be "
1513 "opened for writing")
1514 .arg(newPath.original()).arg(directoryStateFile.fileName()),
1518 QXmlStreamWriter directoryStateWriter(&directoryStateFile);
1519 directoryStateWriter.setAutoFormatting(
true);
1521 directoryStateWriter.writeStartDocument();
1528 m_directory->save(directoryStateWriter, newPath);
1530 directoryStateWriter.writeEndDocument();
1548 connect(workOrder, SIGNAL(finished(
WorkOrder *)),
1549 this, SIGNAL(workOrderFinished(
WorkOrder *)));
1556 m_workOrderHistory->append(workOrder);
1558 emit workOrderStarting(workOrder);
1563 m_undoStack.setClean();
1567 m_undoStack.push(workOrder);
1571 m_workOrderHistory->removeAll(NULL);
1581 template<
typename Data>
void Project::warn(QString text, Data relevantData) {
1582 storeWarning(text, relevantData);
1587 void Project::warn(QString text) {
1588 foreach (QString line, text.split(
"\n")) {
1595 void Project::storeWarning(QString text) {
1596 m_warnings->append(text);
1600 void Project::imagesReady(
ImageList images) {
1602 m_numImagesCurrentlyReading -= images.count();
1604 foreach (
Image *image, images) {
1605 connect(image, SIGNAL(destroyed(
QObject *)),
1608 image, SLOT(updateFileName(
Project *)));
1610 (*m_idToImageMap)[image->
id()] = image;
1611 createOrRetrieveImageList(
FileName(images[0]->fileName()).dir().dirName())->
append(image);
1618 QMutexLocker lock(m_mutex);
1622 foreach (openImage, images) {
1632 if (m_numImagesCurrentlyReading == 0) {
1633 m_imageReadingMutex->unlock();
1638 void Project::addTargetsFromImportedImagesToProject(
ImageList *imageList) {
1641 foreach (
Image *image, *imageList) {
1651 if (*tb == *targetBody) {
1664 m_targets->
append(targetBody);
1665 connect( targetBody.data(), SIGNAL( destroyed(
QObject *) ),
1670 (*m_idToTargetBodyMap)[targetBody->id()] = targetBody.data();
1679 void Project::addCamerasFromImportedImagesToProject(
ImageList *imageList) {
1681 foreach (
Image *image, *imageList) {
1690 if (*gc == *guiCamera) {
1703 m_guiCameras->
append(guiCamera);
1709 (*m_idToGuiCameraMap)[guiCamera->id()] = guiCamera.data();
1717 void Project::removeImages(
ImageList &imageList) {
1718 foreach (
Image *image, imageList) {
1732 QMutableListIterator<ImageList *> it(*m_images);
1733 while (it.hasNext()) {
1736 int foundElement = list->indexOf((
Image *)imageObj);
1738 if (foundElement != -1) {
1743 m_idToImageMap->remove(m_idToImageMap->key((
Image *)imageObj));
1751 int indexToRemove = m_images->indexOf(static_cast<ImageList *>(imageListObj));
1752 if (indexToRemove != -1) {
1753 m_images->removeAt(indexToRemove);
1762 QMutableListIterator<ControlList *> it(*m_controls);
1763 while ( it.hasNext() ) {
1766 int foundElement = list->indexOf( (
Control *)controlObj );
1768 if (foundElement != -1) {
1781 int indexToRemove = m_controls->indexOf(static_cast<ControlList *>(controlListObj));
1782 if (indexToRemove != -1) {
1783 m_controls->removeAt(indexToRemove);
1792 int indexToRemove = m_shapes->indexOf(static_cast<ShapeList *>(shapeListObj));
1793 if (indexToRemove != -1) {
1794 m_shapes->removeAt(indexToRemove);
1803 QMutableListIterator<BundleSolutionInfo *> it(*m_bundleSolutionInfo);
1804 while (it.hasNext()) {
1806 if (!bundleSolutionInfo) {
1810 int foundElement = m_bundleSolutionInfo->indexOf(
1813 if (foundElement != -1) {
1814 m_bundleSolutionInfo->removeAt(foundElement);
1818 m_idToBundleSolutionInfoMap->remove(
1848 void Project::shapesReady(
ShapeList shapes) {
1850 m_numShapesCurrentlyReading -= shapes.count();
1852 foreach (
Shape *shape, shapes) {
1853 connect(shape, SIGNAL(destroyed(
QObject *)),
1856 shape, SLOT(updateFileName(
Project *)));
1858 (*m_idToShapeMap)[shape->
id()] = shape;
1859 createOrRetrieveShapeList(
1867 QMutexLocker lock(m_shapeMutex);
1871 foreach (openShape, shapes) {
1875 if (m_numShapesCurrentlyReading == 0) {
1876 m_shapeReadingMutex->unlock();
1885 QMutableListIterator<ShapeList *> it(*m_shapes);
1886 while (it.hasNext()) {
1889 int foundElement = list->indexOf((
Shape *)imageObj);
1891 if (foundElement != -1) {
1896 m_idToShapeMap->remove(m_idToShapeMap->key((
Shape *)imageObj));
1900 Project::XmlHandler::XmlHandler(
Project *project) {
1901 m_project = project;
1906 bool Project::XmlHandler::startElement(
const QString &namespaceURI,
const QString &localName,
1907 const QString &qName,
const QXmlAttributes &atts) {
1908 if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
1910 if (localName ==
"project") {
1911 QString name = atts.value(
"name");
1913 if (!name.isEmpty()) {
1914 m_project->setName(name);
1917 else if (localName ==
"controlNets") {
1918 m_controls.append(
new ControlList(m_project, reader()));
1920 else if (localName ==
"imageList") {
1922 m_imageLists.append(
new ImageList(m_project, reader()));
1924 else if (localName ==
"shapeLists") {
1925 m_shapeLists.append(
new ShapeList(m_project, reader()));
1927 else if (localName ==
"workOrder") {
1928 QString type = atts.value(
"type");
1931 ASSERT(m_workOrder->metaObject()->className() == type);
1933 m_workOrder->read(reader());
1935 else if (localName ==
"warning") {
1936 QString warningText = atts.value(
"text");
1938 if (!warningText.isEmpty()) {
1939 m_project->warn(warningText);
1942 else if (localName ==
"directory") {
1943 m_project->directory()->load(reader());
1945 else if (localName ==
"dockRestore") {
1952 else if (localName ==
"bundleSettings") {
1954 if (!bundleSettings) {
1965 bool Project::XmlHandler::endElement(
const QString &namespaceURI,
const QString &localName,
1966 const QString &qName) {
1967 if (localName ==
"project") {
1968 foreach (
ImageList *imageList, m_imageLists) {
1969 m_project->imagesReady(*imageList);
1972 foreach (
ShapeList *shapeList, m_shapeLists) {
1973 m_project->shapesReady(*shapeList);
1976 else if (localName ==
"workOrder") {
1977 m_project->m_workOrderHistory->append(m_workOrder);
1980 else if (localName ==
"controlNets") {
1982 foreach (
Control *control, *list) {
1983 m_project->addControl(control);
1989 else if (localName ==
"bundleSettings") {
1993 return XmlStackedHandler::endElement(namespaceURI, localName, qName);
This represents an ISIS control net in a project-based GUI interface.
QString name() const
Get the human-readable name of this shape list.
Internalizes a list of shapes and allows for operations on the entire list.
QString targetBodyRoot() const
Accessor for the root directory of the target body data.
QDir addImageFolder(QString prefix)
Create and return the name of a folder for placing images.
Internalizes a list of images and allows for operations on the entire list.
void controlClosed(QObject *control)
A control is being deleted from the project.
The main project for cnetsuite.
Container class for TargetBody.
QString id() const
Get a unique, identifying string associated with this image.
void closeCube()
Cleans up the Cube *.
static WorkOrder * create(Project *project, QString type)
This instantiates a work order given a project and a type name (class name in a string).
~Project()
Clean up the project.
QString name() const
Get the project's GUI name.
File name manipulation and expansion.
QList< WorkOrder * > workOrderHistory()
Get the entire list of work orders that have executed.
Container class for BundleAdjustment results.
BundleSettingsQsp bundleSettings()
Returns the bundle settings.
Camera * camera()
Return a camera associated with the cube.
void deleteFromDisk(Project *project)
Delete all of the contained Images from disk.
QMutex * mutex()
Return mutex used for Naif calls.
QString bundleSolutionInfoRoot() const
Accessor for the root directory of the results data.
Maintains a list of Controls so that control nets can easily be copied from one Project to another...
void setName(QString newName)
Set the human-readable name of this control list.
void controlListDeleted(QObject *controlList)
An control list is being deleted from the project.
QString name() const
Get the human-readable name of this image list.
void open(QString)
Open the project at the given path.
QString id() const
Get a unique, identifying string associated with this BundleSolutionInfo object.
void saveHistory(QXmlStreamWriter &stream) const
Serialize the work orders into the given XML.
void showWarning(QString text)
Displays a Warning.
bool createsCleanState() const
Returns the CleanState status (whether the Project has been saved to disk or not).
WorkOrder * previous() const
Gets the previous WorkOrder.
void setPath(QString newPath)
Set the relative path (from the project root) to this shape list's folder.
void addControl(Control *control)
Add the given Control's to the current project.
void controlListAdded(ControlList *controls)
apparently not used?
void targetBodyClosed(QObject *targetBodyObj)
A target body is being deleted from the project.
static QString userName()
the user name.
QString runTime() const
Returns the run time.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
List for holding TargetBodies.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
QString id() const
Access the unique ID associated with this Control.
void removeAt(int i)
Removes the image at an index.
This error is for when a programmer made an API call that was illegal.
A type of error that occurred when performing an actual I/O operation.
Container class for GuiCamera.
Control * activeControl()
Return the Active Control (control network)
QString cnetRoot() const
Get where control networks ought to be stored inside the project.
void projectLoaded(Project *)
Emitted when project loaded receivers: CNetSuiteMainWindow, Directory, HistoryTreeWidget.
QString resultsRoot() const
Accessor for the root directory of the results data.
void setName(QString newName)
Set the human-readable name of this shape list.
void createFolders()
This creates the project root, image root, and control net root directories.
void relocateProjectRoot(QString newRoot)
This is called when the project is moved.
void addBundleSolutionInfo(BundleSolutionInfo *bundleSolutionInfo)
Add the given BundleSolutionInfo to the current project.
void saveWarnings(QXmlStreamWriter &stream) const
Serialize the warnings into the given XML.
Target * target() const
Returns a pointer to the target object.
QString shapeDataRoot() const
Accessor for the root directory of the shape model data.
void addToProject(WorkOrder *)
Run the work order and stores it in the project.
void imageClosed(QObject *image)
An image is being deleted from the project.
Parent class for anything that performs an action in Project.
void removeAt(int i)
Removes the shape at an index.
void bundleSolutionInfoAdded(BundleSolutionInfo *bundleSolutionInfo)
Emitted when new BundleSolutionInfo available from jigsaw receivers: ProjectTreeWidget (TODO: should ...
void createH5File(FileName outputFileName) const
Creates a new file using H5F_ACC_EXCL.
void shapeListDeleted(QObject *shapeList)
A shape model list is being deleted from the project.
void shapeClosed(QObject *shape)
A shape model is being deleted from the project.
QSharedPointer< TargetBody > TargetBodyQsp
Defines A smart pointer to a TargetBody obj.
#define _FILEINFO_
Macro for the filename and line number.
void append(Shape *const &value)
Appends an shape to the shape list.
void append(TargetBodyQsp const &value)
Appends a TargetBody to the list.
void deleteAllProjectFiles()
Delete all of the files, that this project stores, from disk.
QString name() const
Get the human-readable name of this control list.
Container class for BundleAdjustment settings.
void guiCamerasAdded(GuiCameraList *targets)
Emitted when new GuiCamera objects added to project receivers: Directory.
void setPrevious(WorkOrder *previousWorkOrder)
Sets the previous WorkOrder in the sequence.
ImageList * activeImageList()
Returns the active ImageList.
void controlAdded(Control *control)
Emitted when new Control added to Project receivers: ProjectTreeWidget.
This represents a cube in a project-based GUI interface.
QString id() const
Get a unique, identifying string associated with this shape.
void setPath(QString newPath)
Set the relative path (from the project root) to this image list's folder.
QDir addBundleSolutionInfoFolder(QString folder)
Create and return the name of a folder for placing BundleSolutionInfo.
void projectRelocated(Project *)
Emitted when project location moved receivers: Control, BundleSolutionInfo, Image, TargetBody.
Directory * directory() const
Returns the directory associated with this Project.
QString fileName() const
Access the name of the control network file associated with this Control.
void imageListDeleted(QObject *imageList)
An image list is being deleted from the project.
void addShapes(QStringList shapeFiles)
Read the given shape model cube file names as Images and add them to the project. ...
void append(Image *const &value)
Appends an image to the image list.
QList< QAction * > userPreferenceActions()
Get a list of configuration/settings actions related to reading images into this Project.
void shapesAdded(ShapeList *shapes)
Emitted when new shape model images are available.
void addImages(QStringList imageFiles)
Read the given cube file names as Images and add them to the project.
This class is used to create and store valid Isis3 targets.
bool modifiesDiskState() const
Returns the modified disk state.
QDir addShapeFolder(QString prefix)
Create and return the name of a folder for placing shape models.
List of GuiCameras saved as QSharedPointers.
void nameChanged(QString newName)
Emitted when project name is changed receivers: ProjectTreeWidget.
void imagesAdded(ImageList *images)
Emitted when new images are available.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
QSharedPointer< GuiCamera > GuiCameraQsp
GuiCameraQsp Represents a smart pointer to a GuiCamera object.
void setName(QString newName)
Change the project's name (GUI only, doesn't affect location on disk).
Every display property for footprint views, provided for convenience.
This represents a shape in a project-based GUI interface.
bool isUndone() const
Returns the WorkOrder undo status.
void bundleSolutionInfoClosed(QObject *bundleSolutionInfo)
A BundleSolutionInfo object is being deleted from the project.
QString toString() const
Returns a string representation of this exception.
QMap< QString, Control * > * m_idToControlMap
This variable will probably go away when we add the bundle results object because it will be under: B...
void append(GuiCameraQsp const &value)
Appends a single GuiCamera to the list.
bool isUndoing() const
Returns the WorkOrderUndoing state.
Cube * cube()
Get the Cube pointer associated with this display property.
void setNext(WorkOrder *nextWorkOrder)
Sets the next WorkOrder in the sequence.
void setPath(QString newPath)
Set the relative path (from the project root) to this control list's folder.
void save(QXmlStreamWriter &stream) const
: Saves a WorkOrder to a data stream.
void targetsAdded(TargetBodyList *targets)
Emitted when new TargetBody objects added to project receivers: Directory.
void removeAt(int i)
Removes the control pointer at the specified index.
virtual bool execute()
The (child) implementation of this method should prompt the user/gather state by any means necessary...
void setName(QString newName)
Set the human-readable name of this image list.
his enables stack-based XML parsing of XML files.
QString projectRoot() const
Get the top-level folder of the project.
QDir addCnetFolder(QString prefix)
Create and return the name of a folder for placing control networks.
void setActiveImageList(ImageList *)
Set the Active ImageList.
void closeCube()
Cleans up the Cube pointer.
void setActiveControl(Control *)
Set the Active Control (control network)
QString imageDataRoot() const
Accessor for the root directory of the image data.
IO Handler for Isis Cubes.
Project(Directory &directory, QObject *parent=0)
Create a new Project.