13 #include <QApplication>
14 #include <QDockWidget>
15 #include <QGridLayout>
16 #include <QMainWindow>
19 #include <QMessageBox>
22 #include <QSizePolicy>
24 #include <QStringList>
27 #include <QXmlStreamWriter>
30 #include "BundleObservation.h"
31 #include "BundleObservationView.h"
32 #include "BundleObservationViewWorkOrder.h"
33 #include "ChipViewportsWidget.h"
34 #include "CloseProjectWorkOrder.h"
35 #include "CnetEditorView.h"
36 #include "CnetEditorViewWorkOrder.h"
37 #include "ControlHealthMonitorView.h"
38 #include "ControlHealthMonitorWorkOrder.h"
39 #include "CnetEditorWidget.h"
41 #include "ControlDisplayProperties.h"
42 #include "ControlList.h"
43 #include "ControlNet.h"
44 #include "ControlNetTool.h"
45 #include "ControlPointEditView.h"
46 #include "ControlPointEditWidget.h"
47 #include "CubeDnView.h"
48 #include "CubeDnViewWorkOrder.h"
49 #include "ExportControlNetWorkOrder.h"
50 #include "ExportImagesWorkOrder.h"
53 #include "Footprint2DView.h"
55 #include "HistoryTreeWidget.h"
56 #include "IException.h"
59 #include "ImageFileListWidget.h"
65 #include "JigsawRunWidget.h"
67 #include "MatrixSceneWidget.h"
69 #include "MosaicControlNetTool.h"
70 #include "MosaicSceneWidget.h"
73 #include "ProjectItem.h"
74 #include "ProjectItemModel.h"
75 #include "ProjectItemTreeView.h"
81 #include "SensorInfoWidget.h"
84 #include "TableView.h"
85 #include "TableViewContent.h"
86 #include "TargetInfoWidget.h"
88 #include "TemplateEditorWidget.h"
91 #include "WarningTreeWidget.h"
92 #include "WorkOrder.h"
93 #include "Workspace.h"
94 #include "XmlStackedHandler.h"
95 #include "XmlStackedHandlerReader.h"
112 "Could not create directory because Project could not be created.",
134 connect(
this, SIGNAL(cnetModified()),
m_project, SLOT(cnetModified()));
135 connect(
project(), SIGNAL(activeControlModified()),
this, SIGNAL(activeControlModified()));
138 connect(
m_project, SIGNAL(discardActiveControlEdits()),
143 connect(
m_projectItemModel, SIGNAL(cleanProject(
bool)),
this, SIGNAL(cleanProject(
bool)));
148 createWorkOrder<SetActiveImageListWorkOrder>();
149 createWorkOrder<SetActiveControlWorkOrder>();
150 createWorkOrder<CnetEditorViewWorkOrder>();
151 createWorkOrder<CubeDnViewWorkOrder>();
152 createWorkOrder<Footprint2DViewWorkOrder>();
153 createWorkOrder<MatrixViewWorkOrder>();
154 createWorkOrder<SensorGetInfoWorkOrder>();
156 createWorkOrder<TargetGetInfoWorkOrder>();
157 createWorkOrder<BundleObservationViewWorkOrder>();
158 createWorkOrder<TemplateEditViewWorkOrder>();
159 createWorkOrder<ControlHealthMonitorWorkOrder>();
175 m_recentProjectsLoaded =
false;
179 "Could not create directory because work orders are corrupt.",
290 emit directoryCleaned();
294 m_bundleObservationViews.clear();
299 m_controlPointEditViewWidget.clear();
320 if (m_recentProjectsLoaded) {
321 QMenu *recentProjectsMenu =
new QMenu(
"&Recent Projects");
325 QString actionText(action->text());
326 if (actionText ==
"&Recent Projects") {
328 recentProjectsMenu = qobject_cast<QMenu*>(action->parentWidget());
336 openRecentProjectAction->setText(projName);
339 if (recentProjectsMenu->isEmpty())
341 recentProjectsMenu->addAction(openRecentProjectAction);
345 QAction *firstAction = recentProjectsMenu->actions().at(0);
348 if (firstAction->text() == projName) {
354 foreach (
QAction *action, recentProjectsMenu->actions()) {
355 if (action->text() == projName) {
356 openRecentProjectAction = action;
361 recentProjectsMenu->insertAction(firstAction, openRecentProjectAction);
363 recentProjectsMenu->removeAction(recentProjectsMenu->actions().last());
369 QMenu *recentProjectsMenu = fileMenu->addMenu(
"&Recent Projects");
372 for (
int i = 0; i < nRecentProjects; i++) {
386 openRecentProjectAction->setText(
m_recentProjects.at(i).split(
"/").last() );
388 recentProjectsMenu->addAction(openRecentProjectAction);
390 fileMenu->addSeparator();
392 m_recentProjectsLoaded =
true;
416 openProjectAction->setIcon(QIcon(
FileName(
417 "$ISISROOT/appdata/images/icons/archive-insert-directory.png").expanded()));
418 fileMenu->addAction(openProjectAction);
423 saveAction->setShortcut(Qt::Key_S | Qt::CTRL);
424 saveAction->setIcon( QIcon(
FileName(
"$ISISROOT/appdata/images/icons/document-save.png")
426 saveAction->setDisabled(
true);
427 connect(
project()->undoStack(), SIGNAL( cleanChanged(
bool) ),
428 saveAction, SLOT( setDisabled(
bool) ) );
429 fileMenu->addAction(saveAction);
433 saveAsAction->setIcon(QIcon(
FileName(
"$ISISROOT/appdata/images/icons/document-save-as.png")
435 fileMenu->addAction(saveAsAction);
438 fileMenu->addSeparator();
440 QMenu *importMenu = fileMenu->addMenu(
"&Import");
445 QMenu *importTemplateMenu = importMenu->addMenu(
"&Import Templates");
449 QMenu *exportMenu = fileMenu->addMenu(
"&Export");
455 clone->setEnabled(
false);
457 clone, SLOT(enableWorkOrder()));
461 exportMenu->addAction(clone);
465 clone->setEnabled(
false);
467 clone, SLOT(enableWorkOrder()));
468 exportMenu->addAction(clone);
470 fileMenu->addSeparator();
481 if (
project()->controls().count() &&
project()->images().count()) {
482 clone->setEnabled(
true);
485 clone->setEnabled(
false);
489 connect(
m_project, SIGNAL(controlsAndImagesAvailable()),
490 clone, SLOT(enableWorkOrder()));
553 emit closeView(cnetEditorView);
569 if (newControl && m_controlPointEditViewWidget) {
570 emit closeView(m_controlPointEditViewWidget);
571 delete m_controlPointEditViewWidget;
605 connect( result, SIGNAL( destroyed(
QObject *) ),
608 connect(result, SIGNAL(windowChangeEvent(
bool)),
611 m_bundleObservationViews.append(result);
613 QString str = fileItem->fileName();
614 FileName fileName = fileItem->fileName();
618 int pos = path.lastIndexOf(
"/");
619 QString bundleResultsName =
"";
621 bundleResultsName = path.remove(0,pos+1);
624 if (str.contains(
"bundleout")) {
625 result->setWindowTitle( tr(
"Summary (%1)").
626 arg( bundleResultsName ) );
627 result->setObjectName( result->windowTitle() );
629 if (str.contains(
"residuals")) {
630 result->setWindowTitle( tr(
"Measure Residuals (%1)").
631 arg( bundleResultsName ) );
632 result->setObjectName( result->windowTitle() );
634 else if (str.contains(
"points")) {
635 result->setWindowTitle( tr(
"Control Points (%1)").
636 arg( bundleResultsName ) );
637 result->setObjectName( result->windowTitle() );
639 else if (str.contains(
"images")) {
640 result->setWindowTitle( tr(
"Images (%1)").
641 arg( bundleResultsName ) );
642 result->setObjectName( result->windowTitle() );
645 emit newWidgetAvailable(result);
659 FileName configFile(
"$HOME/.Isis/" + QApplication::applicationName() +
"/" + title +
".config");
663 if (
project()->activeControl() && (control ==
project()->activeControl())) {
669 connect(result, SIGNAL( destroyed(
QObject *) ),
672 connect(result, SIGNAL(windowChangeEvent(
bool)),
680 connect(result->
cnetEditorWidget(), SIGNAL(cnetModified()),
this, SIGNAL(cnetModified()));
681 connect(
this, SIGNAL(cnetModified()), result->
cnetEditorWidget(), SLOT(rebuildModels()));
686 result->setWindowTitle(title);
687 if (objectName !=
"") {
688 result->setObjectName(objectName);
692 QString newObjectName = QUuid::createUuid().toString().remove(QRegExp(
"[{}]"));
693 result->setObjectName(newObjectName);
696 emit newWidgetAvailable(result);
710 connect( result, SIGNAL( destroyed(
QObject *) ),
713 connect(result, SIGNAL(windowChangeEvent(
bool)),
718 if (objectName !=
"") {
719 result->setObjectName(objectName);
723 QString newObjectName = QUuid::createUuid().toString().remove(QRegExp(
"[{}]"));
724 result->setObjectName(newObjectName);
727 emit newWidgetAvailable(result);
742 connect(
this, SIGNAL(redrawMeasures()), result, SIGNAL(redrawMeasures()));
745 connect(
this, SIGNAL(activeControlModified()), result, SIGNAL(redrawMeasures()));
747 connect (
project(), SIGNAL(activeControlSet(
bool)),
748 result, SLOT(enableControlNetTool(
bool)));
765 if (objectName !=
"") {
766 result->setObjectName(objectName);
770 QString newObjectName = QUuid::createUuid().toString().remove(QRegExp(
"[{}]"));
771 result->setObjectName(newObjectName);
774 connect(result, SIGNAL(destroyed(
QObject *)),
777 connect(result, SIGNAL(windowChangeEvent(
bool)),
780 emit newWidgetAvailable(result);
795 connect(
this, SIGNAL(activeControlModified()), result->
mosaicSceneWidget(), SIGNAL(cnetModified()));
801 connect(
this, SIGNAL(redrawMeasures()), result, SIGNAL(redrawMeasures()));
803 connect (
project(), SIGNAL(activeControlSet(
bool)),
804 result, SLOT(enableControlNetTool(
bool)));
810 return m_controlHealthMonitorView;
816 if (!controlHealthMonitorView()) {
819 if (activeControl == NULL) {
820 QString message =
"No active control network chosen. Choose active control network on "
822 QMessageBox::critical(qobject_cast<QWidget *>(parent()),
"Error", message);
827 result->setWindowTitle(tr(
"Control NetHealth Monitor"));
828 result->setObjectName(result->windowTitle());
830 m_controlHealthMonitorView = result;
831 emit newWidgetAvailable(result);
833 return controlHealthMonitorView();
842 result->setWindowTitle(tr(
"Control Point Editor"));
843 result->setObjectName(result->windowTitle());
846 if (activeControl == NULL) {
848 QString message =
"No active control network chosen. Choose active control network on "
850 QMessageBox::critical(qobject_cast<QWidget *>(parent()),
"Error", message);
855 if (!
project()->activeImageList() || !
project()->activeImageList()->serialNumberList()) {
856 QString message =
"No active image list chosen. Choose an active image list on the project "
858 QMessageBox::critical(qobject_cast<QWidget *>(parent()),
"Error", message);
862 project()->activeImageList()->serialNumberList());
864 m_controlPointEditViewWidget = result;
866 connect(result, SIGNAL(destroyed(
QObject *)),
868 emit newWidgetAvailable(result);
886 this, SIGNAL(cnetModified()));
888 connect (
project(), SIGNAL(activeControlSet(
bool)),
891 connect(result, SIGNAL(windowChangeEvent(
bool)),
895 connect(
m_project, SIGNAL(cnetSaved(
bool)),
909 connect(result, SIGNAL(destroyed(
QObject *)),
this, SLOT(cleanupchipViewportWidges()));
910 m_controlPointChipViews.append(result);
911 result->setWindowTitle(tr(
"ChipViewport View %1").arg(m_controlPointChipViews.count()));
912 result->setObjectName(result->windowTitle());
913 emit newWidgetAvailable(result);
927 connect( result, SIGNAL( destroyed(
QObject *) ),
933 result->setObjectName( result->windowTitle() );
935 emit newWidgetAvailable(result);
948 connect( result, SIGNAL( destroyed(
QObject *) ),
953 result->setWindowTitle( tr(
"%1").arg(target->displayProperties()->displayName() ) );
954 result->setObjectName( result->windowTitle() );
956 emit newWidgetAvailable(result);
969 connect( result, SIGNAL( destroyed(
QObject *) ),
975 result->setObjectName( result->windowTitle() );
977 emit newWidgetAvailable(result);
983 if (jigsawRunWidget()) {
988 connect( result, SIGNAL( destroyed(
QObject *) ),
989 this, SLOT( cleanupJigsawRunWidget(
QObject *) ) );
992 result->setAttribute(Qt::WA_DeleteOnClose);
995 emit newWidgetAvailable(result);
1007 connect( result, SIGNAL( destroyed(
QObject *) ),
1012 result->setWindowTitle( tr(
"%1").arg(camera->displayProperties()->displayName() ) );
1013 result->setObjectName( result->windowTitle() );
1015 emit newWidgetAvailable(result);
1029 connect( result, SIGNAL( destroyed(
QObject *) ),
1036 if (objectName !=
"") {
1037 result->setObjectName(objectName);
1041 QString newObjectName = QUuid::createUuid().toString().remove(QRegExp(
"[{}]"));
1042 result->setObjectName(newObjectName);
1056 result->setWindowTitle( tr(
"Project"));
1057 result->setObjectName( result->windowTitle() );
1064 connect(result, SIGNAL(windowChangeEvent(
bool)),
1111 if (!bundleObservationView) {
1114 m_bundleObservationViews.removeAll(bundleObservationView);
1138 if (!cnetEditorView) {
1194 if (!imageFileListWidget) {
1208 if (!footprintView) {
1225 m_controlPointEditViewWidget = NULL;
1237 if (!matrixWidget) {
1251 if (!sensorInfoWidget) {
1265 if (!targetInfoWidget) {
1279 if (!templateEditorWidget) {
1288 void Directory::cleanupJigsawRunWidget(
QObject *obj) {
1290 if (!jigsawRunWidget) {
1324 results.append(widget);
1339 results.append(widget);
1354 results.append(widget);
1369 results.append(widget);
1384 results.append(widget);
1399 results.append(widget);
1414 results.append(view);
1429 results.append(widget);
1441 return m_controlPointEditViewWidget;
1524 stream.writeStartElement(
"directory");
1527 stream.writeStartElement(
"fileListWidgets");
1530 fileListWidget->
save(stream,
project(), newProjectRoot);
1533 stream.writeEndElement();
1538 stream.writeStartElement(
"footprintViews");
1541 footprint2DViewWidget->
save(stream,
project(), newProjectRoot);
1544 stream.writeEndElement();
1549 stream.writeStartElement(
"cubeDnViews");
1552 cubeDnView->save(stream,
project(), newProjectRoot);
1555 stream.writeEndElement();
1560 stream.writeStartElement(
"cnetEditorViews");
1563 cnetEditorWidget->
save(stream,
project(), newProjectRoot);
1566 stream.writeEndElement();
1570 stream.writeEndElement();
1606 const QString &qName,
const QXmlAttributes &atts) {
1607 bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts);
1609 QString viewObjectName;
1610 if (localName ==
"footprint2DView") {
1611 viewObjectName = atts.value(
"objectName");
1612 m_directory->addFootprint2DView(viewObjectName)->load(reader());
1614 else if (localName ==
"imageFileList") {
1615 viewObjectName = atts.value(
"objectName");
1616 m_directory->addImageFileListView(viewObjectName)->load(reader());
1618 else if (localName ==
"cubeDnView") {
1619 viewObjectName = atts.value(
"objectName");
1620 m_directory->addCubeDnView(viewObjectName)->load(reader(), m_directory->project());
1622 else if (localName ==
"cnetEditorView") {
1623 viewObjectName = atts.value(
"objectName");
1624 QString
id = atts.value(
"id");
1625 m_directory->addCnetEditorView(m_directory->project()->control(
id), viewObjectName);
1703 foreach (singleWidgetPairing, actionPairings) {
1704 QString widgetTitle = singleWidgetPairing.first;
1707 foreach (
QAction *widgetAction, widgetActions) {
1709 QString actionText = widgetAction->text();
1711 restructuredData[actionText].append( qMakePair(widgetTitle, widgetAction) );
1713 if ( !sortedActionTexts.contains(actionText) ) {
1714 sortedActionTexts.append(actionText);
1719 if ( !sortedActionTexts.isEmpty() && !sortedActionTexts.last().isEmpty() ) {
1720 sortedActionTexts.append(
"");
1726 if ( sortedActionTexts.count() && sortedActionTexts.last().isEmpty() ) {
1727 sortedActionTexts.removeLast();
1730 foreach (QString actionText, sortedActionTexts) {
1731 if ( actionText.isEmpty() ) {
1732 results.append(NULL);
1739 if (actions.count() == 1) {
1740 QAction *finalAct = actions.first().second;
1741 QString widgetTitle = actions.first().first;
1743 finalAct->setText( tr(
"%1 on %2").arg(actionText).arg(widgetTitle) );
1744 results.append(finalAct);
1750 menuAct->setMenu(menu);
1755 foreach (widgetTitleAndAction, actions) {
1756 QString widgetTitle = widgetTitleAndAction.first;
1757 QAction *action = widgetTitleAndAction.second;
1759 action->setText(widgetTitle);
1760 actionsInsideMenu.append(action);
1767 foreach (
QAction *actionInMenu, actionsInsideMenu) {
1768 connect( allAct, SIGNAL( triggered() ),
1769 actionInMenu, SIGNAL( triggered() ) );
1770 menu->addAction(actionInMenu);
1773 menu->addSeparator();
1774 menu->addAction(allAct);
1776 results.append(menuAct);
1794 return lhs->text().localeAwareCompare( rhs->text() ) < 0;
1806 m_controlPointEdit, SLOT(loadControlPoint(
ControlPoint *)));
1807 connect(m_cnetEditor, SIGNAL(controlPointCreated(
ControlPoint *)),
1808 m_controlPointEditWidget, SLOT(setEditPoint(
ControlPoint *)));
1814 connect( m_cnetEditor, SIGNAL( controlPointDeleted() ),
1820 connect(m_controlPointEditWidget, SIGNAL(controlPointChanged(QString)),
1840 if (!addControlPointEditView()) {
1845 emit redrawMeasures();
1862 if (!addControlPointEditView()) {
1869 emit redrawMeasures();
1890 bool isGroundSource) {
1893 if (!addControlPointEditView()) {
1898 latitude, longitude, cube, isGroundSource);